Skip to main content
1 of 4
sjdh
  • 7.8k
  • 5
  • 38
  • 48

extract values form replacement list

Solve returns a list of replacement rules

In: Solve[x + y == 3 && x - y == 6, {x, y}]
Out: {{x -> 9/2, y -> -(3/2)}}

I am only interested in the right hand side of these rules. To extract the right hand side I use substitution:

({x, y} /. sol)[[1]]

It gives

{9/2, -(3/2)}

This works, but it is not very elegant. You have to adapt the list of the variables, each time you solve for different variables. Is there a more general way to extract the right hand sides form a list of replacements?

sjdh
  • 7.8k
  • 5
  • 38
  • 48