Hi everyone.
I am learning sympy and I have a question. I have 3 equations, the third is
the sum of the two first
I = c1+v1+m1 = w1
II = c2+v2+m2 = w2
I + II = C + V + M = W
So, C = c1+c2, V=v1+v2, M=m1+m2 and W=w1+w2
I defined everything in symbols:
c1,v1,m1,w1 = symbols('c1 v1 m1 w1')
c2,v2,m2,w2 = symbols('c2 v2 m2 w2')
w1 = c1 + v1 + m1
print ('w1=',w1)
w2 = c2 + v2 + m2
print ('w2=',w2)
C,V,M,W = symbols ('C V M W')
C = c1 + c2
V = v1 + v2
M = m1 + m2
W = w1 + w2
After all this, I want to be a able to print W and get C+V+M... But I can
only get c1+c2+v1+v2+m1+m2
I Am trying to use the subs and sympify function to do this:
A = W.subs({c1+c2:C, v1+v2:V, m1+m2:M, w1+w1:W})
print (sympify(A))
But It stills return
c1+c2+v1+v2+m1+m2
How can I make sympy understand I want it to substitute c1+c2 for C and so
on?
Thanks,
Rafael
--
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 http://groups.google.com/group/sympy.
To view this discussion on the web visit
https://groups.google.com/d/msgid/sympy/8c2ae1d0-2d17-434b-970a-f176972670af%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.