HP Forums
XCas / Prime "solve" question - Printable Version

+- HP Forums (https://archived.hpcalc.org/museumforum)
+-- Forum: HP Museum Forums (https://archived.hpcalc.org/museumforum/forum-1.html)
+--- Forum: Old HP Forum Archives (https://archived.hpcalc.org/museumforum/forum-2.html)
+--- Thread: XCas / Prime "solve" question (/thread-255097.html)



XCas / Prime "solve" question - Nigel J Dowrick - 11-07-2013

Typing

solve(6.67e-11*m/6.4e6^2=9.8,m)
into my new Prime in CAS mode gives an empty list as the answer. (nSolve works fine.) Investigating further, solving "a*m=b" fails if a is less than 10^{-12}. I find that the same thing happens with the online version of Xcas, except that the limit there is 10^{-10}.

Although this behaviour isn't a huge inconvenience, it is rather strange. Can anyone suggest why Xcas has been designed to do this? Should the HP Prime copy its behaviour in this respect?

Or am I making a silly mistake somewhere? Any comments welcome!

Nigel (UK)


Re: XCas / Prime "solve" question - Han - 11-07-2013

Anytime you use a decimal point in the CAS view, you are implicitly telling the CAS to switch over into "approximate" mode for that specific computation. So, I recommend using

solve(exact( ... your equation here ... ), var)

Once the CAS is switch over into approximation mode, it _should_ honor the epsilon value in the CAS settings as far as what to do with values that are very small (i.e. when to interpret a small number as zero). Keep in mind that the command exact() will also use the epsilon setting to convert small numbers to 0! So the above will not always work for numerical solutions. So, when you try to solve a*m=b with a=10^{-12}, that very well could be interpreted as 0=b and would produce no solutions if b is non-zero.

Generally speaking, use solve() when you are trying to find exact solutions and your equations can be stated in exact terms, and use nSolve() when your equations involve non-exact values.

This concept is fairly common in many computer algebra systems.


Re: XCas / Prime "solve" question - Nigel J Dowrick - 11-07-2013

Thank you for explaining this. I find the idea of replacing small numbers with zero rather strange - it makes sense when numbers close to one are also present, but in an equation like ax=b where there is no prior reason for the quantities to have any particular magnitude I don't think it should happen.

Changing the epsilon setting hasn't made any difference that I can see - equations with small numbers in still don't get solved. When solving an equation with one unknown in I can use nSolve, which is fine. But suppose I have an equation with two unknowns, involving small numbers as coefficients, and I want to solve the equation to express one of them in terms of the other. For example: rearranging

E=(6.63e-34*3e8/lambda)/1.6e-19
to make lambda the subject. nSolve won't do this, and solve will object to my small coefficients. Do I have to rearrange the expression step-by-step by hand, or does anyone know if is there another way?

I shall spend some time reading the Xcas documentation, I think!

Nigel (UK)


Re: XCas / Prime "solve" question - parisse - 11-08-2013

If you enter a:=10^(-12) then a is exact and it will not be replaced by 0. If you enter a:=1e-12, then a is approx and may be replaced by 0 (if epsilon is greater than abs(a)). Instead of using exact, I would recommend to enter your parameters as exact numbers if you plan to use solve, or keep them approx and use fsolve.


Re: XCas / Prime "solve" question - Nigel J Dowrick - 11-08-2013

Thank you for this idea. As a physicist I still cannot understand the automatic replacement of approximate numbers less than 10^{-12} by zero, though I accept that mathematicians view the world differently!

It makes the CAS much less useful to me. Most formulae that I use involve numbers which are far from 1. Changing epsilon seems to have no effect on the calculator's behaviour (is this a bug?). If I could turn off this behaviour (by making epsilon zero, for example) it would solve the problem, but this doesn't appear possible. Using fsolve is fine if I want to solve an equation with one unknown in it, but it doesn't help me to rearrange an equation to make a different variable the subject.

Wolfram Alpha is quite happy to rearrange formulae with small approximate numbers in, as is the HP-50g and my ancient TI-89!

Thank you again for your suggestions.

Nigel (UK)

P.S. In nearly every other way I am absolutely delighted with the Prime. Please don't think of me as a complainer!