Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Utilizing the Result From Solve[]

  • To: mathgroup at
  • Subject: [mg64143] Re: [mg64099] Utilizing the Result From Solve[]
  • From: "Erickson Paul-CPTP18" <Paul.Erickson at>
  • Date: Thu, 2 Feb 2006 00:07:03 -0500 (EST)
  • Sender: owner-wri-mathgroup at

Hopefully there is a more general solution for this, but I've used in
that past

z = Solve[z + 2 == 3, z][[1, 1, 2]] (* which is a little hard to
understand ... *)


z = z /. Solve[z + 2 == 3, z][[1]] (* which is a little better, but ...

The z /. ... Converts the rule into a list and therefore that form can
be used for converting any rule to a list of one element. The [[1]]
(Part) pulls out the number. I've always been interested in getting to
the number embedded in a larger equation, so assigning it as the value
to the same variable as above will be a little confusing especially on
subsequent evaluation within the same kernel unless you do an explicit
clear. I'd suggest a separate variable name, if so needed like: 

a = z /. Solve[z + 2 == 3, z][[1]]


-----Original Message-----
From: Shyam Guthikonda [mailto:shyamguth at] 
To: mathgroup at
Subject: [mg64143] [mg64099] Utilizing the Result From Solve[]

If I am solving a simple equation, such as: Solve[z+2 = = 3,z], this
returns {{z->1}}. How can I easily get the result, 1? Solve[] returns
the solution in rule form.

The current method I use to just get the result looks very ugly. Is
there an easier way to do this?

Here is my current method:

ReplaceAll[z, First[ First[ Solve[ z + 2 = = 3, z ]]]]; z = %;

Now I can use z as a normal variable.


  • Prev by Date: Re: does anybody know how to find the inverse Laplace transform of this wierd thing?
  • Next by Date: Re: Singularities at end point in integrations...
  • Previous by thread: Re: Utilizing the Result From Solve[]
  • Next by thread: Re: Utilizing the Result From Solve[]