Differentiating Using Maple

The most basic concepts of calculus are the derivative and the integral. It should come as not surprise that Maple has utililities to symbolically compute both. In this section we consider the derivative. The basic command is

>diff(expression, variable);

Consider the examples.

>diff(x^3+2*x,x);

$3x+2$

>diff(t^2,t);
MATH

Explain this one.

>diff(x^3+2*x,t);

0

Functions can also be used. For example, we might have

>f:=x->(x^4+5*x+1);

>diff(f(x),x);

$4x^{3}+5$

We can also find the second derivative. Here is the command

>diff(f(x),x$2);

$12x^{2}$

Higher order derivatives are just as easy to compute using the following general command

diff(f(x),x$k);

Here, $k$ is the order of the derivative to be determined. The similar command works for whole expressions: diff(expression,x$k); You need not use a function; any expression will do. This sometimes makes computations quicker and easier.

Finding relative maxima and minima

Maple is a power tool for finding relative maxima or minima. To accomplish this we need to used a couple of the commands already learned. There are two basic steps. (1) Find the derivative. (2) Find the critical points. (i.e. Solve MATH (3) Determine whether they are relative maxima or minima. (i.e. Evaluate MATH at the critical points.) Confirm the results using the plot function. Here is a complete example.

Example

Find the relative maxima and minima for the function MATH

> f:=x->x^3+6*x^2+1;

$x^{3}+6x^{2}+1$

> diff(f(x),x);

$3x^{2}+12x$

> solve(%,x);

0, -4

> subs(x=0,diff(f(x),x$2));subs(x=-4,diff(f(x),x$2));

12

-12

We conclude that $f\left( x\right) $ has a relative maximum at $x=-4$ and a relative minimum at $x=0$. Now plot to confirm what has been proved.

>plot(f(x),x=-5..2);


MATH

Note that the the range of the plot was suitably restricted so as to reveal a ``good'' picture of the function within the range in question.

Alternative Forms for derivatives

You can also differentiate using the
MATH
command. In addition, you can use this ``operator'' in composite form to find higher order derivatives as well. Thus MATH will yield the second derivative.Here is how.

Remark

This command will work only for functions as functions ``know'' what the variable is.

> f := x -> x^3 + 2 x^2 + 4;
MATH

Find the first two derivatives as follows:

> D(f) $;$D(D(f)) $;$
MATH

As you can see D(f)yields a function. So, you can use it directly for critical points using fsolve. We obtain

> fsolve(D(f));
MATH

Below is an example using these and a couple of other features of Maple.

Example

Find the relative and absolute maxima and minima and points of inflection for MATH of the function MATH

Solution. Convert the function to Maple syntax and proceed as above.

> f:=x->x^5-4*x^3+4*x^2-5*x+4;

> D(f);
MATH

> crit_values:=fsolve(D(f));

$crit\_values$ MATH

Note in the next step that we index the variable $crit\_values.$ In this way we can reference the one we want. (Use square $\left[ {}\right] $ brackets to enclose the index.) We obtain

> f(crit_values\lbrack1\rbrack);f(crit_values\lbrack2\rbrack);

$30.63135959$

$-.823441934$

To apply the second derivative test, we need MATH. From above we use the command.

> D(D(f));
MATH

>D(D(f))(crit_values\lbrack1\rbrack);D(D(f))(crit_values\lbrack 2\rbrack);

$-79.75666143$

$22.92554895$
MATH

> fsolve(D(D(f)));

MATH

Finally check the endpoints.

> f(-3);f(2);
MATH

MATH

We conclude that $f(-3)=-80.0$ is an absolute minimum; MATH is an absolute maximum, and MATH is a relative minimum.

Candidate for inflection points are the values just above. We need only check that MATH changes sign at these values --- and it does. Now plot the function in the interval MATH. The appropriate command is

> plot(f(x),x=-3..2);
diff_primer__45.png

Exercises

  1. Find the relative maxima and minima for the following functions. Plot the function to confirm your answers.

    1. MATH

    2. MATH

    3. MATH

  2. Find the relative and absolute maxima and minima and points of inflection for the given function over the given interval

    1. MATH for MATH

    2. MATH for MATH

    3. MATH for MATH

    4. MATH for MATH

  3. Find the derivatives of the following functions as indicated.

    1. MATH Find MATH

    2. MATH Find MATH

Remark

Don't forget those semicolons (;).


  1. MATH

This document created by Scientific Notebook 4.0.