Numerical Methods: Mathematica 3.0 Notebooks
(c) John H. Mathews, 1998
To accompany the text:
Numerical Methods:  for Mathematics, 
Science, and Engineering, 2nd Ed, 1992
Prentice Hall, Inc.
Simon & Schuster,  One Lake Street
Upper Saddle River, New Jersey 07458  U.S.A.
Prentice Hall, Inc.; USA, Canada, Mexico ISBN 0-13-624990-6
Prentice Hall, International Editions:      ISBN 0-13-625047-5
www.Prenhall.com
This free software is compliments of the author.
E-mail address:      in%"mathews@fullerton.edu"

CONTENTS

Chapter 1.   Preliminaries from Calculus
	Theorem 1.1    Limits and Continuous Functions.
	Theorem 1.2    Intermediate Value Theorem.
	Theorem 1.3    Extreme Value Theorem for a Continuous Function.
	Theorem 1.4    Differentiable function implies continuous function.
	Theorem 1.5    Rolle's Theorem.
	Theorem 1.6    Mean Value Theorem.
	Theorem 1.7    Extreme Value Theorem for a Differentiable Function.
	Theorem 1.8    Generalized Rolle's Theorem.
	Theorem 1.9    First Fundamental Theorem.
	Theorem 1.10  Second Fundamental Theorem.
	Theorem 1.11  Mean Value Theorem for Integrals.
	Theorem 1.12  Weighted Integral Mean Value Theorem.
	Theorem 1.13  Taylor's Theorem.
	Theorem 1.14  Horner's Method for Polynomial Evaluation.
	Theorem 1.15  Geometric Series.
	Theorem 1.16  Big "O" remainders for Taylor's Theorem.
	Theorem 1.17  Remainder term for Taylor's Theorem.

Be sure to load the following "FilledPlot" graphics package.

<<  Graphics`FilledPlot`Clear["Global`*"];
Off[General::"spell1"];
Clear[a, a1, a2, A, b, b1, b2, B, c, c0, c1, c2, df, dot, dots, dotx, 
        doty, dx, epts, E3, E5, E7, f, fc, f0, F, grf, gr1, gr2, grf0, grf1, 
        grf2, h, H, k, line, lines, lmax, lmin, ln0, ln1, ln2, lns, L, Lx0, 
        Ly0, Lxy, m, maxerr, n, p, prod, pt0, pts, P, P3, P5, P7, P9, 
        Ptimeset, quot, Q, Qtimeset, r1, r2, r3, R, solset, sum, s1, s2, t, 
        v, val, x, xmax, xmin, x0, x1, X, X0, XY, ya, yb, y0, y1, y2, ymax, 
        ymin, yx, Y, Y0];
On[General::"spell1"];

Theorem 1.1  Limits and Continuous Functions.   Assume that  f (x)  is defined on the set  S  and  x  is an element of  S.  The following statements are equivalent:
(i)   The function  f (x)  is continuous at  (Subscript[x, 0]).
(ii)  If  (lim_(n -> ∞ ))(Subscript[x, n]) = (Subscript[x, 0]) ,  then  (lim_(n -> ∞ ))f((Subscript[x, n])) = f ((Subscript[x, 0])).
Section  1.1,   Review of Calculus,  Page 4

Example for page 4.  Let  f(x) = sin(x).
If  (lim_(n -> ∞ ))(Subscript[x, n]) = (π/4),  verify that  (lim_(n -> ∞ ))f((Subscript[x, n])) = f ((π/4)).

\(Clear[f, grf, Lx0, Ly0, Lxy, X, X0, Y, y0, Y0, XY]; 
f[x_] = Sin[x]; 

    X = Table[N[π]\/4 - 2.0\^\(-p\), {p, 1, 15}]; 
Y = Sin[X]; 

    \(X0 = Transpose[{X, 0\ X}]; \)\)Y0 = Transpose[{0 Y, Y}]; \(XY = Transpose[{X, Y}]; 

    Lx0 = ListPlot[X0, DisplayFunction -> Identity]; 

    Ly0 = ListPlot[Y0, DisplayFunction -> Identity]; 

    Lxy = ListPlot[XY, DisplayFunction -> Identity]; 

    Print["y = ", f[x]]; 

    grf = Plot[f[x], {x, 0, 0.8}, PlotStyle -> RGBColor[1, 0, 0], 
        PlotRange -> {{0, 0.8}, {0, 1.05}}, 
        DisplayFunction -> Identity]; 

    Show[grf, Lx0, Ly0, Lxy, PlotRange -> {{0, 0.8}, {0, 0.72}}, 
      Prolog -> {PointSize[0.02]}, 
      Ticks -> {Range[0, 1, 0.1], Range[0, 1, 0.1]}, 
      DisplayFunction -> $DisplayFunction]; 

    pts\  = \ Prepend[\ 
        XY, {\*""\!\(x\_k\)      "", 
          \*""\!\(y\_k\) = Sin[\!\(x\_k\)]""}]; 

    Print[TableForm[pts]]; 
Print["The limiting values are:"]; 

    Print["x            y = Sin[x]"]; 

    Print[N[π\/4], "     ", N[f[π\/4]]]; 

    Print[π\/4, "           ", f[π\/4]]; \)

\(y0 = Limit[f[x], x -> π\/4]; 
f0 = f[π\/4]; 

    Print["f[x] = ", f[x]]; 

    Print[\*""\!\(lim\+\(x -> π\/4\)\) f[x] = "", y0, 
      \*""    and    f[\!\(π\/4\)] = "", f0]\)Print["Is f[x] continuous at x = x0 ?   ", y0 == f0]

Example 1.  Verify that  (lim_(x->(π/6) ))sin(x) = sin ((π/6)).

\(lim\  = \ Limit[Sin[x], x -> π\/6]; 

    Print[\*""(lim_(x -> (π/6))) Sin[x] = "", lim]; 

    Print[\*""   Sin[(π/6)] = "", Sin[π\/6]\ ]; 

    Print[\*""(lim_(x -> (π/6))) Sin[x] = Sin[(π/6)] ?  "", \ 
      Limit[Sin[x], x -> π\/6] == Sin[π\/6]]; \)

Example 2.  Verify that  (lim_(x -> 0 ))((sin (x))/x) = 1.

\(Print[\*""y = \!\(Sin[x]\/x\)""]; 

    Plot[Sin[x]\/x, {x, \(-π\), π}, 
      PlotStyle -> RGBColor[1, 0, 0]]; 

    lim\  = \ Limit[Sin[x]\/x, x -> 0]; 

    Print[\*""\!\(lim\+\(x -> 0\)\) \!\(Sin[x]\/x\) = "", lim]; 
    \)

Example 3.  Verify that  (lim_(x -> ∞ ))x (e^(-x)) = 0.

\(Print[\*""y = x(E^(-x))""]; 

    Plot[x\ E\^\(-x\), {x, 0, 10}, 
      PlotStyle -> RGBColor[1, 0, 0]]; 

    lim\  = \ Limit[x\ E\^\(-x\), x -> ∞]; 

    Print[\*""(lim_(x -> ∞)) x(E^(-x)) = "", lim]; \)

Theorem 1.2  Intermediate Value Theorem.   Assume that  f (x)  is a continuous on the interval  [a, b],  and  L  is  any number between  f (a)  and  f (b).  Then there exists a value  c  with  a < c < b  such that  f (c) = L.
Section  1.1,   Review of Calculus,  Page 4

Example on page 4.  Consider the function  f (x)  =  cos (x - 1),  which is continuous on the interval  [0,  2.5]  and suppose that  L = 0.8 .   Since  f (0) = 0.540302 < L < 1 =  f (1),  there exists a value  (Subscript[c, 1])  with  0 < (Subscript[c, 1]) < 1 so that  f ((Subscript[c, 1])) = L.   Also, since  f (2.5) = 0.0707372 < L < 1 = f (1),  there exists a value  (Subscript[c, 2])  with  1 < (Subscript[c, 2]) < 2.5  so that  f ((Subscript[c, 2])) = L.

\(Clear[a1, a2, b1, b2, c, c1, c2, f, grf, ln0, ln1, ln2, L, x, y1, y2]; 
    
f[x_] = Cos[x - 1]; 
a1 = 0; 
b1 = 1; 
\(a2 = 1; \)\)b2 = 2.5; \(L = 0.8; 
solset\  = \ Solve[f[c] == L, c]; 

    Print["f[x] = ", f[x]]; 
\(Print["   L = ", L]; \)\)\(Print["f[c] = ", L]; 
Print["Solve[f[c]==L,c]"]; 

    Print[\*""\!\(c\_1\) = "", 
      solset[[1, 1, 2]]]; 

    Print[\*""\!\(c\_2\) = "", 
      solset[[2, 1, 2]]]; \)

\(c1 = 1 - ArcCos[0.8]; 
\(y1 = Cos[c1 - 1]; \)\)c2 = 1 + ArcCos[0.8]; y2 = Cos[c2 - 1]; \(grf = 
      Plot[f[x], {x, 0, 1 + π\/2}, PlotStyle -> RGBColor[1, 0, 0], 
        DisplayFunction -> Identity]; 

    ln0 = Graphics[{RGBColor[0, 1, 1], Line[{{0, L}, {1 + π\/2, L}}]}]; 

    ln1 = Graphics[{RGBColor[0, 1, 0], Line[{{c1, 0}, {c1, y1}}]}]; 

    ln2 = Graphics[{RGBColor[0, 1, 0], Line[{{c2, 0}, {c2, y1}}]}]; 

    Print["y = ", f[x]]; 

    Show[grf, ln0, ln1, ln2, DisplayFunction -> $DisplayFunction]; 

    Print["f(x) = ", f[x]]; 

    Print["[a,b] = [", a1, ", ", b1, "]"]; 

    Print["f[", a1, "] = ", N[f[a1]], ",   f[", b1, "] = ", 
      N[f[b1]]]; 
Print["L = ", L]; 

    Print[\*""\!\(c\_1\) = "", c1]; 

    Print[\*""f[\!\(c\_1\)] = "", f[c1]]; 

    Print[a1, "  <  ", c1\ "  <  ", b1]; 
Print[" "]; 

    Print["f(x) = ", f[x]]; 

    Print["[a,b] = [", a2, ", ", b2, "]"]; 

    Print["f[", a2, "] = ", N[f[a2]], ",   f[", b2, "] = ", 
      N[f[b2]]]; 
Print["L = ", L]; 

    Print[\*""\!\(c\_2\) = "", c2]; 

    Print[\*""f[\!\(c\_2\)] = "", f[c2]]; 

    Print[a2, "  <  ", c2\ "  <  ", b2]; \)

Theorem 1.3  Extreme Value Theorem for a Continuous Function.   Assume that  f (x)  is a continuous function on the interval  [a, b].  Then there exists a lower bound  (Subscript[M, 1])  and an upper bound  (Subscript[M, 2])  and two numbers  (Subscript[x, 1])  and  (Subscript[x, 2])  in  [a, b]  such that   
	(Subscript[M, 1]) = f(x1) ≤ f (x) ≤ f(x2) = (Subscript[M, 2]),    whenever  a ≤ x ≤ b.
Section  1.1,   Review of Calculus,  Page 5

Example for page 5.  Let  f (x) = 35 + 59.5 x - 66.5 (x^2) + 15 (x^3).
Find the minimum and maximum of  f (x)  over the interval  [0, 3].

Solution 1.  Use Mathematica's built in function for finding a minimum value.
Compute approximations for the minimum and maximum of  f (x)  over  [0, 3].

\(Clear[dot, f, x]; 
f[x_] = 35 + 59.5\ x - 66.5\ x\^2 + 15\ x\^3; 

    Print["y = ", f[x]]; 
minset = FindMinimum[f[x], {x, 2.5}]; 

    maxset = FindMinimum[\(-f[x]\), {x, 0.5}]; 

    maxset[[1]] = 
      \(-maxset[[1]]\); 

    dot1\  = \ 
      Graphics[{PointSize[0.025], 
          Point[{minset[[2, 1, 2]], 
              minset[[1]]}]}]; 

    dot2\  = \ 
      Graphics[{PointSize[0.025], 
          Point[{maxset[[2, 1, 2]], 
              maxset[[1]]}]}]; 

    grf = Plot[f[x], {x, 0, 3}, PlotStyle -> RGBColor[1, 0, 0], 
        DisplayFunction -> Identity]; 

    Show[grf, dot1, dot2, DisplayFunction -> $DisplayFunction]; 

    Print["For the minimum we have:  ", minset]; 
\(Print[" "]; \)\)Print["For the maximum we have:  ", maxset];

Solution 2.  Since the given function  f (x)  is also differentiable,  locate the critical values 
where  f'(x)=0.

