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.Sun, 16 Nov 2014 07:03:19 +0100Solving an equation in multiple variableshttps://ask.sagemath.org/question/24870/solving-an-equation-in-multiple-variables/ I have this equation :
sqrt((b-a)^2 + (B-A)^2) == A+B and i would like to have it solved to b-a=+- 2 * sqrt(AB) in sage. Right now I have the following code but it doesn't really output what I want. I just get
A^2 - 2*A*B + B^2 + a^2 - 2*a*b + b^2 == A^2 + 2*A*B + B^2
and I don't know how to make sage solve it further.
my code:
var('a,b,c,A,B,C')
eq1 = (sqrt((b-a)^2 + (B-A)^2) == A+B)
(eq1^2).expand()
Thanks in advance
Sat, 15 Nov 2014 12:08:18 +0100https://ask.sagemath.org/question/24870/solving-an-equation-in-multiple-variables/Answer by god.one for <p>I have this equation :
sqrt((b-a)^2 + (B-A)^2) == A+B and i would like to have it solved to b-a=+- 2 * sqrt(AB) in sage. Right now I have the following code but it doesn't really output what I want. I just get <br/>
A^2 - 2<em>A</em>B + B^2 + a^2 - 2<em>a</em>b + b^2 == A^2 + 2<em>A</em>B + B^2 <br/>
and I don't know how to make sage solve it further. </p>
<p>my code: </p>
<p>var('a,b,c,A,B,C') <br/>
eq1 = (sqrt((b-a)^2 + (B-A)^2) == A+B) <br/>
(eq1^2).expand() </p>
<p>Thanks in advance</p>
https://ask.sagemath.org/question/24870/solving-an-equation-in-multiple-variables/?answer=24871#post-id-24871You can try the following with substituting b-a with c
var('a,b,c,A,B,C')
eq1 = (sqrt((c)^2 + (B-A)^2) == A+B)
assume(A>0)
assume(B>0)
solve(eq1,c)
which results in
[c == -2*sqrt(A*B), c == 2*sqrt(A*B)]
But can anybody explain me the results of the computation without the assume statements? For A,B both beeing negative the solver does not do anything and for A being bigger and B being smaller then zero, sage throws an error that maxima needs further inputs (the same as when you're not using assume)Sat, 15 Nov 2014 14:30:25 +0100https://ask.sagemath.org/question/24870/solving-an-equation-in-multiple-variables/?answer=24871#post-id-24871Comment by vdelecroix for <p>You can try the following with substituting b-a with c</p>
<pre><code>var('a,b,c,A,B,C')
eq1 = (sqrt((c)^2 + (B-A)^2) == A+B)
assume(A>0)
assume(B>0)
solve(eq1,c)
</code></pre>
<p>which results in</p>
<pre><code>[c == -2*sqrt(A*B), c == 2*sqrt(A*B)]
</code></pre>
<p>But can anybody explain me the results of the computation without the assume statements? For A,B both beeing negative the solver does not do anything and for A being bigger and B being smaller then zero, sage throws an error that maxima needs further inputs (the same as when you're not using assume)</p>
https://ask.sagemath.org/question/24870/solving-an-equation-in-multiple-variables/?comment=24873#post-id-24873If there was no assume, an expression like sqrt(A*B) is not very well defined. The same kind of behavior occurs with simplify_radical.Sat, 15 Nov 2014 14:42:42 +0100https://ask.sagemath.org/question/24870/solving-an-equation-in-multiple-variables/?comment=24873#post-id-24873Comment by god.one for <p>You can try the following with substituting b-a with c</p>
<pre><code>var('a,b,c,A,B,C')
eq1 = (sqrt((c)^2 + (B-A)^2) == A+B)
assume(A>0)
assume(B>0)
solve(eq1,c)
</code></pre>
<p>which results in</p>
<pre><code>[c == -2*sqrt(A*B), c == 2*sqrt(A*B)]
</code></pre>
<p>But can anybody explain me the results of the computation without the assume statements? For A,B both beeing negative the solver does not do anything and for A being bigger and B being smaller then zero, sage throws an error that maxima needs further inputs (the same as when you're not using assume)</p>
https://ask.sagemath.org/question/24870/solving-an-equation-in-multiple-variables/?comment=24879#post-id-24879Thanks, but in this case using different assume scenarios resulting in different results is strange (escpecially in the both is negative case)Sun, 16 Nov 2014 07:03:19 +0100https://ask.sagemath.org/question/24870/solving-an-equation-in-multiple-variables/?comment=24879#post-id-24879