XCas / Prime "solve" question



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)


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.


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

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)


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.


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!

Possibly Related Threads…
Thread Author Replies Views Last Post
  HP Prime Matrix TERRIBLE bug and question uklo 19 5,166 11-25-2013, 12:10 PM
Last Post: Mic
  HP Prime - vector question bluesun08 3 1,796 11-18-2013, 07:26 PM
Last Post: Han
  Question about transfering programs to the HP Prime Namir 10 3,509 11-17-2013, 04:01 PM
Last Post: Namir
  Another HP Prime CAS question Michael de Estrada 3 1,842 11-09-2013, 10:56 AM
Last Post: Michael de Estrada
  Non-Prime question alert: Hp-41 and synthetic instructions Marcel Samek 11 4,068 11-04-2013, 09:31 PM
Last Post: sjthomas
  HP-Prime/Xcas: vector/list indexing fhub 6 2,877 10-27-2013, 04:52 PM
Last Post: fhub
  HP PRIME - APP Programing question dg1969 2 1,341 10-27-2013, 10:23 AM
Last Post: dg1969
  Using the Prime to solve for eigenvalues Michael de Estrada 28 8,527 10-27-2013, 07:21 AM
Last Post: Tarcisi C
  HP Prime Define: Use with solve, etc. Helge Gabert 0 1,010 10-23-2013, 06:24 PM
Last Post: Helge Gabert
  WP-34S (Prime Number Test) question Barry Mead 3 1,740 10-20-2013, 05:28 PM
Last Post: Dieter

Forum Jump: