Symbolic Increments

by
K. D.  Stroyan
University of Iowa

copyright 1997 by Academic Press, Inc. - All rights reserved.

Special functions used in thie NoteBook

\(Needs["Graphics`Colors`"]; 
Needs["Graphics`FilledPlot`"]; 
    \)

Notebook Overview

This NoteBook computes the symbolic increments of the examples from Chapter 5.

References to the Text

This NoteBook goes with Chapter 5 of the text.

Exercise 5.2.1: Increments of f[x] = (x^n)

Enter each of the following computations and compare the results with the Example in section 5.1 of the text.

Clear[f, x, dx, n, quotient, epsilon]; f[x_] := (x^n)n = 3; f[x]f[x + dx]Expand[f[x + dx]]

((f[x + dx] - f[x])/dx)quotient[x_, dx_] := Expand[((f[x + dx] - f[x])/dx)]; quotient[x, dx]

Limit[quotient[x, dx], dx -> 0]

f'[x]

epsilon[x_, dx_]:=((f[x + dx] - f[x])/dx)-f'[x];Together[epsilon[x, dx]]

Limit[epsilon[x, dx], dx -> 0]

dx = 0.5;
FilledPlot[{((f[x + dx] - f[x])/dx),f'[x]},{x, -10, 10},Fills -> Orange,PlotStyle -> {Blue, Red},AxesLabel -> {"x", "rate"}];
Plot[epsilon[x, dx], {x, -10, 10}, PlotStyle -> {Orange}, 
        AxesLabel -> {"x", "gap"}];

Notice that the largest error with  dx = 0.5  is  epsilon = 15  when  x = 10.  This is only 1/20th the size of the limit  f'[10] = 300.  Let's re-graph the last computation with a smaller value of  dx.

dx = 0.1;
FilledPlot[{((f[x + dx] - f[x])/dx),f'[x]},{x, -10, 10},Fills -> Orange,PlotStyle -> {Blue, Red},AxesLabel -> {"x", "rate"}];
Plot[epsilon[x, dx], {x, -10, 10}, PlotStyle -> {Orange}, 
        AxesLabel -> {"x", "gap"}];

Exercises 5.2.1

For the functions

f[x_] := x^n, n = 1, 2, 4, 5

copy, paste and edit the computation above to find:

a) the difference quotient

((f[x + dx] - f[x])/dx)

b)  the limit of the quotient as  dx -> 0, f'[x]

(lim_(dx -> 0))((f[x + dx] - f[x])/dx) = f'[x]

c)  the error gap, epsilon

epsilon[x, dx]  =  ((f[x + dx] - f[x])/dx)  -  f'[x]

d)  the limit of epsilon as  dx -> 0

d+)  a plot of F[x] = (f[x+dx] - f[x])/dx and  f'[x] at the same time	when  dx is fixed at some "small" value.

Say where the error gap  epsilon is largest on your graph and adjust  dx  so that the largest error for the compact interval  [-10,10]  is at most  0.1.

Example 5.2: Increments of f[x] = (1/x)

Enter each of the following computations and compare the results with the Example 5.2 of the text.

Clear[f, x, dx, n, quotient, epsilon]; f[x_] := (1/(x^n))n = 1; f[x]f[x + dx]

((f[x + dx] - f[x])/dx)quotient[x_, dx_] := Together[((f[x + dx] - f[x])/dx)]; quotient[x, dx]

Limit[quotient[x, dx], dx -> 0]

f'[x]

epsilon[x_, dx_]:=((f[x + dx] - f[x])/dx)-f'[x]Together[epsilon[x, dx]]

Limit[epsilon[x, dx], dx -> 0]

