It would be great if you could provide a concrete test case (with your
expected result) to work on. You are welcome to open a new issue for
this in our issue tracker.
I'll try.... I've simplified my actual problem to get a shorter answer.
The equations come from circuits and the result we're looking for is
"p".
Change the circuit a little and "p" changes.
import sympy
from sympy.abc import *
all_eqn=[-c+c*a+s*a-m*C-m*P,\
-H-f+m*P-L*y,\
c+s-n,\
p+y-c,\
y-D*H/R]
solve=[H,c,p,s,y]
soln=sympy.solve(all_eqn,solve)
for key,val in soln.iteritems():
print key,":",val
Output is:
H : (-R*f + P*R*m)/(R + D*L)
p : (D*f + R*a*n - C*R*m - D*P*m - P*R*m + D*L*a*n - C*D*L*m -
D*L*P*m)/(R + D*L)
y : (-D*f + D*P*m)/(R + D*L)
c : a*n - C*m - P*m
s : n + C*m + P*m - a*n
I'd like to have
p: a*n - C*m - P*m + (D*f - D*P*m)/(R+D*L)
In other words, it would be nice to divide the numer by the denom
leaving any remainder
as a fraction. In yet other words, I'd like to factor the
denominator out of the numerator
to the extent possible.
The expression:
cancel(collect(expand(val),solve))
works in some cases, but not in others (I think because
e.g. C*R*m+C*D*L*m can't factor C*m easily unless you
tell sympy to factor C*m -- but I'm guessing here as I don't really
know)
If this doesn't have a std approach I'll put it in the issue tracker.
Thanks,
Dan
--
You received this message because you are subscribed to the Google Groups
"sympy" group.
To post to this group, send email to sy...@googlegroups.com.
To unsubscribe from this group, send email to
sympy+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/sympy?hl=en.