HP Forums
[SOLVED] Does not give all solutions - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: [SOLVED] Does not give all solutions (/thread-6545.html)



[SOLVED] Does not give all solutions - CH3791 - 07-12-2016 11:54 AM

Hello,
This is a trigonometry question that I have been trying to solve:
https://www.dropbox.com/s/3vl2r5uvfskowkv/Trig%201.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?


RE: Does not give all solutions (Trigonometry) - Didier Lachieze - 07-12-2016 12:05 PM

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)}


RE: Does not give all solutions (Trigonometry) - Tim Wessman - 07-12-2016 02:16 PM

(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.


RE: Does not give all solutions (Trigonometry) - CH3791 - 07-14-2016 07:09 AM

(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.


RE: [SOLVED] Does not give all solutions - JamesWilliams - 07-14-2016 12:28 PM

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?


RE: [SOLVED] Does not give all solutions - Didier Lachieze - 07-14-2016 02:04 PM

(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)



RE: [SOLVED] Does not give all solutions - JamesWilliams - 07-14-2016 09:08 PM

Didier,

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