(C) Copyright 1994 D.C.M. Burbulla and  C.T.J. Dodson
       Notebook to support the book
     Self-Tutor for Computer  Calculus

Using Mathematica 2

by
     D. C. M. Burbulla and C. T. J. Dodson, University of Toronto
 Published by:    
    Prentice-Hall Canada  (English)   ISBN 0130152803     and 
     Prentice-Hall Japan  (Japanese) ISBN4-8101-8558-3 C3055 P2880E

Antiderivatives

Chap6.m

anti/: anti[tableofvalues_][1] = 0

anti/: anti[tableofvalues_][n_] := 
       anti[tableofvalues][n] = anti[tableofvalues][n - 1] + (
       (First[Transpose[tableofvalues]][[n]] - 
       First[Transpose[tableofvalues]][[n - 1]])*
       (Last[Transpose[tableofvalues]][[n]] + 
       Last[Transpose[tableofvalues]][[n - 1]]))/2
       

antiderivative/: antiderivative[tableofvalues_, k_] := Block[{i}, 
       Table[{First[Transpose[tableofvalues]][[i]], anti[tableofvalues][i] + k}, 
       {i, Length[tableofvalues]}]]
       

viewantiderivative/: viewantiderivative[f_, {a_, b_}, initialvalue_] := (one = 
                     Block[{x}, Plot[f[x], {x, a, b}, DisplayFunction ->
		     Identity]]; two = Nest[First, InputForm[one], 5];
		     Block[{x}, ListPlot[antiderivative[two, initialvalue],
		     PlotJoined -> True, PlotLabel -> 
		     {"an approximate antiderivative of", f[x]}]])
		     
viewantiderivative::usage = "viewantiderivative[f, {a, b}, initialvalue] plots the graph 
of an approximate antiderivative F of f on the interval {a, b} with initial condition 
F[a] = initialvalue. The approximation is based on applying the Mean Value Theorem 
to Mathematica's InputForm of the Plot of f on {a, b}."


antiderivativefamily/: antiderivativefamily[f_, {a_, b_, k_:1}] :=
                       (one = Block[{x}, Plot[f[x], {x, a, b}, AspectRatio ->
		       Automatic, DisplayFunction -> Identity]];
		       two = Block[{x}, Integrate[f[x], x] /. x -> a];
		       three = Block[{x, i}, Plot[Release[Table[Integrate[
		       f[x], x] + i, {i, two - 5, two + 5, k}]], {x, a, b},
		       DisplayFunction -> Identity]];
		       Block[{x}, Show[one, three, PlotLabel ->
		       {"antiderivatives of", f[x]}, 
		       DisplayFunction -> $DisplayFunction]])
		       
antiderivativefamily::usage = "antiderivativefamily[f, {a, b, k}] plots F[x] + c, and f[x], 
on the interval {a, b}, where F[x] = Integrate[f[x], x], for a few values of c differing by k. 
The default value of k is 1."

Antidifferentiation

Constructing Antiderivatives

In this section we shall consider briefly the problem of plotting antiderivatives for given functions. This will be particularly useful in the cases where Mathematica cannot integrate the given function. We will not bother finding a specific equation for the antiderivative; we will simply try to plot its graph. This is what we do all the time with paper and pencil when we use information about  f ' to sketch the graph of f . Of course, we will need to have an initial condition to specify one particular antiderivative.

Example 1.  Since any two antiderivatives of  f  will differ by at most a constant, the family of antiderivatives of  f  must consist of a family of curves of the same shape, but shifted vertically from each other. There is a defined function,  antiderivativefamily, in the package  Chap6.m  that will allow you to see this.

?antiderivativefamily

antiderivativefamily[Sin, {-Pi, Pi, 0.5}];

antiderivativefamily[ArcTan, {-6, 6}];

Example 2.  If  F  is an antiderivative of  f  on the interval  [a, b], then the Mean Value Theorem implies there is a number  c  in the interval  [a, b]  such that

	                              F(b)  =  F(a)  +  f (c) (b  - a).

Unfortunately, the Mean Value Theorem simply implies the existence of such a  c ; it does not state its value. However, in some special cases we can find  c  explicitly. Consider a general quadratic function

			      F(x)  =  s  +  t x  +  u x 2  .

F[x_] := s + t x + u x^2

Solve[F'[c] == (F[b] - F[a])/(b - a), c] // Simplify

F'[(a + b)/2] == (F'[a] + F'[b])/2  // Simplify

Example 3.

f[x_] := E^x Sin[Pi x]

Plot[f[x], {x, 0, 2}];

?anti

?antiderivative

antiderivative[N[Table[{i, f[i]}, {i, 0, 2, 0.5}]], 0]

ListPlot[%, PlotJoined -> True];

antiderivative[N[Table[{i, f[i]}, {i, 0, 2, 0.25}]], 0]

ListPlot[%, PlotJoined -> True];

antiderivative[N[Table[{i, f[i]}, {i, 0, 2, 0.125}]], 0]

ListPlot[%, PlotJoined -> True];

antiderivative[N[Table[{i, f[i]}, {i, 0, 2, 1/16}]], 0]

ListPlot[%, PlotJoined -> True];

antiderivative[N[Table[{i, f[i]}, {i, 0, 2, 1/32}]], 0]

ListPlot[%, PlotJoined -> True];

Integrate[f[x], x]

Plot[% + Pi/(1 + Pi^2), {x, 0, 2}];

Show[%, %%%];

Example 4.

?viewantiderivative

viewantiderivative[f, {0, 2}, 0];   (*  f  as  in Example 3  *)

g[x_] := (1 + x^2)^(1/3)

Integrate[g[x], x]

viewantiderivative[g, {-3, 3}, 0];

h[x_] := Cos[Cos[x]]

viewantiderivative[h, {-Pi, Pi}, 0];