dx = 0.5;
FilledPlot[{((f[x + dx] - f[x])/dx),f'[x]},{x, -10, 10},Fills -> Orange,PlotStyle -> {Blue, Red},AxesLabel -> {"x", "rate"}];
Plot[epsilon[x, dx], {x, -10, 10}, PlotStyle -> {Orange}, 
        AxesLabel -> {"x", "gap"}];
epsilon[- .01, dx]

The gap error gets enormous.  Let's see why,

Together[epsilon[x, dx]]

Notice that the error is enormous for values of  x  near 0.  Let's re-plot over a compact interval of "good" values,

dx = 0.1;
FilledPlot[{((f[x + dx] - f[x])/dx),f'[x]},{x, 0.5, 10},Fills -> Orange,PlotStyle -> {Blue, Red},AxesLabel -> {"x", "rate"}];
Plot[epsilon[x, dx], {x, 0.5, 10}, PlotStyle -> {Orange}, 
        AxesLabel -> {"x", "gap"}];
epsilon[0.5, dx]

The error is largest at 0.5 for  x in the interval  [0.5, 10], but still large.  Let's re-plot over the same compact interval with a smaller  dx,

dx = 0.01;
FilledPlot[{((f[x + dx] - f[x])/dx),f'[x]},{x, 0.5, 10},Fills -> Orange,PlotStyle -> {Blue, Red},AxesLabel -> {"x", "rate"}];
Plot[epsilon[x, dx], {x, 0.5, 10}, PlotStyle -> {Orange}, 
        AxesLabel -> {"x", "gap"}];
epsilon[0.5, dx]

Exercises: Beyond the Text

For the functions

f[x_] := (1/(x^n)), n =  2, 3, 4

copy, paste and edit the computation above to find:

1) the difference quotient

((f[x + dx] - f[x])/dx)

2)  the limit of the quotient as  dx -> 0, f'[x]

(lim_(dx -> 0))((f[x + dx] - f[x])/dx) = f'[x]

3)  the error gap, epsilon

epsilon[x, dx]  =  ((f[x + dx] - f[x])/dx)  -  f'[x]

4)  the limit of epsilon as  dx -> 0

5)  a plot of F[x] = (f[x+dx] - f[x])/dx and  f'[x] at the same time	when  dx is fixed at some "small" value.

Say where the error gap  epsilon is largest on your graph and adjust  dx  so that the largest error for the compact interval  [0.1,10]  is at most  0.1.

Example 5.3: Increments of f[x] = (Sqrt[x])

Enter each of the following computations and compare the results with the Example in section 5.1 of the text.

Clear[f, x, dx, quotient, epsilon]; f[x_] := (Sqrt[x])f[x]f[x + dx]

((f[x + dx] - f[x])/dx)Simplify[(((f[x + dx] - f[x]) (f[x + dx] + f[x]))/dx)]
        /(f[x + dx] + f[x])

quotient[x_, dx_] := (1/((Sqrt[x]) + (Sqrt[x + dx]))); quotient[x, dx]

Limit[quotient[x, dx], dx -> 0]

f'[x]

epsilon[x_, dx_]:=Together[quotient[x, dx]-f'[x]];epsilon[x, dx]Together[Simplify[epsilon[x, dx] ((((Sqrt[x]) + (Sqrt[x + dx])))^2)]]
          /((((Sqrt[x]) + (Sqrt[x + dx])))^2)

Limit[epsilon[x, dx], dx -> 0]

dx = 0.5;
FilledPlot[{((f[x + dx] - f[x])/dx),f'[x]},{x, -10, 10},Fills -> Orange,PlotStyle -> {Blue, Red},AxesLabel -> {"x", "rate"}];
Plot[epsilon[x, dx], {x, -10, 10}, PlotStyle -> {Orange}, 
        AxesLabel -> {"x", "gap"}];
epsilon[- .01, dx]

Square root isn't real for negative input.

Let's re-plot over a compact interval of "good" values,

dx = 0.1;
FilledPlot[{((f[x + dx] - f[x])/dx),f'[x]},{x, 0.5, 10},Fills -> Orange,PlotStyle -> {Blue, Red},AxesLabel -> {"x", "rate"}];
Plot[epsilon[x, dx], {x, 0.5, 10}, PlotStyle -> {Orange}, 
        AxesLabel -> {"x", "gap"}];
epsilon[0.5, dx]

The error is largest in magnitude at 0.5 for  x in the interval  [0.5, 10], but still large.  Let's re-plot over the same compact interval with a smaller  dx,

dx = 0.01;
FilledPlot[{((f[x + dx] - f[x])/dx),f'[x]},{x, 0.5, 10},Fills -> Orange,PlotStyle -> {Blue, Red},AxesLabel -> {"x", "rate"}];
Plot[epsilon[x, dx], {x, 0.5, 10}, PlotStyle -> {Orange}, 
        AxesLabel -> {"x", "gap"}];
epsilon[0.5, dx]

Exercises Beyond the Textbook

For the functions

f[x_] :=(x^(1/n)) ,  n = 2, 3, 4

copy, paste and edit the computation above to find:

1) the difference quotient

((f[x + dx] - f[x])/dx)

2)  the limit of the quotient as  dx -> 0, f'[x]

(lim_(dx -> 0))((f[x + dx] - f[x])/dx) = f'[x]

3)  the error gap, epsilon

epsilon[x, dx]  =  ((f[x + dx] - f[x])/dx)  -  f'[x]

4)  the limit of epsilon as  dx -> 0

5)  a plot of F[x] = (f[x+dx] - f[x])/dx and  f'[x] at the same time	when  dx is fixed at some "small" value.

Say where the error gap  epsilon is largest on your graph and adjust  dx  so that the largest error for the compact interval  [0.1,10]  is at most  0.1.

Exercises

See the  exercises in the examples above and compare these to the text Exercises 5.1.1 and Problem 5.1

Exercise on the General Ideas

Without looking at the code above, write a Mathematica definition for  epsilon[x_,dx_]  in terms of a function  f[x]  and its derivative  f'[x].  Test your definition on the examples  f[x_] := x and f[x_] := (x^2).

Clear[f,x,dx,epsilon];
epsilon[x_,dx_] := ???