from sympy import *
u1,u2,u3,u4=var('u1,u2,u3,u4')
x1=u1*sin(u2)*sin(u3)*cos(u4)
x2=u1*sin(u2)*sin(u3)*sin(u4)
x3=u1*sin(u2)*cos(u3)
x4=u1*cos(u2)
x=[x1,x2,x3,x4]
u=[u1,u2,u3,u4]
J=Matrix([[diff(x[i],u[j]) for j in range(4)] for i in range(4)])
d=det(J)
s=simplify(d)
print(x)
print()
print(J)
print()
print(d)
print()
print(s)
