Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2004
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2004

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

Search the Archive

Re: Simple question

  • To: mathgroup at smc.vnet.net
  • Subject: [mg48087] Re: Simple question
  • From: Paul Abbott <paul at physics.uwa.edu.au>
  • Date: Tue, 11 May 2004 05:20:12 -0400 (EDT)
  • Organization: The University of Western Australia
  • References: <c7fi8a$oda$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

In article <c7fi8a$oda$1 at smc.vnet.net>,
 George Kamin <gwkamin at adelphia.net> wrote:

> This is simple question, but I do not know how to go about searching for it 
> in this user groups data base. I also could not find a reference to the 
> solution in the "Mathematica Book". How does one assign the result of 
> Solve[.] or FindRoot[.] in the form {x1-> 3.14,x2->0.763} to the two 
> variables y1,y2 respectively?? 

Others have answered your question -- but I should ask you _why_ you 
want to assign the values (returned as rules) to variables? The idea of 
returning results as a list of replacement rules is to avoid explicit 
variable assignments.

If you have

   vals = {x1-> 3.14,x2->0.763};

then you can substitute these values into any expression involving x1 
and/or x2. For example

   x1^2 - x2 /. vals

or

  ContourPlot[Evaluate[(x-x1)^2+(y-x2)^2 /. vals], {x,-5,5}, {y,-1,1}];

Sometimes variable assignment is desirable or required but, usually, the 
above approach is preferable.

Cheers,
Paul

-- 
Paul Abbott                                   Phone: +61 8 9380 2734
School of Physics, M013                         Fax: +61 8 9380 1014
The University of Western Australia      (CRICOS Provider No 00126G)         
35 Stirling Highway
Crawley WA 6009                      mailto:paul at physics.uwa.edu.au 
AUSTRALIA                            http://physics.uwa.edu.au/~paul


  • Prev by Date: RE: Re: Mandelbrot Set & Mathematica
  • Next by Date: Re: Eliminate duplicates using Union [] in a
  • Previous by thread: Re: Simple question
  • Next by thread: Building List