Ask Your Question
1

solve an equation in terms of an expression?

asked 2013-01-28 14:12:07 +0100

penfold gravatar image

updated 2013-01-28 21:23:39 +0100

calc314 gravatar image

Hi,

Not entirely sure if I worded the subject line of this question right, Essentially what I am trying to do is rearrange an equation based on what I want on the left hand side of it, for example:

I have defined my variables:

var('v_o, v_i, delta, T, v_d, v_c')

Entered my equation:

eqn1= v_i * delta * T == v_o + v_d + v_c - v_i * (1-delta) * T

Made a substitution:

eqn2 = eqn1.substitute(v_c=v_i)

and now, with minimum possible effort I would like sage to put it in the form of:

delta/(1-delta)=...

Many thanks to anyone who's even read this far down, Any help would be much appreciated

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
2

answered 2013-01-28 21:46:51 +0100

benjaminfjones gravatar image

You could try solving for delta and then just compute delta/(1-delta). However, in the equation eqn1 you've given delta cancels out on both sides so it isn't possible to solve for it. Here's a simplified example:

sage: a,b,c,d = var('a,b,c,d')
sage: eqn1= a * d == b - a * (1-d)
sage: eqn1
a*d == (d - 1)*a + b
sage: solve(eqn1, d)
[]

Which means that any value of d is a solution. So maybe you've got a typo in your equation. If, for example, you start with the $a * d == b + a * (1-d)$ --notice that I changed one of the signs on the right hand side-- and you want to derive an expresion for $d/(1-d)$ you could do:

sage: a,b,c,d = var('a,b,c,d')
sage: eqn1= a * d == b + a * (1-d)
sage: S = solve(eqn1, d); S
[d == 1/2*(a + b)/a]
sage: soln_d = S[0].rhs(); soln_d
1/2*(a + b)/a
sage: soln_d / (1 - soln_d)
-(a + b)/(((a + b)/a - 2)*a)
edit flag offensive delete link more
0

answered 2013-01-30 07:25:16 +0100

ndomes gravatar image

Let Sage solve a system of equations:

sage: a,b,c,d,z = var('a,b,c,d,z')
sage: eqn1= a * d == b + a * (1-d)
sage: eqn2 = z == d / (1 - d)
sage: S = solve([eqn1,eqn2], d,z);  S

[ [d == 1/2*(a + b)/a, z == (a + b)/(a - b)] ]

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: 2013-01-28 14:12:07 +0100

Seen: 1,503 times

Last updated: Jan 30 '13