Ask Your Question

How to use the second solution of an equation?

asked 2014-09-10 08:40:28 -0500

this post is marked as community wiki

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 flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted

answered 2014-09-10 09:07:10 -0500

rws gravatar image

updated 2014-09-10 09:08:11 -0500

It'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
edit flag offensive delete link more

answered 2014-09-10 09:09:39 -0500

ndomes gravatar image

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)

[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:

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2014-09-10 08:40:28 -0500

Seen: 61 times

Last updated: Sep 10 '14