Post Reply 
SOLVE wrong answers
05-26-2022, 08:03 AM
Post: #1
SOLVE wrong answers
Hi,

When inputting solve(15=1.7*10*x^(3/2) ,x) into the CAS page, it yields an answer of {0.456...}
which is incorrect. I have used lowercase 'x'. the answer is supposed to be 0.9199...

please advise on why this is happening and how to fix it.

thank you in advance!
Find all posts by this user
Quote this message in a reply
05-26-2022, 11:21 AM
Post: #2
RE: SOLVE wrong answers
Try purge(x), or x='x', before solve. This may fix it.
Find all posts by this user
Quote this message in a reply
05-26-2022, 01:22 PM
Post: #3
RE: SOLVE wrong answers
I get the proper answer in CAS of 0.9199... However, as well as following Albert's advice it's worth bearing in mind that you should be using fsolve for that particular problem, as it's a numerical solve problem.

Luckily the Prime gracefully uses Newton's bisection method as a symbolic solve isn't apt for the problem, but it's good to get in the habit of using the apt solve for the job at hand. You can't always be sure that the Prime OS will gracefully fix your error.
Find all posts by this user
Quote this message in a reply
05-26-2022, 05:35 PM (This post was last modified: 05-26-2022 05:44 PM by C.Ret.)
Post: #4
RE: SOLVE wrong answers
(05-26-2022 11:21 AM)Albert Chan Wrote:  Try purge(x), or x='x', before solve. This may fix it.

Purging the 'x' variable is strongly recommended. See, in the following capture, I deliberately give a value to the symbolic variable x, this does affect the resolution of a non-symbolic expression by taking x=2 as the initial value.
Consequently, the format of the input is of great importance since a non-symbolic expression greatly affects the behavior of the CAS.

(05-26-2022 01:22 PM)jonmoore Wrote:  I get the proper answer in CAS of 0.9199... However, as well as following Albert's advice it's worth bearing in mind that you should be using fsolve for that particular problem, as it's a numerical solve problem.

An alternative method is to use solve, but deliberately giving a guess value or limiting the resolution to a specified interval. See the following screenshot.

All the power of the solve function in CAS mode is summarized in its online help:
Quote:Syntax:
solve(Expr,[Var] ) or solve({Eq1, Eq2,…}, [Var]) or solve(Expr, Var=Guess) or solve(Expr, Var=Val1..Val2)

Returns a list of the solutions (real and complex) to a polynomial equation or a set of polynomial equations.

The user is advised to supply a guess or define an interval in which to search for a solution to get the best results in cases where the solution is known to be approximate. To supply a guess, use the syntax Var=Guess. To supply an interval, use the syntax Var=Val1..Val2. In the latter case, the search is confined to the closed interval [Val1, Val2].

Examples:
solve(x²-3=1) → {-2,2}
solve([x²-y²=0,x²-z²=0],[x,y,z]) → {[x,x,x],[x,-x,-x],[x,x,-x],[x,-x,x]}
solve(x^2-(LN(x)+5)=0, x=2) → 2.42617293082
solve(x^2-(LN(x)+5)=0, x=2..3) → 2.42617293082

The most important fact, missing from the help explanations, is that the symbolic resolve function returns a list while the numeric resolve subroutine gives only a numeric output.

   

The key detail in the user's equation is that ks2000 enters 1.7*10, which does not have the same meaning as the exact, symbolic integer 17. This has a determining effect on how the CAS of the HP Prime interprets the data and on the type of resolution.

See in the screen capture the format of the result depending of entry containing a symbolic 17 versus a 1.7*10 expression.

In case of a non-symbolic expression, giving an intial guess (or a range interval) is strongly recommended.
Find all posts by this user
Quote this message in a reply
05-26-2022, 06:57 PM
Post: #5
RE: SOLVE wrong answers
(05-26-2022 05:35 PM)C.Ret Wrote:  An alternative method is to use solve, but deliberately giving a guess value or limiting the resolution to a specified interval.

I would advise faithfully solving with "purged" variables.
Purging not only remove its value, but its assumption (if any)

Alternative method(s) work (because we tried it ?), but it may not. (unless documentation stated otherwise)
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)