I discovered the problem
In infix notation and linear infix notation , the precedence rules say the brackets () are evaluated first, then unary operators (change of sign/NEG [-]), then the multiplier operators (*, /, mod, ^), then the sum operators (+, -) ... then √, ...
-2 ^ 2 is equivalent to -(2^2) the brackets (2^2) is evaluated first -> 4 then changes sign -(4) -> NEG(4) the end result is -4
(-2)^2, the brackets (-2) is evaluated first NEG(2) -> -2, Then (NEG(2))^ 2 -> -2*-2 the end result is 4
The brackets () are also used to
delimit the function arguments f(arg1, arg2, ..., argN)
sqrt( arg ) or
√(arg) ->
____¬
√arg
HP-PRIME KEY SEQUENCE (TEXT BOOK MODE aka 2D printing, infix notation )
ENTRY LINE
[√▣] + [2] + [±] is
√(-2)¬ -> sqrt(-2) ->
i*√2 // ok
https://www.wolframalpha.com/input/?i=%E2%88%9A(-2)
[√▣] + [2] + [±] + [-3] is
√(-2-3)¬ -> sqrt(-2-3) ->
√(-5) ¬ ->
i*√5 // ok
https://www.wolframalpha.com/input/?i=%E2%88%9A(-2-3)
Now
[√▣] + [2] + [±] + [^2] is
√(-2^2)¬ -> sqrt(-2^2) -> √(-(2^2) )¬ -> √(-(4)) ¬ -> √(-4)¬ ->
2*i // ok
https://www.wolframalpha.com/input/?i=%E2%88%9A(-2%5E2)
[√▣] + [2] + [±] + [>] + [spc] + [spc] «out of the radical » + [-3] is √(-2)¬ -3 -> sqrt(-2)-3 ->
√(-2)-3 ->
-3+(i*√2) // ok
https://www.wolframalpha.com/input/?i=%E2%88%9A(-2)-3
Problem Parser with ^2
in the example above it works well (√(-2)¬ -3) -> sqrt(−2)-3
[√▣] +[2] + [±] + [>] + [spc] « out of the end symbol radical (¬) » + [^2] retunrs
2 //
????
√(-2)^2 Brackets are the delimiters of radical function, must be as sqrt(−2)^2 and not sqrt(−2^2) , otherwise ambiguity is generated with the case
√(-2)-3
[√▣] +[2] + [±] + [>] + [^2]
must be for next firmware =) ( √(-2) )^2 -> sqrt(-2)^2 ->
-> (√(-2))¬^2 -> (√( neg(2) )^2 -> (i*√2)^2 -> 2*(-i)^2 ->
-2 // ok
https://www.wolframalpha.com/input/?i=(%...A(-2))%5E2
HP-PRIME KEY SEQUENCE (ALGEBRAIC MODE aka LINEAR MODE 1D, aka linear infix notation )
ENTRY LINE
[√] + [2] + [±] is √(-2)¬ -> i*√2 // ok
[√] + [2] + [±] + [-3] is √(-2-3)¬ -> √(-5) ¬ -> i*√5 // ok
Now
[√] + [2] + [±] + [>] + [spc] « out of the end symbol radical (¬) » + [-3] is √(-2)¬ -3 -> (i*√2) -3 // ok
[√] + [2] + [±] + [^2] is √(-2^2)¬ -> √(-(2^2) )¬ -> √(-(4)) ¬ -> √(-4)¬ -> 2*i // ok