HP Forums

Full Version: [SOLVED] Does not give all solutions
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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?
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)}
(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.
(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.
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?
(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)
Didier,

It works like a charm! I thought that where command was used only for derivatives. Thank you.
Reference URL's