Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2000
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2000

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

Search the Archive

Re: Bugs in Abs and Sign !?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg25705] Re: [mg25674] Bugs in Abs and Sign !?
  • From: Tomas Garza <tgarza01 at prodigy.net.mx>
  • Date: Thu, 19 Oct 2000 04:35:30 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

I guess it's just a matter of how Abs[] works. Take

In[1]:=
Abs[x^2] // FullForm
Out[1]//FullForm=
Power[Abs[x], 2]

This says that the calculation of Abs[x^2] proceeds by taking first the 
absolute value of x, and then squaring it. This procedure gives the 
right result. However, for an arbitrary function g,

In[2]:=
g[x^2] // FullForm
Out[2]//FullForm=
g[Power[x, 2]]

i.e., first square the argument and then apply g, which is what one 
might expect. Why does Abs[] goes in a different way? That is why one 
gets

In[3]:=
Abs[x^2] /. Abs[u_] -> fnt[u]
Out[4]=
fnt[x]^2

instead of fnt[x^2]. But I wouldn't call it a bug - it's just the way 
Abs[] calculates, and it gives the right result.

Tomas Garza
Mexico City

Jack Goldberg  <jackgold at umich.edu> wrote:

> Try,
>
> Abs[x^2] /. Abs[u_] -> fnt[u]
>
> and
>
> Sign[x^2] /. Sign[u_] -> fnt[u]
>
> In each case I get  fnt[x]^2.  Shouldn't I get  fnt[x^2]? After all,
> g[x^2] /. g[u_] -> fnt[u]  returns fnt[x^2] which is what I have been 
led
> to expect from Mathematica.  I am using ver 4.01 on a PowerMac.
>
> These peculiarities are driving me crazy.  This is the fourth "bug" I 
have
> found in just 2 weeks.  Please tell me I'm wrong.


  • Prev by Date: Re: Mathematica -> "AI"
  • Next by Date: Re: Associated Legendre Definition
  • Previous by thread: Re: Bugs in Abs and Sign !?
  • Next by thread: Re: Bugs in Abs and Sign !?