MathGroup Archive 1994

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

Search the Archive

Re: Simple Solve Question

  • To: mathgroup at christensen.cybernetics.net
  • Subject: [mg363] Re: [mg350] Simple Solve Question
  • From: Richard Mercer <richard at seuss.math.wright.edu>
  • Date: Tue, 27 Dec 1994 13:43:32 -0500

>  Dear MathGroupers-
>  

>      I have a very simple question.  Why when you issue
>  

>  Solve[5 x==10, x]
>  

>  Does MMA return:  {{x->2}}
>  

>  I'm wondering why it's List[List[...]].
>  

>  I hate using Flatten to get rid of this nested List.
>  

>  Thanks in advance, Daryl

It's a double list because when there is more than one solution or more than  
one variable, two levels of List may be necessary, e.g.

In[3]:=
Solve[{x^2 - y^2 == 3, x^2 + y^2 == 5},{x,y}]
Out[3]=
{{x -> -2, y -> -1}, {x -> -2, y -> 1}, {x -> 2, y -> -1}, {x -> 2, y -> 1}}

That of course doesn't mean it need to be there when not necessary, but that's  
the way it's done. This is one of the things my calcE package deals with, viz.

In[5]:=
SolvE[5 x == 10]
Out[5]=
{2}
In[6]:=
SolvE[5 x == 10,Rules]
Out[6]=
{x -> 2}
In[7]:=
SolvE[{x^2 - y^2 == 3, x^2 + y^2 == 5}]
Out[7]=
{{-2, -1}, {-2, 1}, {2, -1}, {2, 1}}
In[8]:=
SolvE[{x^2 - y^2 == 3, x^2 + y^2 == 5},Rules]
Out[8]=
{{x -> -2, y -> -1}, {x -> -2, y -> 1}, {x -> 2, y -> -1}, {x -> 2, y -> 1}}

(Ask for more information if you're interested. This is a tiny feature in a  
large package with hundreds of features.)

Richard Mercer 


  • Prev by Date: Re: Extracting DSolve[]'s solution
  • Next by Date: Re: Suggestions needed for Mathematica course
  • Previous by thread: Re: Simple Solve Question