Drexel dragonThe Math ForumDonate to the Math Forum

Ask Dr. Math - Questions and Answers from our Archives
Associated Topics || Dr. Math Home || Search Dr. Math

Calculus of Piecewise Functions

Date: 06/07/2003 at 21:09:28
From: Matt
Subject: Calculus of the modulus function

The modulus function (absolute value function) is a piecewise function 
that is customarily written as f(x)=|x|. Functions such as the floor 
and ceiling functions are also piecewise, but they are written 
concisely with such notations as g(x)=[x].  

Most of the time, with some exceptions, the integrals and derivatives 
of piecewise functions are piecewise themselves.  

Take for example INT(|x|)dx. Its integral is piecewise, i.e. x^2/2 + C 
for x=>0 and -x^2/2 + C for x<0.  This can be written |x^2/2| + C for 
all x.  

But what if the expression within the absolute value signs is more 
complicated than just x?  What if the integral is INT(|u|)u'dx?  Then 
the arbitrary C's are different for each case of the modulus, and 
there would seem to be no way to consolidate the two cases into one 
expression using case notation.

I guess my real question is, can I take the integral or derivative of 
a piecewise function like the floor function [u] or the absolute value 
function |u| and still somehow notate it in concise form, such as |U| 
or [U]?

Date: 06/07/2003 at 23:17:42
From: Doctor Peterson
Subject: Re: Calculus of the modulus function

Hi, Matt.

First (and this will lead into what I want to say anyway), your answer 
for INT(|x| dx) is wrong. As you say, it is

   x^2/2 + C for x >= 0

  -x^2/2 + C for x < 0

But that is not the same as |x^2| + C, since this is always positive, 
and the correct antiderivative is not!

So let's introduce the function that helps us deal with this more 
effectively, the signum, or sign, function

  sgn(x) = 1  if x > 0
           0  if x = 0
          -1  if x < 0

Using this, we can write your antiderivative as

  sgn(x) * x^2/2 + C

Further, what did you do with the two different C's in your 
antiderivative? It looks as if you ignored the distinction, but it 
worked out okay. What you have to do is to find the connection 
between them, which is based on the fact that the antiderivative has 
to be continuous. You find the C in one piece that makes it match up 
with the one next to it. In our example, we really have

   x^2/2 + C1  for x >= 0

  -x^2/2 + C2  for x < 0

and to be continuous, we need

  0^2/2 + C1 = -0^2/2 + C2

In this case, this means that C1=C2 and we can just call it C. In 
harder cases, you might find that, say, C2 = C1+1, and you would have 
to use C+1 in the second piece.

Now I'll demonstrate a way to handle absolute values in integrals that 
can be a little risky sometimes if you aren't careful, but can get you 
more directly to an answer.

Let's write the absolute value function in terms of signum:

  |x| = sgn(x) * x

Do you see why this is true? And do you see that, since signum is 
constant within each piece of its definition, its derivative is zero 
and it commutes with the integral sign? Then

  INT(|x| dx) = INT(sgn(x) * x dx)

              = sgn(x) INT(x dx)

              = sgn(x) x^2/2 + C

Note, by the way, that this approach also makes it obvious that 
d/dx |x| = sgn(x), if you ignore x=0.

I can't guarantee that this will always work correctly; we're being 
a little loose with theorems about integration here, and the 
discontinuity of signum at x=0 in particular makes this potentially 
illegal. In particular, we are saved by the fact that x^2 is zero 
when sgn(x) is zero, which makes the result continuous. You have to 
check things like that before blindly accepting the result, so the 
best thing to do is to use this method to find a neat answer, use the 
piecewise approach to get the right answer, and then compare them.

If you have any further questions, feel free to write back.

- Doctor Peterson, The Math Forum
Associated Topics:
College Calculus
High School Calculus
High School Functions

Search the Dr. Math Library:

Find items containing (put spaces between keywords):
Click only once for faster results:

[ Choose "whole words" when searching for a word like age.]

all keywords, in any order at least one, that exact phrase
parts of words whole words

Submit your own question to Dr. Math

[Privacy Policy] [Terms of Use]

Math Forum Home || Math Library || Quick Reference || Math Forum Search

Ask Dr. MathTM
© 1994-2013 The Math Forum