ASKSAGE: Sage Q&A Forum - Latest question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 06 Nov 2017 04:29:40 -0600How can I get back an expression for free variables in solve function.http://ask.sagemath.org/question/39396/how-can-i-get-back-an-expression-for-free-variables-in-solve-function/I have a number of linear equations on some symbols A,B,C,D,E,F,G. When I solve them in Sagemath, I get some free variables in the solution.
$A,B,C,D,E,F,G=var('A,B,C,D,E,F,G')$
$eqns=[A+B==0,C+D+E==0,F+G==0,A+E-F==0]$
$solution=solve(eqns,A,B,C,D,E,F,G)$
Sage gives the following solution:
$[[A == r1, B == -r1, C == r1 - r2 - r3, D == r3, E == -r1 + r2, F == r2, G == -r2]]$
Now I can ask Sage to give me an expression of any combination of the symbols, for example:
$(A+C).subs(solution)$, then I get $2*r1 - r2 - r3$.
For my purpose I would now like to have an expression for any of the free variables. If I assign $r1=var('r1')$ and ask Sage $s1.subs(solution)$ I get back $r1$ again. But I would lik to get back an expression in terms of $A,B,C,D,E,F,G$.
Any suggestions on how to do this?TheBeiramMon, 06 Nov 2017 04:29:40 -0600http://ask.sagemath.org/question/39396/separation of variables / parameterizing equations in sage mathhttp://ask.sagemath.org/question/9054/separation-of-variables-parameterizing-equations-in-sage-math/<p>Hi,</p>
<p>I've sometimes run into the situation where sage math is unable to solve a system of equations that I then rearrange and am subsequently able to solve.
The question is, Is sage able to do this re-arranging itself?
</p>
<p>Example:</p>
<p>Given a contraint eq1, and eq2 for an op amp subtractor that mixes variables together </p>
<code>
eq1 = vout == (2*v1 - 3*v2)
</code>
<br>
<code>
eq2 = vout == (v1*(R4/(R3+R4))-(((v2-(v1*(R4/(R3+R4))))/R1)*R2))
</code>
<p>can sage somehow rewrite this as an parameterized equation
in terms of v1 and v2</p>
<code>
eq2 = vout == v1*( (R4/(R3+R4)+((R4/(R3+R4))/R1)*R2)) + v2*((-1/R1)*R2)
</code>
<p>
Without my manual intervention?</p>
<p>
I'd like to know if sage can detect that
<p>
2 == ( (R4/(R3+R4)+((R4/(R3+R4))/R1)*R2))
and -3 == ((-1/R1)*R2)
</p>
and solve those.
</p>
<p>
Can it also automatically detect if an equation can be safely separated in this way along some given variables??
</p>
<p>
Thanks to anyone who tries to answer this!
</p>thamsterSat, 09 Jun 2012 16:56:41 -0500http://ask.sagemath.org/question/9054/