Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #3759

Solve never calls Equal?

From Richard Fateman <fateman@cs.berkeley.edu>
Newsgroups comp.soft-sys.math.mathematica
Subject Solve never calls Equal?
Date 2011-07-16 09:42 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <ivrmeu$840$1@smc.vnet.net> (permalink)
References <201107150118.VAA23606@smc.vnet.net> <ivovvt$qpa$1@smc.vnet.net>

Show all headers | View raw


(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]= {}
>
> Doesn't look like a great idea to me.
>
> Andrzej Kozlowski
>

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.


note that f[x_] := If [x == 0, 1, f[x - 1]*x]; f[5] computes 5! and 
calls Equal 6 times... but Factorial[5] does not.


Perhaps the internal support routines do not call Equal?
or calls to it are compiled away and not in reach of redefinition by the 
user?  Or do they call SameQ?   (no, they don't. I tried it).

Cheers


RJF

Back to comp.soft-sys.math.mathematica | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: Numerical accuracy/precision - this is a bug or a feature? Andrzej Kozlowski <akoz@mimuw.edu.pl> - 2011-07-15 09:07 +0000
  Solve never calls Equal? Richard Fateman <fateman@cs.berkeley.edu> - 2011-07-16 09:42 +0000
  Re: Solve never calls Equal? Andrzej Kozlowski <akoz@mimuw.edu.pl> - 2011-07-17 10:08 +0000
  Re: Solve never calls Equal? Andrzej Kozlowski <akoz@mimuw.edu.pl> - 2011-07-17 10:06 +0000
  Re: Solve never calls Equal? Andrzej Kozlowski <akoz@mimuw.edu.pl> - 2011-07-17 10:07 +0000
    Re: Solve never calls Equal? Richard Fateman <fateman@cs.berkeley.edu> - 2011-07-18 10:15 +0000
    Re: Solve never calls Equal? Richard Fateman <fateman@cs.berkeley.edu> - 2011-07-18 10:17 +0000
    Re: Solve never calls Equal? Andrzej Kozlowski <akoz@mimuw.edu.pl> - 2011-07-18 10:16 +0000
      Re: Solve never calls Equal? Richard Fateman <fateman@cs.berkeley.edu> - 2011-07-19 10:55 +0000
    Re: Solve never calls Equal? Andrzej Kozlowski <akoz@mimuw.edu.pl> - 2011-07-19 10:56 +0000
    Re: Solve never calls Equal? Richard Fateman <fateman@eecs.berkeley.edu> - 2011-07-19 11:00 +0000
    Re: Solve never calls Equal? Daniel Lichtblau <danl@wolfram.com> - 2011-07-19 11:01 +0000
  Re: Solve never calls Equal? Andrzej Kozlowski <akoz@mimuw.edu.pl> - 2011-07-17 10:08 +0000
  Re: Solve never calls Equal? Andrzej Kozlowski <akoz@mimuw.edu.pl> - 2011-07-18 10:13 +0000

csiph-web