Mathematica Labs | Denis Shubleka

Subject: Calculus

Topic: Extrema

Goal: Use Mathematica to identify local maxima and minima.

Task 1

Local extrema occur at critical points of f(x), where f’(x) either equals 
zero or does not exist. In this exercise we will use Mathematica to 
identify such points.
First, let us define a function:

f[x_]:=2(x^2)-(x^3)

The graph of f(x) is a cubic that starts in the second quadrant and ends 
in the fourth. We plot the curve and observe two local extrema, at the
origin (local min) and somewhere in the first quadrant (local max):

Plot[f[x],{x,-2,3},PlotRange->{-8,8}]

f(x) is a polynomial and therefore differentiable everywhere. Therefore,
its critical points are only of the type where f’(x) equal zero.
Mathematica can identify the x-coordinates of the critical points:

Reduce[f'[x]==0,x]

Read the result as x equals 0 or (4/3). Alternatively, we can use the
Solve command and then use it to evaluate the y-values:

Solve[f'[x]==0,x]

After executing the command above, define the set of critical points.
(Note that, generally, the resulting points aren’t necessarily all extrema)

points={x,f[x]}/.%

Here is a graph of f(x) and the critical points highlighted.

Plot[f[x],{x,-2,3},Epilog->{PointSize[0.03],Blue,Point[points]}]

We conclude this task by determining whether each point is a max, min, or
neither. Since of f(x) is twice differentiable, we can use the second 
derivative test:

f''[0]>0

And also test the other critical point to confirm a local minimum:

f''[4/3]<0

Note that we could have also used the first derivative test here, by
observing the sign change of f'(x) at x=0 and x=(4/3). Feel free to try it!

Related Exercises/Notes:

ap-calc.github.io