On 04/01/2021 21:30, Thomas Ligon wrote:
Hello David,
indeed, when I enter print(sqrt(-1)), I get I, just as you do.
However, when I enter print(4s**2), it is flagged with an error "unexpected token 's'", so I immediately see that I have something wrong. But, when I  enter print(4j**2), I get (-16 + 0j), so python is just making a complex number out of it, and so I overlooked the error.

Right - I find that rather scary - just accidentally reverting to normal algebraic notation - means you don't get an error message, but just a wrong answer - only if you happen to use j in the calculation! I had always assumed that assigning a variable to a symbol concealed python's native processing (roughly speaking).

I wonder if there is a way to turn off the 'j' feature in Python. It really does seem to be something of a hack (in Python, not SymPy) - here is what I got without importing sympy

>>> 4j
4j
>>> j=0
>>> 4j**2
(-16+0j)
>>> j**2
0
>>> 1j**2
(-1+0j)

David


--
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/0e10ee24-8a28-4ca8-0ae9-800232191d15%40dbailey.co.uk.

Reply via email to