MathGroup Archive 1990

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

Search the Archive

Power[] corrupts, Absolute[Power[]] corrupts absolutely

  • To: mathgroup at
  • Subject: Power[] corrupts, Absolute[Power[]] corrupts absolutely
  • From: fateman at peoplesparc.Berkeley.EDU (Richard Fateman)
  • Date: Tue, 11 Dec 90 11:05:45 PST

There is some heuristic in Mma to the effect that
some functions have ``known'' derivatives, and some do not.
For example, in version 1.2, D[Abs[x],x] is Abs`[x]. 
It appears that a user definition of (appx the same)  absolute value
function by dividing the domain, say


also cannot be differentiated  (that is, D[f[x],x] = f'[x]).
Mma presumably decided that f's derivative was unknown,
based on the information available. OK so far.

Consider yet another version of the absolute value
function function 


which Mma thinks CAN be differentiated.  
It gives a mess (at least in version 1.2)
involving the derivative of ``If'' with respect to each of its
arguments. This is not too useful.  
Also, if you try evaluating g at some unexpected places, you may be surprised.
g[y] evaluates to  If[y>0,y,-y].
g[3+4I] gives an error message
 Greater::nord: Comparison with complex number 3+4 I attempted.

In an attempt to suppress this message, and also to make g[y]
come out simpler, consider this redefinition:


Here, the last clause to the If
is supposed to provide a result in case the test (x>0, in this case)
``gives neither True nor False''.  
Unfortunately it doesn't always work as expected.  
Now g[y] returns Abs[y]. That's ok.  But
g[3+4I] gives the same error message. [The fix, if one were to
be using Lisp, is to provide an ``errorset'' around the conditional
to convert all errors into appropriate values.]

Now consider the definitions
r[x_]:= Sqrt[x]
s[x_]:= x^2

Of course, well known to readers of this list,
we can Plot[r[s[x]],{x,-1,1}] to see that it looks exactly like
Abs[x]. Yet r[s[x]] simplifies to just x. And D[r[s[x]],x]
simplifies to just 1. This is unreasonable since r[s[-3]]
simplifies to 3, not -3.

Power corrupts...
Seasons greetings.

Richard Fateman (fateman at

  • Prev by Date: Re: Coefficient
  • Next by Date: replace by value in expr
  • Previous by thread: Coefficient[]
  • Next by thread: replace by value in expr