Forum Archive

Bug when adding ".doit()" after some symbol when working with Sympy

ylian

@omz
Bug report


from sympy import re, im, E, I
from sympy import *
import numpy as np
x,y,z = symbols('x y z')
mat = Matrix([
    [exp(I*x)*exp(I*z)* (1+cos(y))/2, 
    exp(I*z)*(-1/sqrt(2))*sin(y),
    exp(-I*x)*exp(I*z)* (1-cos(y))/2], 
[exp(I*x)*(1/sqrt(2))*sin(y), 
cos(y), 
exp(-I*x)*(-1/sqrt(2))*sin(y)], 
[exp(I*x)*exp(-I*z)* (1-cos(y))/2, 
exp(-I*z)*(1/sqrt(2))*sin(y), 
exp(-I*x)*exp(-I*z)*(1+cos(y))/2]
])
vec = Matrix([1,0,0])

x1,y1,z1 = symbols('x1 y1 z1')
mat1 = Subs(mat,(x,y,z),(x1,y1,z1))
vec1 = Matrix([1,0,0])

a,b = symbols('a b')
PSI = cos(a/2)*(mat*vec) + sin(a/2)*exp(I*b)*(mat1*vec1) # XXX

pprint(mat1.doit()*vec)

If I put ".doit()" after mat1 in the line commented by XXX
The app crashes
I dont know why ... :-(
Hope you can solve it, it is quite annoying

But in general I love Pythonista :-D

JonB

Please use triple backquote ``` to surround your pasted code so it shows up properly