[Date Index]
[Thread Index]
[Author Index]
Re: Solve never calls Equal?
*To*: mathgroup at smc.vnet.net
*Subject*: [mg120290] Re: Solve never calls Equal?
*From*: Bill Rowe <readnews at sbcglobal.net>
*Date*: Sun, 17 Jul 2011 06:02:23 -0400 (EDT)
On 7/16/11 at 5:41 AM, fateman at cs.berkeley.edu (Richard Fateman)
wrote:
>(in a different thread, where replacing Equal by SameQ was proposed)
>On 7/15/2011 2:07 AM, Andrzej Kozlowski wrote:
>>Well, here is one example of what would happen:
>>In[3]:= Unprotect[Equal]
>>Out[3]= {Equal}
>>In[5]:= Equal[a_, b__] := SameQ[a, b]
>>In[6]:= Protect[Equal]
>>Out[6]= {Equal}
>>In[7]:= Solve[3 x == 1, x]
>>Out[7]= {}
>That's because 3*x==1 is immediately changed to False, and
>Solve[False, x] is indeed not a great idea.
>Equal[a_?NumberQ, b_?NumberQ] := SameQ[a, b];
>works better. That Solve example works just fine.
>Indeed, if one does this..
>Equal[a_?NumberQ, b_?NumberQ] := (Print[test[a, b]]; SameQ[a, b]);
>one can detect when, if ever, the Solve program calls Equal on two
>numbers. It will print test[...] on such occasions.
>When does Solve call Equal on 2 numbers? I poked around a little
>and found -- never. I tried Integrate, Factor, Do, Product, Plot..
>--never.
Clearly, Andrzej's example is flawed. And perhaps, the code for
Solve never calls Equal and modification of Equal has no impact
on Solve. But so what?
Version 8 of Mathematica has over 4000 built in symbols some of
which would be unlikely to have calls to Equal others that may
well call Equal. Without access to the source code, I don't know
how it would be possible to ascertain modification of something
as fundamental as Equal could not have undesired effects on
other portions of Mathematica. In fact, I suspect even with
access to the source code, it would take extensive testing to
verify there was no undesired impact.
So, it seems to me, it is quite unwise to modify the behavior of
fundamental functions such as Equal in Mathematica. Far better
to define your own function that behaves as you want. Any
function you define is certain to not change operation of
built-in functions.
Prev by Date:
**Re: Numerical accuracy/precision - this is a bug or**
Next by Date:
**Re: MultinormalDistribution Question**
Previous by thread:
**Re: Numerical accuracy/precision - this is a bug or**
Next by thread:
**I: NONLINEARMODELFIT**
| |