Symbolic Math Toolbox    

Extended Calculus Example

This section presents an extended example that illustrates how to find the maxima and minima of a function. The section covers the following topics:

Defining the Function

The starting point for the example is the function

You can create the function with the commands

which return

The example shows how to find the maximum and minimum of the second derivative of . To compute the second derivative, enter

which returns

Equivalently, you can type f2 = diff(f,x,2). The default scaling in ezplot cuts off part of the graph of f2. You can set the axes limits manually to see the entire function:

From the graph, it appears that the maximum value of is 1 and the minimum value is -4. As you will see, this is not quite true. To find the exact values of the maximum and minimum, you only need to find the maximum and minimum on the interval . This is true because is periodic with period , so that the maxima and minima are simply repeated in each translation of this interval by an integer multiple of . The next two sections explain how to do find the maxima and minima.

Finding the Zeros of f3

The maxima and minima of occur at the zeros of . The statements

compute and display it in a more readable form:

You can simplify this expression using the statements

Now, to find the zeros of , enter

This returns a 5-by-1 symbolic matrix

each of whose entries is a zero of . The commands

convert the zeros to double form:

So far, you have found three real zeros and two complex zeros. However, as the following graph of f3 shows, these are not all its zeros:

The red circles in the graph correspond to zerosd(1), zerosd(4), and zerosd(5). As you can see in the graph, there are also zeros at . The additional zeros occur because contains a factor of , which is zero at integer multiples of . The function, solve(sin(x)), however, only finds the zero at x = 0.

A complete list of the zeros of in the interval is

You can display these zeros on the graph of with the following commands:

Finding the Maxima and Minima of f2

To find the maxima and minima of , calculate the value of at each of the zeros of . To do so, substitute zeros into f2 and display the result below zeros:

This shows the following:

You can display the maxima and minima with the following commands:

This displays the following figure.

The preceding analysis shows that the actual range of is [-4, 1.0051].

Integrating

To see whether integrating twice with respect to x recovers the original function , enter the command

which returns

This is certainly not the original expression for . Now look at the difference .

You can simplify this using simple(d) or simplify(d). Either command produces

This illustrates the concept that differentiating twice, then integrating the result twice, produces a function that may differ from by a linear function of .

Finally, integrate once more:

The result

involves the arctangent function.

Note that is not an antiderivative of for all real numbers, since it is discontinuous at odd multiples of , where is singular. You can see the gaps in in the following figure.

To change into a true antiderivative of that is differentiable everywhere, you can add a step function to . The height of the steps is the height of the gaps in the graph of . You can determine the height of the gaps by taking the limits of as x approaches from the left and from the right. The limit from the left is

On the other hand, the limit from the right is

The height of the gap is the distance between the left and right hand limits, which is , as shown in the following figure.

You can create the step function using the round function, which rounds numbers to the nearest integer, as follows:

Each step has width and the jump from one step to the next is , as shown in the following figure.

Next, add the step function J(x) to F(x) with the following code:

Adding the step function raises the section of the graph of F(x) on the interval up by , lowers the section on the interval down by , and so on, as shown in the following figure.

When you plot the result by entering

you see that this representation does have a continuous graph.


  Calculus Example Simplifications and Substitutions 

Learn more about the latest releases of MathWorks products:

 © 1994-2009 The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS