ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 15 May 2017 23:49:55 +0200Symbolic solution not fully solved?https://ask.sagemath.org/question/37592/symbolic-solution-not-fully-solved/I'm not a mathematician, and only barely literate as a programmer, so please excuse me if I've overlooked something simple.
I'm using sage to make plots to help in the design of heating elements.
For the first iteration of my solution I could solve/check everything by hand but when trying to include load dependent voltage sag the equations became unwieldy and I want to use sage to symbolically solve the equations involved.
For most of the equations I've entered, when I use "solve" on the symbolic expression it places the element that I wanted to solve for on the lhs of the equation, followed by an expression completely devoid of that term on the rhs.
This is what I want.
E.g.:
Rl,Rp,W,Vb,Rho,L,r,pi,F = var('Rl,Rp,W,Vb,Rho,L,r,pi,F')
eq42 = solve((Vb^2 * Rl)/(Rp + Rl)^2 == W, Rl)
eq42
yields:
[Rl == 1/2*(Vb^2 - 2*Rp*W - sqrt(Vb^2 - 4*Rp*W)*Vb)/W, Rl == 1/2*(Vb^2 - 2*Rp*W + sqrt(Vb^2 - 4*Rp*W)*Vb)/W]
However for one equation it left a term that it "solved for" on the rhs. Does this mean that the equation can't be solved? Because these are physical, highly predictable systems I find that hard to believe, but I don't see another explanation?
E.g.:
eq72 = solve(1/2*(Vb^2 - 2*Rp*W + sqrt(Vb^2 - 4*Rp*W)*Vb)*pi*r^2/(Rho*W) == W/(F * 2
* pi * r), W)
yields:
[W == -(F*Rp*pi^2*r^3 + sqrt(F^2*Rp^2*pi^2*r^4 + F*Rho*Vb^2*r + sqrt(Vb^2 - 4*Rp*W)*F*Rho*Vb*r)*pi*r)/Rho, W == -(F*Rp*pi^2*r^3 - sqrt(F^2*Rp^2*pi^2*r^4 + F*Rho*Vb^2*r + sqrt(Vb^2 - 4*Rp*W)*F*Rho*Vb*r)*pi*r)/Rho]
Which is a symbolic expression that still depends on the "solved for" variable?!
Is this behavior a bug? Am I missing something? Is this equation simply lacking a solution?
Thank you for your time
Mon, 15 May 2017 05:26:33 +0200https://ask.sagemath.org/question/37592/symbolic-solution-not-fully-solved/Answer by tmonteil for <p>I'm not a mathematician, and only barely literate as a programmer, so please excuse me if I've overlooked something simple. </p>
<p>I'm using sage to make plots to help in the design of heating elements. </p>
<p>For the first iteration of my solution I could solve/check everything by hand but when trying to include load dependent voltage sag the equations became unwieldy and I want to use sage to symbolically solve the equations involved. </p>
<p>For most of the equations I've entered, when I use "solve" on the symbolic expression it places the element that I wanted to solve for on the lhs of the equation, followed by an expression completely devoid of that term on the rhs.
This is what I want. </p>
<p>E.g.:</p>
<pre><code>Rl,Rp,W,Vb,Rho,L,r,pi,F = var('Rl,Rp,W,Vb,Rho,L,r,pi,F')
eq42 = solve((Vb^2 * Rl)/(Rp + Rl)^2 == W, Rl)
eq42
</code></pre>
<p>yields:</p>
<pre><code>[Rl == 1/2*(Vb^2 - 2*Rp*W - sqrt(Vb^2 - 4*Rp*W)*Vb)/W, Rl == 1/2*(Vb^2 - 2*Rp*W + sqrt(Vb^2 - 4*Rp*W)*Vb)/W]
</code></pre>
<p>However for one equation it left a term that it "solved for" on the rhs. Does this mean that the equation can't be solved? Because these are physical, highly predictable systems I find that hard to believe, but I don't see another explanation?</p>
<p>E.g.:</p>
<pre><code>eq72 = solve(1/2*(Vb^2 - 2*Rp*W + sqrt(Vb^2 - 4*Rp*W)*Vb)*pi*r^2/(Rho*W) == W/(F * 2
* pi * r), W)
</code></pre>
<p>yields:</p>
<pre><code>[W == -(F*Rp*pi^2*r^3 + sqrt(F^2*Rp^2*pi^2*r^4 + F*Rho*Vb^2*r + sqrt(Vb^2 - 4*Rp*W)*F*Rho*Vb*r)*pi*r)/Rho, W == -(F*Rp*pi^2*r^3 - sqrt(F^2*Rp^2*pi^2*r^4 + F*Rho*Vb^2*r + sqrt(Vb^2 - 4*Rp*W)*F*Rho*Vb*r)*pi*r)/Rho]
</code></pre>
<p>Which is a symbolic expression that still depends on the "solved for" variable?!
Is this behavior a bug? Am I missing something? Is this equation simply lacking a solution?</p>
<p>Thank you for your time</p>
https://ask.sagemath.org/question/37592/symbolic-solution-not-fully-solved/?answer=37596#post-id-37596I did not check further, but apparently `sympy` is able to solve it:
sage: Rl,Rp,W,Vb,Rho,L,r,pi,F = var('Rl,Rp,W,Vb,Rho,L,r,pi,F')
sage: eq = 1/2*(Vb^2 - 2*Rp*W + sqrt(Vb^2 - 4*Rp*W)*Vb)*pi*r^2/(Rho*W) - W/(F * 2 * pi * r)
sage: seq = eq._sympy_() ; seq
pi*r**2*(-2*Rp*W + Vb**2 + Vb*sqrt(-4*Rp*W + Vb**2))/(2*Rho*W) - W/(2*F*pi*r)
sage: import sympy
sage: sympy.solve(seq,W)
[pi*(-2*F*Rho*Rp*pi*r**3 + sqrt(2)*Vb*sqrt(F*Rho**3*r**3))/Rho**2,
-pi*(2*F*Rho*Rp*pi*r**3 + sqrt(2)*Vb*sqrt(F*Rho**3*r**3))/Rho**2]
However i am not sure this leads to a correct solution (to be hand-checked):
sage: s = _[0]
sage: seq.subs({W:s})
Rho*r**2*(Vb**2 + Vb*sqrt(Vb**2 - 4*Rp*pi*(-2*F*Rho*Rp*pi*r**3 + sqrt(2)*Vb*sqrt(F*Rho**3*r**3))/Rho**2) - 2*Rp*pi*(-2*F*Rho*Rp*pi*r**3 + sqrt(2)*Vb*sqrt(F*Rho**3*r**3))/Rho**2)/(2*(-2*F*Rho*Rp*pi*r**3 + sqrt(2)*Vb*sqrt(F*Rho**3*r**3))) - (-2*F*Rho*Rp*pi*r**3 + sqrt(2)*Vb*sqrt(F*Rho**3*r**3))/(2*F*Rho**2*r)
sage: seq.subs({W:s}) == 0
FalseMon, 15 May 2017 23:49:55 +0200https://ask.sagemath.org/question/37592/symbolic-solution-not-fully-solved/?answer=37596#post-id-37596