MathGroup Archive 1998

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

Search the Archive

Re: Question about equations solutions?


ieblanc at ibm.net wrote:
> 
> This is probably a dumb question but can anyone help.
> 
> a = Solve[y^2+5*y*x+6*x^2==0,y]  gives an answer of  {{y->-3 x},{y->-2
> x}}
> 
> and
> 
> Print[a] then displays {{y->-3 x},{y->-2 x}}
> 
> How do get Print or some later input to reference the actual solutions
> "2x" or "3x" instead of {{y->-3 x},{y->-2 x}}
> 
> Thanks Ian

This form of output is a transformation rule.  In your case,

Map[(y/.#)&,Flatten[{{y->-3 x},{y->-2 x}},1]]

will return

{-3 x,-2 x}

and you can access the solutions as elements of the list.

The snippet of code above uses Map, from the functional paradigm along
with (y/.#)&, a pure function construct of a form from the
transformational paradigm.  I learned this mostly from third party
books on mathematica programming.  I recommend something like the Power
Programming book by David Wagner.


  • Prev by Date: Re: coordinate transformation
  • Next by Date: Re: coordinate transformation
  • Previous by thread: Question about equations solutions?
  • Next by thread: Re: Question about equations solutions?