MathGroup Archive 2000

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

Search the Archive

Re: [mg 25674] Bugs in Abs etc.

  • To: mathgroup at
  • Subject: [mg25740] Re: [mg 25674] Bugs in Abs etc.
  • From: Jack Goldberg <jackgold at>
  • Date: Sat, 21 Oct 2000 14:42:50 -0400 (EDT)
  • Sender: owner-wri-mathgroup at

Hi Group,

Many thanks to all of you who were kind enough to point out to me my
blunder in assuming that numeric functions never evaluate non-numeric 
symbolic arguments.  On thinking over your comments, I would like to note
some further peculiarities that are not necessarily serious, but do raise
issues of consistency.  I do my computations using ver 4.01 on a PowerMac
and on a Sun.  The results are the same, thank goodness!

(1) Look in the Help Browser for Abs.  The second item down is
this:-"Abs[z] is left unevaluated if z is not a numeric quantity".
Although this is not quite the same thing as saying Abs does not evaluate
symbolic arguments, it is suggestive of this particularly because there is
not the slightest hint that Abs[x^n]->Abs[x]^n anywhere in the Help
Browser or the Mathematica Book references given by the Help Browser. 

(2) Consider  Sign[x].  When I entered ?Sign I get this "Sign[x] gives
-1,0, or 1 depending on whether x is negative, zero, or positive. But Sign
accepts complex entries!  Sign[I] -> I. You find this out when you use the
Help Browser.  Shouldn't this be part of ?.   

(3) As I mention in an earlier post, Abs[(x-1)^2]->Abs[x-1]^2 but 
Abs[x^2-2x+1] returns unevaluated. There are significant problems here
relative to pattern matching.  This is obvious so I stop here.

Let me make one point very clear:  None of these three items are
"killers".  As Alan Hayes points out, we can use Unevaluated and then Mathematica 
treats Abs[(x-1)^2] and Abs[x^2-2x+1] the same way so we need not worry if
Abs[u] is buried deep in some code we write - provided we remember to
include a hold of some sort.  But there are implications here.  

	What other numeric functions shares "evaluates (sometimes) its
symbolic arguments" with Abs and Sign?  Guess?  Can't think of any? What
should you do if some built-in, say BuiltIn[x_], does some simplification
for symbolic arguments? How do you find out about it?  Its not documented.
Perhaps  BuiltIn[x_-a_]->BuiltIn[x].  How would you know to check this
rather than say BuiltIn[x^2]->BuiltIn[x]^2?  So, the only safe course is
to use Unevaluated everywhere!  But this is no good because Unevaluated
stops evaluation of All arguments to BuiltIn including  BuiltIn[1-1].

	I don't recall whether Daniel Lichtblau (sp?) or some other kind
responder pointed out that this troublesome feature (at least to me) was
introduced in ver. 4.  I for one believe Mathematica should, for the reasons I
have outlined, go back to the way Abs and Sign were handled in earlier
versions.  Consistency and therefore predictability are second in
importance only to correctness. You can quote me on this :-)


  • Prev by Date: SingularValues of symmetric real matrix not converging
  • Next by Date: Re: Re: Mathematica -> "AI"
  • Previous by thread: Re: SingularValues of symmetric real matrix not converging
  • Next by thread: Regressions!