LESSON 4
Mathematica  For Graphing and for Derivatives

Author's notice

This tutorial was written by 

Fred Goodman
Department of Mathematics
University of Iowa
Iowa City, IA 52242
goodman@math.uiowa.edu

This material may be freely copied and used for non-commercial purposes.  Please retain this author's notice, and do not distribute any altered version of this material without the author's permission  (unless  the material is altered beyond recognition).

Mathematica can take derivatives.

Mathematica knows all the rules for computing derivatives.  As you are learning the rules, you can use Mathematica for checking your work.

f[x_]  :=  a^x
f'[x]

f[x_] := (x^2) Log[x]
f'[x]

f[x_] := 
      Log[(E^((x^2))) + (x^2)]
f'[x]

f[x_] := (x^2) (E^(-x))
f'[x]
Factor[%]

Mathematica can plot graphs of functions.

f[x_] := (x^5) + 16 (x^2) - 4 x + 3
Plot[f[x],  {x,  -5,  5}]

f[x_] := (x^2) (E^(-x))
Plot[f[x],  {x,  -2,  8}]

It is possible to plot more than one function on the same set of axes.  Here is a function plotted together with its derivative.  Where is the derivative positive, negative, zero?   Where is the function increasing, decreasing?

f[x_] := (x^2) (E^(-x))
f'[x]
Factor[%]
Plot[{f[x],  f'[x]},  {x,  -2,  8}]

If you would like the two graphs to have different colors, you have to use fancier programming:

Needs["Graphics`Colors`"]
plot1  :=  
        Plot[f[x], {x,  -2,  
            8},   PlotStyle -> {AbsoluteThickness[2], Red},  
          DisplayFunction  ->  Identity];
plot2  :=  
        Plot[f'[x], {x,  -2,  8},  
          PlotStyle  -> {AbsoluteThickness[2],  Blue},  
          DisplayFunction  ->  Identity];
Show[{plot1,  plot2},  
      DisplayFunction  ->  $DisplayFunction]

You can copy this code to make your own plots of several functions, in colors,on the same axes:

Needs["Graphics`Colors`"]
plot0 := 
        Plot[x, {x, -3, 3}, 
          PlotStyle -> {AbsoluteThickness[2], Black}, 
          DisplayFunction -> Identity];
plot1 := 
        Plot[(x^2), {x, -3, 3}, 
          PlotStyle -> {AbsoluteThickness[2], Red}, 
          DisplayFunction -> Identity];
plot2 := 
        Plot[(x^3), {x, -3, 3}, 
          PlotStyle -> {AbsoluteThickness[2], Blue}, 
          DisplayFunction -> Identity];
Show[{plot0,  plot1, plot2}, 
      DisplayFunction -> $DisplayFunction]