MathGroup Archive 2010

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

Search the Archive

Re: Question about the derivative of Abs

  • To: mathgroup at
  • Subject: [mg106118] Re: [mg106097] Question about the derivative of Abs
  • From: Leonid Shifrin <lshifr at>
  • Date: Sat, 2 Jan 2010 05:03:41 -0500 (EST)
  • References: <>


The problem seems to be that Abs is defined generally on complex numbers.
Once you specify that your argument is real, it works:

In[1]:= FullSimplify[Abs'[x], Assumptions -> {Element[x, Reals]}]

Out[1]= Sign[x]

In fact, it works also for specific integer arguments (although not

In[2]:= FullSimplify[Abs'[2]]

Out[2]= 1

For a reason I don't understand, this does not work for specific real
arguments however:

In[3]:= FullSimplify[Abs'[2.0]]

Out[3]= (Abs^\[Prime])[2.]

I don't see a good reason for this and think that it should be fixed to also
simplify just like in the case of integers. On the other hand, the above
simplification with FullSimplify seems to be rather a point-like solution -
a result of some specific rule that has been added to the kernel. For
example, the second derivative would not simplify:

In[4]:= FullSimplify[Abs''[2]]

Out[4]= (Abs^\[Prime]\[Prime])[2]

So, coming back to your specific question, here is what I would do:

1. Define your own function <abs>, for example like this:


you may check that it works for derivatives without any extra simplification

In[5]:= abs'[1.5]

Out[5]= 1

In[6]:= abs''[1.5]

Out[6]= 0

2. Use replacement rules to replace Abs with <abs>, in places where you need

In[7]:= Abs''[2.0]/.Abs-> abs

Out[7]= 0

Hope this helps.


On Fri, Jan 1, 2010 at 2:36 AM, Sam Takoy <samtakoy at> wrote:

> Hi,
> I kind of asked this question before, but in a more confusing context,
> so now I would like to ask it by itself.
> In the course of my computations, I get Abs' and Abs''. It is applied to
> a positive number, so I think those values should be 1 and 0. However,
> Mathematica fails to simplify it.
> For example
> In[34]:= Abs'[2.0]
> Out[34]=
> \!\(\*SuperscriptBox["Abs", "\[Prime]",
> MultilineFunction->None]\)[2.]
> These expressions really mess up my answers. How do I get Mathematica to
> do these simplifications?
> Thanks
> Sam

  • Prev by Date: Re: Database Challenge
  • Next by Date: Re: Uninstalling/Reinstalling Mathematica 7?
  • Previous by thread: Question about the derivative of Abs
  • Next by thread: Re: Question about the derivative of Abs