Post Reply 
[SOLVED] Does not give all solutions
07-12-2016, 11:54 AM (This post was last modified: 07-14-2016 07:11 AM by CH3791.)
Post: #1
[SOLVED] Does not give all solutions
Hello,
This is a trigonometry question that I have been trying to solve:
https://www.dropbox.com/s/3vl2r5uvfskowk...1.PNG?dl=0
In this example, there should be two solutions: 1.318 and 4.965. However, the HP Prime only gives 1.318. Why?
Find all posts by this user
Quote this message in a reply
07-12-2016, 12:05 PM (This post was last modified: 07-12-2016 12:07 PM by Didier Lachieze.)
Post: #2
RE: Does not give all solutions (Trigonometry)
Try with 1/4 instead of 0.25 to get the exact solutions.
solve(cos(x) = 1/4)|(x>0 AND x<2*π) => {acos(1/4),2*π-acos(1/4)}
Find all posts by this user
Quote this message in a reply
07-12-2016, 02:16 PM
Post: #3
RE: Does not give all solutions (Trigonometry)
(07-12-2016 11:54 AM)CH3791 Wrote:  However, the HP Prime only gives 1.318. Why?

Specifically, when you put in the ".25" you are telling the CAS "I am doing this calculation in an approximate way using non-exact numbers". Thus when it starts solving things, it switches to a numerical method to isolate a result and you end up with one result within the range you gave. Numerical solution methods as a general rule work on the "try the calculation, check the result, scoot the input up/down a bit, check the result again" and so on until you converge to a numerical value that is close enough to a result.

Any numerical value containing a decimal is a "non-exact" number. Thus something like 4 / 5 is actually very different then 4. / 5 from the CAS point of view. One is the fraction of two exact integer values and represents the "concept" of 4/5. The other is an approximated value of four, divided by the perfect integer value of 5 and the result of that calculation is and approximate value of .8

To ensure the CAS won't approximate, keep decimal approximations out of your inputs. Either put in 1/4 (which is an exact mathematical representation of that number), or surround your fraction with exact(.25) which converts the decimal to a fraction beforehand.

TW

Although I work for HP, the views and opinions I post here are my own.
Find all posts by this user
Quote this message in a reply
07-14-2016, 07:09 AM
Post: #4
RE: Does not give all solutions (Trigonometry)
(07-12-2016 02:16 PM)Tim Wessman Wrote:  
(07-12-2016 11:54 AM)CH3791 Wrote:  However, the HP Prime only gives 1.318. Why?

Specifically, when you put in the ".25" you are telling the CAS "I am doing this calculation in an approximate way using non-exact numbers". Thus when it starts solving things, it switches to a numerical method to isolate a result and you end up with one result within the range you gave. Numerical solution methods as a general rule work on the "try the calculation, check the result, scoot the input up/down a bit, check the result again" and so on until you converge to a numerical value that is close enough to a result.

Any numerical value containing a decimal is a "non-exact" number. Thus something like 4 / 5 is actually very different then 4. / 5 from the CAS point of view. One is the fraction of two exact integer values and represents the "concept" of 4/5. The other is an approximated value of four, divided by the perfect integer value of 5 and the result of that calculation is and approximate value of .8

To ensure the CAS won't approximate, keep decimal approximations out of your inputs. Either put in 1/4 (which is an exact mathematical representation of that number), or surround your fraction with exact(.25) which converts the decimal to a fraction beforehand.

Thanks man.
Find all posts by this user
Quote this message in a reply
07-14-2016, 12:28 PM
Post: #5
RE: [SOLVED] Does not give all solutions
To Didier Lachieze,

In CAS, I typed in the line exactly as you did, namely,

solve(cos(x) = 1/4)|(x>0 AND x<2*π)

and got the generic HP Prime error with the red circle and white X. Can you please tell me precisely how you entered this? In particular, what key did you press to enter the vertical bar? There is nothing in the description of solve in the user guide (p. 366) about this idea of adding a vertical bar followed by conditions. Where can I find more information about it?
Find all posts by this user
Quote this message in a reply
07-14-2016, 02:04 PM
Post: #6
RE: [SOLVED] Does not give all solutions
(07-14-2016 12:28 PM)JamesWilliams Wrote:  To Didier Lachieze,

In CAS, I typed in the line exactly as you did, namely,

solve(cos(x) = 1/4)|(x>0 AND x<2*π)

and got the generic HP Prime error with the red circle and white X. Can you please tell me precisely how you entered this? In particular, what key did you press to enter the vertical bar? There is nothing in the description of solve in the user guide (p. 366) about this idea of adding a vertical bar followed by conditions. Where can I find more information about it?

You can find the vertical bar in the math template (the key to the right of the toolbox). You can also find it in the catalog after ztrans. Here is what the user's manual says about it p. 458:
Quote: Found in the Catalog menu and the Template menu, the where command has several uses associated with variable declarations. For one, it is used to substitute values for one or more variables in an expression. It can also be used to define the domain of a variable.

Expr|Var=Val or Expr|{Var1=Val1, Var2=Val2…Varn=Valn} or Expr|Var>n or Expr| Var<n and so on.

Examples:
(X+Y)|{X=2, Y=6} returns 8
int((1-x)^p|p>0,x,0,1) returns ((-x+1)^(p+1))/(-p-1)
Find all posts by this user
Quote this message in a reply
07-14-2016, 09:08 PM
Post: #7
RE: [SOLVED] Does not give all solutions
Didier,

It works like a charm! I thought that where command was used only for derivatives. Thank you.
Find all posts by this user
Quote this message in a reply
Post Reply 




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