Thanks! So I made a stupid mistake, and forgot a *. I do that often, but usually find the mistake fast. Now I also found a remark in Stack Overflow: Python adopted the convention used by electrical engineers. In that field, i is used to represent current and use j as the square root of -1.
On Monday, January 4, 2021 at 11:38:17 AM UTC+1 Oscar wrote: > In Python 4j is the literal syntax to create an imaginary number (0 + > 4*I). You need to use 4*j. > > On Mon, 4 Jan 2021 at 10:10, Thomas Ligon <[email protected]> wrote: > > > > My understanding is that Sympy uses I as sqrt(-1), but I am running into > a problem with j. I have defined j as a symbol, but j**2 is sometimes > returning -1. > > Here is the code: > > > > from sympy import latex > > from sympy import symbols, sqrt > > m = symbols('m') > > j = symbols('j') > > s = symbols('s') > > print(sqrt(-1)) > > print(latex(sqrt(-1))) > > > print(latex(-((s)/(j))*(4*(j-1)*s+4*j**2+4*j-2-4*(s-j+1)*m+m**2)/(2*(4j**2-1)-4*m+m**2))) > > # print gives: > > # - \frac{s \left(4 j^{2} + 4 j + m^{2} - m \left(- 4 j + 4 s + 4\right) > + s \left(4 j - 4\right) - 2\right)}{j \left(m^{2} - 4 m - 34.0\right)} > > # in other words, all "j" are symbols except that j**2 == -1 > > > > > > -- > > 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/50ead3a4-846a-4b6d-979c-2605d4cbc992n%40googlegroups.com > . > -- 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/6f46e1da-6af6-45c3-8504-386b4bfce81en%40googlegroups.com.
