HP Forums
Problem calculating an expression with roots - 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: Problem calculating an expression with roots (/thread-2973.html)

Pages: 1 2


RE: Problem calculating an expression with roots - Snorre - 02-02-2015 08:20 PM

Somehow "expln" seems to be special on my Prime (both device and emulator).
If I enter "expln+0" within CAS I get "101". Entering "expln" alone yields "expln" as for every other unknown variable. But in conjunction with an addition, subtraction, multiplication or power it behaves like if it was 101.
Why is that?


RE: Problem calculating an expression with roots - Han - 02-02-2015 08:51 PM

(02-02-2015 08:20 PM)Snorre Wrote:  Somehow "expln" seems to be special on my Prime (both device and emulator).
If I enter "expln+0" within CAS I get "101". Entering "expln" alone yields "expln" as for every other unknown variable. But in conjunction with an addition, subtraction, multiplication or power it behaves like if it was 101.
Why is that?

This doesn't answer your question, but a similar behavior exists for 'list' (whose value seems to be 256)


RE: Problem calculating an expression with roots - salvomic - 02-02-2015 08:52 PM

also by me...
expln*2 give 202...
but expln without anything give no value.


RE: Problem calculating an expression with roots - Snorre - 02-02-2015 09:35 PM

Tried it with some other Xcas commands (which are not implemented on the Prime). Most of them (I tried) were of type DOM_INT.
It looks like artefacts from a Giac/Xcas reserved names table. But maybe some day they'll be filled with life...


RE: Problem calculating an expression with roots - Tim Wessman - 02-02-2015 09:35 PM

(02-02-2015 08:52 PM)salvomic Wrote:  also by me...
expln*2 give 202...
but expln without anything give no value.

Basically, those are special "constants" that xcas uses when passing around certain arguments - usually categorical type things. For example, colors, specific type of a function and similar. I'm not certain what possible benefit allowing them to automatically convert into numerical values has versus an error when encountered in an incorrect useage, but that is the default behavior of the xcas software.


RE: Problem calculating an expression with roots - parisse - 02-03-2015 06:40 AM

This has to do with Giac internals. Constants like expln, red, etc. are integers with a "subtype", the subtype is checked for complex operations (like reading arguments for a plot) or for printing, but not for simple operations (like +) because this would slow down too much (for example if you multiply 2 matrices with small integer coefficiens of large size).


RE: Problem calculating an expression with roots - retoa - 02-03-2015 10:55 AM

(02-02-2015 12:53 PM)parisse Wrote:  ...because the expression is not defined for all values of x (or ambiguous like the definition of x^(1/3) for x<0).

