Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Possible Duplicate:
Assign the results from a Solve to variable(s)

In the following example:

Clear[g1, z1, a, g2, z2]
sa = Solve[ g1 == 1 + l z1/(z1^2 + a), a]
sb = Solve[ g2 == 1 - l z2/(z2^2 + b), b] /. z2 -> z1 + l

This gives me solutions for a and b that are in the form

{{ a -> astuff }}
{{ b -> bstuff }}

I want to use this result in a secondary computation, and did so by cut and pasting from the Solve[] results like so

 Solve[ astuff == bstuff, z1 ]

How can I just extract those results without cut and pasting? I don't like the cut and paste dependency since I'd have to redo it all if I make any sort of correction to the first couple identities.

share|improve this question

marked as duplicate by Jens, Artes, Ajasja, Mr.Wizard Dec 15 '12 at 20:46

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

You can use Part to extract the relevant bits. – b.gatessucks Dec 15 '12 at 20:06

You could use ReplaceAll (/.):

Clear[g1, z1, a, g2, z2]
sa = Solve[g1 == 1 + l z1/(z1^2 + a), a]
sb = Solve[g2 == 1 - l z2/(z2^2 + b), b] /. z2 -> z1 + l

Solve[(a /. sa[[1]]) == (b /. sb[[1]]), z1]

Here the /. command is used to manipulate the expressions a and b according to the rules given by sa and sb.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.