Ask Your Question
1

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

asked 2011-07-29 19:56:54 +0100

Ondra gravatar image

updated 2011-07-29 20:21:52 +0100

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 flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
1

answered 2011-08-01 17:32:23 +0100

benjaminfjones gravatar image

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)
edit flag offensive delete link 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.

Ondra gravatar imageOndra ( 2011-09-16 15:05:06 +0100 )edit
0

answered 2013-12-04 15:27:09 +0100

Hazon Da'kir gravatar image

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.

edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools

Stats

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

Seen: 1,058 times

Last updated: Dec 04 '13