# How to use the second solution of an equation?

asked 2014-09-10 08:40:28 -0500 This post is a wiki. Anyone with karma >750 is welcome to improve it.

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/2a0^2 - j(v0 + j(vMax), aMax = sqrt(1/2a0^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!

edit retag close merge delete

Sort by » oldest newest most voted

It's a Python list:

sage: sol=solve(x^2==1,x)
sage: sol
[x == -1, x == 1]
sage: sol
x == -1
sage: sol
x == 1

more solve 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 ; sol ; sol[-1]

x == -2
x == 2
x == 2


Access to the right hand side of the second equation:

sol.rhs()

more