Post Reply 
Problem calculating an expression with roots
02-02-2015, 08:20 PM
Post: #21
RE: Problem calculating an expression with roots
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?
Find all posts by this user
Quote this message in a reply
02-02-2015, 08:51 PM
Post: #22
RE: Problem calculating an expression with roots
(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)

Graph 3D | QPI | SolveSys
Find all posts by this user
Quote this message in a reply
02-02-2015, 08:52 PM
Post: #23
RE: Problem calculating an expression with roots
also by me...
expln*2 give 202...
but expln without anything give no value.

∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib
Visit this user's website Find all posts by this user
Quote this message in a reply
02-02-2015, 09:35 PM (This post was last modified: 02-02-2015 09:46 PM by Snorre.)
Post: #24
RE: Problem calculating an expression with roots
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...
Find all posts by this user
Quote this message in a reply
02-02-2015, 09:35 PM
Post: #25
RE: Problem calculating an expression with roots
(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.

TW

Although I work for HP, the views and opinions I post here are my own.
Find all posts by this user
Quote this message in a reply
02-03-2015, 06:40 AM
Post: #26
RE: Problem calculating an expression with roots
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).
Find all posts by this user
Quote this message in a reply
02-03-2015, 10:55 AM (This post was last modified: 02-03-2015 12:26 PM by retoa.)
Post: #27
RE: Problem calculating an expression with roots
(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
Find all posts by this user
Quote this message in a reply
02-03-2015, 11:59 AM (This post was last modified: 02-03-2015 12:39 PM by Snorre.)
Post: #28
RE: Problem calculating an expression with roots
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).
Find all posts by this user
Quote this message in a reply
02-03-2015, 01:28 PM (This post was last modified: 02-03-2015 01:29 PM by retoa.)
Post: #29
RE: Problem calculating an expression with roots
(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
Find all posts by this user
Quote this message in a reply
02-03-2015, 02:36 PM
Post: #30
RE: Problem calculating an expression with roots
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.
Find all posts by this user
Quote this message in a reply
05-15-2015, 01:40 PM
Post: #31
RE: Problem calculating an expression with roots
hi Reto,
the original problem seems to be corrected in FW 7820: there result of Simplify now is (3*√2)/4

Try yourself...

Salvo

∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib
Visit this user's website Find all posts by this user
Quote this message in a reply
05-15-2015, 02:43 PM
Post: #32
RE: Problem calculating an expression with roots
Cannot get it. How did you do that? Only simplify?
Find all posts by this user
Quote this message in a reply
05-15-2015, 03:08 PM
Post: #33
RE: Problem calculating an expression with roots
(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?

∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib
Visit this user's website Find all posts by this user
Quote this message in a reply
05-15-2015, 03:22 PM
Post: #34
RE: Problem calculating an expression with roots
On the first post, as you see accurately, the expression has cubic root and 4th root in the denominator.
Find all posts by this user
Quote this message in a reply
05-15-2015, 03:35 PM (This post was last modified: 05-15-2015 03:44 PM by salvomic.)
Post: #35
RE: Problem calculating an expression with roots
(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

∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib
Visit this user's website Find all posts by this user
Quote this message in a reply
05-15-2015, 03:52 PM
Post: #36
RE: Problem calculating an expression with roots
Like me. Still isn´t the "pretty" way of showing it, but at least it does not hang.
Find all posts by this user
Quote this message in a reply
05-15-2015, 03:53 PM
Post: #37
RE: Problem calculating an expression with roots
(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!

∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)