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 1995

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

Search the Archive

Re: Re: Simple Solve Question

  • To: mathgroup at
  • Subject: [mg385] Re: [mg362] Re: [mg350] Simple Solve Question
  • From: danl (Daniel Lichtblau)
  • Date: Tue, 3 Jan 1995 10:49:19 -0600

  Automatic flattenning is not/will not be done because it is the  
wrong thing to do. The output of Solve is a list of solns, each of  
which is a list of rules. Flattenning would destroy this structure.  
Among other drawbacks, it would kill any code that automatically  
extracts info from Solve output, because such code would assume the  
output of Solve was as described above.

  Daniel Lichtblau, WRI

Begin forwarded message:

Date: Tue, 27 Dec 94 13:36:02 EST
From: wmm at (Martin McClain)
Subject: [mg362] Re: [mg350] Simple Solve Question
To: mathgroup at
Content-Length: 1144

>Dear MathGroupers-
>    I have a very simple question.
>Why when you issue
>Solve[5 x==10, x]
>Does MMA return:
>I'm wondering why it's List[List[...]].
>I hate using Flatten to get rid of this nested List.
>Thanks in advance,

It's because in general, Solve[] produces multiple sets of multiple
replacements, like
{{x->1,y->2},{x->3,y->4}}.  When there is only a single solution for  
single unknown, the double brackets survive because to get rid of  
them they
would have to test for them explicitly, and I suppose this would make
Solve[] a tiny bit slower.

But I agree completely with you.  I use Mma a lot for simple  
problems, and
automatic removal of the outer bracket (when there is only one  
but with multiple unknowns), or removal of both brackets (when there  
single solution  for a single unknown) would be a great convenience. 

Failure to Flatten here always causes trouble down the page.  This is  
of the most frequent errors I and my undergraduate students make.

WRI, please note:  If you automate the flattening, existing programs  
explicit flattening will  still work perfectly.

  • Prev by Date: Re: Unique List
  • Next by Date: NDSolve
  • Previous by thread: Re: Simple Solve Question
  • Next by thread: FindMinimum in specified range if gradient cannot be found symbolically