Hi, I have just started using sympy and I don't really know how to make
this work. I've got functions that should return a matrix (I don't know if
that is possible) whose elements are expressions of symbolic variables.
This is my code, I've made a logical analysis of it (in pseudo-code) and it
should do what I want to, the issue is that I am neither used to sympy
variables nor to python syntaxis, so I would really appreciate your help.
from sympy import *
from sympy import cos
from sympy.tensor.array import Array
from sympy import I, Matrix, symbols
from sympy import init_printing
from sympy import init_session
from IPython.display import display, Math, Latex
var('Tita1 Tita2 Tita3 Tita4 Tita5 Tita6 Beta eps', real=True)
def delta(n):
f='Tita'+str(n)
return sqrt(cos(f)*cos(f)*eps*eps+1)
def EF(i):
return Matrix([[0,0],[0,2*delta(i)]])
ID=Matrix([[1,0],[0,1]])
def ExtDim(X,n):
if n==1:
return X
else:
return kron(ExtDim(X,n-1),ID)
def n_energy(n):
if n==1:
return EF(n)
else:
return kron(ID,n_energy(n-1))+ExtDim(EF(n),n) #This should be a
matrix
Thanks in advance!
--
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 post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sympy.
To view this discussion on the web visit
https://groups.google.com/d/msgid/sympy/ea805a03-ad40-44e9-8b44-f9957536e192%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.