Matrices can have expressions as elements. What does the code do when you run it? It doesn't run for me because kron is not defined.
Aaron Meurer On Sat, Apr 29, 2017 at 7:52 AM, Carlos Bouthelier Madre < [email protected]> wrote: > 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 > <https://groups.google.com/d/msgid/sympy/ea805a03-ad40-44e9-8b44-f9957536e192%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- 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/CAKgW%3D6%2BaL3SQu6KEf%3DB8HRkSxk1iSpa-BbS6LVQ-8RsAJTb9sA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
