Re: Simple Solve Question
- To: mathgroup at christensen.cybernetics.net
- Subject: [mg362] Re: [mg350] Simple Solve Question
- From: wmm at chem.wayne.edu (Martin McClain)
- Date: Tue, 27 Dec 94 13:36:02 EST
>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 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 a 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 solution, but with multiple unknowns), or removal of both brackets (when there is single solution for a single unknown) would be a great convenience. Failure to Flatten here always causes trouble down the page. This is one of the most frequent errors I and my undergraduate students make. WRI, please note: If you automate the flattening, existing programs with explicit flattening will still work perfectly.