Parisse, I agree with you that working with nth roots is not very useful, I think I never found such expressions in real life calculation and it is very difficult to find practical examples with roots above the 3rd (except the 12th root of 2 in music, but you don't have a variable in it).

But I still have a question about x^(1/3) for x<0.

If I try to calculate (-8)^(1/3), one solution is -2, because (-2)^3=-8

In CAS mode the Prime gives one of the complex solutions, 1+sqrt(3) i
In home it gives the complex solution if you enable complex numbers and an error if you don't.
3rd root of (-8) gives -2 (both in home and CAS)

Why does the Prime give a complex solution to (-8)^(1/3) and not the trivial one -2?
And why does the Prime in home mode not give the -2 solution when it works with real numbers?

As a comparison I tried to calculate (-8)^(1/3) on other platforms:

HP 11C : Error 0
HP 35s : INVALID y^x (or 1 i sqrt(3) if you use -8 i 0 )
Casio fx82 solar : -2
TI-30X Pro : -2
TI nspire CAS : -2
WP 34S : Domain Error
Elektronika MK56 : Error
Calculator application in linux mint: -2
Maxima : -2
Wolfram aplha : 1+sqrt(3)i

So it seems to be more a philosophical question, cause any producer choose his own way, but would it not be better to give the real solution -2 ?

Kind regards

Reto


RE: Problem calculating an expression with roots - Snorre - 02-03-2015 11:59 AM

Hello Reto,

In Home it seems to be related to evaluation order: 1/3 is evaluated to the approximated floating 0.333 first. There seems to be no further internal test if the exponent is rational.
If you enter it as ³√(-8) you'll get -2.
(The other way around is similiar: (1/3)NTHROOT(-2) is not the same as (-2)^3)

The CAS seems to evaluate (-1)^(p/q) to the first complex solution as long as the denominator q is ≤4 (autosimplification turned off).
Sorry, can't tell you why (just guess).


RE: Problem calculating an expression with roots - retoa - 02-03-2015 01:28 PM

(02-03-2015 11:59 AM)Snorre Wrote:  If you enter it as ³√(-8) you'll get -2.
(The other way around is similiar: (1/3)NTHROOT(-2) is not the same as (-2)^3)

That with \( \sqrt[3](-8) \) the answer is -2 is quite clear.

I tried \( \sqrt[1/3](-2) \) in both home and CAS

in CAS the answer is -8
in home (complex) it is -8.00000000002-7.58171027068E-11*i, so the imaginary part is almost zero.
As the imaginary part is not exactly zero the answer is not real and can not be displayed in real mode. I don't know if the Prime tries to calculate it and comes to a non real answer or it avoid calculating it, the error is "Error: (X<0)^(not in Z)". Actually the exponent is 3 and is in Z.
I know it does not make much sense to use \( \sqrt[1/3](-2) \) instead of (-2)^3, but it is interesting to see that in home it comes to a complex approximation of a real number (natural number actually).

Regards

reto


RE: Problem calculating an expression with roots - parisse - 02-03-2015 02:36 PM

I follow the same convention as maple for (-8)^(1/3), it seems mathematica too. I did not know maxima does not follow that convention, that's strange, I find it is more natural to have a definition that extends to the complex domain like for the logarithm (i.e. continuous for Im(z)>=0).
And you can use surd/NTHROOT if you prefer the real root.


RE: Problem calculating an expression with roots - salvomic - 05-15-2015 01:40 PM

hi Reto,
the original problem seems to be corrected in FW 7820: there result of Simplify now is (3*√2)/4

Try yourself...

Salvo


RE: Problem calculating an expression with roots - akmon - 05-15-2015 02:43 PM

Cannot get it. How did you do that? Only simplify?


RE: Problem calculating an expression with roots - salvomic - 05-15-2015 03:08 PM

(05-15-2015 02:43 PM)akmon Wrote:  Cannot get it. How did you do that? Only simplify?

(√3*3*√(2*x))/(4*√(3*x)) gives √2*3*¼, simplifying the last I get (3*√2)/4)

Is that the problem?


RE: Problem calculating an expression with roots - akmon - 05-15-2015 03:22 PM

On the first post, as you see accurately, the expression has cubic root and 4th root in the denominator.


RE: Problem calculating an expression with roots - salvomic - 05-15-2015 03:35 PM

(05-15-2015 03:22 PM)akmon Wrote:  On the first post, as you see accurately, the expression has cubic root and 4th root in the denominator.

sorry, I misunderstood...

\[ \frac{\sqrt{3}*\sqrt[3]{2*x}}{\sqrt[4]{3*x}} \]

you're right.

I get (directly, without simplify)
\[ \frac{3^{\frac{1}{4}}3\sqrt{2x}}{x^{\frac{1}{4}}} \]

(with simplify on the original formula I get ...the same formula).

No loop, here, in CAS


RE: Problem calculating an expression with roots - akmon - 05-15-2015 03:52 PM

Like me. Still isn´t the "pretty" way of showing it, but at least it does not hang.


RE: Problem calculating an expression with roots - salvomic - 05-15-2015 03:53 PM

(05-15-2015 03:52 PM)akmon Wrote:  Like me. Still isn´t the "pretty" way of showing it, but at least it does not hang.

yes, indeed!