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. This means that both j and I mean sqrt(-1). Just to add to the confusion, the mathematics paper I have been working on was published in 1878 and the author used i and j as summation indices. But then, someone else published an additional analysis in 1896 and avoided the use of i as an index, using j and s instead, and saving i for sqrt(-1), and I have been following that author's conventions. Now I think it would probably be smart top avoid both i and j, or better, avoid i, I and j, because i is used by mathematicians, I is used by sympy, and j is used by python and electrical engineers.
On Monday, January 4, 2021 at 5:22:07 PM UTC+1 da...@dbailey.co.uk wrote: > On 04/01/2021 10:37, Oscar Benjamin wrote: > > In Python 4j is the literal syntax to create an imaginary number (0 + > 4*I). You need to use 4*j. > > > I don't understand this because Thomas Lignon imported sqrt from sympy, so > why didn't he get the imaginary answer he was expecting? > > Indeed, trying this with Python 3.7 and SymPy 1.7, I get: > > import sympy > from sympy import sqrt > sqrt(-1) > I > > 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 sympy+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/292aef1f-be93-41dc-b011-90beff19b300n%40googlegroups.com.