Post Reply 
(sqrt(-2))^2
10-06-2016, 07:26 PM
Post: #12
RE: (sqrt(-2))^2
(10-06-2016 06:05 PM)parisse Wrote:  
(10-06-2016 02:12 PM)Tim Wessman Wrote:  √(-2)^2 is what is being passed to the CAS though. Shouldn't that be interpreted identically to sqrt(-2)^2? It gets evaluated and changed to √((-2)^2) which would indicate to me that the √ function token is being handled in a different way/priority then the spelled out "sqrt" function.
Yes, they are parsed differently because you don't need parenthesis after √, unlike for sqrt. The token for the bison parser is T_NOT, which means you must add parenthesis around the sqrt (they are not required inside): (√-2)^2.

I am not sure if what I noticed is very relevant to the discussion, but I will post it anyway.

1. sqrt(-2*i)^2-> -2*i which is OK because ((-2*i)^1/2)^2-> -2*i
2. radical -2*i ^2, no barckets, I get 2*i, but when I enclose in brackets the (radical -2*i)^2 I get -2*i, the same as in 1 above.

I looks that when you do like in 2 above, even when calculator does show that you are outside of the radical sign and do the ^2 the parser puts in the brackets and squares (-2*i)^2, what is under the radical sign and that evaluates to -4. The radical then evaluates the -4 as (-1)*4 that gives i*2 and that is not correct with what you expect.

For me the problem with the radical as square root is that the parser does not enclose in brackets the radical with what is inside of it, but only what is inside, and in the case of ^2 applies it only to what is inside, under the radical, hence, the wrong result.

If you put brackets around:(radical for square root -2*i)^2 you will get -2*i the correct result.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
(sqrt(-2))^2 - retoa - 10-05-2016, 02:33 PM
RE: (sqrt(-2))^2 - toml_12953 - 10-05-2016, 03:01 PM
RE: (sqrt(-2))^2 - retoa - 10-05-2016, 03:04 PM
RE: (sqrt(-2))^2 - parisse - 10-05-2016, 07:13 PM
RE: (sqrt(-2))^2 - retoa - 10-05-2016, 09:24 PM
RE: (sqrt(-2))^2 - Tim Wessman - 10-05-2016, 10:37 PM
RE: (sqrt(-2))^2 - parisse - 10-06-2016, 05:10 AM
RE: (sqrt(-2))^2 - retoa - 10-06-2016, 06:47 AM
RE: (sqrt(-2))^2 - Tim Wessman - 10-06-2016, 02:12 PM
RE: (sqrt(-2))^2 - parisse - 10-06-2016, 06:05 PM
RE: (sqrt(-2))^2 - John P - 10-06-2016 07:26 PM
RE: (sqrt(-2))^2 - compsystems - 10-06-2016, 07:58 PM
RE: (sqrt(-2))^2 - compsystems - 10-06-2016, 04:01 PM
RE: (sqrt(-2))^2 - parisse - 10-06-2016, 08:19 PM
RE: (sqrt(-2))^2 - compsystems - 10-06-2016, 08:36 PM
RE: (sqrt(-2))^2 - parisse - 10-07-2016, 06:27 AM
RE: (sqrt(-2))^2 - compsystems - 10-08-2016, 03:38 AM



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