Ask Your Question

How to make solve to use certain variables on the right side

if I have

I1, IR1, IR2, U1, R1, R2 = var('I1 IR1 IR2 U1 R1 R2')
equations = [
I1 == IR1 + IR2,
IR1 == U1/R1,
IR2 == U1/R2
]


how can I make solve to return

I == (R1 + R2)*U1/(R1*R2)


?

solve(equations, I)


now returns just an empty list

or similait problem is with

I1, IC1, IC2, U1d, U2d, C1, C2 = var('I1, IC1, IC2, U1d, U2d, C1, C2')
equations = [
I1 == IC1 + IC2,
IC1 == C1*U1d,
IC2 == C2*U1d
]


and desired result is

I1 == (C1 + C2)*IC2/C2

edit retag close merge delete

2 Answers

Sort by » oldest newest most voted

I don't know what I is in your code, perhaps you meant I1. It looks like to me that you have one equation involving I1 and you want to substitute the values of IR1 and IR2 from the second two equations into it. If that's really all you want, then calling solve is overkill. Try this:

sage: eqn = I1 == IR1 + IR2
sage: eqn = eqn.subs(IR1 == U1/R1)
sage: eqn = eqn.subs(IR2 == U1/R2)
sage: eqn
I1 == U1/R1 + U1/R2
sage: eqn.rhs()
U1/R1 + U1/R2
sage: eqn.rhs().factor()
(R1 + R2)*U1/(R1*R2)

more

Comments

yes! factor() is what I was looking for. but this returns "(R1 + R2)*U1/(R1*R2)". can I make it somehow to return "I1 == (R1 + R2)*U1/(R1*R2)"? from the documentation, it seems that factor only is method of expressions, not equations.

( 2011-09-16 15:05:06 +0200 )edit

Did I do this right, I1=(R1+R2)U2/(R1R2) ok R= reality, U= universe I1= (31+32)12/(3132), I1=(3+6)12/(36), I1=92/18, I1=18/18, I1=1, I=1. I might just be a total numbskull I don't even know if this has anything to do with your guy's equations sorry if I was way off.

more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Stats

Asked: 2011-07-29 19:56:54 +0200

Seen: 774 times

Last updated: Dec 04 '13