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.Wed, 10 Sep 2014 16:09:39 +0200How to use the second solution of an equation?https://ask.sagemath.org/question/24084/how-to-use-the-second-solution-of-an-equation/Hi,
I'm new to Sage and have the following question:
After solving an equation, Sage gives me two possible solutions:
**sage**: solve((vMax-v0) == (DeltaV11+DeltaV13), aMax)
[aMax == -sqrt(1/2*a0^2 - j(v0 + j(vMax), aMax = sqrt(1/2*a0^2 - j(v0 + j(vMax)]
For the further calculations, I have to use the second one. How can I do that?
Thank you for your help!
Wed, 10 Sep 2014 15:40:28 +0200https://ask.sagemath.org/question/24084/how-to-use-the-second-solution-of-an-equation/Answer by rws for <p>Hi,
I'm new to Sage and have the following question:</p>
<p>After solving an equation, Sage gives me two possible solutions:</p>
<p><strong>sage</strong>: solve((vMax-v0) == (DeltaV11+DeltaV13), aMax)</p>
<p>[aMax == -sqrt(1/2<em>a0^2 - j(v0 + j(vMax), aMax = sqrt(1/2</em>a0^2 - j(v0 + j(vMax)]</p>
<p>For the further calculations, I have to use the second one. How can I do that?</p>
<p>Thank you for your help!</p>
https://ask.sagemath.org/question/24084/how-to-use-the-second-solution-of-an-equation/?answer=24085#post-id-24085It's a Python list:
sage: sol=solve(x^2==1,x)
sage: sol
[x == -1, x == 1]
sage: sol[0]
x == -1
sage: sol[1]
x == 1
Wed, 10 Sep 2014 16:07:10 +0200https://ask.sagemath.org/question/24084/how-to-use-the-second-solution-of-an-equation/?answer=24085#post-id-24085Answer by ndomes for <p>Hi,
I'm new to Sage and have the following question:</p>
<p>After solving an equation, Sage gives me two possible solutions:</p>
<p><strong>sage</strong>: solve((vMax-v0) == (DeltaV11+DeltaV13), aMax)</p>
<p>[aMax == -sqrt(1/2<em>a0^2 - j(v0 + j(vMax), aMax = sqrt(1/2</em>a0^2 - j(v0 + j(vMax)]</p>
<p>For the further calculations, I have to use the second one. How can I do that?</p>
<p>Thank you for your help!</p>
https://ask.sagemath.org/question/24084/how-to-use-the-second-solution-of-an-equation/?answer=24086#post-id-24086solve returns a list of equations (or a list of lists of equations)
Assign to a name (for example sol)
sol = solve(x^2 == 4 , x)
sol
[x == -2, x == 2]
Access to the equations in the list
First, second, last:
sol[0] ; sol[1] ; sol[-1]
x == -2
x == 2
x == 2
Access to the right hand side of the second equation:
sol[1].rhs()
Wed, 10 Sep 2014 16:09:39 +0200https://ask.sagemath.org/question/24084/how-to-use-the-second-solution-of-an-equation/?answer=24086#post-id-24086