MathGroup Archive 2003

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

Search the Archive

Re: Re: Re: NSolve fails where Solve succeeds!

  • To: mathgroup at smc.vnet.net
  • Subject: [mg43557] Re: [mg43530] Re: [mg43478] Re: NSolve fails where Solve succeeds!
  • From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
  • Date: Sat, 20 Sep 2003 06:39:26 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

On Friday, September 19, 2003, at 04:41 PM, Murray Eisenberg wrote:

> Are you objecting to the absence of a (vector) variable on the 
> left-hand
> side of the equation, or just to an equation with a matrix (list of
> equal-length lists) on the left-hand side and a scalar on the 
> right-hand
> side?
>
> If the latter:  Why should Mathematica NOT like {{a,b}, {c,d}} == 0 ?
> After all, it has no trouble returning a reasonable result for:
>
>    ((a, b}, {c, d}} + 0
>
> I'm not talking about the way the language IS, but rather the way it
> OUGHT to be designed!

I don't agree. Note than:

In[1]:=
Attributes[Plus]

Out[1]=
{Flat, Listable, NumericFunction, OneIdentity, Orderless,
   Protected}
In[2]:=
Attributes[Equal]
Out[2]=
{Protected}

Note that unlike Plus, Equal does not have the attribute Listable (and 
for good reasons!). The role of Listable in such cases is of course 
crucial:

In[4]:=
F[{{a,b},{c,d}},0]

Out[4]=
F[{{a,b},{c,d}},0]

In[5]:=
SetAttributes[F,Listable]

In[6]:=
F[{{a,b},{c,d}},0]

Out[6]=
{{F[a,0],F[b,0]},{F[c,0],F[d,0]}}

Now, since Equal does not have the Listable attribute it is Solve that 
is responsible for the threading of Equal over List which happens only 
within Solve. I personally find this quite convenient, but it does not 
appear to be documented  and seems to me as a case of putting 
convenience ahead of logic of design. (It is not really a good general 
principle for a function to sometimes behave as if it had an attribute 
it actually does not have). What is worse is that NSolve seems to 
behave differently in this respect, thus:

In[9]:=
NSolve[{x, y} == 0, {x, y}]

Out[9]=
{{x -> 0., y -> 0.}}

In[10]:=
NSolve[{{x, y}} == 0, {x, y}]

----Error message ---
Out[10]=
NSolve[{{x, y}} == 0, {x, y}]



Andrzej Kozlowski
Yokohama, Japan
http://www.mimuw.edu.pl/~akoz/
http://platon.c.u-tokyo.ac.jp/andrzej/



>
>
> Jens-Peer Kuska wrote:
>
>> Hi,
>>
>> you say that the matrix {{a,b}
>>                          {c,d}}
>>
>> should be equal to a scalar 0 and you wonder
>> why Mathematica dont' like it ...
>>
>> I wonder why Solve[] gives a solution at all
>> and *this* seems to be the bug. You mean
>>
>> NSolve[Flatten[Thread  /@ Thread[{{a, b}, {c, d}} == 0]]]
>>
>> you you should tell Mathematica *what* you mean.
>>
>> Regards
>>   Jens
>>
>>
>> Pavel Pokorny wrote:
>>
>>>  Dear Mathematica friends
>>>
>>>   Solve[{{a,b},{c,d}}==0]
>>>
>>> gives the correct solution in Mathematica 5.0 while
>>>
>>>   NSolve[{{a,b},{c,d}}==0]
>>>
>>> fails.
>>>
>>> Is it a bug or an intention?
>>>
>>> It would be nice to have Solve and NSolve giving
>>> as close results as possible.
>>>
>>> --
>>> Pavel Pokorny
>>> Math Dept, Prague Institute of Chemical Technology
>>> http://www.vscht.cz/mat/Pavel.Pokorny
>>
>>
>>
>
> -- 
> Murray Eisenberg                     murray at math.umass.edu
> Mathematics & Statistics Dept.
> Lederle Graduate Research Tower      phone 413 549-1020 (H)
> University of Massachusetts                413 545-2859 (W)
> 710 North Pleasant Street            fax   413 545-1801
> Amherst, MA 01003-9305
>
>
>


  • Prev by Date: Re: Re: Trouble importing Mathematica EPS files into Deneba Canvas
  • Next by Date: Re: how to import data???
  • Previous by thread: Re: NSolve fails where Solve succeeds!
  • Next by thread: Re: NSolve fails where Solve succeeds!