solset=Solve[f'[x]==0,x];
xmin  =  solset[[2, 1, 2]];
ymin  =  f[xmin];
xmax  =  solset[[1, 1, 2]];
ymax  =  f[xmax];
Print["y = ", f[x]];
epts = ListPlot[{{xmin, ymin}, {xmax, ymax}}, 
          DisplayFunction -> Identity];
lmin = Graphics[{RGBColor[0, 1, 0], 
            Line[{{xmin + 0.5, ymin}, {xmin - 0.5, ymin}}]}];
lmax = Graphics[{RGBColor[0, 0, 1], 
            Line[{{xmax + 0.5, ymax}, {xmax - 0.5, ymax}}]}];
Show[grf, epts, lmin, lmax, Prolog -> {PointSize[0.02]}, 
        Ticks -> {Range[0, 3, 0.5], Range[0, 60, 10]}, 
        DisplayFunction -> $DisplayFunction];
Print["f[x] = ", f[x]];
Print["
f'[x] = ",f'[x]];
Print["Solve  
f'[x] = 0"];
Print[solset];
Print[" "];
Print["The maximum value for the function f(x):"];
Print["f(x) = ", f[x]]; \(Print[\*""(Subscript[x, 1]) = "", xmax]; 

    Print[\*""(max_(0 ≤ x ≤ 3)) f(x) = f("", xmax, \*"") = (Subscript[y, 1]) = "", ymax]; 
\(Print[" "]; \)\)Print["The minimum value for the function f(x):"]; Print["f(x) = ", f[x]]; \(Print[\*""(Subscript[x, 2]) = "", xmin]; 

    Print[\*""(min_(0 ≤ x ≤ 3)) f(x) = f("", xmin, \*"") = (Subscript[y, 2]) = "", ymin]; \)

Theorem 1.4  Differentiable function implies continuous function.
If  f (x)  is differentiable at  x = (Subscript[x, 0]),  then  f (x)  is continuous at  x = (Subscript[x, 0]).
Section  1.1,   Review of Calculus,  Page 5

Example for page 5.  Let  f (x) = sin (x + 1).  Investigate the
derivative via limiting slopes of secant lines at  (Subscript[x, 0])  = 0.

f[x_] = Sin[x + 1] (a^2)

\(Clear[a, b, df, f, ln0, lns, m, pt0, x0, x1, dx, y0, y1, yx]; 

    f[x_] = Sin[x + 1]; 
\(df[x_] = Cos[x + 1]; \)\)a = 0; \(b = 1.85; 
ln0 = {}; 
\(pt0 = {}; \)\)\(For[j = 1, j ≤ 14, \(j++\), x0 = N[a]; y0 = N[f[x0]]; 
      x1 = N[a + 1\/2\^j]; y1 = N[f[x1]]; dx = x1 - x0; dy = y1 - y0; 
      m = dy\/dx; 
      ln0 = Append[ln0, 
          Graphics[{Hue[1 - \(j - 1\)\/20], 
              Line[{{x0, y0}, {b, y0 + b\ m}}]}]]; 
      pt0 = Append[pt0, {dx, dy, dy\/dx}]; ]; 
Print["y = ", f[x]]; 

    grf = Plot[f[x], {x, a, b}, PlotStyle -> RGBColor[0, 1, 0], 
        DisplayFunction -> Identity]; 

    Show[grf, ln0, PlotRange -> {{0, 1.85}, {0, 1.85}}, 
      AspectRatio -> 1, DisplayFunction -> $DisplayFunction]; 

    \(Print["Table of values for the slope."]; \)\)\(Print[
      \*""  Δx               Δy               Δ(y/Δ)x""]; 
\(Print[TableForm[pt0]]; 
    \)\)Print["The function f[x] = ", f[x]]; Print["is differentiable at x = ", a];

x00 = {}; y00 = {}; xy0 = {}; For[j = 1, j ≤ 14, j++, x1 = N[a + (1/(2^j))]; 
      y1 = N[f[x1]]; x00 = Append[x00, {x1, 0}]; y00 = Append[y00, {0, y1}]; 
      xy0 = Append[xy0, {x1, y1}]; ]; dot0 = ListPlot[xy0, DisplayFunction -> Identity]; dotx = ListPlot[x00, DisplayFunction -> Identity]; \(doty = ListPlot[y00, DisplayFunction -> Identity]; 

    Print["y = ", f[x]]; 

    Show[grf, dot0, dotx, doty, PlotRange -> {{0, 0.5}, {0, 1.0}}, 
      Prolog -> {PointSize[0.02]}, 
      DisplayFunction -> $DisplayFunction]; 

    \(Print[\*""  \!\(x\_n\)               \!\(y\_n\)""]; 

    \(Print[TableForm[xy0]]; \)\)\)Print["The limiting values are:"]; \(Print[x0, "	 	 	 	 	", y0]; 

    \(Print["The function f[x] = ", f[x]]; \)\)Print["is continuous at x = ", a];

Theorem 1.5  Rolle's Theorem.  Assume that  f (x)  is continuous on the interval  [a, b],  and that  f'(x)  exists for all  a < x < b.   If  f (a) = 0  and   f (b) = 0, then there exists a value  c,  with  a < c < b,  such that  f'(c)=0.
Section  1.1,   Review of Calculus,  Page 5

Example for page 5.  The function  f (x)= sin (x)-(1/2)  has two zeros in  [0, 3]. 
Solution.  According to Rolle's theorem, there exists a value  c  with  0 < c < 3  such that  f'(c)=0.

\(Clear[f, x]; 
f[x_] = Sin[x] - 1\/2; 

    solset\  = \ Solve[f[x] == 0, x]; 
Print["f[x] = ", f[x]]; 

    Print["Solve  f[x] = 0 ."]; 
Print[solset]; 

    Print["A solution is   ", 
      solset[[1, 1, 2]]]; 

    Print["Another one is  ", 
      π - solset[[1, 1, 2]]]; \)

Or, two roots can obtained using the inverse function.

\(r1 = ArcSin[1\/2]; 
r2 = r1 + 2\ \((π\/2 - r1)\); 

    Print[\*""   \!\(r\_1\) = "", r1]; 

    Print[\*""f[\!\(r\_1\)] = "", f[r1]]; 

    Print[\*""   \!\(r\_2\) = "", r2]; 

    Print[\*""f[\!\(r\_2\)] = "", f[r2]]; \)

Find the function  f'(x)  and its zeros.

solset=Solve[f'[x]==0,x];
c = solset[[2, 1, 2]];
yc = f[c];
Print[" f[x] = ", f[x]];
Print["
f'[x] = ",f'[x]];
Print["Solve  
f'[c] = 0 ."];
Print["   c  = ", c];
Print[" f[c] = ", yc];
Print["
f'[c] = ",f'[c]];

\(grf = Plot[f[x], {x, 0, π}, PlotStyle -> RGBColor[1, 0, 0], 
        DisplayFunction -> Identity]; 

    cpt = ListPlot[{{x1, y1}}, DisplayFunction -> Identity]; 

    dot\  = \ Graphics[{PointSize[0.025], Point[{c, f[c]}]}]; 

    lmax = Graphics[{RGBColor[0, 1, 0], 
          Line[{{c + 1, f[c]}, {c - 1, f[c]}}]}]; 

    Show[grf, cpt, lmax, dot, 
      PlotRange -> {{0, π}, {\(-0.5\), 0.5}}, 
      Prolog -> {PointSize[0.02]}, 
      Ticks -> {Range[0, 3, 0.5], Range[\(-1\), 1, 0.25]}, 
      DisplayFunction -> $DisplayFunction]; 

    \(Print["The value c for Rolle's theorem for the function"]; \)\)Print["f(x) = ", f[x]]; Print["c = ", c];
\(Print["f(c) = f(", c, \*"") = \!\(y\_c\) = "", f[c]]\);
Print["f'(c) = ",f'[c]];

Theorem 1.6  Mean Value Theorem.   Assume that  f (x)  is continuous on the interval  [a, b],  and that  f'(x)  exists for all  a < x < b.  Then there exists a number  c,  with  a < c < b,  such that 
	f'(c) = ((f (b) - f (a))/(b  -  a)) = m .
Section  1.1,   Review of Calculus,  Page 5

Example on page 6.  Consider  f (x) = sin (x)  over  [0.1, 2.1].   According to 
the Mean Value theorem, there exists a value  c  with  0.1 < c < 2.1  such that
	f (c) = ((f (2.1) - f (0.1))/(2.1  -  0.1)) = m . 
Solution.  Enter the function  f (x)  and compute  m:

Clear[a, b, f]f[x_] = Sin[x]; a = 0.1; b = 2.1; m = ((f[b] - a)/(b - a)); Print["f[x] = ", f[x]]; Print["The interval is  [", a, ", ", b, "]."]; Print["The slope is  m = ", m];

Use the function  f'(x)  and find where  f'(c)= m:

solset=Solve[f'[x]==m,x];\(c0 = solset[[2, 1, 2]]; 

    \(y0 = f[c0]; \)\)ya = f[a]; yb = f[b]; dots = Graphics[{Point[{a, f[a]}], Point[{b, f[b]}], 
          Point[{c0, f[c0]}]}]; \(lines = 
      Graphics[{RGBColor[0, 1, 0], Line[{{a, f[a]}, {b, f[b]}}], 
          Line[{{c0 - 1\/2, f[c0] - m\/2}, {c0 + 1\/2, f[c0] + m\/2}}]}]; 

    \(grf = Plot[f[x], {x, 0.1, 2.1}, PlotStyle -> RGBColor[1, 0, 0], 
        DisplayFunction -> Identity]; 
Print["f[x] = ", f[x]]; 

    Show[grf, dots, lines, PlotRange -> {{0, 2.2}, {0, 1.12}}, 
      Prolog -> {PointSize[0.02]}, 
      Ticks -> {Range[0, 3, 0.5], Range[0, 1, 0.5]}, 
      DisplayFunction -> $DisplayFunction]; 

    \(Print["The interval is [", a, " , ", b, "]"]; \)\)\)Print["f`(x) = ",f'[x]];
\(Print[\*""\!\(\(f \((2.1)\) - f \((0.1)\)\)\/\(2.1\\  - \\ 0.1\)\) = "", m]\);
Print["The value c where  f`(c) = m = ", m, "  is:"];
Print["c = ", c0];
Print[a, "  <  ", c0, "  <  ", b];

Theorem 1.7  Extreme Value Theorem for a Differentiable Function.   Assume that  f (x)  is continuous on the interval  [a, b]  and that  f'(x)  exists for all  a < x < b.  Then there exists a lower bound  (Subscript[M, 1])  and an upper bound  (Subscript[M, 2])  and two numbers  (Subscript[x, 1])  and  (Subscript[x, 2])  in  [a, b]  such that   
	(Subscript[M, 1]) = f(x1) ≤ f (x) ≤ f(x2) = (Subscript[M, 2]),    whenever   a ≤ x ≤ b.  
The numbers  (Subscript[x, 1])  and  (Subscript[x, 2])  are either critical points of  f (x)  or an endpoint of  [a, b].
Section  1.1,   Review of Calculus,  Page 6

Example on page 5.  Let  f (x) = 35 + (119/2) x - (133/2) (x^2) + 15 (x^3).
Find the minimum and maximum of  f (x)  over the interval  [0, 3].

\(Clear[a, b, c, f, x]; 

    f[x_] = 35 + 119\/2\ x - 133\/2\ x\^2 + 15\ x\^3; 

    Print["y = ", N[f[x]]]; 

    grf = Plot[f[x], {x, 0, 3}, PlotStyle -> RGBColor[1, 0, 0]]; \)

Solution.  Since the given function f(x) is also differentiable, 
locate the critical values where  f'(x)=0.

Print["
f'[x] = ",f'[x]];

The quadratic equation can be used to solve  f'(x)=a (x^2)  +  b x  +  c = 0.

a  =  45;
b  =  -133;
c  =  (119/2);
x1 = ((-b - (Sqrt[(b^2) - 4 a c]))/(2 a));
x2 = ((-b + (Sqrt[(b^2) - 4 a c]))/(2 a));
Print["Solve  
f'[x] = ",f'[x]," = 0 ."];
\(Print[\*""    \!\(x\_1\) = "", x1]\);
Print["
f'[(Subscript[x, 1])] = ",f'[x1]];
Print["
f'[(Subscript[x, 1])] = ",Simplify[f'[x1]]];
\(Print[\*""    \!\(x\_2\) = "", x2]\);
Print["
f'[(Subscript[x, 2])] = ",f'[x2]];
Print["
f'[(Subscript[x, 2])] = ",Simplify[f'[x2]]];

Or Mathematica's can be used to solve  f'(x)=0.
First, we do it symbolically and then numerically.

Print["Solve  ",f'[x]," = 0"];solset=Solve[f'[x]==0,x]xmin = solset[[2, 1, 2]];
ymin = f[xmin];
xmax = solset[[1, 1, 2]];
ymax = f[xmax];
\(Print[\*""\!\(x\_min\) = "", xmin]\);
Print["
f'[(Subscript[x, min])] = ",f'[xmin]];
Print["
f'[(Subscript[x, min])] = ",Simplify[f'[xmin]]];
\(Print[\*""\!\(y\_min\) = f[\!\(x\_min\)] = "", f[xmin]]\);
\(Print[\*""\!\(y\_min\) = f[\!\(x\_min\)] = "", 
        Simplify[f[xmin]]]\);
Print[" "];
\(Print[\*""\!\(x\_max\) = "", xmax]\);
Print["
f'[(Subscript[x, max])] = ",f'[xmax]];
Print["
f'[(Subscript[x, max])] = ",Simplify[f'[xmax]]];
\(Print[\*""\!\(y\_max\) = f[\!\(x\_max\)] = "", f[xmax]]\);
\(Print[\*""\!\(y\_max\) = f[\!\(x\_max\)] = "", 
        Simplify[f[xmax]]]\);

Print["Solve  ",f'[x]," = 0"];solset=NSolve[f'[x]==0,x]xmin = solset[[2, 1, 2]];
ymin = f[xmin];
xmax = solset[[1, 1, 2]];
ymax = f[xmax];
\(Print[\*""\!\(x\_min\) = "", xmin]\);
Print["
f'[(Subscript[x, min])] = ",f'[xmin]];
\(Print[\*""\!\(y\_min\) = f[\!\(x\_min\)] = "", f[xmin]]\);
Print[" "];
\(Print[\*""\!\(x\_max\) = "", xmax]\);
Print["
f'[(Subscript[x, max])] = ",f'[xmax]];
\(Print[\*""\!\(y\_max\) = f[\!\(x\_max\)] = "", f[xmax]]\);

\(grf = 
      Plot[f[x], {x, 0, 3}, PlotStyle -> RGBColor[1, 0, 0], 
        DisplayFunction -> Identity]; 

    \(epts = ListPlot[{{xmin, ymin}, {xmax, ymax}}, 
        DisplayFunction -> Identity]; \)\)\(lmin = 
      Graphics[{RGBColor[0, 1, 0], 
          Line[{{xmin + 0.5, ymin}, {xmin - 0.5, ymin}}]}]; 

    lmax = Graphics[{RGBColor[0, 0, 1], 
          Line[{{xmax + 0.5, ymax}, {xmax - 0.5, ymax}}]}]; 

    Print["y = ", f[x]]; 

    Show[grf, epts, lmin, lmax, Prolog -> {PointSize[0.02]}, 
      Ticks -> {Range[0, 3, 0.5], Range[0, 60, 10]}, 
      DisplayFunction -> $DisplayFunction]; 

    \(Print["The maximum value for the function f(x):"]; \)\)Print["f(x) = ", f[x]]; \(Print[\*""(Subscript[x, 1]) = "", xmax]; 

    Print[\*""(max_(0 ≤ x ≤ 3)) f(x) = f("", xmax, \*"") = (Subscript[y, 1]) = "", ymax]; 
\(Print[" "]; \)\)Print["The minimum value for the function f(x):"]; Print["f(x) = ", f[x]]; \(Print[\*""(Subscript[x, 2]) = "", xmin]; 

    Print[\*""(min_(0 ≤ x ≤ 3)) f(x) = f("", xmin, \*"") = (Subscript[y, 2]) = "", ymin]; \)

Theorem 1.8  Generalized Rolle's Theorem.   Assume that  f (x)  is continuous on the interval  [a, b],  and  that the derivatives  f'(x),f''(x),⋯,Derivative[n][f](x)  exist on  (a, b),  and that  (Subscript[x, 0]), (Subscript[x, 1]), (Subscript[x, 2]), ⋯, (Subscript[x, n])  all lie in  [a, b].  
	If  f ((Subscript[x, j])) = 0  for  j = 0, 1, ⋯, n  then there exists a value  c,  with  a < c < b  such that  Derivative[n][f](c)=0.
Section  1.1,   Review of Calculus,  Page 6

Example for Page 6.  The function  f (x) = (x^3) - 7 (x^2) + 14 x - 8  has three zeros in [0, 5]. 
Applying the generalized Rolle's theorem, there exists a value  c  with  0 < c < 5  such that  f''(c)=0.
Solution.  Enter the function  f (x)  and find its zeros.

\(Clear[a, b, c0, c1, c2, f, r1, r2, r3]; 
a = 0; 
b = 5; 

    \(f[x_] = x\^3 - 7\ x\^2 + 14\ x - 8; \)\)\(solset = Solve[f[x] == 0, x]; 

    r1 = solset[[1, 1, 2]]; 

    r2 = solset[[2, 1, 2]]; 

    r3 = solset[[3, 1, 2]]; 

    Print["f[x] = ", f[x]]; 
Print["Solve  ", f[x], " = 0 ."]; 

    Print[solset]; 
Print[\*""\!\(r\_1\) = "", r1]; 

    Print[\*""\!\(r\_2\) = "", r2]; 

    Print[\*""\!\(r\_3\) = "", r3]; \)

Use the function  f'(x)  and find its zeros.  Mathematica can be used to find the roots.
These values are entered into  (Subscript[c, 1])  and  (Subscript[c, 2]).

Print["
f'[x] = ",f'[x]];
Print["Solve  ",f'[x]," = 0 ."];
solset1=Solve[f'[x]==0,x]\(c1 = solset1[[1, 1, 2]]; 

    c2 = solset1[[2, 1, 2]]; 

    Print[\*""\!\(c\_1\) = "", c1, " = ", N[c1]]; 

    Print[\*""\!\(c\_2\) = "", c2, " = ", N[c2]]; \)

Use the function  (f')'(x)  and find its root(s).

Print["
f''[x] = ",f''[x]];
Print["Solve  ",f''[x]," = 0 ."];
solset2=Solve[f''[x]==0,x]\(c0 = solset2[[1, 1, 2]]; 

    Print[\*""\!\(c\_0\) = "", c0, " = ", N[c0]]; \)

\(grf0 = 
      Plot[f[x], {x, a, b}, PlotStyle -> RGBColor[1, 0, 0], 
        DisplayFunction -> Identity]; 

    dots = Graphics[{Point[{r1, f[r1]}], Point[{r2, f[r2]}], 
          Point[{r3, f[r3]}]}]; 
Print["y = f[x] = ", f[x]]; 

    Show[grf0, dots, PlotRange -> {{0, 5}, {\(-5\), 5}}, 
      Prolog -> {PointSize[0.02]}, 
      Ticks -> {Range[0, 5, 1], Range[\(-5\), 5, 1]}, 
      DisplayFunction -> $DisplayFunction]; 

    Print["The interval is [", a, " , ", b, "]"]; 

    Print["f[x] = ", f[x]]; 

    Print["There are 3 roots of f[x] in this interval."]; 

    Print[\*""\!\(r\_1\) = "", r1, \*"",   \!\(r\_2\) = "", r2, 
      \*"",   \!\(r\_3\) = "", r3]; \)

grf1=Plot[f'[x],{x, a, b},PlotStyle -> RGBColor[0, 0, 1],DisplayFunction -> Identity];
dots=Graphics[{Point[{c1,f'[c1]}],Point[{c2,f'[c2]}]}];
Print["y = 
f'[x] = ",f'[x]];
Show[grf1, dots, PlotRange -> {{0, 5}, {-3, 9}}, 
          Prolog -> {PointSize[0.02]}, 
          Ticks -> {Range[0, 5, 1], Range[-4, 15, 2]}, 
          DisplayFunction -> $DisplayFunction];
Print["The interval is [", a, " , ", b, "]"]; Print["f'(x) = ",f'[x]];Print["There are 2 roots of 
f'[x] in this interval."];
\(Print[\*""\!\(c\_1\) = "", N[c1], 
        \*"",   \!\(c\_2\) = "", N[c2]]\);

grf2=Plot[f''[x],{x, a, b},PlotStyle -> RGBColor[0, 1, 0],DisplayFunction -> Identity];
dots=Graphics[{Point[{c0,f''[c0]}]}];
Print["y = 
f''[x] = ",f''[x]];
Show[grf2, dots, PlotRange -> {{0, 5}, {-9, 9}}, 
        Prolog -> {PointSize[0.02]}, 
        Ticks -> {Range[0, 5, 1], Range[-14, 15, 2]}, 
        DisplayFunction -> $DisplayFunction];
Print["The interval is [", a, " , ", b, "]"];
Print["There is 1 root of 
f''[x] in this interval."];
\(Print[\*""\!\(c\_0\) = "", N[c0]]\);

Theorem 1.9  First Fundamental Theorem.   If  f (x)  is continuous over the interval [a, b],  then there exists a function  F (x),  called the antiderivative of   f (x),  such that
	(∫_a^b)f (x) dx  =  F (b)  -  F (a)   where  F'(x)=f (x).
Section  1.1,   Review of Calculus,  Page 7

Example for Page 7.   Let  f (x) =  tan (x).   Show that
 	(∫_(-π/3)^(π/4))f (x) dx  =  F((π/4)) - F(((-π)/3)),   where   F'(x)=f (x)

\(Clear[a, b, f, F, v, x]; 
f[x_] = Tan[x]; 

    \(F[x_] = ∫f[x] \[DifferentialD]x; \)\)Print["f[x] = ", f[x]]; Print["The integral is:"]; Print["F[x] = ∫f[x]\[DifferentialD]x = ", F[x]];

a = -(π/3); b = (π/4); Print["f[x] = ", f[x]]; Print["F[x] = ", F[x]]; Print["The interval is  [", a, ",", b, "]"]; Print["The value of the integral is:"]; Print["F[b] - F[a] = ", F[b] - F[a], "  =  ", 
      N[F[b] - F[a]]];

Or use Mathematica's integrate command with limits of integration:

\(a = \(-\(π\/3\)\); 
\(b = π\/4; \)\)Print["f[x] = ", f[x]]; v = (∫_a^b) f[x] \[DifferentialD]x; Print["The interval is  [", a, ",", b, "]"]; \(Print["The value of the integral is:"]; 

    Print[\*""(∫_(-π/3)^(π/4))f[x]\[DifferentialD]x = "", v, " = ", N[v]]; \)

<<  Graphics`FilledPlot`\(gr1\  = \ 
      FilledPlot[{f[x]}, 
\ {x, a, 0}, 
        Fills -> {{{1, Axis}, RGBColor[1, 0, 0]}}, 
        DisplayFunction -> Identity]; 

    gr2\  = \ FilledPlot[{f[x]}, 
\ {x, \ 0, b}, 
        Fills -> {{{1, Axis}, RGBColor[0, 1, 0]}}, 
        DisplayFunction -> Identity]; 

    grf = Plot[f[x], {x, a, b}, 
        Ticks -> {Range[\(-1\), 1, 0.5], Range[\(-2\), 1, 0.5]}, 
        DisplayFunction -> Identity]; 

    \(lines = 
      Graphics[{Line[{{a, 0}, {a, f[a]}}], Line[{{b, 0}, {b, f[b]}}]}]; \)\)\(Show[gr1, gr2, grf, lines, DisplayFunction -> $DisplayFunction]; 

    \(Print["The function is f[x] = ", f[x]]; \)\)Print["The value of the integral is over [", a, ",", b, 
      "] is:  ", N[v]];

Theorem 1.10  Second Fundamental Theorem.   If  f (x)  is continuous over the interval [a, b],  then    (∂_x) ((∫_a^x)f (t) dt) =  f (x),     where  a < x < b.
Section  1.1,    Review of Calculus,  Page 8

Clear[f, F, t, x];
F[x_]  =  (∫_a^x) f[t] \[DifferentialD]t;
Print[" F[x] = ", F[x]];
Print["
F'[x] = ",F'[x]];

Example for Page 7.  Let  f (x) = (x^2) (e^x) sin (x).   Show that   (∂_x) ((∫_a^x)f (t) dt) =  f (x).

Clear[f, F, t, x]f[t_] = 2 (t^2) Exp[t] Sin[t];
F[x_] = (∫_0^x) f[t] \[DifferentialD]t;
Print["f[t] = ", f[t]];
F[x_] = (∫_0^x) f[t] \[DifferentialD]t;
\(Print[\*""F[x] = \!\(∫\_0\%x\)f[t]\[DifferentialD]t""]
        \);
Print["F[x] = ", F[x]];
Print["
F'[x] = ",F'[x]];
Print["
F'[x] = ",Expand[F'[x]]];
Print[" f[x] = ", f[x]];

Example for Page 7.  Let  f (x)=(1/((Sqrt[2 π])))(e^(-(x^2)/2)).  Show that
(∂_x) ((∫_a^x)f (t) dt) =  f (x).

Clear[f, F, t, x]f[t_] = Exp[-((t^2)/2)]/(Sqrt[2 π]);
F[x_] = (∫_0^x) f[t] \[DifferentialD]t;
Print["f[t] = ", f[t]];
\(Print[\*""F[x] = \!\(∫\_0\%x\)f[t]\[DifferentialD]t""]
        \);
Print["F[x] = ", F[x]];
Print["
F'[x] = ",F'[x]];
Print[" f[x] = ", f[x]];

\(Plot[f[x], {x, \(-4\), 4}, PlotStyle -> RGBColor[1, 0, 0]]; 

    Print["Graph of f[x] = ", f[x]]; \)

\(Plot[F[x] + 1\/2, {x, \(-4\), 4}, PlotStyle -> RGBColor[0, 1, 0]]; 
    
Print[\*""Graph of F[x] + \!\(1\/2\) = "", F[x] + 1\/2]; \)

(1/(b - a)) (∫_a^b) f (x) \[DifferentialD]x  = 
       f (c)

Theorem 1.11  Mean Value Theorem for Integrals.   If  f (x)  is continuous over  [a, b],  then there exists a number  c,  with  a < c < b,  such that
	(1/(b - a))(∫_a^b)f (x) dx = f (c).
Section   1.1,    Review of Calculus,  Page 8

Example on Page 7.  Let  f (x)=sin (x)+(1/3) sin(3 x),  find  c so that
	(1/2.5)(∫_0^2.5)(sin (x) + (1/3) sin (3 x)) 
              dx = f (c).

\(Clear[a, b, c, f, g, h, L, solset, v, val, x]; 

    f[x_] = Sin[x] + 1\/3\ Sin[3\ x]; 

    g[x_] = ∫f[x] \[DifferentialD]x; 
Print["f[x] = ", f[x]]; 
    
Print["g[x] = ∫f[x]\[DifferentialD]x = ", g[x]]; \)

\(a = 0; 
\(b = 2.5; \)\)v = (∫_a^b) f[x] \[DifferentialD]x;
val = (((∫_a^b) f[x] \[DifferentialD]x)/(2.5 - 0));
solset = FindRoot[f[x] == val, {x, 1}];
c = solset[[1, 2]];
h  =  f[c];
Print["          c = ", c];
Print[" \!\(\*
StyleBox[\(∫\_\(\*
StyleBox[\(0\),
FontSize->10]\)\%\(\*
StyleBox[\(2.5\),
FontSize->10]\)\),
FontSize->16]\)f[x]\[DifferentialD]x = ",v];
Print["\!\(\(\*
StyleBox[\(∫\_\(\*
StyleBox[\(0\),
FontSize->10]\)\%\(\*
StyleBox[\(2.5\),
FontSize->10]\)\),
FontSize->16]f[x] \[DifferentialD]x\)\/2.5\) = ",val];
Print["       f[c] = ", h];

<<  Graphics`FilledPlot`\(gr1\  = \ 
      FilledPlot[{f[x]}, 
\ {x, a, b}, 
        Fills -> {{{1, Axis}, RGBColor[0, 1, 0]}}, 

        DisplayFunction -> Identity]; 

    grf = Plot[f[x], {x, a, b}, 
        Ticks -> {Range[0, 2.5, 0.5], Range[0, 1, 0.2]}, 
        DisplayFunction -> Identity]; 

    \(lines = 
      Graphics[{Line[{{a, 0}, {a, f[a]}}], Line[{{b, 0}, {b, f[b]}}]}]; \)\)line2 = 
      Graphics[{Line[{{a, 0}, {a, h}}], Line[{{a, h}, {b, h}}], 
          Line[{{b, h}, {b, 0}}]}]; \(Show[gr1, grf, lines, line2, DisplayFunction -> $DisplayFunction]; 
    
\(Print["The function is f[x] = ", f[x]]; \)\)\(Print["The value of the integral is over [", a, ",", b, 
      "] is  ", N[v]]; 

    \(Print["The area under the curve is the same as"]; \)\)Print["the area of a rectangle of height  h = ", h];

Theorem 1.12  Weighted Integral Mean Value Theorem.   Assume that both  f (x)  and  g (x)  are continuous over  [a, b],  and that  0 ≤ g (x)  for  a ≤ x ≤ b.  Then there exists a number  c,  with  a < c < b,   such that  
	(∫_a^b)f (x) g (x) dx =  f(c) (∫_a^b)g (x) dx. 
Section  1.1,    Review of Calculus,  Page 8

Example for Page 8.   Let   f (x) = (x^2)  and  g (x) = 1 + sin (x)  and let  [a, b]=[0,((3 π)/2)].   Find the value  c  so that
	(∫_0^(((3 π)/2)))f (x) g (x) dx =  f(c) (∫_0^(((3 π)/2)))g (x) dx.

\(Clear[c, f, fc, g, h\ , L, R, x]; 
f[x_] = x\^2; 
g[x_] = 1 + Sin[x]; 
    
h[x_] = f[x]\ g[x]; 
Print["f[x] = ", f[x]]; 

    Print["g[x] = ", g[x]]; 
Print["h[x] = ", h[x]]; \)

L = Expand[(∫_0^(((3 π)/2)))h[x] \[DifferentialD]x];
R = (∫_0^(((3 π)/2)))g[x] \[DifferentialD]x;
fc = N[(L/R)];
c = (Sqrt[fc]);
Print["\!\(\*
StyleBox[\(∫\_0\%\(\(3 π\)\/2\)\),
FontSize->18]\)f(x)g(x)\[DifferentialD]x = ",L];
Print["\!\(\*
StyleBox[\(∫\_0\%\(\(3 π\)\/2\)\),
FontSize->18]\)g(x)\[DifferentialD]x = ",R];
Print["f[c] = ", (L/R)];
Print["f[c] = ", Simplify[(L/R)]];
Print["f[c] = ", N[(L/R)]];
Print["c = ", (Sqrt[Simplify])[(L/R)]];
Print["c = ", (Sqrt[N])[(L/R)]];

Print["\!\(\*
StyleBox[\(∫\_0\%\(\(3 π\)\/2\)\),
FontSize->18]\)f(x)g(x)\[DifferentialD]x =  f(c) \!\(\*
StyleBox[\(∫\_0\%\(\(3 π\)\/2\)\),
FontSize->18]\)g(x)\[DifferentialD]x"];
Print["The value  c  and  f(c)  are given by:"];
Print["c = ", c];
Print["f(c) =  ", f[c]];
Print["Computations for the left and right side are:"];
Print["The left  side is:  ", N[L]];
Print["The right side is:  ", f[c] N[R]];

Theorem 1.13  Taylor's Theorem.   Assume that the function  f (x)  and its first n derivatives  f'(x),f''(x),⋯,Derivative[n + 1][f](x)  are all continuous on  [a, b],  and  (Subscript[x, 0])  is a fixed value.  Then
	f (x)  =  (Subscript[P, n]) (x)  +  (Subscript[R, n]) (x),  where
	(Subscript[P, n]) (x) = (∑_(k = 0)^n) ((Derivative[k][f]((Subscript[x, 0])))/(k!))(((x - (Subscript[x, 0])))^k)
is the n-th degree Taylor polynomial expanded about  (Subscript[x, 0])  and 
	 (Subscript[R, n]) (x) = ((Derivative[n + 1][f](c))/((n + 1)!))(((x - (Subscript[x, 0])))^(n + 1))  
is the Lagrange form of the remainder.
Section  1.1,    Review of Calculus,  Page 10

Example on Page 10.   Let  f (x) = sin (x).   Find the Taylor polynomial 
of degree  n = 9  for  f (x)  expanded about the point  (Subscript[x, 0]) = 0.

Clear[f, n, P9, x0]n = 9; x0 = 0; \(f[x_] = Sin[x]; 
P9[x_] = Normal[Series[f[x], {x, x0, n}]]; 

    Print[" f[x] = ", f[x]]; 

    Print[\*""\!\(P\_9\)[x] = "", P9[x]]; \)

\(Plot[{f[x], P9[x]}, {x, 0, 2\ π}, 
      PlotRange -> {{0, 2  π}, {\(-1\), 4}}, 
      PlotStyle -> {RGBColor[1, 0, 0], RGBColor[0, 1, 0]}]; 

    Print[" f[x] = ", f[x]]; 

    \(Print[\*""\!\(P\_9\)[x] = "", Pn[x]]; \)\)

Theorem 1.14  Horner's Method for Polynomial Evaluation.   Assume that 
	P (x) =  
        (Subscript[a, n]) (x^n)  +  (Subscript[a, n - 1]) (x^(n - 1))  + 
          ⋯ +  (Subscript[a, 2]) (x^2)  +  (Subscript[a, 1]) x  +  (Subscript[a, 0])
Then	P (x)  can be computed recursively as follows.  Set
	(Subscript[b, n])  =  (Subscript[a, n]) ,
	(Subscript[b, k])  =  (Subscript[a, k])  +  x (Subscript[a, k + 1])   for  k = n - 1, n - 2, ⋯, 1, 0.  
Then	P (x)  =  (Subscript[b, 0]).
Section  1.1,    Review of Calculus,  Page 12

Example on Page 13.  Use Horner's method to evaluate  P (3)  where 
	P (x) = (x^5) - 6 (x^4) + 8 (x^3) + 8 (x^2) + 4 x - 40.
First, find Horner's nested form of the polynomial.

\(Clear[A, B, H, k, n, P, Q, x]; 

    P[x_] = x\^5 - 6\ x\^4 + 8\ x\^3 + 8\ x\^2 + 4\ x - 40; 

    \(Q[x_] = 
      \(-40\) + \((4 + \((8 + \((8 + \((\(-6\) + x)\)\ x)\)\ x)\)\ x)\)\ x; 
    \)\)A = CoefficientList[P[x], x]; n = Length[A]; \(\(H[x_] := 
      Module[{}, 
\ \ \ \ B = Table[0, {n}]; 
\ \ \ \ 
        B[[n]] = 
          A[[n]]; 
\ \ \ \ \ \ \ \ 
        For[k = n - 1, 1 ≤ k, \(k--\), 
\ \ \ \ \ \ \ \ 
          B[[k]] = 
            A[[k]] + 
              x\ B[[k + 1]]]; 
\ \ \ \ 
        Return[B[[1]]]]; \)\)

\(Print["P[x] = ", P[x]]; 
Print["Q[x] = ", Q[x]]; 

    Print["H[x] = ", H[x]]; 
Print["P[3] = ", P[3]]; 

    Print["Q[3] = ", Q[3]]; 
Print["H[3] = ", H[3]]; \)

Consider the computational time for vector arguments 
for evaluating  P(x)  and the nested form  Q(x).

Clear[i, V]\(V = Table[i, {i, 1, 1000}]; 
\(Ptimeset = Timing[P[V]]; \)\)Qtimeset = Timing[Q[V]]; Ptimeset[[1]]Qtimeset[[1]]

Remark. It might be interesting to perform the computation several times and see the different results.

\(V = Table[i, {i, 1, 200}]; 
\(Ptimeset = Timing[P[V]]; \)\)Qtimeset = Timing[Q[V]]; Ptimeset[[1]]Qtimeset[[1]]

V = Table[i, {i, 1, 400}]; Ptimeset = Timing[P[V]]; Qtimeset = Timing[Q[V]]; Ptimeset[[1]]Qtimeset[[1]]

V = Table[i, {i, 1, 800}]; Ptimeset = Timing[P[V]]; Qtimeset = Timing[Q[V]]; Ptimeset[[1]]Qtimeset[[1]]

Theorem 1.15  Geometric Series.   If  | r |  <  1,  then
	1  +  r  +  (r^2)  +  ⋯ +  (r^(n - 1))  +  
          (r^n)  + ⋯ = (1/(1 - r)),  
		or
	(∑_(n = 0)^∞)(r^n)  =  (1/(1 - r)).
Section  1.2,    Binary Numbers,  Page 18

Example 1.2, Page 19.  Sum the infinite series
	1 + (1/4) + (1/(4^2)) + (1/(4^3)) + (1/(4^4)) + (1/(4^5)) + 
          ⋯ + (1/(4^n)) + ⋯ = (∑_(n = 0)^∞)(1/(4^n)).

Clear[n, S, V]V = {}; S = 0; For[n = 0, n ≤ 12, n++, S = S + N[(1/(4^n))]; 
      V = Append[V, {n, S}]]; dots = ListPlot[V, DisplayFunction -> Identity]; line = Graphics[{Line[{{0, (4/3)}, {12, (4/3)}}]}]; \(Show[dots, line, PlotRange -> {{0, 12}, {0, 1.35}}, 
      Prolog -> {PointSize[0.02]}, 
      Ticks -> {Range[0, 15, 1], Range[0, 1.5, 0.25]}, 
      DisplayFunction -> $DisplayFunction]; 

    Print[\*""Partial sums (∑_(k = 0)^n)(1/(4^k)) for the series.""]; \)

Mathematica  can find the sum of the infinite series.

\(Clear[n, val]; 
val\  = \ ∑\+\(n = 0\)\%∞ 1\/4\^n; 

    Print[\*""\!\(∑\+\(n = 0\)\%∞\)\!\(1\/4\^n\) = "", 
      val]; \)

S = 0.1011001100110  (Subscript[⋯, two])

Example 1.3, Page 21.  Find the sum of the binary number  S = 0.1011001100110  (Subscript[⋯, two]) .
Solution.  We can write  S  as the sum of geometric series:
S = 
        (1/2) +  (1/8) 
            (1 + (1/16) + ⋯ + (1/(16^n)) + ⋯)
               +  (1/16) 
            (1 + (1/16) + ⋯ + (1/(16^n)) + ⋯)
              , 
S = 
        (1/2) +  (3/16) 
            (1 + (1/16) + (1/(16^2)) + (1/(16^3)) + ⋯ + 
                  (1/(16^n)) + ⋯).
Now use Mathematica to find the infinite sum.

\(Clear[n, s1, s2]; 

    s1\  = \ 1\/2 + 1\/8\ \(∑\+\(n = 0\)\%∞ 1\/16\^n\) + 
        1\/16\ \(∑\+\(n = 0\)\%∞ 1\/16\^n\); 

    s2\  = \ 1\/2 + 3\/16\ \(∑\+\(n = 0\)\%∞ 1\/16\^n\); 

    Print[\*""(1/2)+(1/8) (∑_(n = 0)^∞)(1/(16^n))+(1/16) (∑_(n = 0)^∞)(1/(16^n))  =  "", s1]; 

    Print[\*""(1/2)+(3/16) (∑_(n = 0)^∞)(1/(16^n))  =  "", s2]; \)

Theorem 1.16  Big "O" remainders for Taylor's Theorem.   Assume that   
f (h)  =  p (h) +  O ((h^n)),   and   g (h)  =  q (h) +  O ((h^m)),  and  p  =  min {m, n}.  
Then		f (h) + g (h)  =  p (h) + q (h)  +  O ((h^p)) f (h)*g (h) =  p (h)*q (h)  +  O ((h^p))            ((f (h))/(g (h))) =(( p (h))/(q (h))) + O ((h^p))
Section  1.2,   Binary Numbers,  Page 33

Clear[f, g, h, m, n, P, Q]\(m = 2; 
n = 3; 
P[h_]\  = \ Series[f[h], {h, 0, m - 1}]; 

    Q[h_]\  = \ Series[g[h], {h, 0, n - 1}]; 
Print["m = ", m]; 

    Print["P[h] = ", P[h]]; 
Print["n = ", n]; 

    Print["Q[h] = ", Q[h]]; 
Print["p = min{m,n} = ", Min[m, n]]; 

    Print["P[h]+Q[h] = ", P[h] + Q[h]]; 

    Print["P[h]*Q[h] = ", P[h]*Q[h]]; 

    Print[\*""    \!\(P[h]\/Q[h]\) = "", P[h]\/Q[h]]; \)

Example 1.11, Page 34.   First find Taylor expansions for  (e^h)  and  cos (h).

\(Clear[h, m, n, p, prod, P, Q, quot, sum]; 
n = 5; 
\(m = 7; \)\)\(p = Min[n, m]; 
P[h_]\  = \ Series[E\^h, {h, 0, n - 1}]; 
    
Q[h_]\  = \ Series[Cos[h], {h, 0, m - 1}]; 

    Print["P[h] = ", P[h]]; 
Print["Q[h] = ", Q[h]]; \)

Then find the series for their sum.

\(sum\  = \ Series[E\^h + Cos[h], {h, 0, p - 1}]; 

    Print["P[h]+Q[h] = ", P[h] + Q[h]]; 
Print["          = ", sum]; 
    \)

Then find the series for their product.

\(prod = Series[E\^h\ Cos[h], {h, 0, p - 1}]; 

    Print["P[h]+Q[h] = ", P[h]*Q[h]]; 
Print["          = ", prod]; 
    \)

Then find the series for their quotient.

\(quot = Series[E\^h\/Cos[h], {h, 0, p - 1}]; 

    Print[\*""\!\(P[h]\/Q[h]\) = "", P[h]\/Q[h]]; 

    Print["      = ", quot]; \)

Theorem 1.17  Remainder term for Taylor's Theorem.   Assume that the function  f (x) and its first n derivatives  f'(x),f''(x),⋯,Derivative[n + 1][f](x)  are all continuous on  [a, b].   If  both  (Subscript[x, 0])  and  x = (Subscript[x, 0]) + h  lie in the interval  [a, b],  then
	f (x)  =  (Subscript[P, n]) (x)  +  O ((h^(n + 1))),  where
	(Subscript[P, n]) (x) = (∑_(k = 0)^n) ((Derivative[k][f]((Subscript[x, 0])))/(k!))(((x - (Subscript[x, 0])))^k)
is the n-th degree Taylor polynomial expanded about  (Subscript[x, 0]).
Section  1.2,   Error Analysis,  Page 34

Example for Page 34.  Consider  f (x) = sin (x)  and the Taylor polynomials of degree  n = 3, 5  and  7  expanded about  (Subscript[x, 0])  =  0.
\(Taylor\ 
            \(polynomial : \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 
              Order\ of\ \(approximation : 

\(P\_3\) \((x)\)\)\)\) = x-(((x^3))/6)                                                       O((x^5)) ≈ (((x^5))/120)
(Subscript[P, 5]) (x) = x-(((x^3))/6)+(((x^5))/120)                                         O((x^7)) ≈ (((x^7))/5040)
(Subscript[P, 7]) (x) = x-(((x^3))/6)+(((x^5))/120)-(((x^7))/5040)                         O((x^9)) ≈ (((x^9))/362880)

(i)   Show that  \[VerticalSeparator]sin (x)  -  (Subscript[P, 3]) (x)\[VerticalSeparator]<\[VerticalSeparator](((x^5))/120)\[VerticalSeparator]  over  [-2, 2].

\(Clear[f, E3, maxerr, P3, x]; 
f[x_] = Sin[x]; 

    \(P3[x_] = Normal[Series[f[x], {x, 0, 3}]]; \)\)E3[x_] = ((x^5)/(5!)); \(maxerr = Abs[f[2.0] - P3[2.0]]; 

    Plot[{Abs[f[x] - P3[x]], Abs[E3[x]]}, {x, \(-2\), 2}, 
      PlotRange -> {{\(-2\), 2}, {0, \ maxerr}}, 
      PlotStyle -> {RGBColor[1, 0, 0], RGBColor[0, 0, 1]}]; 

    Print["f(x)  = ", f[x]]; 

    Print["f(x)  = ", Series[f[x], {x, 0, 3}]]; 

    Print[\*""(Subscript[P, 3])(x) = "", P3[x]]; 

    Print[\*""|sin(x) - (Subscript[P, 3])(x)| ≤ |((x^5)/(5!))|  over [-2,2].""]; 

    Print["The maximum error over [-2,2] is:  ", maxerr]; \)

(ii)   Show that  \[VerticalSeparator]sin (x)  -  (Subscript[P, 5]) (x)\[VerticalSeparator]<\[VerticalSeparator](((x^7))/5040)\[VerticalSeparator]    over  [-2, 2].

\(Clear[f, E5, maxerr, P5, x]; 
f[x_] = Sin[x]; 

    \(P5[x_] = Normal[Series[f[x], {x, 0, 5}]]; \)\)E5[x_] = ((x^7)/(7!)); \(maxerr = Abs[f[2.0] - P5[2.0]]; 

    Plot[{Abs[f[x] - P5[x]], Abs[E5[x]]}, {x, \(-2\), 2}, 
      PlotRange -> {{\(-2\), 2}, {0, maxerr}}, 
      PlotStyle -> {RGBColor[1, 0, 0], RGBColor[0, 0, 1]}]; 

    Print["f(x)  = ", f[x]]; 

    Print["f(x)  = ", Series[f[x], {x, 0, 5}]]; 

    Print[\*""(Subscript[P, 5])(x) = "", P5[x]]; 

    Print[\*""|sin(x) - (Subscript[P, 5])(x)| ≤ |((x^7)/(7!))|  over [-2,2].""]; 

    Print["The maximum error over [-2,2] is:  ", maxerr]; \)

(iii)   Show that   \[VerticalSeparator]sin (x)  -  (Subscript[P, 7]) (x)\[VerticalSeparator]<\[VerticalSeparator](((x^9))/362880)\[VerticalSeparator]    over  [-2, 2].

\(Clear[f, E7, maxerr, P7, x]; 
f[x_] = Sin[x]; 

    P7[x_] = Normal[Series[f[x], {x, 0, 7}]]; 
E7[x_] = x\^9\/\(9!\); 

    maxerr = Abs[f[2.0] - P7[2.0]]; 

    Plot[{Abs[f[x] - P7[x]], Abs[E7[x]]}, {x, \(-2\), 2}, 
      PlotRange -> {{\(-2\), 2}, {0, maxerr}}, 
      PlotStyle -> {RGBColor[1, 0, 0], RGBColor[0, 0, 1]}]; 

    Print["f(x)  = ", f[x]]; 

    Print["f(x)  = ", Series[f[x], {x, 0, 7}]]; 

    Print[\*""(Subscript[P, 7])(x) = "", P7[x]]; 

    Print[\*""|sin(x) - (Subscript[P, 7])(x)| ≤ |((x^9)/(9!))|  over [-2,2].""]; 

    Print["The maximum error over [-2,2] is:  ", maxerr]; \)