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: [mg25727] Re: [mg25674] Bugs in Abs and Sign !?
  • From: "Mark Harder" <harderm at ucs.orst.edu>
  • Date: Thu, 19 Oct 2000 04:35:58 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Jack,
    In this case, the Trace function was helpful:
In[121]:=
Trace[
  Abs[x^2] /. Abs[q_] -> fnt[q] ]

Out[121]=
            2             2
2                                        2
{{Abs[x ], Abs[x] }, {Abs[q_] -> fnt[q], Abs[q_] -> fnt[q]}, Abs[x]  /.
Abs[q_] -> fnt[q], fnt[x] }

In other words, the first thing Mathematica did was "simplify" the Abs[x^2] to
Abs[x]^2, and go completely wrong from then on.  I found that
Abs[x^2]/.Abs[q_^2]->fnt[q^2] gives you what you want, but that's a little
too specific.  Maybe there's some way Mathematica allows you to specify a pattern
that stands for a compound expression like x^2, but I don't know what it is.
To avoid the "bug", try Hold[]-ing the expression to be simplified:

In[125]:=
ReleaseHold[Hold[Abs[x^2]] /. Abs[q_] -> fnt[q] ]
Out[125]=
fnt[x^2]

-mark harder



From: Jack Goldberg <jackgold at umich.edu>
To: mathgroup at smc.vnet.net
Subject: [mg25727] [mg25674] Bugs in Abs and Sign !?


>Hi group.
>
>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.
>
>Thanks guys.
>
>Jack
>
>
>



  • Prev by Date: Re: Displaying 3D data as 2D + color
  • Next by Date: Re: Change objetive function in Non-Linear Fit
  • Previous by thread: Re: Bugs in Abs and Sign !?
  • Next by thread: Re: Bugs in Abs and Sign !?