Differentiation and integration

Byungik Kahng, Michael O'Reilly, Imre Tuba

Abstract.  We learn about derivatives integrals.  We define derivatives and discuss their properties and list the derivatives of the most common functions .  We study how to differentiate products and quotients of functions and composite functions.  We learn about implicit and logarithmic differentiation and how to find derivatives using Mathematica.  We introduce the concept of integrals through various approaches.  After explaining indefinite integrals (antiderivatives), we move on to definite integrals and the fundamental theorem of calculus.  We take the intuitive approach first before formally defining definite integrals and proving the fundamental theorem of calculus.  In Section 4, we present yet another approach to understand the concept of Riemann sums and definite integrals: numerical integration.

General Setup

Off[General::spell];
Off[General::spell1];
SetOptions[Limit, Analytic -> True];

Graphics Setup

2D setup

<< Graphics`Colors`;
<< Graphics`Graphics`;
<< Graphics`ImplicitPlot`;
<< Graphics`FilledPlot`;
<< Graphics`Animation`;

    
Begin["`Private`"];
SetOptions[ParametricPlot, 
        AspectRatio -> Automatic];
SetOptions[Plot, AspectRatio -> Automatic];
SetOptions[Graphics, AspectRatio -> Automatic];

3D setup

<< RealTime3D`;
MathView = {2.5, 2.0, 1.5};

Vector Setup

2D vectors

Options[Arrow] = {HeadRatio -> 0.15, Sharpness -> 0.25, 
          ShaftRatio -> 0.25};
Arrow[from_?VectorQ, to_?VectorQ, 
          opts___] := 
Module[{vector, vectorlength, 
              unitvector, perp, headratio, arrowbase, sharpness, shaftratio, 
              ii}, 
{headratio, sharpness, 
                shaftratio} = {HeadRatio, Sharpness, 
                    ShaftRatio} /. {opts} /. 
                Options[Arrow]; 
vector = 
              to - from; 
vectorlength = (Sqrt[N])[vector . vector]; 
If[vectorlength > 0, 
              unitvector = (vector/vectorlength), 
              unitvector = {0, 
                  0}]; 
perp = {unitvector[[2]], -unitvector[[1]]}; 
arrowbase = 
              from + (1 - headratio)*
                  vector; 
Flatten[{
Polygon[{to, 
                    arrowbase + (headratio*vectorlength*Tan[sharpness]) 
                        perp, 
arrowbase + (headratio*
                            shaftratio) 
                        vector, 
arrowbase - (headratio*
                            vectorlength*Tan[sharpness]) perp, 
                    to}], 
Line[{from, 
                    arrowbase + (headratio*shaftratio) 
                        vector}]
}]
] /; 
          Length[from] == Length[to] == 2;

3D vectors

Options[Arrow3D] = {HeadRatio -> 0.15, 
          Sharpness -> (π/12)};
Arrow3D[from_?VectorQ, to_?VectorQ, opts___]:=
Module[{vector, vectorlength, unitvector, tmpvector, 
                tmplength, , perp, biperp, headratio, arrowbase, arrowvertex, 
                sharpness, ii, jj, kk},
{headratio, 
                    sharpness} = {HeadRatio, Sharpness} /. {opts} /. 
                    Options[Arrow3D];
vector = to - from;
vectorlength = (Sqrt[N])[vector . vector];
If[vectorlength > 0, 
                  unitvector = (vector/vectorlength), 
                  unitvector = {0, 0, 0}];
tmpvector = {0, 
                    unitvector[[3]], -unitvector[[2]]};
tmplength = (Sqrt[N])[unitvector[[2]]^2 + unitvector[[3]]^2];
If[tmplength > 0, 
                  perp = (tmpvector/tmplength), perp = {0, 1, 0}];
biperp = 
                  N[Det[{{ii, jj, kk}, unitvector, 
                          perp}] /. {ii -> {1, 0, 0}, 
                        jj -> {0, 1, 0}, kk -> {0, 0, 1}}];
arrowbase = 
                  from + (1 - headratio)*vector;
arrowvertex = 
                  Table[arrowbase + (headratio*vectorlength*
                            Tan[sharpness]) (Cos[(π/4) ii] perp + 
                            Sin[(π/4) ii] biperp), {ii, 0, 8, 1}];
Flatten[{
Table[
Polygon[{to, 
                          arrowvertex[[ii]], 
                          arrowvertex[[ii + 
                                1]]}], 
{ii, 1, 8, 
                        1}], 
Line[{from, 
                        to}]
}]
]/;Length[from] == Length[to] == 3;

Vector fields

<< Graphics`PlotField`;
<< Graphics`PlotField3D`;

1.  Properties of Derivatives

(1.1)  The derivative at a point.

Definition 1.1.1.

Let \(TraditionalForm\`f : 
          D ⊂ ℝ -> ℝ\) and a ∈ D.  The derivative f' (a) of the function f at the point a is defined as the following limit.

f' (a) = 
        (lim_(h -> 0))((f(a  +  h)  -  f(a))/h).

By taking b = a + h, so that h = b - a, we can express the above limit in the following equivalent form.

f' (a) = 
        (lim_(b -> a))((f(b)  -  f(a))/(b  -  a)).

1.1.2.  The Derivative as the slope of a graph.

The slope of a graph at a point is defined as the slope of the tangent line at the point.  The latter can be approximated through the slopes of various secant lines.  That is,

the slope of the tangnet line ≈ the slope of the secant line 
                                 \(\(=\)\(\(the\ difference\ of\ y\ value\)\/\(the\ difference\ of\ x\ value\)\)\)
                                 \(\(=\)\(\(Δ\ y\)\/\(Δ\ x\)\ \ \ \((rise\/run)\)\)\)
                                 =((f (b)  -  
                  f (a))/(b  -  a)).

Clearly, the approximation gets better as b -> a.  Therefore, we can regard the derivative f' (a) as the slope of the graph of f at the point a.  This idea is illustrated in the following example.

Example 1.1.3.

In this example, the original function

f(x) = -(x^4) - (x^3) + 2  (x^2)

and its tangent line at the specified point x = a are graphed with various secant lines

y = ((f(a  +  b)  -  f(a))/(b  -  
                  a)) (x - a) + f(a),

with different b values.

Static view.

Clear[f, x, h, a];
f[x_] = -(x^4) - (x^3) + 2  (x^2);
a = 0.35;
tangent[x_] = f'[a] (x - a) + 
          f[a];
secant[x_, h_] = ((f[a + h] - f[a])/h) (x - a) + 
          f[a];
tangentplot = 
        Plot[{f[x], tangent[x]}, {x, 0.1, 0.95}, 
          PlotStyle -> {{Blue, Thickness[0.005]}, {Red, 
                Thickness[0.005]}}, PlotRange -> {-0.05, 0.45}, 
          DisplayFunction -> Identity];
secantlines = 
        Table[Plot[secant[x, h], {x, 0.2, 0.95}, 
            PlotStyle -> {DarkGreen}, 
            PlotRange -> {-0.05, 0.45}, 
            DisplayFunction -> Identity], {h, 0.1, 0.5, 
            0.1}];
Show[secantlines, tangentplot, 
        DisplayFunction -> $DisplayFunction];

Animation.

Clear[f, x, h, a];
f[x_] = -(x^4) - (x^3) + 2  (x^2);
a = 0.35;
tangent[x_] = f'[a] (x - a) + 
          f[a];
secant[x_, h_] = ((f[a + h] - f[a])/h) (x - a) + 
          f[a];
Table[
        Plot[{f[x], tangent[x], secant[x, h]}, {x, 0.1, 0.95}, 
          PlotStyle -> {Blue, Red, DarkGreen}, 
          PlotRange -> {-0.05, 0.45}], {h, 0.6, 
          0.02, -0.02}];

1.1.4.  The Derivative as the instantaneous rate of change.

The average rate of change of the function y = f(x) is a quantity that measures how much the function value (y value) changes with respect  to the change of the original  variable (x value).  That is,

the average rate of change=\(\(the\ change\ of\ function\ value\)\/\(the\ change\ of\ the\ original\ variable\)\)
                         \(\(=\)\(\(Δ\ y\)\/\(Δ\ x\) = \(f \((b)\)\  - \ f \((a)\)\)\/\(b\  - \ a\)\)\)
                          =the slope of the secant line.

Clear[f, x, a, 
        b];
f[x_] = -(x^4) - (x^3) + 
          2  (x^2);
a = 0.35; 
    b = 0.75;
secant[
          x_] = ((f[b] - f[a])/(b - a)) (x - a) + 
          f[a];
secantplot = 
        Plot[{f[x], secant[x]}, {x, 0.1, 0.95}, 
          PlotStyle -> {Blue, DarkGreen}, 
          PlotRange -> {-0.05, 0.45}, 
          DisplayFunction -> 
            Identity];
slopeplot = 
        Graphics[{Red, 
            Line[{{a, f[a]}, {b, f[a]}, {b, 
                  f[b]}}]}];
Show[secantplot,slopeplot,DisplayFunction -> $DisplayFunction,
Epilog->{Text["Δx",{((a + b)/2), 
                      f[a] - ((0.05 (f[b] - f[a]))/Abs)[f[b] - f[a]]}],Text["Δy",{b + ((0.06 (b - a))/Abs)[b - a], ((f[a] + f[b])/2)}]}
];

Hence, the definition of the derivative, f' (a) = 
        (lim_(b -> a))((f(b)  -  f(a))/(b  -  a)) tells us that the derivative measures the average rate of change of the function f in an infinitesimally small interval [a, b].  In other words, the derivative f' (a) measures the instantaneous rate of change.

(1.2)  The derivative as a function.

Let \(TraditionalForm\`f : 
          D ⊂ ℝ -> ℝ\) and a ∈ D.  Recall that a derivative f' (a) of a function f at a point a is defined by the following limit.

f' (a) = 
        (lim_(h -> 0))((f(a  +  h)  -  f(a))/h).

Consequently, the derivative f' (a) is a real number (when the limit exists, of course).  Therefore, we can define a function f' in the domain D that takes the value f' (x), whenever it exists.  Let us elaborate this idea.

Definition 1.2.1.

Let \(TraditionalForm\`f : 
          D ⊂ ℝ -> ℝ\).  We define the derivative function f' of the original function f by

f' (x) = 
        (lim_(h -> 0))((f(x  +  h)  -  f(x))/h).

Since the derivative was defined as a limit, not every f' (x) exists.  Thievery, the domain of f' can be strictly smaller than D.

Definition 1.2.2.

Let \(TraditionalForm\`f : 
          D ⊂ ℝ -> ℝ\) and a ∈ D.  We say f is differentiable at x, if the limit

f' (x) = 
      (lim_(h -> 0))((f(x  +  h)  -  f(x))/h)

exists.  We say f : D -> ℝ is differentiable in (entire) D, if f' (x) exists for all x ∈ D.  We say \(TraditionalForm\`f : ℝ -> ℝ\) is differentiable function, if f' (x) exists for all x ∈ ℝ.

Theorem 1.2.3.

Let f : D -> ℝ, p ∈ D.  If f is differentiable at p, then it must be continuous at p.

Proof.

Since f is differentiable at p, we have

(lim_(x -> p))[f(x) - f(p)] = 
      (lim_(x -> p))((f(x)  -  f(p))/(x  -  p)) (x  -  
              p)
\(TraditionalForm\`\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(\(=\)\(lim\_\(x -> p\)\(\(f(
                  x)\  - \ f(p)\)\/\(x\  - \ 
                p\)\) \(lim\_\(x -> p\)\((x\  - \ 
                p)\)\)\)\)\)
\(TraditionalForm\`\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(\(=\)\(f' \((p)\)\ •\ 0 = 0. \)\)\)

Thus,

(lim_(x -> p))f(x) = f(p).

Example 1.2.4.

Here are the graphs three functions.  Which function is differentiable at 0?

Clear[f, g, h, x];
f[x_] = (x^3);
g[x_] = Sqrt[Abs[x] + (1/100)];
h[x_] := Cos[x] /; x ≥ 0;
h[x_] := -(x^2) /; x < 0;
fplot = 
        Plot[f[x], {x, -1, 1}, PlotStyle -> {Blue}, 
          Axes -> True, PlotRange -> {-1, 1}, 
          DisplayFunction -> Identity];
gplot = 
        Plot[g[x], {x, -1, 1}, PlotStyle -> {{Blue}}, 
          Axes -> True, 
          DisplayFunction -> Identity];
hplot = 
        Plot[h[x], {x, -1, 1}, PlotStyle -> {{Blue}}, 
          Axes -> True, 
          DisplayFunction -> Identity];
Show[GraphicsArray[{fplot, gplot, hplot}], 
        DisplayFunction -> $DisplayFunction];

Solution.

Only the first function is differentiable at 0.  The second has a cusp at 0, and the third is discontinuous.

(1.3)  The derivative as a rate of change.

Recall that the average rate of change can be expressed as,

the average rate of change=\(\(the\ change\ of\ function\ value\)\/\(the\ change\ of\ the\ original\ variable\)\)
                         \(\(=\)\(\(Δ\ y\)\/\(Δ\ x\) = \(f \((b)\)\  - \ f \((a)\)\)\/\(b\  - \ a\)\)\)
                          =the slope of the secant line.

Clear[f, x, a, 
        b];
f[x_] = -(x^4) - (x^3) + 
          2  (x^2);
a = 0.35; 
    b = 0.75;
secant[
          x_] = ((f[b] - f[a])/(b - a)) (x - a) + 
          f[a];
secantplot = 
        Plot[{f[x], secant[x]}, {x, 0.1, 0.95}, 
          PlotStyle -> {Blue, DarkGreen}, 
          PlotRange -> {-0.05, 0.45}, 
          DisplayFunction -> 
            Identity];
slopeplot = 
        Graphics[{Red, 
            Line[{{a, f[a]}, {b, f[a]}, {b, 
                  f[b]}}]}];
Show[secantplot,slopeplot,DisplayFunction -> $DisplayFunction,
Epilog->{Text["Δx",{((a + b)/2), 
                      f[a] - ((0.05 (f[b] - f[a]))/Abs)[f[b] - f[a]]}],Text["Δy",{b + ((0.06 (b - a))/Abs)[b - a], ((f[a] + f[b])/2)}]}
];

Now, set h = a - b so that

\(TraditionalForm\`\(f(b)\  - \ f(a)\)\/\(b\  - \ a\) = \(\(f(a)\  - \ f(b)\)\/\(a\  - \ b\) = \(f(a)\  - \ f(a\  - \ h)\)\/h\)\).

We use the latter quotient to represent the average rate of change as a function.

Definition 1.3.1.

Let \(TraditionalForm\`f : 
          D ⊂ ℝ -> ℝ\).  For fixed real number h, we define the (average) growth-rate function as,

\(TraditionalForm\`\(f\_h\%'\)(x) = \(f(x)\  - \ f(x\  - \ h)\)\/h\).

Remark 1.3.2.

We took

((f(x)  -  f(x  -  h))/h)

instead of traditional Newton quotient

((f(x  +  h)  -  f(x))/h)

for a very practical reason.  If x stands for current status, then f(x + h) for h > 0 would mean a future value, which may not be known yet.  Therefore, it makes more sense to take the first quotient to represent, say 50-day moving average growth rate of S&P 500 index.

The following example illustrates \(TraditionalForm\`\(f\_h\%'\)(x) -> f' \((x)\)\), as h -> 0.

Example 1.3.3.

Let us define \(TraditionalForm\`f : ℝ -> ℝ\) as

f(x) = -(x^4) - (x^3) + 2  (x^2).

The following depicts the graphs of various growth-rate functions and the derivative function.

Static view.

Clear[f, g, x, h];
f[x_] = -(x^4) - (x^3) + 2  (x^2);
growthrate[x_, 
          h_] = ((f[x] - f[x  -  h])/h);
derivativeplot = 
        Plot[f'[x], {x, -2, 2}, 
          PlotStyle -> {{Blue, Thickness[0.005]}}, 
          PlotRange -> {-5, 4}, AspectRatio -> 1/GoldenRatio, 
          DisplayFunction -> Identity];
growthrateplots = 
        Table[Plot[growthrate[x, h], {x, -2, 2}, 
            PlotStyle -> {Brown}, PlotRange -> {-5, 4}, 
            AspectRatio -> 1/GoldenRatio, 
            DisplayFunction -> Identity], {h, 0.25, 2.0, 
            0.25}];
Show[derivativeplot, growthrateplots, 
        DisplayFunction -> $DisplayFunction];

Animation.

Clear[f, g, x, h];
f[x_] = -(x^4) - (x^3) + 2  (x^2);
growthrate[x_, 
          h_] = ((f[x] - f[x  -  h])/h);
Table[
        Plot[{f'[x], growthrate[x, h]}, {x, -2, 2}, 
          PlotStyle -> {Blue, Brown}, PlotRange -> {-5, 4}, 
          AspectRatio -> 1/GoldenRatio], {h, 2.0, 
          0.05, -0.05}];

(1.4)  The sign of a derivative.

1.4.1.  Increasing functions and decreasing functions.

We say a certain real function f is increasing in an interval I,  if f(x) ≤ f(y) whenever x ≤ y, where x, y ∈ I.  On the other hand, we say f is decreasing in I, if f(x) ≥ f(y) whenever x ≤ y, x, y ∈ I.  Graphically, y = f(x) is increasing if y value goes up as x value moves to the right.

We say f is monotone, if it is either increasing or decreasing.  We say f is strictly increasing if f(x) < f(y) whenever x < y, and strictly decreasing if f(x) > f(y) whenever x < y.  A constant function is both increasing and decreasing everywhere at the same time, but it is considered neither strictly increasing nor strictly decreasing anywhere.

For example, in the following graph, f is decreasing in the interval (-0.5, 0), increasing in (0, 0.7), and decreasing again in (0.7, 1.1).

Clear[f, g, x]
f[x_] = -(x^4) - (x^3) + 2  (x^2);
fplot = 
        Plot[f[x], {x, -0.5, 1.1}, PlotStyle -> {Blue}, 
          DisplayFunction -> Identity];
maxplot = 
        Graphics[{Blue, PointSize[0.02], 
            Point[{(1/8) (-3 + (Sqrt[73])), 
                f[(1/8) (-3 + (Sqrt[73]))]}]}];
minplot = 
        Graphics[{Blue, PointSize[0.02], 
            Point[{0, 0}]}];
Show[fplot, maxplot, minplot, 
        DisplayFunction -> $DisplayFunction];

Note that the slope is positive in the interval in which f increases, and the slope is negative in the interval where f decreases.

Theorem 1.4.2.

Let f be a real function that is differentiable in an interval I.  
1.	If f' ≥ 0 in the interval I ⊂ D, then f is increasing in I.  
2.	If f' ≤ 0 in I, then f is decreasing in I.  
3.	If f' > 0 in I, then f is strictly increasing in I.  
4.	If f' < 0 in I, then f is strictly decreasing in I. 
5.	If f' ≡ 0 in the interval I, then f must be a constant in I.

We are not ready to prove Theorem 1.4.2, yet.  We will prove it in Chapter 4, where we learn Mean Value Theorem, among others.

Example 1.4.3.

The following graph stands for the graph of the derivative function, y = f' (x).  Determine the intervals in which the original function f(x) increases or decreases.

Clear[f, x];
f[x_] = 
        ((x^3)/15) + x Sin[x] + Cos[x] - 1;
\(\(Plot[{f[x]}, {x, \(-2.5\), 3.5}, 
        AspectRatio -> 
          1/GoldenRatio, 
	\ \ PlotStyle -> {
{Thickness[0.005], Blue}
}, 
        AxesLabel -> {"x", ""}];\)\)

Solution.

When x ≲ -1.9, f' (x) stays negative, so f is decreasing.  When -1.9 ≲ x ≲ 3.2, f' (x) is now positive, so f is increasing.  Finally, when x ≳ 3.2, f' (x) goes negative again, so f decreases there.  The following program depicts the graphs y = f' (x) and y = f(x) together.  Note that the change of sign of the derivative function (x ≈ -1.9 and x ≈ 3.2) gives rise to a local minimum and a local maximum of y = f(x).  Note also, that y = f(x) has horizontal tangent (slope 0) at x = 0, but it does not change the increasing/decreasing behavior of y = f(x), because the sign of f' (x) does not change around x = 0.

Clear[f, g, x];
g[x_] = 
        ((x^3)/15) + x Sin[x] + Cos[x] - 1;
f[x_] = -x + ((x^4)/60) - x Cos[x] + 
          2 Sin[x];
\(\(Plot[{g[x], f[x]}, {x, \(-2.5\), 3.7}, 
        AspectRatio -> 1/GoldenRatio, 
        PlotRange -> {\(-0.5\), 1.65}, 
	\ \ PlotStyle -> {Blue, 
            Red}, AxesLabel -> {"x", ""}];\)\)
Print["f[x] = "' f[x]];
Print["f'[x] = ", f'[x]];

(1.5)  Higher derivatives.

1.5.1.  Rate of changes of rate of changes.

Since the rate of change is itself a function (the derivative function), we can consider its rate of change (derivative), too.  Thus, starting from the original function f(x), we get the first derivative f' (x), the derivative of f' (x), f'' (x), the derivative of f'' (x), f''' (x), and so on.  We call them the first derivative, the second derivative, the third derivative, and so on.  The role of the second derivative f'' (x) on the original function f(x) is rather indirect, because the former measures how fast f' (x) (the rate of change of f) changes.  The implication of the third derivative is even less imposing.

The role of the second derivative on the graph of the original function will be discussed in Chapter 4.  here, let us have a glimpse of what we will do in Chapter 4 with the following example.

Example 1.5.2.

Here are the graphs of a function f(x), its derivative function f' (x), and the second derivative function f'' (x), plotted in the same viewing window.  Determine which is which.

Clear[f, x];
f[x_] = 
        (x^2) Sin[(x/5)] + x Cos[((x^2)/2)];
Plot[{f[x], f'[x], f''[x]}, {x, -2.5, 2.5}, 
        PlotStyle -> {Blue, Red, DarkGreen}, 
        PlotRange -> {-4, 4}, 
        AspectRatio -> 1/GoldenRatio];

Solution.

Recall that the rate of change (slope) is positive, when the original function is increasing, negative when the original function is decreasing.  In the above picture, the red graph goes down when the green is negative, goes up when the green is positive.  Also, the blue graph increases and decreases according to the sign of the red graph.  No other pair exhibits such relation, out of total six possible pairs, (r, g), (r, b), (g, r), (g, 
        b), (b, r), (b, g).  Therefore, we conclude that f(x) is blue, f' (x) is red, and f'' (x) is green.

1.5.3.  Position, velocity and acceleration.

Arguably the best example that the first and the second derivatives affecting the original function must be the position-velocity-acceleration model in physics.  If we define the position of a train, for instance, in a rail way track as a function of time, say r(t), then its velocity, v(t) is measured by the rate of change, v(t)=r' (t).  Its acceleration, a(t) is measures how steeply the velocity changes, that is, a(t)=v' (t)=r'' (t).  Newton's Law of motion says,

F(t) = m a(t) = m r'' (t).

That is, the external force F(t) has the above relation with the acceleration.  Therefore, there is little need to consider the third derivatives or higher in elementary physics.

Example 1.5.4.

Here is the motion of a pendulum.  The horizontal position of the pendulum, x(t) is visualized as a blue dot.  Its velocity v(t)=x' (t) is visualized as the red dot.  The acceleration, a(t)=v' (t)=r'' (t) is shown as a green dot.  Note that the velocity reaches the maximum (right hand side endpoint) and the minimum (left hand side endpoint) as the position of the pendulum passes the center.  When the position reaches the endpoints, the velocity hits 0.  Note that the speed of the motion changes accordingly.  The acceleration reaches the maximum, the minimum and 0, according to the change of the velocity.

Program.

Clear[g, l, r, θ, t, ti, tf];
AniNo = 50;                  
initial = N[(π/4)];      
l = 1;             
ρ = 0.05;        
g = 9.8;         
margin = 0.1;     
{θ[t_]} = θ[t] /. 
          NDSolve[
{-g Sin[θ[t]] 
                  Cos[θ[t]] == 
                l θ''[t] Cos[θ[t]] - 
                  l (((θ'[t]))^2) Sin[θ[
                        t]], 
θ[0] == 
                initial, θ'[0] == 
                0}, 
θ[t], {t, 0, 5}];
ti = 0;
tf=t/.FindRoot[θ'[t] == 0,{t,2.5}];
r[t_] = 
        l {Sin[θ[t]], -Cos[θ[t]]};
traceplot = 
          ParametricPlot[r[t], {t, ti, tf}, PlotStyle -> Blue, 
            DisplayFunction -> Identity];

  
xlength = 
        Abs[Sin[initial]];
maxspeed = 
        Abs[r'[(tf - ti)/
                4][[1]]];
maxacc = 
        Abs[r''[0][[1]]];
vratio = 
        (xlength/maxspeed);
accratio = 
        (xlength/maxacc);
  

aniplot[ii_] := 
        Module[{lineplot, pointplot, topedge, 
            bottomedge}, 
topedge = 
            Graphics[{GrayLevel[0.5], 
                Polygon[{{-(l/2), 0}, {(l/2), 0}, {(l/2), 
                      0.05}, {-(l/2) - 0, 0.05}, {-(l/2), 
                      0}}]}]; 
bottomedge = 
            Graphics[{Black, Thickness[0], 
                Line[{{-(l/2), 0}, {(l/2), 
                      0}}]}]; 
lineplot = 
            Graphics[{Black, Thickness[0], 
                Line[{{0, 0}, r[ii]}]}]; 
pointplot = 
            Graphics[{Black, PointSize[ρ], 
                Point[r[ii]]}]; 

xline = 
            Graphics[{Black, Thickness[0], 
                Line[{{-xlength, -l - 2  margin}, {xlength, -l - 
                        2  margin}}]}]; 
positionplot = 
            Graphics[{Blue, PointSize[0.015], 
                Point[{r[ii][[1]], -l - 
                      2  margin}]}]; 
velocityline = 
            Graphics[{Black, Thickness[0], 
                Line[{{-xlength, -l - 3  margin}, {xlength, -l - 
                        3  margin}}]}]; 
velocityplot = 
            Graphics[{Red, PointSize[0.015], 
                Point[{(xlength/maxspeed) r'[
                          ii][[1]], -l - 
                      3  margin}]}]; 
accline = 
            Graphics[{Black, Thickness[0], 
                Line[{{-xlength, -l - 4  margin}, {xlength, -l - 
                        4  margin}}]}]; 
accplot = 
            Graphics[{DarkGreen, PointSize[0.015], 
                Point[{(xlength/maxacc) r''[ii][[1]], -l - 
                      4  margin}]}]; 
verticalline = 
            Graphics[{GrayLevel[0.75], Thickness[0], 
                Line[{{0, -l - 4  margin}, {0, 
                      0}}]}]; 
Show[verticalline, xline, 
            positionplot, velocityline, velocityplot, accline, accplot, 
            topedge, bottomedge, lineplot, pointplot, Axes -> False, 
            PlotRange -> {{-l - ρ, 
                  l + ρ}, {-l - 5  margin, 0.2}}, 
            DisplayFunction -> $DisplayFunction];
];
Table[
        aniplot[ii], {ii, ti, 
          tf - (((tf - ti))/AniNo), (((tf - ti))/AniNo)}];

Justification of the program.

The motion of the pendulum must follow a circular path, because the weight is attached to the ceiling.

(Overscript[r,  ->]) [θ(t)] = 
        l θ' (t) (Cos[θ], Sin[θ]).

Differentiating it twice we get,

\(TraditionalForm\`\(d\/dt\) \(r\& -> \)[θ(t)] = \(\(d\/dt\) \(l(
              Sin[θ], \(-Cos[θ]\))\) = 
          l\ θ' \((t)\) \((Cos[θ], Sin[θ])\)\)\),

\(TraditionalForm\`\(d\^2\/dt\^2\) \(r\& -> \)[θ(t)] = \(d\/dt\)[
          l\ θ' \((t)\) \((Cos[θ], Sin[θ])\)]\)
\(TraditionalForm\`\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(\(=\)\(l\ θ'' \((Cos[θ], Sin[θ])\) + 
          l\ \(\((θ')\)\^2\) \(\((\(-Sin[θ]\), 
                Cos[θ])\)\(.\)\)\)\)\)

Thus,

(eq:1.5.4-1)		\(TraditionalForm\`\(d\^2\/dt\^2\) \(r\& -> \)[θ(t)] = 
        l[θ'' \((Cos[θ], 
                Sin[θ])\) + \(\((θ')\)\^2\) \((\(-Sin[θ]\), Cos[θ])\)]\).

On the other hand, the gravitational force can be written as,

(Overscript[F,  ->])  = m g(0, -1).

From simple geometry, we can find the tangential and the radial components of F.

Clear[t, θ];
θ = (π/6);
rr = {Sin[θ], -Cos[θ]};
grav = 0.5;
gravity = grav {0, -1};
arc[t_] = {Sin[t], -Cos[t]};
ρ = 0.05;
topedge = 
        Graphics[{GrayLevel[0.5], 
            Polygon[{{-(1/2), 0}, {(1/2), 0}, {(1/2), 
                  0.05}, {-(1/2), 0.05}, {-(1/2), 
                  0}}]}];
bottomedge = 
        Graphics[{Black, Thickness[0], 
            Line[{{-(1/2), 0}, {(1/2), 
                  0}}]}];
lineplot = 
        Graphics[{Black, Thickness[0], 
            Line[{{0, 0}, rr}]}];
pointplot = 
        Graphics[{Black, PointSize[ρ], 
            Point[rr]}];
verticalline = 
        Graphics[{GrayLevel[0.75], Thickness[0], 
            Line[{{0, -1.1}, {0, 0}}]}];
arcplots = 
        ParametricPlot[{arc[t], 0.1  arc[t], 0.11  arc[t], rr + 0.1  arc[t], 
            rr + 0.11  arc[t]
}, {t, 0, θ}, 
          PlotStyle -> {Blue}, 
          DisplayFunction -> Identity];
gravforce = 
        Graphics[{GrayLevel[0.5], Thickness[0], 
            Arrow[rr, rr + gravity]}];
radialforce = 
        Graphics[{GrayLevel[0.5], Thickness[0], 
            Arrow[rr, 
              rr + grav*Cos[θ] rr]}];
tangentialforce = 
        Graphics[{Red, Thickness[0], 
            Arrow[rr, 
              rr + grav*
                  Sin[θ] {-Cos[θ], -Sin[θ]}, 
              HeadRatio -> 0.25]}];
Show[verticalline, topedge, bottomedge, gravforce, radialforce, 
        tangentialforce, arcplots, lineplot, pointplot, 
        PlotRange -> All, 
        DisplayFunction -> $DisplayFunction];

From the above picture, we see

(eq:1.5.4-2)	(Overscript[(Subscript[F, tan]), ⟶])=-m g Sin[θ] (Cos[θ], 
              Sin[θ]).

Now, we apply Newton's Law of Motion.

\(TraditionalForm\`\(F\_tan\)\&⟶ = \(m\ \(\(a\& -> \)(t)\) = 
          m \(d\^2\/dt\^2\) \(r\& -> \)[θ(t)]\)\),

From (eq:1.5.4-1) and (eq;1.5.4-2), we can rewire the above equation as,

\(TraditionalForm\`\(-m\)\ g\ Sin[θ] \((Cos[θ], 
            Sin[θ])\) = 
        m\ l[θ'' \((Cos[θ], 
                  Sin[θ])\) + \(\((θ')\)\^2\) \((\(-Sin[θ]\), Cos[θ])\)]\).

By taking the x-component, as depicted below, we get the following differential equation.

Clear[t, θ];
θ = (π/6);
rr = {Sin[θ], -Cos[θ]};
grav = 0.5;
gravity = grav {0, -1};
arrowsize = 1.7;
ρ = 0.1;
lineplot = 
        Graphics[{Black, Thickness[0], 
            Line[{{0, 0}, rr}]}];
pointplot = 
        Graphics[{Black, PointSize[ρ], 
            Point[rr]}];

    
arcplots = 
        ParametricPlot[{{Sin[t], -Cos[t]}, rr - 0.055 {Cos[t], Sin[t]}, 
            rr - 0.05 {Cos[t], Sin[t]}
}, {t, 0, (π/6)}, 
          PlotStyle -> {Blue}, 
          DisplayFunction -> Identity];
tangentialforce = 
        Graphics[{Red, Thickness[0], 
            Arrow[rr, 
              rr + arrowsize*grav*
                  Sin[θ] {-Cos[θ], -Sin[θ]}]}];
horizontalforce = 
        Graphics[{DarkGreen, Thickness[0], 
            Arrow[rr, 
              rr + arrowsize*grav*Sin[θ] 
                  Cos[θ] {-1, 0}]}];
verticalforce = 
        Graphics[{GrayLevel[0.5], Thickness[0], 
            Arrow[rr, 
              rr + arrowsize*grav*Sin[θ] Sin[θ] {0, -1}, 
              HeadRatio -> 0.2]}];
tangentialforce = 
        Graphics[{Red, Thickness[0], 
            Arrow[rr, 
              rr + arrowsize*grav*
                  Sin[θ] {-Cos[θ], -Sin[θ]}]}];
Show[tangentialforce, verticalforce, horizontalforce, arcplots, 
        lineplot, pointplot, 
        PlotRange -> {{0.05, 
              Sin[θ] + ρ}, {-1.1, -0.4}}, 
        DisplayFunction -> $DisplayFunction];

-m g Sin[θ] Cos[θ] = 
      m l(θ'' Cos[θ] - (((θ'))^2) 
              Sin[θ])

Thus,

Cos[θ] θ'' - 
          Sin[θ] (((θ'))^2) + (g/l) Sin[2  θ] 
            Cos[θ] = 0.

The program in the previous cell is based on the numerical solution of the above equation with respect to an natural initial condition,

θ[0] = (Subscript[θ, 0])  and  θ'[0] = 0.

That is, the pendulum motion begins by releasing the pendulum at the angle (Subscript[θ, 0]).

2.  Derivatives of Elementary functions

(2.1)  Derivatives of power functions and polynomials.

Before listing any differentiation formulae, let us make the following observation.

Proposition 2.1.1.

Let f and g be functions and let f' and g' be their derivatives.  Let a be an arbitrary real number.  Then we have the following derivative rules.

(d/d)x[
          f(x) + g(x)] = f' (x) + g' (x).

(d/d)x[
          a f(x)] = a f' (x).

(d/d)x[constant] = 
        0.

Proof.

As h -> 0, we have,

\(TraditionalForm\`\(\([f(x\  + \ h)\  + \ g(x\  + \ h)]\)\  - \ \([f(x)\  + \ g(x)]\)\)\/h = \(f(x\  + \ h)\  - \ f(x)\)\/h + \(g(x\  + \ h)\  - \ g(x)\)\/h\)
\(TraditionalForm\`\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(\(\(->\)\(f' \((x)\) + g' \((x)\)\)\)\(,\)\)\)

\(TraditionalForm\`\(\([a\ \(f(x\  + \ h)\)]\)\  - \ \([a\ \(f(x)\)]\)\)\/h = 
        a \([f(x\  + \ h)\  - \ f(x)]\)\/h -> a\ f' \((x)\)\),

and

\(TraditionalForm\`\(\([f(x\  + \ h)]\)\  - \ \([f(x)]\)\)\/h = \(\([constant\  - \ constant]\)\/h = 0\)\).

The following theorem, when coupled with Proposition 2.1.1, allows us to calculate the derivatives of all polynomial functions.

Theorem 2.1.2.  The Power Rule.

The derivative a power function f(x) = (x^k) can be computed through the following formula, known as the Power Rule.

(d/d)x (x^k) = 
        k (x^( k - 1)).

Proof.

The proof of Theorem 2.1.1 for arbitrary k value requires a special technique called log-differentiation.  Here, let us prove Theorem 2.1.1 only when k is a positive integer.  From the binomial theorem,

(((x + h))^k)=(({{k}, {k}}))(x^k)(h^0)+(({{k}, {k - 1}})) (x^(k - 1))(h^1)+⋯+(({{k}, {1}}))(x^1)(h^(k - 1))+(({{k}, {0}}))(x^0)(h^k)
               =(x^k) + 
            k (x^(k - 1)) h + o ((h^2)).

Here, o((h^2)) indicates the terms with order (h^2) or higher.  Therefore,

\(TraditionalForm\`\(\((x\  + \ h)\)\^k\  - \ x\^k\)\/h = \(\(k\ h\ x\^\(k - 1\)\  - \ o(h\^2)\)\/h = 
          k\ x\^\(k - 1\) - o(h) -> k\ x\^\(k - 1\)\)\),

as h -> 0.  The proof of Theorem 2.1.2 for arbitrary k requires a technique called logarithmic-differentiation.  It will be covered in Section 4.

Example 2.1.3.

Find the derivatives of the following functions.

(d/d)x[
          (x^3) - 2  (x^2)] = ?

(d/d)x[
          (x^3) - 2  (x^2)] = 3  (x^2) - 2  • 2  (x^1) = 
          3  (x^2) - 4  x.

(d/d)x[
          3  (x^2) - 2  x + 4] = ?

(d/d)x[
          3  (x^2) - 2  x + 4] = 3  • 2  (x^1) - 
            2  • 1  (x^0) + 4  • 0  (x^(-1)) = 
          6  x - 2.

(d/d)x[
          x - (Sqrt[x]) + (2/x)] = ?

(d/d)x[
          x - (Sqrt[x]) + (2/x)] = (d/d)x[
          (x^1) - (x^(1/2)) + 2  (x^(-1))]
\(TraditionalForm\`\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(\(=\)\(x - \(1\/2\) x\^\(\(-1\)/2\) - 2  x\^\(-2\)\)\)\)

The third example is particularly interesting.  Converting to the power form is the starting point of a lot of problems in calculus.

(2.2)  Derivatives of exponential and logarithmic functions.

Theorem 2.2.1.

The derivative the exponential function can be computed through the following formula.

\(TraditionalForm\`\(d\/dx\) e\^\(\(\ \)\(x\)\) = e\^\(\(\ \)\(x\)\)\).

Theorem 2.2.2.

Here is the derivative formula for the log function.

(d/d)x Log[x] = 
        (1/x).

The proof of Theorem 2.2.1 and Theorem 2.2.2 will not be attempted here.  We did not even define (e^( x)) and Log[x], yet.

(2.3)  Derivatives of trigonometric functions.

There are three formulae to remember.

Theorem 2.3.1.

(d/d)x Sin[x] = 
        Cos[x],  (d/d)x 
          Cos[x] = -Sin[x],  (d/d)x 
          Tan[x] = (Sec^2)[x].

Derivatives of the other trig functions can be calculated from the above formulae and the differentiation rules that will be presented in the next section.

Proof.

Recall the limits of trigonometric limits,

(lim_(h -> 0))Sin[h]/h = 1,

(lim_(h -> 0))((1  -  Cos[h])/h) = 0.

\(TraditionalForm\`lim\_\(h -> 0\)\(1\  - \ Cos[h]\)\/h = 
        lim\_\(h -> 0\)\(1\  - \ \(Cos\^2\)[h]\)\/\(h(1\  + \ Cos[h])\)\)
\(TraditionalForm\`\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(\(=\)\(lim\_\(h -> 0\)\(Sin\^2\)[h]\/\(h(1\  + \ Cos[h])\)\)\)\)
\(TraditionalForm\`\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(\(=\)\(lim\_\(h -> 0\)\(Sin[
                  h]\/h\) \(lim\_\(h -> 0\)Sin[h]\/\((1\  + \ Cos[h])\)\)\)\)\)
\(TraditionalForm\`\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(\(=\)\(1*0\/\(1\  + \ 1\) = 0. \)\)\)

The Newton quotient of Sin[x] becomes,

\(TraditionalForm\`\(Sin[x\  + \ h]\  - \ Sin[x]\)\/h = \(\((Sin[x] Cos[h]\  + \ Cos[x] Sin[h])\)\  - \ Sin[x]\)\/h\)
\(TraditionalForm\`\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(\(=\)\(\(Sin[x] \((Cos[h]\  - \ 1)\)\)\/h + \(Cos[x] Sin[h]\)\/h\)\)\)
\(TraditionalForm\`\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(\(->\)\(Sin[x]*0 + Cos[x]*1\)\)\)
\(TraditionalForm\`\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(\(=\)\(\(Cos[x]\)\(.\)\)\)\)

Similarly, the Newton quotient of Cos[x] can be transformed as the following.

\(TraditionalForm\`\(Cos[x\  + \ h]\  - \ Cos[x]\)\/h = \(\((Cos[x] Cos[h]\  - \ Sin[x] Sin[h])\)\  - \ Cos[x]\)\/h\)
\(TraditionalForm\`\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(\(=\)\(\(Cos[x] \((Cos[h]\  - \ 1)\)\)\/h - \(Sin[x] Sin[h]\)\/h\)\)\)
\(TraditionalForm\`\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(\(->\)\(Cos[x]*0 - Sin[x]*1\)\)\)
\(TraditionalForm\`\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(\(=\)\(-\(\(Sin[x]\)\(.\)\)\)\)\)

The derivative of Tan[x] can be calculated the through the quotient rule (Section 2).

\(TraditionalForm\`\(d\/dx\) 
          Tan[x] = \(d\/dx\) \((Sin[x]\/Cos[x])\)\)
\(TraditionalForm\`\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(\(=\)\(\(Cos[x] Cos[x]\  - \ \((Sin[x])\) \((\(-Sin[x]\))\)\)\/\(Cos\^2\)[
              x]\)\)\)
\(TraditionalForm\`\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(\(=\)\(\(\(Cos\^2\)[x]\  + \ \(Sin\^2\)[x]\)\/\(Cos\^2\)[x] = 
          1\/\(Cos\^2\)[x]\)\)\)
\(TraditionalForm\`\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(\(=\)\(\(\(Sec\^2\)[x]\)\(.\)\)\)\)

The derivatives of other trig functions can be derived from those of Sin[x] and Cos[x], too.

(2.4)  Derivatives of hyperbolic functions.

2.4.1.  Hyperbolic functions.

Here are the definitions of hyperbolic functions.

Sinh[
          x] = (((e^x)  -  (e^(-x)))/2)			Csch[x] = (1/Sinh)[x]
	Cosh[
          x] = (((e^x)  +  (e^(-x)))/2)			Sech[x] = (1/Cosh)[x]
	\(TraditionalForm\`Tanh[
          x] = \(Sinh[x]\/Cosh[x] = \(e\^x\  - \ e\^\(-x\)\)\/\(e\^x\  + \ e\^\(-x\)\)\)\)		Coth[x] = (1/Tanh)[x]

Here are some hyperbolic identities.

Sinh[-x] = -Sinh[x]		        Cosh[-x] = 
        Cosh[x]

(Cosh^2)[x] - (Sinh^2)[x] = 1	    1 - (Tanh^2)[x] = (Sech^2)[
          x]

Sinh[x + y] = Sinh[x] Cosh[x] + Cosh[x] Sinh[x]
	Cosh[x + y] = Cosh[x] Cosh[x] + Sinh[x] Sinh[x]

The similarity between trigonometric identities and hyperbolic identities are due to their similarities of definitions.  In complex number system, ℂ, trigonometric functions are defined by

\(TraditionalForm\`Sin[
          x] = \(1\/\(2  i\)\) \((e\^\(i\ x\) - e\^\(\(-i\)\ x\))\)\)  and  \(TraditionalForm\`Cos[
          x] = \(1\/2\) \((e\^\(i\ x\) + e\^\(\(-i\)\ x\))\)\).

The above identities will be discussed briefly again in Calculus II.

2.4.2.  Graphs of hyperbolic functions.

Clear[x];

Plot[Sinh[x], {x, -2, 2}, PlotStyle -> Blue];

Plot[Cosh[x], {x, -2, 2}, PlotStyle -> Blue];

Plot[Tanh[x], {x, -2, 2}, PlotStyle -> Blue];

2.4.3.  Derivatives hyperbolic functions.

Here is the list of derivatives of hyperbolic functions.

(d/d)x Sinh[x] = 
        Cosh[x]	
	(d/d)x Cosh[x] = 
        Sinh[x]	
	(d/d)x 
          Tanh[x] = (Sech^2)[x]

Derivatives of the other hyperbolic functions can be driven from the above formulae, or directly from the exponential functions.

3.  Differentiation

(3.0)  Derivatives of elementary functions.

Here is the list of the differentiation rules that we covered in the previous section.

(d/d)x[
          f(x) + g(x)] = f' (x) + g' (x).
	(d/d)x[
          a f(x)] = a f' (x).
	(d/d)x[constant] = 
        0.

(d/d)x (x^k) = 
        k (x^( k - 1)).
	\(TraditionalForm\`\(d\/dx\) e\^\(\(\ \)\(x\)\) = e\^\(\(\ \)\(x\)\)\).
	(d/d)x Log[x] = 
        (1/x).

(d/d)x Sin[x] = 
        Cos[x].
	(d/d)x 
          Cos[x] = -Sin[x].
	(d/d)x 
          Tan[x] = (Sec^2)[x].

Here is the list of the differentiation formulae that will be discussed in this section.

(d/d)x 
          g∘f(x) = (d/d)x 
            g[f(x)] = g'[f(x)] f' (x).
 
	(d/d)x[f(x) g(
              x)] = f' (x) g(x) + f(x) g' (x).
  
	\(TraditionalForm\`\(d\/dx\)[\(f(x)\)\/\(g(x)\)] = \(f' \((x)\) \(g(x)\)\  - \ \(f(x)\) g' \((x)\)\)\/\(g(x)\)\^2\).

(3.1)  Derivatives of composite functions.

In computational point of view, The following theorem (including its applications) is by far the most important topic in calculus I.  It is also, the most difficult.

Theorem 3.1.1.  The Chain Rule.

The derivatives of composite functions can be calculated through the following formula, known as the Chain Rule.

(d/d)x 
          g∘f(x) = (d/d)x 
            g[f(x)] = g'[f(x)] f' (x).

The sketch of a slightly broken proof.

Let y = f(x) and z = g(y) = g[f(x)].  Then,

\(TraditionalForm\`\(Δ\ z\)\/\(Δ\ x\) = \(\(Δ\ z\)\/\(Δ\ y\)\) \(Δ\ y\)\/\(Δ\ x\)\).

That is,  \(TraditionalForm\`\(z\_1\  - \ z\_0\)\/\(x\_1\  - \ x\_0\) = \(\(z\_1\  - \ z\_0\)\/\(y\_1\  - \ 
                y\_0\)\) \(y\_1\  - \ y\_0\)\/\(x\_1\  - \ x\_0\)\).

When Δ x -> 0, that is, (Subscript[x, 1]) -> (Subscript[x, 0]), we must have Δ y -> 0 (in other words, (Subscript[y, 1]) -> (Subscript[y, 0])), too, and

\(TraditionalForm\`dy\/dx = 
        lim\_\(Δ\ x -> 0\)\(Δ\ y\)\/\(Δ\ x\)\),  and,  \(TraditionalForm\`dz\/dy = 
        lim\_\(Δ\ y -> 0\)\(Δ\ z\)\/\(Δ\ y\)\).

That is,  f' ((Subscript[x, 0])) = 
        (lim_((Subscript[x, 1]) -> (Subscript[x, 0])))(((Subscript[y, 1])  -  (Subscript[y, 0]))/((Subscript[x, 1])  -  (Subscript[x, 0]))),  and, \(TraditionalForm\`\(\(\ \)\(g' \((y\_0)\) = 
        lim\_\(y\_1 -> y\_0\)\(z\_1\  - \ z\_0\)\/\(y\_1\  - \ y\_0\)\)\)\).

Hence,

\(TraditionalForm\`\(Δ\ z\)\/\(Δ\ x\) = \(\(\(Δ\ z\)\/\(Δ\ y\)\) \(\(Δ\ y\)\/\(Δ\ x\)\)\ ⟹\ \(dz\/dx\) = \(dz\/dy\) dy\/dx\)\).

That is,

\(TraditionalForm\`\(z\_1\  - \ z\_0\)\/\(x\_1\  - \ x\_0\) = \(\(\(z\_1\  - \ z\_0\)\/\(y\_1\  - \ 
                  y\_0\)\) \(\(y\_1\  - \ y\_0\)\/\(x\_1\  - \ 
                    x\_0\)\)\ ⟹\ \((g∘
                    f)\)' \((x\_0)\) = \(g'\)[f(x\_0)] f' \((x\_0)\)\)\).

This holds for every (Subscript[x, 0]), so the conclusion of Theorem 3.1.1 follows.

Can you find the mistake in the above proof?  How did  we prove the chain rule in class?

Example 3.1.2.

Find the derivatives of the following functions.

\(TraditionalForm\`\(d\/dx\) \@\(x\^3 - 2  x\^2\) = ?\)

\(TraditionalForm\`\(d\/dx\) \@\(x\^3 - 2  x\^2\) = \(\(d\/dx\) \((x\^3 - 2  x\^2)\)\^\(1/2\) = \(1\/2\) \(\((x\^3 - 2  x\^2)\)\^\(\(-1\)/2\)\) \((3 
                   x\^2 - 4  x)\)\)\).

Clear[f, x];
f[x_] = (Sqrt[(x^3) - 2  (x^2)]);
f'[x]

\(TraditionalForm\`\(d\/dx\) e\^\(4 - x\^2\) = ?\)

\(TraditionalForm\`\(d\/dx\) e\^\(4 - x\^2\) = \(\(e\^\(4 - x\^2\)\)(
            0 - 2  x) = \(-2\) x\ e\^\(4 - x\^2\)\)\).

Clear[f, x];
f[x_] = (E^(4 - (x^2)));
f'[x]

(d/d)x 
          Log[(x^2) + (e^(4 - (x^2)))] = ?

We must apply the chain rule twice in thie problem.

\(TraditionalForm\`\(d\/dx\) 
          Log[x\^2 + e\^\(4 - x\^2\)] = \(\(1\/\(x\^2\  + \ e\^\(4 - x\^2\)\)\) \((2  
                  x + \(d\/dx\) e\^\(4 - x\^2\))\) = \(2  x\  - \ 2  x\ e\^\(4 - x\^2\)\)\/\(x\^2\  + \ e\^\(4 - x\^2\)\)\)\).

Clear[f, x];
f[x_] = Log[(x^2) + (E^(4 - (x^2)))];
f'[x]

(d/d)x 
          Sin[(x^2) + Cos(x)] = ?

(d/d)x 
          Sin[(x^2) + Cos(x)] = Cos[(x^2) + Cos(x)] (2  x - Sin[x]).

Clear[x, f];
f[x_] = Sin[(x^2) + Cos[x]];
f'[x]

(d/d)x 
          Sin[(x^2) + Log[Cos(x)]] = ?

Again, we must apply the chain rule twice.

(d/d)x 
        Sin[(x^2) + Log[Cos(x)]]
    =Cos[(x^2) + Log[Cos(x)]] [
          2  x + (1/Cos)[x] (d/d)x 
              Cos[x]]
    =Cos[(x^2) + Log[Cos(x)]] [
          2  x + (1/Cos)[x] (-Sin[x])]
    =Cos[
            (x^2) + Log[Cos(x)]] (2  x - Tan[x]).

(3.2)  Derivatives of products and quotients.

The chain rule (Theorem 3.1.1) may be the most important (and the most difficult) in computational purpose, but it is the next theorem that is the trickiest.  In complicated problems, one tends to overlook Theorem 3.2.1 and make the mistake mentioned in Remark 3.2.2.

Theorem 3.2.1.  The Product Rule.

The derivatives of the product of two functions can be calculated through the following formula, known as the Product Rule, or as Leibniz Rule.

(d/d)x[f(x) g(
              x)] = f' (x) g(x) + f(x) g' (x).

Depending on textbooks, the product rule is introduced in alternative (yet equivalent) forms.

(d/d)x[f(x) g(
              x)] = f(x) g' (x) + f' (x) g(x).

(d/d)x[f(x) g(
              x)] = f(x) g' (x) + g(x) f' (x).

Proof.

\(TraditionalForm\`\(\([\(f(x\  + \ h)\)\ \(g(x\  + \ h)\)]\)\  - \ \([\(f(x)\)\ \(g(x)\)]\)\)\/h\)

=(([f(x  +  h) g(
                    x  +  h)]  -  [f(x) g(
                    x  +  h)]  +  [f(x) g(
                    x  +  h)]  -  [f(x) g(
                    x)])/h)

\(TraditionalForm\`\(\(=\)\(\(\([\(f(x\  + \ h)\)\ \(g(x\  + \ h)\)]\)\(\ \)\(-\)\(\ \)\([\(f(x)\)\ \(g(x\  + \ h)\)]\)\(\ \)\)\/h + \(\([\(f(x)\)\ \(g(x\  + \ h)\)]\)\  - \ \([\(f(x)\)\ \(g(x)\)]\)\)\/h\)\)\)

\(TraditionalForm\`\(\(=\)\(\((\(\(f(x\  + \ h)\)\(\ \)\(-\)\(\ \)\(f(x\  + \ h)\)\(\ \)\)\/h)\) \(g(x + h)\) + \(f(
              x)\) \((\(g(x\  + \ h)\  - \ g(x)\)\/h)\)\)\)\)

->f' (x) g(x) + f(x) g' (x),  as   h->0.

Remark 3.2.2.

We cannot emphasize this too much.

(d/d)x[f(x) g(
                x)]≠f' (x) g' (x).

There are numerous counter-examples.  Let us consider f(x) = x, g(x) = 1/x, so that f(x) g(x) = 1.  In this case,

(d/d)x[f(x) g(
              x)] = (d/d)x 1 = 0.

However,

f' (x) 
          g' (x) = x' ((x^(-1)))' = 1 (-1) 
              (x^(-2)) = -(1/(x^2)).

Apparently, they are not equal.

Theorem 3.2.3.  The Quotient Rule.

The derivatives of the quotient of two functions can be calculated through the following formula, known as the Quotient Rule, as long as g(x) ≠ 0.

\(TraditionalForm\`\(d\/dx\)[\(f(x)\)\/\(g(x)\)] = \(f' \((x)\) \(g(x)\)\  - \ \(f(x)\) g' \((x)\)\)\/\(g(x)\)\^2\).

Depending on textbooks, the quotient rule is presented in an alternative (yet equivalent) form.

\(TraditionalForm\`\(d\/dx\)[\(f(x)\)\/\(g(x)\)] = \(\(g(x)\) f' \((x)\)\  - \ \(f(x)\) g' \((x)\)\)\/\(g(x)\)\^2\).

Proof.

We can prove the quotient rule directly from the Newton quotient of f(x)/g(x), as we did in the proof of the product rule.  However, the following method is easier.

\(TraditionalForm\`\(d\/dx\)[\(f(x)\)\/\(g(x)\)] = \(d\/dx\)[\(f(x)\)\ [g(x)]\^\(-1\)]\)
\(TraditionalForm\`\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(\(=\)\(f' \((x)\) \(g(x)\)\^\(-1\) + \(f(
              x)\) \(d\/dx\)[\(g(x)\)\^\(-1\)]\)\)\)
\(TraditionalForm\`\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(\(=\)\(\(f' \((x)\)\)\/\(g(x)\) + \(f(x)\)[\((\(-1\))\) \(\(g(x)\)\^\(-2\)\) 
              g' \((x)\)]\)\)\)
\(TraditionalForm\`\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(\(=\)\(\(f' \((x)\) \(g(x)\)\)\/\(g(x)\)\^2 - \(\(f(x)\) g' \((x)\)\)\/\(g(x)\)\^2\)\)\)
\(TraditionalForm\`\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(\(=\)\(\(\(f' \((x)\) \(g(x)\)\  - \ \(f(x)\) g' \((x)\)\)\/\(g(x)\)\^2\)\(.\)\)\)\)

We used the product rule in the second line and the chain rule in the third line.  Finally, when we took the common denominator and the conclusion of the quotient rule followed.

Example 3.2.3.

Calculate the following derivatives.

(d/d)x[
          (x^2) (e^x)] = ?

(d/d)x[
          (x^2) (e^x)] = 
        2  x (e^x) + (x^2) (e^x).

D[(x^2) (E^x), x]

(d/d)x[
          x (e^(1 - (x^2)))] = ?

\(TraditionalForm\`\(d\/dx\)[
          x\ e\^\(1 - x\^2\)] = 
        1  e\^\(1 - x\^2\) + 
          x\ \(d\/dx\)[e\^\(1 - x\^2\)]\)
\(TraditionalForm\`\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(\(=\)\(e\^\(1 - x\^2\) + 
          x\ \(\(e\^\(1 - x\^2\)\)(\(-2\) x)\)\)\)\)
\(TraditionalForm\`\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(\(=\)\(\((1 - 2  x\^2)\) \(\(e\^\(1 - x\^2\)\)\(.\)\)\)\)\)

D[x (E^(1 - (x^2))), x]

(d/d)x[
          Log[x]/((x^2)  +  1)] = ?

\(TraditionalForm\`\(d\/dx\)[
          Log[x]\/\(x\^2\  + \ 1\)] = \(\((1/x)\) \((x\^2 + 1)\)\  - \ Log[x] \((2  x)\)\)\/\((x\^2\  + \ 1)\)\^2\)
\(TraditionalForm\`\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(\(=\)\(\(\(\((x\^2 + 1)\)\  - 
                2  x\^2\ Log[x]\)\/\(x(x\^2\  + \ 1)\)\^2\)\(.\)\)\)\)

D[Log[x]/((x^2) + 1), x]

(d/d)x 
          Sin[x]/Log[x] = ?

\(TraditionalForm\`\(d\/dx\) 
          Sin[x]\/Log[x] = \(Cos[x] Log[x]\  - \ Sin[x] \((1/x)\)\)\/Log[x]\^2\).

Clear[f, x];
f[x_] = Sin[x]/Log[x];
f'[x]

(d/d)x 
          Sin[(x^2)] (e^x) = ?

(d/d)x 
          Sin[(x^2)] (e^x) = 
        Cos[(x^2)] (2  x) (e^x) + 
          Sin[(x^2)] (e^x).

Clear[f, x];
f[x_] = Sin[(x^2)] (E^x);
f'[x]

(3.3)  Higher derivatives.

We can differentiate twice to get the derivative of the derivative function f' (x).  We call it the second derivative, and denote it f'' (x).  Similarly, we can differentiate multiple times to get the n-th derivative, (f^((n)))(x).

Example 3.3.1.

Calculate the first and the second derivatives of the following functions.

f(x) = (e^(1 - (x^2))),   g(x) = Cos[Log[x]],   h(x) = Log[Log[x]].

Solution1.

f' (x) = (e^(1 - 
                  (x^2)))(-2 x) = -2 
            x (e^(1 - (x^2))),

\(TraditionalForm\`f'' \((x)\) = \(\(-2\)\ e\^\(1 - x\^2\) + \((\(-2\) x)\) \((\(-2\) x\ e\^\(1 - x\^2\))\) = \((4 
                   x\^2 - 2)\) e\^\(1 - x\^2\)\)\).

g' (x) = -Sin[Log[x]] 
            (1/x) = -Sin[Log[x]]/x,

g'' (x) = (-Sin[Log[x]] 
              (x^(-1)))'

                  =(-Cos[Log[x]] (1/x)) 
            (1/x) + (-Sin[
                  Log[x]]) (-(x^(-2)))

                  =((Sin[Log[x]]  -  
                Cos[Log[x]])/(x^2)).

h' (x) = (1/Log)[x] (1/x) = 
          (1/(x Log[x])),

\(TraditionalForm\`\(\(\ \)\(h'' \((x)\) = \([\((x\ Log[x])\)\^\(-1\)]\)'

      \ \ \ \ \ \ \ \ \ \ \ \ \(\(=\)\(\(-\((x\ Log[x])\)\^\(-2\)\) \((Log[
                x] + x  1\/x)\)\)\)

      \ \ \ \ \ \ \ \ \ \ \ \ \(\(=\)\(-\(\(\(Log[x]\  + \ 1\)\/\(\(x\^2\) 
                  Log[x]\^2\)\)\(.\)\)\)\)\)\)\)

Solution2.

Clear[f, x];
f[x_] = (E^(1 - (x^2)));
Print["f[x] = ", f[x]];
Print["f'[x] = ", f'[x]];
Print["f''[x] = ", f''[x]];

Clear[g, x];
g[x_] = Cos[Log[x]];
Print["g[x] = ", g[x]];
Print["g'[x] = ", g'[x]];
Print["g''[x] = ", g''[x]];

Clear[h, x];
h[x_] = Log[Log[x]];
Print["h[x] = ", h[x]];
Print["h'[x] = ", h'[x]];
Print["h''[x] = ", h''[x]];

All three functions in Example 3.3.1 needed only the chain rule when calculating the first derivatives.  For the second derivatives, however, we needed a whole lot more.  Most conspicuously, the product rule must be used in addition.  This is common when calculating higher derivatives.

Summary.

Here is the list of the differentiation rules that we covered in this section.

(d/d)x[
          f(x) + g(x)] = f' (x) + g' (x).
	(d/d)x[
          a f(x)] = a f' (x).
	(d/d)x[constant] = 
        0.

(d/d)x (x^k) = 
        k (x^( k - 1)).
	\(TraditionalForm\`\(d\/dx\) e\^\(\(\ \)\(x\)\) = e\^\(\(\ \)\(x\)\)\).
	(d/d)x Log[x] = 
        (1/x).

(d/d)x Sin[x] = 
        Cos[x].
	(d/d)x 
          Cos[x] = -Sin[x].
	(d/d)x 
          Tan[x] = (Sec^2)[x].

(d/d)x 
          g∘f(x) = (d/d)x 
            g[f(x)] = g'[f(x)] f' (x).
 
	(d/d)x[f(x) g(
              x)] = f' (x) g(x) + f(x) g' (x).
  
	\(TraditionalForm\`\(d\/dx\)[\(f(x)\)\/\(g(x)\)] = \(f' \((x)\) \(g(x)\)\  - \ \(f(x)\) g' \((x)\)\)\/\(g(x)\)\^2\).

4.  Implicit Differentiation

(4.1)  Implicit differentiation.

4.1.1.  Implicit equations

An equation connecting variables x and y is said to define y implicitly as a function of x (sometimes, as several functions of x).  For example, the equation

(eq:4.1.1-1)	(x^2) y + y - x = 1

can be solves with respect to y in the following fashion.

(x^2) y + y = x + 1

    y((x^2) + 1) = x + 1

(eq:4.1.1-2)	y  =  ((x  +  1)/((x^2)  +  1)).

Consequently, the variable y in (eq:4.1.1) is expressed as a function of x in (eq;4.1.1-2).  This is not always the case.  For instance,

(eq:4.1.1-3)	(x^2) + (y^2) = 1

can be manipulated as

(y^2) = 1 - (x^2)

and thus,

(eq:4.1.1-4)	y  = ±(Sqrt[1 - (x^2)]).

Hence, y in (eq:4.1.1-3) is expressed by not one, but two functions of x in (eq:4.1.1-4).

4.1.2.  Finding derivatives of implicitly defined functions.

Sometimes, y can not be solved as easily as in the two examples in 4.1.1   For instance the equation

(x^3) - 3  y + (y^3) = 1

cannot be manipulated so easily.  Those who wish to represent y as a function (or as several functions) of x may use the following Mathematica code.

Solve[(x^3) - 3  y + 3  (y^3) == 1, y]

Clearly, this computation is not appetizing.  Although it is difficult to express the y with respect to x, it is possible to calculate the derivative y' (x), or alternatively, dy/dx.  The key is to apply the chain rule.

Let us start from the given equation,

(x^3) - 3  y + (y^3) = 1.

Now, lets us take the derivative with respect to the variable x.

(d/d)x ((x^3) - 
              3  y + (y^3)) = (d/d)x 1.

The right hand side is simple.  It is the derivative of the constant 1, so it is 0.  The left hand side can be split up like

(d/d)x (x^3) - 
          3 (d/d)x 
            y + (d/d)x (y^3) = 0.

The first term is easy.  The function is (x^3) and we differentiate it with respect to x, so we apply the power rule to get 3  (x^2).  The second term is also straightforward.  We are differentiating y with respect to x and get the quantity dy/dx, which is the quantity we are looking for as the final answer.  The third term is more complicated.  So far we got,

\(TraditionalForm\`3  x\^2 - 
          3 dy\/dx + \(d\/dx\) y\^3 = 0\).

Now, let us apply the chain rule to the third term.

\(TraditionalForm\`3  x\^2 - 
          3 dy\/dx + \(dy\/dx\) \(d\/dy\) y\^3 = 0\).

Hence, the third term became the derivative of (y^3) with respect to the variable y, multiplied with the quantity dy/dx.  Hence,

\(TraditionalForm\`3  x\^2 - 
          3 dy\/dx + \(dy\/dx\) 3  y\^2 = 0\).

All we have to do now is to solve the above equation with respect to dy/dx.  This is a linear equation, so it is easy to solve.

3 
           (x^2) + (3  (y^2) - 3) d(y/d)x = 
      0
(3  (y^2) - 
            3) d(y/d)x = -3 
        (x^2)
\(TraditionalForm\`dy\/dx = \(\(\(-3\) x\^2\)\/\(3  y\^\(\(2\)\(\ \)\) - \ 3\) = x\^2\/\(1\  - \ y\^2\)\)\)

Hence,

\(TraditionalForm\`dy\/dx = \(\(\(-3\) x\^2\)\/\(3  y\^\(\(2\)\(\ \)\) - \ 3\) = x\^2\/\(1\  - \ y\^2\)\)\).

This method to find dy/dx is called the implicit differentiation.

4.1.3.  implicit differentiation and geometry.

An equation of x and y often define a curve.  For example, the equation

(x^3) - 3  y + (y^3) = 1,

Solve[{(x^3) - 3  y + (y^3) == 1, x == 1}, y]

which we studied in 4.1.2 defines the following curve.

Clear[x, y];
ImplicitPlot[(x^3) - 3  y + (y^3) == 1, {x, -2, 2}, 
        PlotStyle -> {Blue}];

Hence, the derivative dy/dx we calculated in 4.1.2 represents the slope of the curve at an arbitrarily given point (x, y).  For example, if the point (x, y) is given as (x, y) = (1, (Sqrt[3])), then

\(TraditionalForm\`dy\/dx = \(x\^2\/\(1\  - \ y\^2\) = \(1\/\(1\  - \ 3\) = \(-\(1\/2\)\)\)\)\).

Therefore, the slope of the curve at (1, (Sqrt[3])) is 1, and the equation of the tangent line is

y = -(1/2) (x - 1) + (Sqrt[3]).

The following picture illustrates the curve given by (x^3) - 3  y + (y^3) = 1 and its tangent line at (1, (Sqrt[3])).

Clear[x, y];
curveplot = 
        ImplicitPlot[(x^3) - 3  y + (y^3) == 1, {x, -2, 2}, 
          PlotStyle -> {Blue}, 
          DisplayFunction -> Identity];
tangentplot = 
        Plot[-(1/2) (x - 1) + (Sqrt[3]), {x, -1, 2.5}, 
          PlotStyle -> {Red}, 
          DisplayFunction -> Identity];
Show[curveplot, tangentplot, 
        DisplayFunction -> $DisplayFunction];

The following program visualizes the curve and its tangent lines at various points.

Clear[x, y, s, t, i];
AniNo = 30;
yi = -2.3;
yf = 2.3;
width = 1;
curveplot = 
        ImplicitPlot[(x^3) - 3  y + (y^3) == 1, {x, -2, 2}, 
          PlotStyle -> {Blue}, PlotRange -> All, 
          DisplayFunction -> Identity];
y[i_] := i;
x[
          i_] := ((1 + 3 y[i] - y[i]^3)/Abs)[
                1 + 3 y[i] - 
                  y[i]^3] (((Abs[1 + 3 y[i] - y[i]^3]))^(1/3));
ani[i_] := 
        Module[{t, unitvector, pointplot, 
            tangentplot}, 
pointplot = 
            Graphics[{Red, PointSize[0.02], 
                Point[{x[i], 
                    y[i]}]}]; 

tangentplot = 
            ParametricPlot[{x[i], 
                  y[i]} + {(1 - y[i]^2), 
                        x[i]^2}/(Sqrt[(((1 - y[i]^2))^2) + (((x[i]^2))^2)]) t, {t, -width, width}, PlotStyle -> {Red}, 
              DisplayFunction -> Identity]; 
Show[
            curveplot, pointplot, tangentplot, 
            PlotRange -> {{-2.1, 2.1}, {-2.5, 2.5}}, 
            DisplayFunction -> $DisplayFunction];
];
Table[ani[i], {i, yi, yf, ((yf - yi)/AniNo)}];

Example 4.1.4.

Calculate the derivative dy/dx with respect to the following equation.

(x^3) + (y^3) = 6  x y

The above equation defines the following curve.

Clear[x, y];
ImplicitPlot[(x^3) + (y^3) == 6  x y, {x, -4.5, 3.2}, 
        PlotStyle -> {Blue}];

Solution.

Let us differentiate the given equation implicitly.

(d/d)x ((x^3) + 
            (y^3)) = (d/d)x (6  
            x y)

The left hand side is rather straightforward, but pay attention to the right hand side, where the product rule is applied.

\(TraditionalForm\`3  x\^2 + 
        3 \( y\^2\) dy\/dx = \(\(d\((6  x)\)\/dx\) y + 
          6  x dy\/dx = 
        6  y + 6  x dy\/dx\)\)

Thus,

(3  (y^2) - 
              6  x) d(y/d)x = 
        6  y - 3  (x^2),

\(TraditionalForm\`dy\/dx = \(\(6  y\  - \ 3  x\^2\)\/\(3  y\^2\  - \ 6  x\) = \(2  y\  - \ x\^2\)\/\(y\^2\  - \ 2  x\)\)\).

Example 4.1.5.

Calculate the derivative dy/dx with respect to the following equation at the specified point.

((((x^2) - x y + (y^2)))^2) = x y,  at  (1, 1).

Here is the plot associated with this problem.

Clear[x, y];
ImplicitPlot[((((x^2) - x y + (y^2)))^2) == x y, {x, -1.5, 
          1.5}, PlotStyle -> Blue];

Solution.

Again, we start from the implicit differentiation.  The right hand side requires the product rule as in the previous problem.  The left hand side requires the chain rule.

2 ((x^2) - x y + 
            (y^2)) (d/d)x ((x^2) - x y + 
            (y^2)) = y + x d(y/d)x

2 ((x^2) - x y + (y^2))[
          2  x - (y + x d(y/d)x) + 
            2  y d(y/d)x] = 
      y + x d(y/d)x

It is difficult to solve this equation with respect to dy/dx, and then plug in (x, y) = (1, 1).  It is better to plug it in now.

2 (1 - 1 + 1)[
          2 - (1 + 1 d(y/d)x) + 
            2 d(y/d)x] = 
      1 + 1 d(y/d)x

2 (2 - 1 - d(y/d)x + 
            2 d(y/d)x) = 
      1 + d(y/d)x

2 (1 + d(y/d)x) = 
      1 + d(y/d)x

2 + 2 d(y/d)x = 
      1 + d(y/d)x

d(y/d)x = -1

Verification.

Clear[x, y];
curveplot = 
        ImplicitPlot[((((x^2) - x y + (y^2)))^2) == x y, {x, -1.5, 
            1.5}, PlotStyle -> Blue, 
          DisplayFunction -> Identity];
tangentplot = 
        Plot[-1 (x - 1) + 1, {x, 0.5, 1.5}, PlotStyle -> Red, 
          DisplayFunction -> Identity];
Show[curveplot, tangentplot, 
        DisplayFunction -> $DisplayFunction];

(4.2)  Derivatives of inverse functions.

4.2.1.  Inverse functions.

Suppose a function f is given as the following.

f(x) = ((2  x  +  3)/(x  -  5)).

Then, we can find its inverse in the following fashion.

y = ((2  x  +  3)/(x  -  5)),    (x - 5) y = 2  x + 3,    x y - 5 y = 2  x + 3,

x y - 2  x = 5  y + 3,    (y - 2) x = 5  y + 3,    x = ((5  y  +  3)/(y  -  2)).

Hence, the inverse function is

(f^(-1))(
          x) = ((5 x  +  3)/(x  -  2)).

By taking the derivative of the above function, we can calculate the derivative of the inverse function, ((f^(-1)))' (x).

However, if the original function is more complicated, it is very difficult and often impossible to find the inverse function (f^(-1))(x) directly.  Luckily, there is a way to find the derivative of inverse functions, without calculate the inverse function itself.

4.2.2.  Calculating the derivatives of inverse functions through implicit differentiation.

Suppose we have an explicitly defined function

y = f(x).

Then, we can find the derivative of its inverse function as follows.

y = (f^(-1))(x),    x = f(y),

\(dx\/dx = \(d\/dx\) \(f(y)\)\)
          \(1 = \(dy\/dx\) \(d\/dy\) \(f(y)\)\)
\(1\/\(dy/dx\) = \(\(d\/dy\) \(f(y)\) = f' \((y)\)\)\)

Therefore,

d(y/d)x = 
      (1/(f' (y)))

Since y = f(x), we can write

\(TraditionalForm\`\(d\/dx\) \(\(f\^\(-1\)\)(
            x)\) = \(dy\/dx = \(1\/\(f' \((y)\)\) = 1\/\(f'\)[f(x)]\)\)\).

Example 4.2.3.

Let

f(x) = (e^x).

Calculate the derivative of its inverse function (f^(-1))(x).

Solution.

Everybody knows that the inverse function is in fact the natural log function.  Therefore,

(f^(-1))(x) = Log[x],    \(TraditionalForm\`\(d\/dx\) \(\(f\^\(-1\)\)(x)\) = 1\/x\).

Let us pretend, however, that we don't know this, and apply the implicit differentiation.

y = (f^(-1))(x),    f(y) = x.

That is,

(e^y) = x.

Now, let us differentiate the above equation implicitly.  Then,

\(TraditionalForm\`\(e\^y\) dy\/dx = 1\),    \(TraditionalForm\`dy\/dx = \(1\/e\^y = 1\/x\)\).

Thus, this result is consistent with the result from known formula.

Example 4.2.4.

Find the derivatives of the following inverse trigonometric functions.

(d/d)x 
        ArcSin[x] = ?

Let us begin with

y = ArcSin[x].

By taking the inverse of the both sides of the equalities,

Sin[y] = x.

Now, we apply the implicit differentiation.

Cos[y] d(y/d)x = 1.

Therefore,

d(y/d)x = (1/Cos)[y].

We can stop here and plug in numbers, if the problem asked us to find the derivative at a point.  Unfortunately, it asked us to find the derivative in general.  By applying the Pythagorean identity, (Cos^2)[x] + (Sin^2)[x] = 1, we get,

\(TraditionalForm\`dy\/dx = \(1\/\(±\@\(1\  - \ \(Sin\^2\)[y]\)\) = \(1\/\(±\@\(1\  - \ \((Sin[ArcSin[x]])\)\^2\)\) = 1\/\(±\@\(1\  - \ x\^2\)\)\)\)\).

The fundamental domain of ArcSin[x] is [-(π/2), (π/2)], in which Cos[y] ≥ 0.  Thus, we need only the positive sign.  Hence,

(d/d)x ArcSin[x] = 
        (1/(Sqrt[1  -  (x^2)])).

(d/d)x 
        ArcTan[x] = ?

Similarly, we start from Tan[y] and differentiating it implicitly.

y = ArcTan[x],    Tan[y] = x.

(Sec^2)[y] d(y/d)x = 
        1,    d(y/d)x = 
        (1/((Sec^2)))[y].

From the Pythagorean identity, (Cos^2)[x] + (Sin^2)[x] = 1, we get 1 + (Tan^2)[x] = (Sec^2)[x].  Hence,

\(TraditionalForm\`dy\/dx = \(1\/\(Sec\^2\)[y] = \(1\/\(1\  + \ \(Tan\^2\)[y]\) = \(1\/\(1\  + \ \((Tan[ArcTan[x]])\)\^2\) = 1\/\(1\  + \ x\^2\)\)\)\)\).

(d/d)x ArcTan[x] = 
        (1/(1  +  (x^2))).

(4.3)  Logarithmic differentiation.

First, let us review the exponent rules and log rules from prerequisite materials.

4.3.1.  The summary of exponent rules and log rules.

Here is a brief summary of the exponent rules and the log rules.

Basic rules.

(e^( Log[x])) = x		Log[(e^( x))] = x
	\(TraditionalForm\`e\^\(\(\ \)\(x\  + \ y\)\) = \(e\^\(\(\ \)\(x\)\)\) e\^\(\(\ \)\(y\)\)\)		Log[x y] = Log[x] + Log[y]
	\(TraditionalForm\`e\^\(\(\ \)\(x\  - \ y\)\) = e\^\(\(\ \)\(x\)\)\/e\^\(\(\ \)\(y\)\)\)		Log[(x/y)] = Log[x] - Log[y]
	\(TraditionalForm\`\((e\^\(\(\ \)\(a\)\))\)\^\(\(\ \)\(k\)\) = e\^\(\(\ \)\(a\ k\)\)\)		Log[(x^( k))] = k Log[x]
	(e^0) = 1,  (e^1) = e		Log[1] = 0,  Log[e] = 1
	\(TraditionalForm\`lim\_\(x -> \(-∞\)\)e\^\(\(\ \)\(x\)\) = 0\)	(lim_(x -> 0+))Log[
            x] = -∞

Graphs.

Clear[x];
expplot = 
        Plot[(E^x), {x, -5, 5}, PlotStyle -> Blue, 
          PlotRange -> {-5, 5}, 
          DisplayFunction -> 
            Identity];
logplot = 
        Plot[Log[x], {x, 0, 5}, PlotStyle -> Red, 
          PlotRange -> {-5, 5}, 
          DisplayFunction -> 
            Identity];
axisplot = 
        Plot[x, {x, -5, 5}, PlotStyle -> Purple, 
          DisplayFunction -> Identity];
Show[expplot,logplot,axisplot,DisplayFunction -> $DisplayFunction,
Epilog->{Text["y = (E^x)",{-3, 2}],Text["y = Log[x]",{3, -2}]}];

Change-of-base rule.

\(TraditionalForm\`\(\(\ \)\(a\^\(\(\ \)\(b\)\) = e\^\(\(\ \)\(b\ Log[a]\)\)\)\)\)		(Subscript[Log,  a])[b] = Log[b]/Log[a]

Now, we are ready to begin some differentiation problems on log functions.

Example 4.3.2.

Find the derivatives of the following functions.

f(x) = Log[(x^2) + (e^x)]

We apply the chain rule.

\(TraditionalForm\`f' \((x)\) = \(\(1\/\(x\^2\  + \ e\^\(\(\ \)\(x\)\)\)\) \((2  
                  x + e\^x)\) = \(2  x\  + \ e\^x\)\/\(x\^2\  + \ e\^x\)\)\).

f(x) = 
        Log[((x^2) + (e^x)) (((2  x - Sin[x]))^5)]

You can apply the chain rule and then the product rule, if you wish.

\(TraditionalForm\`f' \((x)\) = \(\((2  x + e\^x)\) \((2  x - Sin[x])\)\^5 + \((x\^2 + e\^x)\) 5 \(\((2  x - Sin[x])\)\^4\) \((2 - Cos[x])\)\)\/\(\((x\^2\  + \ e\^x)\) \((2  x\  - \ Sin[x])\)\^5\)\).

It works.  But it is complicated.  It is better to simplify the function before differentiating it.

f(x) = 
      Log[((x^2) + (e^x)) (((2  x - Sin[x]))^5)]
\(TraditionalForm\`\ \ \ \ \ \ \ \ \ \(\(=\)\(Log[\((x\^2 + e\^x)\)] + 5 \(\( Log[2  x - Sin[x]]\)\(.\)\)\)\)\)

Thus,

\(TraditionalForm\`f' \((x)\) = \(2  x\  + \ e\^x\)\/\(x\^2\  + \ e\^x\) + \(5 \((2\  - \ Cos[x])\)\)\/\(2  x\  - \ Sin[x]\)\).

\(TraditionalForm\`f(x) = 
        Log[\(\((x\^2\  + \ e\^x)\) \((2  x\  - \ Sin[x])\)\^5\)\/\@\(3\  - \ Cos[x]\  + \ Log[x]\)]\)

This time, it is really necessary to simplify the function before differentiating it.

\(TraditionalForm\`f(x) = 
      Log[\(\((x\^2\  + \ e\^x)\) \((2  x\  - \ Sin[x])\)\^5\)\/\@\(3\  - \ Cos[x]\  + \ Log[x]\)]\)
         =Log[
          (x^2) + (e^x)] + 
        5  Log[2  x - Sin[x]] - (1/2) Log[
              3 - Cos[x] + Log[x]].

Hence,

\(TraditionalForm\`f' \((x)\) = \(2  x\  + \ e\^x\)\/\(x\^2\  + \ e\^x\) + \(5 \((2\  - \ Cos[x])\)\)\/\(2  x\  - \ Sin[x]\) - \(1\/2\) \(1\  + \ Sin[x]\  + \ 1\/x\)\/\(3\  - \ Cos[x]\  + \ Log[x]\)\).

4.3.4.  Logarithmic differentiation.

In Example 4.3.2, we learned that log rules can be applied to simplify the function before differentiating it.  We can apply similar trick to non-logarithmic functions, too, to make the differentiation easier.  For instance, it is possible to apply the quotient rule, the product rule and the chain rule multiple times to differentiate the following function.

\(TraditionalForm\`f(
          x) = \(\((x\^2\  + \ e\^x)\) \((2  x\  - \ Sin[x])\)\^5\)\/\@\(3\  - \ Cos[x]\  + \ Log[x]\)\).

Clear[f, x];
f[
          x_] = ((((x^2)  +  (E^x)) (((2  x  -  Sin[x]))^5))/(Sqrt[3  -  Cos[x]  +  Log[x]]));
Print["f'[x] = ", f'[x]];

However, we can differentiate is much easily by doing the following.

1.  Take the natural log of both sides.

Take the log of the following equation.

\(TraditionalForm\`y = \(\((x\^2\  + \ e\^x)\) \((2  x\  - \ Sin[x])\)\^5\)\/\@\(3\  - \ Cos[x]\  + \ Log[x]\)\).

Then we get,

\(TraditionalForm\`Log[y] = 
        Log[\(\((x\^2\  + \ e\^x)\) \((2  x\  - \ Sin[x])\)\^5\)\/\@\(3\  - \ Cos[x]\  + \ Log[x]\)]\).

2.  Simplify.

Log[y] = 
      Log[(x^2) + (e^x)] + 
        5  Log[2  x - Sin[x]] - (1/2) Log[3 - Cos[x] + Log[x]]

3.  Differentiate implicitly.

\(TraditionalForm\`\(1\/y\) dy\/dx = \(y'\/y = \(2  x\  + \ e\^x\)\/\(x\^2\  + \ e\^x\) + \(5 \((2\  - \ Cos[x])\)\)\/\(2  x\  - \ Sin[x]\) - \(1\/2\) \(1\  + \ Sin[x]\  + \ 1\/x\)\/\(3\  - \ Cos[x]\  + \ Log[x]\)\)\)

4.  Solve for y'.

\(TraditionalForm\`y' = 
      y(\(2  x\  + \ e\^x\)\/\(x\^2\  + \ e\^x\) + \(5 \((2\  - \ Cos[x])\)\)\/\(2  x\  - \ Sin[x]\) - \(1\/2\) \(1\  + \ Sin[x]\  + \ 1\/x\)\/\(3\  - \ Cos[x]\  + \ Log[x]\))\)

Recall that

\(TraditionalForm\`y = \(\((x\^2\  + \ e\^x)\) \((2  x\  - \ Sin[x])\)\^5\)\/\@\(3\  - \ Cos[x]\  + \ Log[x]\)\).

Therefore,

\(TraditionalForm\`f' \((x)\) = \(\(\((x\^2\  + \ e\^x)\) \((2  x\  - \ Sin[x])\)\^5\)\/\@\(3\  - \ Cos[x]\  + \ Log[x]\)\) \((\(2  x\  + \ e\^x\)\/\(x\^2\  + \ e\^x\) + \(5 \((2\  - \ Cos[x])\)\)\/\(2  x\  - \ Sin[x]\) - \(1\/2\) \(1\  + \ Sin[x]\  + \ 1\/x\)\/\(3\  - \ Cos[x]\  + \ Log[x]\))\)\).

Such method is called log-differentiation.

Besides large products and quotients, we can apply the log-differentiation exponential functions of general bases.

Example 4.3.5.

Find the derivative of the following function.

f(x) = (x^Sin)[x].

Solution 1.

We apply the log-differentiation technique.

y = (x^Sin)[x],    Log[y] = Log[(x^Sin)[x]] = Sin[x] Log[x].

Then, by the product rule,

\(TraditionalForm\`y'\/y = Cos[x] Log[x] + Sin[x] 1\/x\).

By moving y to the other side, we get

y' = y(Cos[x] Log[x] + Sin[x] (1/x)).

From the original problem, we can write the final answer as

f' (x) = (x^Sin)[x](
          Cos[x] Log[x] + Sin[x] (1/x)).

Solution 2.

The second method is to apply the change-of-base formula and make the original function a natural exponential function.

f(
          x) = (x^Sin)[x] = (e^(Sin[x] Log[x])).

Therefore, from the chain rule and the product rule.

f' (x) = (e^(Sin[x] Log[x]))(
          Cos[x] Log[x] + Sin[x] (1/x)).

Finally, let us prove the power rule (Theorem 2.1.2) for arbitrary k ∈ ℝ through the logarithmic differentiation.

Example 4.3.6.

Find the derivative of the following function.

f(x) = (x^k),  where  x > 0  and  k ∈ ℝ.

Solution.

Put

y = (x^k),

so that

Log[y] = Log[(x^k)] = k Log[x].

Now, differentiate the above with implicit differentiation technique.

\(TraditionalForm\`y'\/y = k\/x\).

Thus,

f' (x) = y' = k y (1/x) = k (x^k) 
                (1/x) = k (x^(k - 1)).

Warning.  This solution is still not perfect, because we did not define exponential and logarithmic functions properly, let alone their derivatives.

5.  Differentiation with Mathematica

We used Mathematica commands for differentiation in a number of places in Section 2, mostly for checking purpose.  This time, let us study differentiation by Mathematica systematically.

(5.1)  The basic syntax.

There are two commonly used methods to calculate derivatives with Mathematica.  The first method is to use the basic syntax, D[..., *].

Clear[a, b, k, t, x];

D[(x^2) + 3  x - (Sqrt[x]), x]

D[Sin[(t^2)], t]

D[a (x^2) + (Sqrt[(x^k) + b])]

The first command, Clear[...] literally clears all the variables listed inside the bracket.  Although, most calculus project level programs will work just fine without Clear command, it is generally a good idea to start any Mathematica program with Clear[...].  The other commands are basic syntaxes for differentiation.

The second method is to define a function first and then, use traditional derivative symbol.

Clear[a, b, k, t, x];

f[x_] = (x^2) + 3  x - (Sqrt[x])
f'[x]

f[t_] = Sin[(t^2)]
f'[t]

f[x_] = a (x^2) + (Sqrt[(x^k) + b])
f'[x]

We will use the second method more often in UMM Calculus, because it resembles traditional symbols more than the first.

(5.2)  Learning partial derivatives through Mathematica.

In text or hand-writing, the simplest differentiation command is '.  For instance, f' stands for the derivative of f.  This, however, is very dubious symbol for computers.  Try these commands first.

Example 5.2.1.

Clear[a, b, k, t, x];

((x^2) + 3  x - (Sqrt[x]))'

(Sin[(t^2)] - t)'

(a (x^2) + (Sqrt[(x^k) + b]))'

Didn't work, did they.  Of course, we learned the correct methods in the previous subsection.  The topic of this subsection is to understand the reason why computers are unable to handle such of commands.  In class, we all implicitly agreed to use x as the independent variable, and to regard (⋯)' as the derivative with respect to x unless specified otherwise.  If we use another letter as the independent variable, say t, as in the second example, we tacitly agree to differentiate by t, while using the same notation (⋯)'.  Such tacit and flexible agreements are beyond a computer's capability.  In order to run programs correctly with computers, we must specify explicitly which is the variable we want to differentiate with.  This particularly important when there are more than one characters in a function, like the third function of Example 5.2.1.  Let us clarify this observation through the following example.

Example 5.2.2.

Find the derivative f' when the function f is defined as the following.

f(x) = (x^2) + 3  x - (Sqrt[x]),

f(t) = Sin[(t^2)] - t,

f(x) = a (x^2) + (Sqrt[(x^k) + b]).

Solution 1.

First, we define the function f properly, and then ask Mathematica to calculate its derivative.

Clear[f, x];
f[x_] = (x^2) + 3  x - (Sqrt[x])
f'[x]

Clear[f, t];
f[t_] = Sin[(t^2)] - t
f'[t]

Clear[f, x, a, b, k];
f[x_] = a (x^2) + (Sqrt[(x^k) + b])
f'[x]

The first line of each program Clear[...] is there for safety.  It literally clears the variables inside the bracket before doing something with them.  It is generally good idea to clear everything before starting the real program, but your program will work just fine (most of the time) without it.  The key step is the second line, where we defined the function and the variable properly.  Be sure to include the underscore.  That is, you must write f[x_] instead of f[x] when defining the function (and the variable).  Third line is the derivative computation.  This time, the traditional symbol ' works just fine.  That is because we defined the function and the variable properly in previous step.

The third problem is particularly interesting because it contains some parameters.  That is, the characters a, b and k are considered constants, as far as x is concerned.  Since computers do not make any implicit assumption, we must explicitly specify that which is the variable in the definition of the function (the second line).  Compare the third solution with the following.

Clear[f, x, a, b, k];
f[x_, k_] = a (x^2) + (Sqrt[(x^k) + b])
f'[x, k]

You get nothing, because there are two variables x and k (a and b are parameters, because they were not called  with underscore), and Mathematica did not understand with respect to which variable you are differentiating.  Verdict: ' won't do.

Solution 2.

Let us now discuss about an alternative method.  This time, we will not define a function.  We will explicitly specify to which variable Mathematica must differentiate.  The syntax is D[..., x], if you are differentiating with respect to x, and D[..., t], if you are differentiating with respect to t.  Similarly, one can consider D[..., y],  D[..., y], and so on.

Clear[x];
D[(x^3) + 3  x - (Sqrt[x]), x]

Clear[t];
D[Sin[(t^2)] - t, t]

Clear[x, a, b, k];
D[a (x^2) + (Sqrt[(x^k) + b]), x]

Compare the last solution with the following derivatives.

D[a (x^2) + (Sqrt[(x^k) + b]), k]
D[a (x^2) + (Sqrt[(x^k) + b]), a]
D[a (x^2) + (Sqrt[(x^k) + b]), b]

Compare the above syntaxes with those of other Mathematica commands, too.  For instance,

Clear[a, b, c, x, y];

Solve[a (x^2) + 2  b x + c == 0, x]

Solve[(x^2) y + x == 1, x]

Solve[(x^2) y + x == 1, y]

Do you see the general rule of the structure, [..., *]?

By the way, you get nothing if your forget to specify the variable, which is the whole point.

Clear[a, b, k, t, x];

D[(x^3) + 3  x - (Sqrt[x])]

D[Sin[(t^2)] - t]

D[a (x^2) + (Sqrt[(x^k) + b])]

Solution 3.

In fact, the third method is identical to the second method, except that it is expressed in traditional mathematical symbols.

Clear[a, b, c, k, t, x];

(∂_x) ((x^2) + 3  x - (Sqrt[x]))

(∂_t) (Sin[(t^2)] - t)

(∂_x) (a (x^2) + (Sqrt[(x^k) + b]))

Indeed, (∂_x) ( ... ) is identical to D[..., x].  Consequently, the above Mathematica commands are equivalent to the following traditional notations.

(∂_x) ((x^2) + 3  x - (Sqrt[x])) = 
        2  x + 3 - (1/2) (x^(-1/2)),

(∂_t) (Sin[(t^2)] - t) = 
        2  t Cos[(t^2)] - 1,

(∂_x) (a (x^2) + (Sqrt[(x^k) + b])) = 
        2  a x + (1/2) 
            k (((x^(k - 1))((x^2) + b))^(-1/2)).

This technique is called partial differentiation and its solutions are called partial derivatives.  Partial differentiation is nothing more than taking derivative with respect to one variable, regarding the other variables as constants.  Computers does not, or rather, cannot distinguish ordinary differentiation and partial differentiation.

(5.3)  Learning higher order derivatives through Mathematica.

In text or hand-writing, we use multiple apostrophes to indicate higher order derivatives.  Mathematica can work in similar way, too.

Example 5.3.1.

Find the first, the second and the third derivative of the following function.

f(x) = Tan[a (x^k) + b] + c x.

Solution 1.

Let us define the function properly and then apply apostrophes.

Clear[f, x, a, b, c, k];
f[x_] = Tan[a (x^k) + b] + c x
f'[x]
f''[x]
f'''[x]

Solution 2.

This time, let us take short cut.  Please pay attention to the commands.

Clear[a, b, c, k, x];
D[Tan[a (x^k) + b] + c x, x]
D[Tan[a (x^k) + b] + c x, x, x]
D[Tan[a (x^k) + b] + c x, x, x, x]

We need to differentiate multiple times, and each time we must tell the computer by which variable it must differentiate.

If you do not wish to type ,x 10 times, there is a better way to calculate much higher order derivatives.

Clear[a, b, c, k, x, f, n];
f[0, x_] := Tan[a (x^k) + b] + c x;
f[n_, x_] := f[n, x] = 
          D[f[n - 1, x], x];
f[10, x]

The above program is equivalent to the following.

Clear[a, b, c, k, x];
D[Tan[a (x^k) + b] + c x, x]
D[%, x]
D[%, x]

Here, % means the output from the previous line.  In other words, the second and the third lines calculate  D[D[Tan[a (x^k) + b] + c x, x], x] and  D[D[D[Tan[a (x^k) + b] + c x, x], x], x], only faster.

Solution 3.

Let us use traditional symbols again.  Recall that D[...,x] is equivalent to (∂_x) (⋯).  Thus,

Clear[a, b, k, x];
(∂_x) (Tan[a (x^k) + b] + 
          c x)
(∂_(x, x)) (Tan[a (x^k) + b] + 
          c x)
(∂_(x, x, x)) (Tan[a (x^k) + b] + c x)

Each time, we must specify the variable.  Therefore, we need x, x, ⋯.

Now, recall that we can take other characters as the independent variables, too.  In this case, we will have higher order partial derivatives.

Example 5.3.2.

Find the following second order partial derivatives.

f(x, k) = Tan[a (x^k) + b] + c x,
	(∂_(x,  x)) f(x, k) = ?
	(∂_(x,  k)) f(x, k) = ?
	(∂_(k,  x)) f(x, k) = ?
	(∂_(k,  k)) f(x, k) = ?

Solution.

This time, a method analogous to Solution 1 of Example 5.3.1 will not work, because we must consider more than one variable.

Clear[a, b, c, k, x];
D[Tan[a (x^k) + b] + c x, x, x]
D[Tan[a (x^k) + b] + c x, k, x]
D[Tan[a (x^k) + b] + c x, x, k]
D[Tan[a (x^k) + b] + c x, k, k]

The first derivative command differentiates the function with respect to x twice.  The last command differentiates the function with respect to k twice.  The interesting part is the middle two.  We can differentiate by k first and then by x, or we can do it vice versa.  As you see, we get the same result in the end.  This phenomenon is called Clairut's Theorem and it holds if every partial derivatives exists and they are all continuous.  In traditional symbol, it goes like

Clear[a, b, c, k, x];
(∂_(x, x))(Tan[a (x^k) + b] + 
          c x)
(∂_(x, k))(Tan[a (x^k) + b] + 
          c x)
(∂_(k, x))(Tan[a (x^k) + b] + 
          c x)
(∂_(k, k))(Tan[a (x^k) + b] + c x)

You can include the other characters (a, b, c) as well, if you like.  Mathematica commands and theoretical background both remain identical.  All you need is to specify the variable by which to differentiate each time a (partial) derivative is taken.

6.  Antidifferentiation

(6.1)  Antiderivatives and antidifferentiation.

6.1.1.  Antiderivatives and antidifferentiation.

Antidifferentiation is literally the inverse procedure of differentiation.  Let F(x) be a function and f(x) is its derivative.  That is, F' (x) = f(x).  Then, we call F(x), an antiderivative an of f(x).  The process to find an antiderivative is called the antidifferentiation.

Note that antiderivatives are not unique.  For instance, both (x^2) - 2  x and (x^2) - 2  x + 3 are antiderivatives of 2  x - 2.  However, they are not completely unrelated.  If two functions share the same derivative, they differ only by a constant.  This simple observation turns out quite difficult to prove.  The requires Mean Value Theorem.

6.1.2.  Indefinite integrals.

Antiderivatives are also known as indefinite integrals.  Antidifferentiation is called alternatively as integration.  To integrate is to find an indefinite integral.  We use the following notation to represent the indefinite integral of a function f(x).

∫f(x) dx

The original function f(x) is called the integrand.

Be sure to include both ∫ and dx.  Like parenthses and brackets, you must open the integral with ∫ and close it with dx.

6.1.3.  The basic properties of antiderivatives.

Antiderivatives or indefinite integrals have the following properties.

∫[f(x) + 
                g(x)] dx = ∫f(
                x) dx + ∫g(
                x) dx.

∫[k f(x)] dx = 
        k ∫f(x) dx.

As is the case with the differentiation, integral of product is not the same as the product of integrals.

∫f(x) g(
              x) dx ≠ (∫f(
                  x) dx) (∫g(
                  x) dx)

Due to the mutual inverse nature of differentiation and integration, we must have

\(TraditionalForm\`\(d\/dx\) \(∫\(f(x)\) dx\) = f(x)\).

∫f' (x) dx = 
        f(x) + C.

Note that an arbitrary constant C follows as explained in 5.1.1.

\(TraditionalForm\`\(d\/dx\) \(∫\(f(x)\) dx\) = f(x)\).

(6.2)  A list of basic antiderivatives.

Here is the bare-bone-minimum list of integration formulae.

\(TraditionalForm\`∫\(x\^k\) dx = \(1\/\(k\  + \ 1\)\) x\^\(k + 1\) + C\),  if  k ≠ -1.
	∫(1/x) dx = 
        Log | x | +C.
	\(TraditionalForm\`∫\(e\^x\) dx = e\^x + C\).

∫Sin[x] dx = -Cos[x] + 
          C.
	∫Cos[x] dx = Sin[x] + C.
	∫(Sec^2)[x] dx = 
        Tan[x] + C.
	∫(1/(1  +  
                  (x^2))) dx = ArcTan[x] + C.

There are a lot more formulae, but most of them can be derived from above list or appear scarcely.

Example 6.2.1.

Calculate the following antiderivatives.

∫(2  (x^2) + 2  Cos[x] - 
                5) dx = ?

∫(2  (x^2) + 2  Cos[x] - 
                5) dx = (2/3) (x^3) + Sin[x] - 5  x + C.

∫(2  (x^2) + 2  Cos[x] - 5) \[DifferentialD]x

∫(Sqrt[x + 5]) dx = ?

\(TraditionalForm\`∫\@\(x + 5\)\ dx = ∫\(\((x + 5)\)\^\(1/2\)\) dx\)
\(TraditionalForm\`\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(\(=\)\(\(2\/3\) \((x + 5)\)\^\(3/2\) + C\)\)\)
\(TraditionalForm\`\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(\(=\)\(\(2\/3\) \((x + 5)\)\^\(3/2\) + C\)\)\)

∫(Sqrt[x + 5]) \[DifferentialD]x

∫(2  (x^3) + (2/(Sqrt[x])) - 
                (3/x)) dx = ?

∫(2  (x^3) + (2/(Sqrt[x])) - 
                (3/x)) dx = ∫(2  (x^3) + 
                2  (x^(-1/2)) - 3  (1/x)) dx
\(TraditionalForm\`\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(\(=\)\(\(1\/2\) x\^4 + 
            2  •\ 2  x\^\(1/2\) - 3  Log | x | \(+C\)\)\)\)
\(TraditionalForm\`\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(\(=\)\(\(1\/2\) x\^4 + 4 \@ x - 3  Log | 
          x | \(+C\)\)\)\)

∫(2  (x^3) + (2/(Sqrt[x])) - 
            (3/x)) \[DifferentialD]x
Expand[%]

(6.3)  More general formulae.

We can generalize the formulae in (1.2) slightly through the chain rule.

∫(((a x + 
                    b))^k) dx = (1/(a(
                  k  +  1))) (((a x + b))^(k + 1)) + C,  if  k ≠ -1.
	∫(1/(a x  +  
                  b)) dx = (1/a) Log | 
          a x + b | +C.

\(TraditionalForm\`∫\(e\^\(\(\ \)\(a\ x\  + \ 
                  b\)\)\) dx = \(1\/a\) e\^\(\(\ \)\(a\ x\  + \ b\)\) + C\).

∫Sin[
              a x + b] dx = -(1/a) Cos[a x + b] + 
          C.
	∫Cos[
              a x + b] dx = (1/a) Sin[a x + b] + C.
	∫(Sec^2)[
              a x + b] dx = (1/a) Tan[a x + b] + C.

The recurring theme is the multiplication of 1/a that comes from the chain rule on the inner function (a x + b).  The following formulae do not contain the first order polynomial (a x + b), but they appear relatively often.

∫(1/((a^2)  +  
                  (x^2))) dx = (1/a) ArcTan[(x/a)] + C.

∫((f' (x))/(f(
                  x))) dx = Log | f(x) | +C.

Example 6.3.1.

Calculate the following indefinite integrals.

∫(Sqrt[2  x + 5]) dx = ?

\(TraditionalForm\`∫\@\(2  x + 5\)\ dx = ∫\(\((2  x + 5)\)\^\(1/2\)\) dx\)
\(TraditionalForm\`\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(\(=\)\(\(2\/3\) \(\((2  x + 5)\)\^\(3/2\)\) 1\/2 + C\)\)\)
\(TraditionalForm\`\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(\(=\)\(\(1\/3\) \((2  x + 5)\)\^\(3/2\) + C\)\)\)

∫(Sqrt[2  x + 5]) \[DifferentialD]x

\(TraditionalForm\`∫\((2  e\^\(\(\ \)\(3\ x\)\) + 2  Cos[1 - 2  x] - 5\/\(2\  - \ 3  x\))\) dx = ?\)

\(TraditionalForm\`∫\((2  e\^\(\(\ \)\(3\ x\)\) + 2  Cos[1 - 2  x] - 5\/\(2\  - \ 3  x\))\) dx\)
\(TraditionalForm\`	\(\(=\)\(\(2\/3\) e\^\(\(\ \)\(3\ x\)\) - \(2\/2\) Sin[1 - 2  x] - \(5\/\(-3\)\) Log | 2 - 3  x | \(+C\)\)\)\)
\(TraditionalForm\`	\(\(=\)\(\(2\/3\) e\^\(\(\ \)\(3\ x\)\) - Sin[1 - 2  x] + \(5\/3\) Log | 2 - 3  x | \(+C\)\)\)\)

∫(2  (E^( 3 x)) + 
            2  Cos[1 - 2  x] - 
            (5/(2  -  3  x))) \[DifferentialD]x

Clear[f, x];
f[x_] = (2/3) (E^( 3 x)) - 
          Sin[1 - 2  x] + (5/3) 
            Log[2 - 3  x];
f'[x]

∫(1/(4  +  
                  (x^2))) dx = ?

∫(1/(4  +  
                  (x^2))) dx = ∫((1/
                  4)/(1  +  (x^2)/4)) dx
\(TraditionalForm\`\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(\(=\)\(\(1\/4\) \(∫\(1\/\(1\  + \ \((x/2)\)\^2\)\) dx\)\)\)\)
\(TraditionalForm\`\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(\(=\)\(\(1\/4\) 2  ArcTan[x\/2] + C\)\)\)
\(TraditionalForm\`\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(\(=\)\(\(1\/2\) ArcTan[x\/2] + C\)\)\)

∫(1/(4 + (x^2))) \[DifferentialD]x

7.  Definite Integrals

(7.1)  The mutual inverse nature of slope and signed area.

7.1.1.  Slopes, rate of changes and derivatives.

Readers will remember that the derivative is represented by the slope of the graph and measures the rate of change.  Let us review this once more before exploring the inverse process.  Suppose the following graph models the growth of a certain animal.  Here, let us assume that the horizontal axis represents the time t, and the vertical axis stands for the height h.

Clear[h, a, b, c, k, m, t];
a = 1.0;
b = 260.0;
c = 80.0;
k = 0.25;
m = 11.0;
h[
          t_] = ((b/(1 +  a Exp[-k t])) - 
              c) (1 - (1/10.0) 
                Exp[-((((t - m))^2)/20.0)]);
heightplot = 
        Plot[h[t], {t, -1, 25}, AspectRatio -> (1/GoldenRatio), 
          PlotStyle -> {Blue}];

The rate of change is measured by the difference of the height Δ h over a fixed time frame Δ t.  The instantaneous rate of change is, therefore,

\(TraditionalForm\`lim\_\(Δ\ t -> 0\)\(Δ\ h\)\/\(Δ\ t\) = \(dh\/dt = \(h'\)[t]\)\).

Here is the graph of the derivative function of the above growth model.

growthplot = 
        Plot[{h'[t]}, {t, -1, 25},  
          PlotStyle -> {Red}];

The growth rate is the biggest at birth, decreases for a while, hits another hump around 14 time units, and then, steadily decreases.  Let us explore this change through the following animation.  The blue graph in the left hand side represents the height of the animal as it ages.  The blue dot on the vertical axis represents its height, and the blue dot on the graph represents both its height and age.  The red graph on the left hand side stands for the growth rate.  The growth rate is represented in the left hand side plot, too, as the slope of tangent line.

Animation.

Clear[h, t];
AniNo = 
      50;                    
ti = 0; 
    tf = 24;           
h[
        t_] = ((260.0/(1 +  1.0 Exp[-0.25 t])) - 
            80.0) (1 - (1/10.0) 
              Exp[-((((t - 11.0))^2)/20.0)]);
heightplot = 
        Plot[h[t], {t, -1, 25}, AspectRatio -> (1/GoldenRatio), 
          PlotStyle -> {Blue}, 
          DisplayFunction -> Identity];
growthplot = 
        Plot[{h'[t]}, {t, -1, 25},  PlotStyle -> {Red}, 
          DisplayFunction -> Identity];

    
aniplot[ii_] := 
        Module[{t}, 
tangentline = 
            Plot[h'[ii] (t - ii) + h[ii], {t, Max[ii - 5, ti - 1], 
                Min[ii + 5, tf + 1]}, PlotStyle -> {Red}, 
              AspectRatio -> (1/GoldenRatio), 
              DisplayFunction -> 
                Identity]; 
tangentpoint = 
            Graphics[{Blue, PointSize[0.02], 
                Point[{ii, h[ii]}]}]; 
pointplot = 
            Graphics[{Blue, PointSize[0.02], 
                Point[{0, h[ii]}]}]; 
growthrate = 
            Graphics[{Red, PointSize[0.025], 
                Point[{ii, h'[ii]}]}]; 
firstplot = 
            Show[heightplot, tangentline, tangentpoint, pointplot, 
              PlotRange -> {0, 182}, 
              DisplayFunction -> 
                Identity]; 
secondplot = 
            Show[growthplot, growthrate, 
              DisplayFunction -> Identity]; 
Show[
            GraphicsArray[{firstplot, secondplot}], 
            DisplayFunction -> $DisplayFunction];
];
Table[aniplot[ii], {ii, ti, tf, (((tf - ti))/AniNo)}];

The next topic is the inverse process.  We will explain graphically, how taking the antiderivative is related to calculating the (signed) area.

7.1.2.  Signed areas and antiderivatives.

This time, let us explore the backward implication.  We start with the growth rate y(t).

Clear[h, a, b, c, k, m, t];
a = 1.0;
b = 260.0;
c = 80.0;
k = 0.25;
m = 11.0;
h[
          t_] = ((b/(1 + a Exp[-k t])) - 
              c) (1 - (1/10.0) 
                Exp[-((((t - m))^2)/20.0)]);
growthplot = 
        Plot[h'[t], {t, -0.5, 25}, PlotRange -> All, 
          PlotStyle -> {Red}];

That is,

\(TraditionalForm\`y(t) = \(dh\/dt = 
          lim\_\(Δ\ t -> 0\)\(Δ\ h\)\/\(Δ\ t\)\)\).

When the time difference Δ t is sufficiently small, we have,

(eq:7.1.2-1)	\(TraditionalForm\`y(
          t) ≃ \(Δ\ h\)\/\(Δ\ t\)\).

Hence, we get the following approximate equality.

(eq:7.1.2-2)	Δ h ≃ y(
            t) Δ t.

Therefore, Δ h represents an area of the following rectangle, because y(t) is the height and Δ t is the width.  The difference of the height in the time period is represented approximately as the area of the (thin) rectangle illustrated below.  The height of the rectangle is fixed at y(t), and the width is fixed at Δ t.  All we need is that Δ t is sufficiently small.  t doesn't have to be at the center (or any special point) of the time period.  The following program to randomly selects the vertical edges of the rectangle.

Clear[x, r];
x = 5;
Δt = 2;
r = Random[];
rectangleplot = 
        Graphics[{DarkGreen, 
            Line[{{x - r Δt, 
                  0}, {x - r Δt, h'[
                    x]}, {x + (1 - r) Δt, h'[
                    x]}, {x + (1 - r) Δt, 
                  0}, {x - r Δt, 
                  0}}]}];
lineplot = 
        Graphics[{Blue, 
            Line[{{x, 0}, {x, h'[x]}}]}];
pointplot = 
        Graphics[{Black, PointSize[0.015], 
            Point[{x, h'[x]}]}];
Show[growthplot, rectangleplot, lineplot, pointplot];

Now, instead of restricting ourselves within a short time frame Δ t around a certain time t, let us consider the entire life of the animal which is x years old.  That is, we are interested in the shaded period.

Clear[x];
x = 15;
pastplot = 
        FilledPlot[h'[t], {t, 0, x}, 
          PlotStyle -> {{Red, Thickness[0.005]}}, 
          AspectRatio -> (1/GoldenRatio), 
          Fills -> {GrayLevel[0.75]}, 
          DisplayFunction -> Identity];
Show[pastplot, growthplot, 
        DisplayFunction -> $DisplayFunction];

We can divide the life the life of the animal (up to x time units) with n stages from its birth (Subscript[t, 0]) = 0 to current age (Subscript[t, n]) = x as,

0 = (Subscript[t, 0]) < (Subscript[t, 1]) < (Subscript[t, 2]) < ⋯ < 
            (Subscript[t, n - 1]) < (Subscript[t, n]) = x.

For simplicity, let us define

(Subscript[h, 0]) = h((Subscript[t, 0])) = 
          h(0),  ⋯ ,  (Subscript[h, n]) = h((Subscript[t, n])) = h(x),

and

Δ (Subscript[t, i]) = (Subscript[t, i]) - (Subscript[t, i - 1]),    Δ (Subscript[h, i]) = (Subscript[h, i]) - (Subscript[h, i - 1]).

By taking sufficiently large number of stages (large n), we can set the time difference Δ (Subscript[t, i]) sufficiently small that (eq:7.1.2-1) and (eq:7.1.2-2) hold.  Consequently, we get

(eq:7.1.2-3)	Δ (Subscript[h, i]) ≃ 
        (Subscript[y, i]) Δ (Subscript[t, i]),

where (Subscript[y, i]) is a y-coordinate value of any point on the graph in the small interval [(Subscript[t, i - 1]), (Subscript[t, i])].  That is, we can write

\(TraditionalForm\`y\_i = y[t\&~\_i]\),  for some  \(TraditionalForm\`t\&~\_i\),  \(TraditionalForm\`t\_\(i - 1\) ≤ t\&~\_i ≤ 
        t\_i\).

Thus, (eq:7.1.2-3) can be rewritten as

(eq:7.1.2-4)	\(TraditionalForm\`\(\(\ \)\(h\_i - h\_\(i - 1\) ≃ 
        y[t\&~\_i] \((t\_i - t\_\(i - 1\))\)\)\)\).

This idea is depicted below.  This time, the vertical edges are fixed with t = (Subscript[t, i - 1]) and t = (Subscript[t, i]).  The height \(TraditionalForm\`y(t\&~\_i)\) is selected at random, where \(TraditionalForm\`t\_\(i - 1\) ≤ t\&~\_i ≤ 
        t\_i\).

tn = 5;
Δt = 2;
tt = tn - Random[] Δt;
rectangleplot = 
        Graphics[{DarkGreen, 
            Line[{{tn, 0}, {tn - Δt, 
                  0}, {tn - Δt, h'[tt]}, {tn, h'[
                    tt]}, {tn, 0}}]}];
lineplot = 
        Graphics[{Blue, 
            Line[{{tt, 0}, {tt, h'[tt]}}]}];
pointplot = 
        Graphics[{Black, PointSize[0.015], 
            Point[{tt, h'[tt]}]}];
Show[growthplot, rectangleplot, lineplot, pointplot];

By adding up (eq:7.1.2-4) for all i's, we get

(eq:7.1.2-5)	\(TraditionalForm\`\(\(\ \)\(h(x) - h(0) = 
        h\_n - h\_0

      \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(\(=\)\(\((h\_n - 
              h\_\(n - 1\))\) + ⋯ + \((h\_1 - 
              h\_0)\)\)\)

      \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(\(=\)\(∑\+\(i = 1\)\%n\((h\_i - 
                h\_\(i - 1\))\) = ∑\+\(i = 1\)\%n Δ\ h\_i\)\)

      \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(\(≃\)\(∑\+\(i = 1\)\%n y[t\&~\_i] \((t\_i - t\_\(i - 1\))\)\)\)

      \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(\(≃\)\(∑\+\(i = 1\)\%n y[t\&~\_i] Δ\ t\_i\)\)\)\)\)

Hence, we can represent the height function h(t) as follows.

\(TraditionalForm\`\(\(\ \)\(h(x) ≃ 
        h(0) + ∑\+\(i = 1\)\%n y[t\&~\_i] Δ\ t\_i\)\)\).

Note that the right hand side of (eq:7.1.2-5) is the sum of the area of the rectangles, which we call a Riemann Sum.  The following programs plot the rectangles and provide the approximation of h(x) - h(0).

The first program is the standard program.  It selects (Subscript[t, i])'s and \(TraditionalForm\`\(t\_i\)\&~\)'s at random, but keeps Δ (Subscript[t, i])'s sufficiently small (Δ (Subscript[t, i]) ≤ 2  x/n).  The default setting is x = 15 and n = 20.  One can get more accurate figure by increasing n value (Δ (Subscript[t, i]) ≤ 2  x/n -> 
        0, as n -> ∞).

Clear[h, t, x, i, n];
x = 15; n = 20;
ti = 0; 
    tf = x;
h[
          t_] = ((260.0/(1 +  1.0 Exp[-0.25 t])) - 
              80.0) (1 - (1/10.0) 
                Exp[-((((t - 11.0))^2)/20.0)]);
growthplot = 
        Plot[{h'[t]}, {t, -1, 25},  PlotStyle -> {Red}, 
          DisplayFunction -> Identity];
pp = 
        Union[Table[
            i + (2  Random[] - 1) (((tf - ti))/(2  n)), {i, 
              ti + ((tf - ti)/n), 
              tf - ((tf - ti)/n), ((tf - ti)/n)}], {ti, 
            tf}];
xx = 
        Table[Random[], {i, 1, n}];
Riemannplot = 
        Table[Graphics[{Blue, 
              Line[{{pp[[i]], 
                    0}, {pp[[i]], h'[
                      pp[[i]] + (pp[[i + 1]] - pp[[i]]) 
                          xx[[i]]]}, {pp[[i + 1]], h'[
                      pp[[i]] + (pp[[i + 1]] - pp[[i]]) 
                          xx[[i]]]}, {pp[[i + 1]], 0}, {pp[[i]], 
                    0}}]}], {i, 1, n}];
Show[
        Riemannplot, growthplot, DisplayFunction -> $DisplayFunction, 
        Axes -> 
          True];
\(Print[\*""(∑_(i = 1)^n)y[\!\(t\&~\_i\)]Δ(Subscript[t, i]) ≃ "", ∑\+\(i = 1\)\%n\( h'\)[
              pp[\([i]\)] + \((pp[\([i + 1]\)] - pp[\([i]\)])\) 
                  xx[\([i]\)]] \((pp[\([i + 1]\)] - 
                pp[\([i]\)])\)];\)
Print["h[x] - \
h[0] ≃ ", 
        h[x] - h[0]];
Print["n = ", 
        n, "  and  x = ", x];

The second program has additional randomness.  It selects (Subscript[t, i])'s and \(TraditionalForm\`\(t\_i\)\&~\)'s at random, regardless of the size of Δ (Subscript[t, i])'s.  Probabilistically, Δ (Subscript[t, i]) -> 0, as n -> ∞, most of the time, but there is no guarantee.  Consequently, the approximation is less accurate.  This program, however, provides arbitrary Riemann sums for arbitrary partition.

Clear[h, t, x, i, n];
x = 15; n = 20;
ti = 0; 
    tf = x;
h[
          t_] = ((260.0/(1 +  1.0 Exp[-0.25 t])) - 
              80.0) (1 - (1/10.0) 
                Exp[-((((t - 11.0))^2)/20.0)]);
growthplot = 
        Plot[{h'[t]}, {t, -1, 25},  PlotStyle -> {Red}, 
          DisplayFunction -> Identity];
pp = 
        Union[Table[ti + (tf - ti) Random[], {i, 1, n - 1}], {ti, 
            tf}];
xx = 
        Table[Random[], {i, 1, n}];
Riemannplot = 
        Table[Graphics[{Blue, 
              Line[{{pp[[i]], 
                    0}, {pp[[i]], h'[
                      pp[[i]] + (pp[[i + 1]] - pp[[i]]) 
                          xx[[i]]]}, {pp[[i + 1]], h'[
                      pp[[i]] + (pp[[i + 1]] - pp[[i]]) 
                          xx[[i]]]}, {pp[[i + 1]], 0}, {pp[[i]], 
                    0}}]}], {i, 1, n}];
Show[
        growthplot, Riemannplot, 
        DisplayFunction -> $DisplayFunction];
\(Print[\*""(∑_(i = 1)^n)y[\!\(t\&~\_i\)]Δ(Subscript[t, i]) ≃ "", ∑\+\(i = 1\)\%n\( h'\)[
              pp[\([i]\)] + \((pp[\([i + 1]\)] - pp[\([i]\)])\) 
                  xx[\([i]\)]] \((pp[\([i + 1]\)] - 
                pp[\([i]\)])\)];\)
Print["h[x] - \
h[0] ≃ ", 
        h[x] - h[0]];
Print["n = ", 
        n, "  and  x = ", x];

By taking Δ (Subscript[t, i]) -> 0, the sum of area of the rectangles (the Riemann sum) approaches the (signed) area under the graph of y(t) = h' (t).  Consequently, (eq:7.1.2-5) becomes,

h(x) - 
          h(0) = The (signed) area under y = 
          h' (t) in [0, x].

The limit of Riemann sums (as Δ (Subscript[t, i]) -> 0) is called the definite integral.  It is visualized as the signed area under a graph, whenever a graph can be plotted.  The concepts of Riemann sums and the definite integral stays valid, though, even when it is impossible to plot graph.  We will discuss more about Riemann sums and the definition of the definite integral in the next subsection.

The example we discussed in 7.1.1 and 7.1.2 does not go below the x-axis.  Therefore, it was easier to understand for beginners, but it did not show the concept of signed area completely.  Let us study this concept through the following example.

Example 7.1.3.

Suppose the following graph represents the daily profit of your business venture for 10 years.

Clear[f, x];
f[x_] = (Sqrt[x]) ((Sqrt[x]) + Sin[((x + 1)/2)]) - 
          3;
Plot[f[x], {x, 0, 10}, PlotStyle -> {Blue}, 
        PlotRange -> All];

Find the total asset (accumulated profit) of this venture after 2 years, 3 years, 4 years and 10 years.

Solution.

Here is the given graph again.

Clear[f, x];
f[x_] = (Sqrt[x]) ((Sqrt[x]) + Sin[((x + 1)/2)]) - 
          3;
{zero} = {x} /. 
          FindRoot[f[x] == 0, {x, 2}];
fplus[x_] = Max[0, f[x]];
fminus[x_] = Min[0, f[x]];
plusplot = 
        Plot[f[x], {x, zero, 10}, PlotStyle -> Blue, 
          DisplayFunction -> Identity];
minusplot = 
      Plot[f[x], {x, 0, zero}, PlotStyle -> Red, 
        DisplayFunction -> Identity]; 
    Show[plusplot, minusplot, 
      DisplayFunction -> $DisplayFunction];

The y value represents your profit for the day.  The 10 years of accumulated wealth from this business is represented by the signed area under the curve.  The business started slow, losing money at first.  This is represented by the negative y value for x ≲ 2.  The total loss for the first couple of years is measured by the signed area of the region under the graph between x = 0 and x = 2.

curveplot = 
        Plot[f[x], {x, 2, 2.2}, PlotStyle -> Blue, 
          DisplayFunction -> Identity];
plusplot = 
        FilledPlot[fplus[x], {x, 0, 2}, PlotStyle -> {Blue}, 
          Fills -> {RGBColor[0.6, 0.7, 1]}, 
          DisplayFunction -> Identity];
minusplot = 
        FilledPlot[fminus[x], {x, 0, 2}, PlotStyle -> {Red}, 
          Fills -> {RGBColor[1, 0.6, 0.7]}, 
          DisplayFunction -> Identity];
Show[plusplot, minusplot, curveplot, PlotRange -> All, 
        AspectRatio -> Automatic, 
        DisplayFunction -> $DisplayFunction];
Print["Accumulated Profit ≃ ", 
        NIntegrate[f[x], {x, 0, 2}]];

After a tough couple of years, your venture began to make profit.  However, the accumulated profit still stays negative after 3 years.

curveplot = 
        Plot[f[x], {x, 3, 3.2}, PlotStyle -> Blue, 
          DisplayFunction -> Identity];
plusplot = 
        FilledPlot[fplus[x], {x, 0, 3}, PlotStyle -> {Blue}, 
          Fills -> {RGBColor[0.6, 0.7, 1]}, 
          DisplayFunction -> Identity];
minusplot = 
        FilledPlot[fminus[x], {x, 0, 3}, PlotStyle -> {Red}, 
          Fills -> {RGBColor[1, 0.6, 0.7]}, 
          DisplayFunction -> Identity];
Show[plusplot, minusplot, curveplot, PlotRange -> All, 
        AspectRatio -> Automatic, 
        DisplayFunction -> $DisplayFunction];
Print["Accumulated Profit ≃ ", 
        NIntegrate[f[x], {x, 0, 3}]];

At the end of the fourth year, you have made up all your initial loss and your venture stabilizes.

curveplot = 
        Plot[f[x], {x, 4, 4.2}, PlotStyle -> Blue, 
          DisplayFunction -> Identity];
plusplot = 
        FilledPlot[fplus[x], {x, 0, 4}, PlotStyle -> {Blue}, 
          Fills -> {RGBColor[0.6, 0.7, 1]}, 
          DisplayFunction -> Identity];
minusplot = 
        FilledPlot[fminus[x], {x, 0, 4}, PlotStyle -> {Red}, 
          Fills -> {RGBColor[1, 0.6, 0.7]}, 
          DisplayFunction -> Identity];
Show[plusplot, minusplot, curveplot, PlotRange -> All, 
        AspectRatio -> Automatic, 
        DisplayFunction -> $DisplayFunction];
Print["Accumulated Profit ≃ ", 
        NIntegrate[f[x], {x, 0, 4}]];

Here is the total profit in 10 years.

curveplot = 
        Plot[f[x], {x, 10, 10.2}, PlotStyle -> Blue, 
          DisplayFunction -> Identity];
plusplot = 
        FilledPlot[fplus[x], {x, 0, 10}, PlotStyle -> {Blue}, 
          Fills -> {RGBColor[0.6, 0.7, 1]}, 
          DisplayFunction -> Identity];
minusplot = 
        FilledPlot[fminus[x], {x, 0, 10}, PlotStyle -> {Red}, 
          Fills -> {RGBColor[1, 0.6, 0.7]}, 
          DisplayFunction -> Identity];
Show[plusplot, minusplot, curveplot, PlotRange -> All, 
        AspectRatio -> Automatic, 
        DisplayFunction -> $DisplayFunction];
Print["Accumulated Profit ≃ ", 
        NIntegrate[f[x], {x, 0, 10}]];

Now, things are really looking up!

7.1.4.  Summary

As pointed out in Example 7.1.3, the signed area measures accumulation, whereas the slope measures the rate of change.  The former is quantified by a quantity called definite integral, while the latter is quantified by derivatives.  The process to calculate the definite integral (integration) and the process to find the derivative (differentiation) are mutually inverse, as explained in 7.1.1 and 7.1.2.  Thus, antidifferentiation (integration) and antiderivatives (indefinite integrals) are key ingredients to study definite integrals (signed areas).

(7.2)  Riemann sums and the definite integral.

7.2.1.  Partition.

A finite subset P of a closed interval [a, b] is called a partition of [a, b] if P includes the endpoints a and b.  That is,

P = {(Subscript[x, 0]), (Subscript[x, 1]), ⋯ , (Subscript[x, n - 1]), 
          (Subscript[x, n])},

where

a = (Subscript[x, 0]) < (Subscript[x, 1]) < ⋯  < 
            (Subscript[x, n - 1]) < (Subscript[x, n]) = b.

7.2.2.  Riemann sum.

A Riemann sum is a finite sum that approximates the signed area under a graph of a function in an interval.  The general form of a Riemann sum of the function f with respect to a partition P = {(Subscript[x, 0]), (Subscript[x, 1]), ⋯ , (Subscript[x, n - 1]), 
          (Subscript[x, n])} is the following.

\(TraditionalForm\`R(f, 
          P) = ∑\+\(i = 1\)\%n\( f(
              x\&~\_i)\) \((x\_i - x\_\(i - 1\))\)\),  where  \(TraditionalForm\`x\_\(i - 1\) ≤ x\&~\_i ≤ 
        x\_i\).

The Riemann sum R(f, P) can be written alternatively as

\(TraditionalForm\`R(f, 
          P) = ∑\+\(i = 1\)\%n y\&~\_i\ Δ\ x\_i\),  where  \(TraditionalForm\`y\&~\_i = f(x\&~\_i)\),  Δ (Subscript[x, i]) = (Subscript[x, i]) - (Subscript[x, i - 1]).

Thus, in the graph y = f(x), the Riemann sum R(f, P) stands for the sum of the area of the rectangles, because \(TraditionalForm\`y\&~\_i\) and Δ (Subscript[x, i]) represent the height and width of the individual rectangles illustrated below.

The first program is the standard program.  It selects an arbitrary partition P = {(Subscript[x, 0]), (Subscript[x, 1]), ⋯ , (Subscript[x, n - 1]), 
          (Subscript[x, n])}, for given n value, and then selects arbitrary \(TraditionalForm\`x\&~\_i\)'s to form a Riemann sum.

Clear[f, x, i, a, b, 
        n];
f[x_] = (Sqrt[x]) ((x/2) + Sin[x]) - 
          1.5;
a = 0; b = 5; 
    n = 10;
curveplot=Plot[f[x],{x, a, b},
	  PlotStyle -> {{Blue, Thickness[0.01]}},DisplayFunction -> Identity];
pp = 
        Union[Table[a + (b - a) Random[], {i, 1, n - 1}], {a, 
            b}];
xx = 
        Table[pp[[i]] + (pp[[i + 1]] - pp[[i]]) Random[], {i, 
            1, n}];
Riemannplot = 
        Table[Graphics[{Red, 
              Line[{{pp[[i]], 0}, {pp[[i]], 
                    f[xx[[i]]]}, {pp[[i + 1]], 
                    f[xx[[i]]]}, {pp[[i + 1]], 0}, {pp[[i]], 
                    0}}]}], {i, 1, n}];
Show[
        Riemannplot, curveplot, DisplayFunction -> $DisplayFunction, 
        Axes -> 
          True];
\(Print[\*""(∑_(i = 1)^n)y[\!\(t\&~\_i\)]Δ(Subscript[t, i]) ≃ "", ∑\+\(i = 1\)\%n f[
              xx[\([i]\)]] \((pp[\([i + 1]\)] - 
                pp[\([i]\)])\), "     (n = ", 
        n, ")"];\)
\(Print[\*""(∫_a^b)f[x]\[DifferentialD]x ≃ "", 
        NIntegrate[f[x], {x, a, b}]];\)

The second program yields less arbitrary Riemann sum.  The width of the rectangles Δ (Subscript[x, i])'s are all bounded by 2 (b  -  a)/n.

Clear[f, x, i, a, b, 
        n];
f[x_] = (Sqrt[x]) ((x/2) + Sin[x]) - 
          1.5;
a = 0; b = 5; 
    n = 10;
curveplot=Plot[f[x],{x, a, b},
	  PlotStyle -> {{Blue, Thickness[0.01]}},DisplayFunction -> Identity];
pp = 
        Union[Table[
            i + (2  Random[] - 1) (((b - a))/(2  n)), {i, 
              a + ((b - a)/n), b - ((b - a)/n), ((b - a)/n)}], {a, 
            b}];
xx = 
        Table[pp[[i]] + (pp[[i + 1]] - pp[[i]]) Random[], {i, 
            1, n}];
Riemannplot = 
        Table[Graphics[{Red, 
              Line[{{pp[[i]], 0}, {pp[[i]], 
                    f[xx[[i]]]}, {pp[[i + 1]], 
                    f[xx[[i]]]}, {pp[[i + 1]], 0}, {pp[[i]], 
                    0}}]}], {i, 1, n}];
Show[
        Riemannplot, curveplot, DisplayFunction -> $DisplayFunction, 
        Axes -> 
          True];
\(Print[\*""(∑_(i = 1)^n)y[\!\(t\&~\_i\)]Δ(Subscript[t, i]) ≃ "", ∑\+\(i = 1\)\%n f[
              xx[\([i]\)]] \((pp[\([i + 1]\)] - 
                pp[\([i]\)])\), "     (n = ", 
        n, ")"];\)
\(Print[\*""(∫_a^b)f[x]\[DifferentialD]x ≃ "", 
        NIntegrate[f[x], {x, a, b}]];\)

The third program yields even more specific families of Riemann sums.  The width of the rectangles Δ (Subscript[x, i])'s are all identical.  That is, Δ (Subscript[x, i]) = (b - a)/n.  Lower level calculus books consider only these types of Riemann sums for simplicity.

In other words, we consider only the Riemann sums of the following type.

\(TraditionalForm\`R(f, 
          P) = \(∑\+\(i = 1\)\%n y\&~\_i\ Δ\ x\_i = ∑\+\(i = 1\)\%n\( f(x\&~\_i)\)\ \(b\  - \ a\)\/n\)\).

Clear[f, x, i, a, b, 
        n];
f[x_] = (Sqrt[x]) ((x/2) + Sin[x]) - 
          1.5;
a = 0; b = 5; 
    n = 10;
curveplot=Plot[f[x],{x, a, b},
	  PlotStyle -> {{Blue, Thickness[0.01]}},DisplayFunction -> Identity];
pp = 
        Table[i, {i, a, b, ((b - a)/n)}];
xx = 
        Table[pp[[i]] + (pp[[i + 1]] - pp[[i]]) Random[], {i, 
            1, n}];
Riemannplot = 
        Table[Graphics[{Red, 
              Line[{{pp[[i]], 0}, {pp[[i]], 
                    f[xx[[i]]]}, {pp[[i + 1]], 
                    f[xx[[i]]]}, {pp[[i + 1]], 0}, {pp[[i]], 
                    0}}]}], {i, 1, n}];
Show[
        Riemannplot, curveplot, DisplayFunction -> $DisplayFunction, 
        Axes -> 
          True];
\(Print[\*""(∑_(i = 1)^n)y[\!\(t\&~\_i\)]Δ(Subscript[t, i]) ≃ "", ∑\+\(i = 1\)\%n f[
              xx[\([i]\)]] \((pp[\([i + 1]\)] - 
                pp[\([i]\)])\), "     (n = ", 
        n, ")"];\)
\(Print[\*""(∫_a^b)f[x]\[DifferentialD]x ≃ "", 
        NIntegrate[f[x], {x, a, b}]];\)

Finally, here is the fourth set of programs that yield Riemann sums with no randomness.  Instead of taking any \(TraditionalForm\`x\&~\_i\) at random within the interval [(Subscript[x, i - 1]), (Subscript[x, i])], we take \(TraditionalForm\`x\&~\_i = x\_\(i - 1\)\) (the left endpoint), \(TraditionalForm\`x\&~\_i = x\_i\) (the right endpoint), and \(TraditionalForm\`x\&~\_i = \((x\_i - x\_\(i - 1\))\)/2\) (the midpoint), respectively.  These methods are useful when calculating definite integrals numerically (Section 4).

The Left Riemann Sum.

Clear[f, x, i, a, b, 
        n];
f[x_] = (Sqrt[x]) ((x/2) + Sin[x]) - 
          1.5;
a = 0; b = 5; 
    n = 10;
curveplot=Plot[f[x],{x, a, b},
	  PlotStyle -> {{Blue, Thickness[0.01]}},DisplayFunction -> Identity];
pp = 
        Table[i, {i, a, 
            b, ((b - a)/n)}];
Riemannplot = 
        Table[Graphics[{Red, 
              Line[{{pp[[i]], 0}, {pp[[i]], 
                    f[pp[[i]]]}, {pp[[i + 1]], 
                    f[pp[[i]]]}, {pp[[i + 1]], 0}, {pp[[i]], 
                    0}}]}], {i, 1, n}];
Show[
        Riemannplot, curveplot, DisplayFunction -> $DisplayFunction, 
        Axes -> 
          True];
\(Print[\*""The left Riemann sum, (∑_(i = 1)^n)y[\!\(t\&~\_i\)]Δ(Subscript[t, i]) ≃ "", ∑\+\(i = 1\)\%n f[
              pp[\([i]\)]] \((pp[\([i + 1]\)] - 
                pp[\([i]\)])\), "     (n = ", 
        n, ")"];\)
\(Print[\*""(∫_a^b)f[x]\[DifferentialD]x ≃ "", 
        NIntegrate[f[x], {x, a, b}]];\)

The Right Riemann Sum.

Clear[f, x, i, a, b, 
        n];
f[x_] = (Sqrt[x]) ((x/2) + Sin[x]) - 
          1.5;
a = 0; b = 5; 
    n = 10;
curveplot=Plot[f[x],{x, a, b},
	  PlotStyle -> {{Blue, Thickness[0.01]}},DisplayFunction -> Identity];
pp = 
        Table[i, {i, a, 
            b, ((b - a)/n)}];
Riemannplot = 
        Table[Graphics[{Red, 
              Line[{{pp[[i]], 0}, {pp[[i]], 
                    f[pp[[i + 1]]]}, {pp[[i + 1]], 
                    f[pp[[i + 1]]]}, {pp[[i + 1]], 0}, {pp[[i]], 
                    0}}]}], {i, 1, n}];
Show[
        Riemannplot, curveplot, DisplayFunction -> $DisplayFunction, 
        Axes -> 
          True];
\(Print[\*""The right Riemann sum, (∑_(i = 1)^n)y[\!\(t\&~\_i\)]Δ(Subscript[t, i]) ≃ "", ∑\+\(i = 1\)\%n f[
              pp[\([i + 1]\)]] \((pp[\([i + 1]\)] - 
                pp[\([i]\)])\), "     (n = ", 
        n, ")"];\)
\(Print[\*""(∫_a^b)f[x]\[DifferentialD]x ≃ "", 
        NIntegrate[f[x], {x, a, b}]];\)

The Midpoint Riemann Sum.

Clear[f, x, i, a, b, 
        n];
f[x_] = (Sqrt[x]) ((x/2) + Sin[x]) - 
          1.5;
a = 0; b = 5; 
    n = 10;
curveplot=Plot[f[x],{x, a, b},
	  PlotStyle -> {{Blue, Thickness[0.01]}},DisplayFunction -> Identity];
pp = 
        Table[i, {i, a, b, ((b - a)/n)}];
xx = 
        Table[i, {i, a + ((b - a)/(2  n)), 
            b - ((b - a)/(2  n)), ((b - a)/n)}];
Riemannplot = 
        Table[Graphics[{Red, 
              Line[{{pp[[i]], 0}, {pp[[i]], 
                    f[xx[[i]]]}, {pp[[i + 1]], 
                    f[xx[[i]]]}, {pp[[i + 1]], 0}, {pp[[i]], 
                    0}}]}], {i, 1, n}];
Show[
        Riemannplot, curveplot, DisplayFunction -> $DisplayFunction, 
        Axes -> 
          True];
\(Print[\*""The midpoint Riemann sum, (∑_(i = 1)^n)y[\!\(t\&~\_i\)]Δ(Subscript[t, i]) ≃ "", ∑\+\(i = 1\)\%n f[
              xx[\([i]\)]] \((pp[\([i + 1]\)] - 
                pp[\([i]\)])\), "     (n = ", 
        n, ")"];\)
\(Print[\*""(∫_a^b)f[x]\[DifferentialD]x = "", 
        NIntegrate[f[x], {x, a, b}]];\)

The third program in this set, the midpoint Riemann sum, will turn out important in Section 4, numerical integration.  Also, the first two programs can be modified to yield the following program that approximates the definite integral through the sum of the areas of trapezoids.  This is not a Riemann sum, but it approximates the definite integrals just as well, and at times, better.  Again, this approximation method will be discussed in detail

The Trapezoid approximation.

Clear[f, x, i, a, b, 
        n];
f[x_] = (Sqrt[x]) ((x/2) + Sin[x]) - 
          1.5;
a = 0; b = 5; 
    n = 10;
curveplot=Plot[f[x],{x, a, b + 0.1},
	  PlotStyle -> {{Blue, Thickness[0]}},DisplayFunction -> Identity];
regionplot=FilledPlot[f[x],{x, a, b},
	  PlotStyle -> {{Blue, Thickness[0]}},Fills -> {RGBColor[0.5, 0.75, 1]},DisplayFunction -> Identity];
pp = 
        Table[i, {i, a, 
            b, ((b - a)/n)}];
Riemannplot = 
        Table[Graphics[{Red, Thickness[0.01], 
              Line[{{pp[[i]], 0}, {pp[[i]], 
                    f[pp[[i]]]}, {pp[[i + 1]], 
                    f[pp[[i + 1]]]}, {pp[[i + 1]], 0}, {pp[[i]], 
                    0}}]}], {i, 1, n}];
Show[
        regionplot, Riemannplot, curveplot, 
        DisplayFunction -> $DisplayFunction, 
        Axes -> 
          True];
Print["The trepezoid \
approximation = ", (∑_(i = 1)^n)(( f[pp[[i]]] + 
                  f[pp[[i + 1]]])/2) (pp[[i + 1]] - 
                pp[[i]]), "     (n = ", 
        n, ")"];
\(Print[\*""(∫_a^b)f[x]\[DifferentialD]x ≃ "", 
        NIntegrate[f[x], {x, a, b}]];\)

7.2.3.  Riemann sums and definite integrals.

A finite subset P of a closed interval [a, b] is called a partition of [a, b] if P includes the endpoints a and b.  That is,

P = {(Subscript[x, 0]), (Subscript[x, 1]), ⋯ , (Subscript[x, n - 1]), 
          (Subscript[x, n])},

where

a = (Subscript[x, 0]) < (Subscript[x, 1]) < ⋯  < 
            (Subscript[x, n - 1]) < (Subscript[x, n]) = b.

A Riemann sum R(f, P) of f in the closed interval [a, b] with respect to the partition P is defined as

\(TraditionalForm\`R(f, 
          P) = ∑\+\(i = 1\)\%n\( f(
              x\&~\_i)\) \((x\_i - x\_\(i - 1\))\)\),  where  \(TraditionalForm\`x\_\(i - 1\) ≤ x\&~\_i ≤ 
        x\_i\).

It can be written alternatively as

\(TraditionalForm\`R(f, 
          P) = ∑\+\(i = 1\)\%n y\&~\_i\ Δ\ x\_i\),  where  \(TraditionalForm\`y\&~\_i = f(x\&~\_i)\),  Δ (Subscript[x, i]) = (Subscript[x, i]) - (Subscript[x, i - 1]).

In general, the selection of the partition P = {(Subscript[x, 0]), (Subscript[x, 1]), ⋯ , (Subscript[x, n - 1]), 
          (Subscript[x, n])} and the choice of \(TraditionalForm\`x\&~\_i\) in each interval [(Subscript[x, i - 1]), (Subscript[x, i])] is arbitrary, as illustrated by the following program.

Clear[f, x, i, a, b, 
        n];
f[x_] = (Sqrt[x]) ((x/2) + Sin[x]) - 
          1.5;
a = 0; b = 5; 
    n = 10;
curveplot=Plot[f[x],{x, a, b},
	  PlotStyle -> {{Blue, Thickness[0.01]}},DisplayFunction -> Identity];
pp = 
        Union[Table[a + (b - a) Random[], {i, 1, n - 1}], {a, 
            b}];
xx = 
        Table[pp[[i]] + (pp[[i + 1]] - pp[[i]]) Random[], {i, 
            1, n}];
Riemannplot = 
        Table[Graphics[{Red, 
              Line[{{pp[[i]], 0}, {pp[[i]], 
                    f[xx[[i]]]}, {pp[[i + 1]], 
                    f[xx[[i]]]}, {pp[[i + 1]], 0}, {pp[[i]], 
                    0}}]}], {i, 1, n}];
Show[
        Riemannplot, curveplot, DisplayFunction -> $DisplayFunction, 
        Axes -> 
          True];
\(Print[\*""(∑_(i = i)^n)f[\!\(x\&~\_i\)]Δ(Subscript[x, i]) ≃ "", ∑\+\(i = 1\)\%n f[
              xx[\([i]\)]] \((pp[\([i + 1]\)] - 
                pp[\([i]\)])\), "     (n = ", 
        n, ")"];\)
\(Print[\*""(∫_a^b)f[x]\[DifferentialD]x ≃ "", 
        NIntegrate[f[x], {x, a, b}]];\)

However, the general definition of the Riemann sum contain too much randomness so that it is difficult to study it numerically.  (For instance, one gets different approximation each time one runs above program.)  In this section, therefore, let us restrict ourselves to a special type of Riemann sums that has identical Δ (Subscript[x, i])'s.  That is,

\(TraditionalForm\`R(f, 
          P) = ∑\+\(i = 1\)\%n\( f(x\&~\_i)\) Δ\ x\),  where  Δ x = (Subscript[x, i]) - 
            (Subscript[x, i - 1]) = ((b  -  a)/n).

In this case, Δ x = (b - a)/n -> 0, as n -> ∞.  Therefore, we can express the definite integral as

\(TraditionalForm\`∫\_a\%b\( f(
              x)\) dx = \(lim\_\(Δ\ x -> 0\)\(∑\+\(i = 1\)\%n\( f(x\&~\_i)\) Δ\ x\) = 
          lim\_\(n -> ∞\)\(∑\+\(i = 1\)\%n\( f(
                  x\&~\_i)\) \(b\  - \ a\)\/n\)\)\).

The following program visualizes the type of Riemann sums we consider in this section.

Clear[f, x, i, a, b, 
        n];
f[x_] = (Sqrt[x]) ((x/2) + Sin[x]) - 
          1.5;
a = 0; b = 5; 
    n = 10;
curveplot=Plot[f[x],{x, a, b},
	  PlotStyle -> {{Blue, Thickness[0.01]}},DisplayFunction -> Identity];
pp = 
        Table[i, {i, a, b, ((b - a)/n)}];
xx = 
        Table[pp[[i]] + (pp[[i + 1]] - pp[[i]]) Random[], {i, 
            1, n}];
Riemannplot = 
        Table[Graphics[{Red, 
              Line[{{pp[[i]], 0}, {pp[[i]], 
                    f[xx[[i]]]}, {pp[[i + 1]], 
                    f[xx[[i]]]}, {pp[[i + 1]], 0}, {pp[[i]], 
                    0}}]}], {i, 1, n}];
Show[
        Riemannplot, curveplot, DisplayFunction -> $DisplayFunction, 
        Axes -> 
          True];
\(Print[\*""(∑_(i = i)^n)f[\!\(x\&~\_i\)]Δ(Subscript[x, i]) ≃ "", ∑\+\(i = 1\)\%n f[
              xx[\([i]\)]] \((pp[\([i + 1]\)] - 
                pp[\([i]\)])\), "     (n = ", 
        n, ")"];\)
\(Print[\*""(∫_a^b)f[x]\[DifferentialD]x ≃ "", 
        NIntegrate[f[x], {x, a, b}]];\)

7.2.4.  Approximation formulae.

The programs in 4.1.1 are useful when studying Riemann sums, but they are useless as approximation formulae for definite integrals because of the randomness.  Readers who run the above programs multiple times will notice that the approximate answer obtained by the above programs change each time they run the programs.  We can easily negate this problem by fixing the random term \(TraditionalForm\`x\&~\_i\)'s.  The most commonly used methods are to take \(TraditionalForm\`x\&~\_i = x\_\(i - 1\)\) (the left endpoint), \(TraditionalForm\`x\&~\_i = x\_i\) (the right endpoint), and \(TraditionalForm\`x\&~\_i = \((x\_\(i - 1\) + x\_i)\)/2\) (the midpoint).

Left hand side approximation.

	(∫_a^b) f(x) dx = 
        (lim_(Δ x -> 0))(∑_(i = 1)^n) f(
                (Subscript[x, i - 1])) Δ x
\(TraditionalForm\`\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(\(=\)\(lim\_\(n -> ∞\)\(∑\+\(i = 1\)\%n\( f(
                x\_\(i - 1\))\) \(\(\(b\  - \ a\)\/n\)\(.\)\)\)\)\)\)

Clear[f, x, i, a, b, 
        n];
f[x_] = (Sqrt[x]) ((x/2) + Sin[x]) - 
          1.5;
a = 0; b = 5; 
    n = 10;
curveplot=Plot[f[x],{x, a, b},
	  PlotStyle -> {{Blue, Thickness[0.01]}},DisplayFunction -> Identity];
pp = 
        Table[i, {i, a, 
            b, ((b - a)/n)}];
Riemannplot = 
        Table[Graphics[{Red, 
              Line[{{pp[[i]], 0}, {pp[[i]], 
                    f[pp[[i]]]}, {pp[[i + 1]], 
                    f[pp[[i]]]}, {pp[[i + 1]], 0}, {pp[[i]], 
                    0}}]}], {i, 1, n}];
Show[Riemannplot, curveplot, 
          DisplayFunction -> $DisplayFunction, Axes -> True];

\(Print[\*""The left Riemann sum, (∑_(i = 1)^n)f[(Subscript[x, i - 1])]Δ(Subscript[x, i]) ≃ "", ∑\+\(i = 1\)\%n f[
              pp[\([i]\)]] \((pp[\([i + 1]\)] - 
                pp[\([i]\)])\), "     (n = ", 
        n, ")"];\)
\(Print[\*""(∫_a^b)f[x]\[DifferentialD]x ≃ "", 
        NIntegrate[f[x], {x, a, b}]];\)

Right hand side approximation.

	(∫_a^b) f(x) dx = 
        (lim_(Δ x -> 0))(∑_(i = 1)^n) f(
                (Subscript[x, i])) Δ x
\(TraditionalForm\`\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(\(=\)\(lim\_\(n -> ∞\)\(∑\+\(i = 1\)\%n\( f(
                x\_i)\) \(\(\(b\  - \ a\)\/n\)\(.\)\)\)\)\)\)

Clear[f, x, i, a, b, 
        n];
f[x_] = (Sqrt[x]) ((x/2) + Sin[x]) - 
          1.5;
a = 0; b = 5; 
    n = 10;
curveplot=Plot[f[x],{x, a, b},
	  PlotStyle -> {{Blue, Thickness[0.01]}},DisplayFunction -> Identity];
pp = 
        Table[i, {i, a, 
            b, ((b - a)/n)}];
Riemannplot = 
        Table[Graphics[{Red, 
              Line[{{pp[[i]], 0}, {pp[[i]], 
                    f[pp[[i + 1]]]}, {pp[[i + 1]], 
                    f[pp[[i + 1]]]}, {pp[[i + 1]], 0}, {pp[[i]], 
                    0}}]}], {i, 1, n}];
Show[
        Riemannplot, curveplot, DisplayFunction -> $DisplayFunction, 
        Axes -> 
          True];
\(Print[\*""The right Riemann sum, (∑_(i = 1)^n)f[(Subscript[x, i])]Δ(Subscript[x, i]) ≃ "", ∑\+\(i = 1\)\%n f[
              pp[\([i]\)]] \((pp[\([i + 1]\)] - 
                pp[\([i]\)])\), "     (n = ", 
        n, ")"];\)
\(Print[\*""(∫_a^b)f[x]\[DifferentialD]x ≃ "", 
        NIntegrate[f[x], {x, a, b}]];\)

Midpoint approximation.

	(∫_a^b) f(x) dx = 
        (lim_(Δ x -> 0))(∑_(i = 1)^n) 
                f((((Subscript[x, i - 1])  +  (Subscript[x, i]))/2)) Δ x
\(TraditionalForm\`\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(\(=\)\(lim\_\(n -> ∞\)\(∑\+\(i = 1\)\%n\( 
                f(\(x\_\(i - 1\)\  + \ x\_i\)\/2)\) \(\(\(b\  - \ 
                      a\)\/n\)\(.\)\)\)\)\)\)

Clear[f, x, i, a, b, 
        n];
f[x_] = (Sqrt[x]) ((x/2) + Sin[x]) - 
          1.5;
a = 0; b = 5; 
    n = 10;
curveplot=Plot[f[x],{x, a, b},
	  PlotStyle -> {{Blue, Thickness[0.01]}},DisplayFunction -> Identity];
pp = 
        Table[i, {i, a, b, ((b - a)/n)}];
xx = 
        Table[i, {i, a + ((b - a)/(2  n)), 
            b - ((b - a)/(2  n)), ((b - a)/n)}];
Riemannplot = 
        Table[Graphics[{Red, 
              Line[{{pp[[i]], 0}, {pp[[i]], 
                    f[xx[[i]]]}, {pp[[i + 1]], 
                    f[xx[[i]]]}, {pp[[i + 1]], 0}, {pp[[i]], 
                    0}}]}], {i, 1, n}];
Show[
        Riemannplot, curveplot, DisplayFunction -> $DisplayFunction, 
        Axes -> 
          True];
\(Print[\*""The midpoint Riemann sum, (∑_(i = 1)^n)f[(((Subscript[x, i - 1]) + (Subscript[x, i]))/2)]Δ(Subscript[x, i]) ≃ "", ∑\+\(i = 1\)\%n f[pp[\([i]\)]] \((pp[\([i + 1]\)] - pp[\([i]\)])\), "     (n = ", 
        n, ")"];\)
\(Print[\*""(∫_a^b)f[x]\[DifferentialD]x ≃ "", 
        NIntegrate[f[x], {x, a, b}]];\)

The first two methods have smaller number of calculations, while the third method requires an additional step, ((Subscript[x, i - 1]) + (Subscript[x, i]))/2 for each i.  That may have been a disadvantage in 18th century, but not any more, thanks to computers.  We will study the third method in more detail in the next subsection.

7.2.5.  Definite integral.

With the help of Riemann sums, we can define the definite integral of a function f in a closed interval [a, b] without help of the graph and the signed area.

\(TraditionalForm\`∫\_a\%b\( f(x)\) dx = 
        lim\_\(Δ\ x -> 0\)\(∑\+\(i = 1\)\%n\( f(
                x\&~\_i)\) Δ\ x\_i\)\),  where  Δ x = Max Δ (Subscript[x, i]).

Since Δ x -> 0, it is necessary that n -> ∞.  But it is not necessarily vice versa.  Note also that the symbol dx is frequently referred as the infinitesimal difference.  For instance, in differentiation,

\(TraditionalForm\`\(Δ\ y\)\/\(Δ\ x\) -> dy\/dx\).

In integration, as the finite difference Δ x turns the infinitesimal difference dx, the discrete sum ∑ turns the continuous sum ∫.  In fact, the integral symbol ∫ was obtained by stretching the alphabet S, the initial of "Sum".

∑->∫,  as  Δ x -> dx.

If the above limit exists, we call it the definite integral of f in [a, b].  The function f is called the integrand of the definite integral.

We say the function is integrable if the above limit converges.  It is known that every continuous function is integrable, and so is every piecewise continuous function.  However, we can deal with the integrability of functions so complicated it is nearly impossible to approach graphically.  Therefore, it is not wise to attempt defining definite integrals graphically.

7.2.6.  Overestimation and underestimation.

Since we can take arbitrary partition P = {(Subscript[x, 0]), (Subscript[x, 1]), ⋯ , (Subscript[x, n - 1]), 
          (Subscript[x, n])} and then take arbitrary \(TraditionalForm\`x\&~\_i\)'s, there are uncountablely many Reimann sums for one given function f in a closed interval [a, b].  Among them, two classes of Riemann  sums are particularly interesting.

By taking the largest possible \(TraditionalForm\`y\&~\_i = f(x\&~\_i)\) in each interval [(Subscript[x, i - 1]), (Subscript[x, i])], we can overestimate the signed area.  We call these Riemann sums, upper (Riemann) sums.

U(f, 
          P) = (∑_i) (Subscript[M, i]) Δ (Subscript[x, i]),  where  (Subscript[M, i])  is the maximum of  \(TraditionalForm\`f(x\&~\_i)\)'s  in  [(Subscript[x, i - 1]), (Subscript[x, i])].

Clear[f, x, i, a, b];
a = 0;   b = 
      1;
partitionNo = 
        10;
f[x_] = - (x^4) -  (x^3) + 
          2 (x^2);
curveplot=Plot[f[x],{x, -0.2, 1.02},AspectRatio -> 1/GoldenRatio,
	  PlotStyle -> {{Red}},AxesLabel -> {"x", ""},DisplayFunction -> Identity];

rectangleplot1 = 
        Graphics[{Blue, 
Line[{  {0, 0}, {0.2, 0}, {0.2, 
                  f[0.2]}, {0, f[0.2]}, {0, 
                  0}
}]}];
rectangleplot2 = 
        Graphics[{Blue, 
Line[{  {0.2, 0}, {0.4, 
                  0}, {0.4, f[0.4]}, {0.2, f[0.4]}, {0.2, 
                  0}
}]}];
rectangleplot3 = 
        Graphics[{Blue, 
Line[{  {0.4, 0}, {0.5, 
                  0}, {0.5, f[0.5]}, {0.4, f[0.5]}, {0.4, 
                  0}
}]}];
rectangleplot4 = 
        Graphics[{Blue, 
Line[{  {0.5, 0}, {0.8, 
                  0}, {0.8, f[(1/8) (-3 + (Sqrt[73]))]}, {0.5, 
                  f[(1/8) (-3 + (Sqrt[73]))]}, {0.5, 
                  0}
}]}];
rectangleplot5 = 
        Graphics[{Blue, 
Line[{  {0.8, 0}, {0.95, 
                  0}, {0.95, f[0.8]}, {0.8, f[0.8]}, {0.8, 
                  0}
}]}];
rectangleplot6 = 
        Graphics[{Blue, 
Line[{  {0.95, 0}, {1, 0}, {1, 
                  f[0.95]}, {0.95, f[0.95]}, {0.95, 
                  0}
}]}];
UpperPlot = 
        Show[rectangleplot1, rectangleplot2, rectangleplot3, rectangleplot4, 
          rectangleplot5, rectangleplot6, curveplot, Axes -> True, 
          DisplayFunction -> $DisplayFunction];

Similarly, let us underestimate the signed area by selecting \(TraditionalForm\`y\&~\_i\)'s the lowest possible values.  We call these Riemann sums, lower (Riemann) sums.

L(f, 
          P) = (∑_i) (Subscript[m, i]) Δ (Subscript[x, i]),  where  (Subscript[m, i])  is the minimum of  \(TraditionalForm\`f(x\&~\_i)\)'s  in  [(Subscript[x, i - 1]), (Subscript[x, i])].

Clear[f, x, i, a, b];
a = 0;   b = 
      1;
partitionNo = 
        10;
f[x_] = - (x^4) -  (x^3) + 
          2 (x^2);
curveplot=Plot[f[x],{x, -0.2, 1.02},AspectRatio -> 1/GoldenRatio,
	  PlotStyle -> {{Red}},AxesLabel -> {"x", ""},DisplayFunction -> Identity];

rectangleplot1 = 
        Graphics[{DarkGreen, 
Line[{  {0, 0}, {0.2, 
                  0}
}]}];
rectangleplot2 = 
        Graphics[{DarkGreen, 
Line[{  {0.2, 0}, {0.4, 
                  0}, {0.4, f[0.2]}, {0.2, f[0.2]}, {0.2, 
                  0}
}]}];
rectangleplot3 = 
        Graphics[{DarkGreen, 
Line[{  {0.4, 0}, {0.5, 
                  0}, {0.5, f[0.4]}, {0.4, f[0.4]}, {0.4, 
                  0}
}]}];
rectangleplot4 = 
        Graphics[{DarkGreen, 
Line[{  {0.5, 0}, {0.8, 
                  0}, {0.8, f[0.5]}, {0.5, f[0.5]}, {0.5, 
                  0}
}]}];
rectangleplot5 = 
        Graphics[{DarkGreen, 
Line[{  {0.8, 0}, {0.95, 
                  0}, {0.95, f[0.95]}, {0.8, f[0.95]}, {0.8, 
                  0}
}]}];
rectangleplot6 = 
          Graphics[{DarkGreen, 
Line[{  {0.95, 0}, {01, 
                    0}
}]}];

LowerPlot = 
        Show[rectangleplot1, rectangleplot2, rectangleplot3, rectangleplot4, 
          rectangleplot5, rectangleplot6, curveplot, Axes -> True, 
          DisplayFunction -> $DisplayFunction];

Since,

\(TraditionalForm\`\(\(\ \)\(m\_i ≤ f(x\&~\_i) ≤ 
      M\_i\)\)\)

for each i = 1, ⋯ , n, we must have,

L(f, P) ≤ R(f, P) ≤ 
        U(f, P).

Show[GraphicsArray[{LowerPlot, UpperPlot}],  
        DisplayFunction -> $DisplayFunction];
Show[UpperPlot, LowerPlot, Axes -> True, 
        DisplayFunction -> $DisplayFunction];

It can be proved that lower sums increase and always converge to a certain fixed value as the partition gets finer (that is, add more points to the partition, consequently reducing the width of the rectangles).   We call the limit the lower integral of f in [a, b] and denote

\(TraditionalForm\`\(∫\_a\%b\+-\)\(f(
            x)\) dx\).

Similarly, upper sums decrease to a certain limit as the partition gets finer.  This limit is called the upper integral of f in [a, b].  We denote the upper integral as

\(TraditionalForm\`\(∫\_a\%b\&-\)\(f(
            x)\) dx\).

The lower integral is the limit value obtained by underestimating, while the upper integral is the limit given by overestimation.  Therefore,

\(TraditionalForm\`\(∫\_a\%b\+-\)\(f(
              x)\) dx ≤ \(∫\_a\%b\&-\)\(f(
              x)\) dx\).

The limits given by other Riemann sums fall in between the two.  Therefore, if the lower integral and the upper integral are the same, then the limit of every Riemann sum converge to the same limit, by the sandwich rule.  In other words, we can define the integrability in the following alternative fashion.

f  is integrable in  [a, b]  if  \(TraditionalForm\`\(∫\_a\%b\+-\)\(f(
              x)\) dx = \(∫\_a\%b\&-\)\(f(
              x)\) dx\).

Remark.

Maxima and minima do not always exist.  To be more precise, therefore, we must define upper sums and lower sums as

U(f, 
          P) = (∑_(i = 1)^n) (Subscript[M, i]) Δ (Subscript[x, i]),  where  (Subscript[M, i])  is the supremum of  f[(Subscript[x, i - 1]), (Subscript[x, i])].

L(f, 
          P) = (∑_(i = 1)^n) (Subscript[m, i]) Δ (Subscript[x, i]),  where  (Subscript[m, i])  is the infimum of  f[(Subscript[x, i - 1]), (Subscript[x, i])].

(7.3)  The fundamental theorem of calculus.

Calculating definite integrals directly from the definition is very difficult in general.  The following theorem allows us to calculate definite integrals easily from indefinite integrals (anti-derivatives).

Theorem 7.3.1.  The Fundamental Theorem of Calculus.

Suppose f : [a, b] -> ℝ is a continuous function.  Then f is integrable in [a, b], and it has an antiderivative F : [a, b] -> ℝ, F' (x) = f(x) in (a, b).  Moreover,

(∫_a^b) f(x) dx = 
        F(b) - F(a).

Graphically, the fundamental theorem of calculus tells us that taking slope (differentiation) and taking signed area (integration) are inverse of each other.

Example 7.3.2.

Calculate the following definite integrals.

\(TraditionalForm\`∫\_0\%1\((x\^2 - e\^x - \@x)\) dx = ?\)

(∫_0^1)((x^2) - (e^x) - 
              (x^(1/2))) dx
=(Subscript[([(1/3) 
                  (x^3) - (e^x) - (2/3) 
                  (x^(3/2))]), 0]^1)
\(TraditionalForm\`\(\(=\)\(\((1\/3×1\^3 - e\^1 - 
              2\/3×1\^\(3/2\))\) - \((1\/3×0\^3 - e\^0 - 2\/3×0\^\(3/2\))\)\)\)\)
=(1 - e - (2/3)) - (0 - 
                1 - 0) = (2/3) - e.

(∫_0^1)((x^2) - (E^x) - (Sqrt[x])) \[DifferentialD]x

(∫_0^1)((1/(2  -  x)) - 
                Sin[π x] - (Sqrt[3  x + 1])) dx = ?

\(TraditionalForm\`∫\_0\%1\((\(-\(1\/\(x\  - \ 2\)\)\) - 
              Sin[π\ x] - \((3  x + 1)\)\^\(1/2\))\) dx\)

\(TraditionalForm\`\(\(=\)\(\([\(-Log\) | 
                x\  - \ 2 | \(+\(1\/π\)\) 
                    Cos[π\ x] - \(2\/3\) \(1\/3\) \((3  x + 1)\)\^\(3/2\)]\)\_0\%1\)\)\)

\(TraditionalForm\`\(\(=\)\((\(-Log\) | 
            1\  - \ 2 | \(+\(1\/π\)\) 
                Cos[1  π] - \(2\/3\) \(1\/3\) \((3×1 + 1)\)\^\(3/2\))\)\)\)
\(TraditionalForm\`\ \ \ \ \(-\ \((\(-Log\) | 
            0 - 2 | \(+\(1\/π\)\) 
                Cos[0  π] - \(2\/3\) \(1\/3\) \((3×0 + 1)\)\^\(3/2\))\)\)\)

=(-Log[1] + (1/π) 
              Cos[π] - (2/9) (((4))^(3/2)))
    -(-Log | 
            2 | +(1/π) 
                Cos[0] - (2/9) (((1))^(3/2)))

=(0 - 
              (1/π) - (2/9)×8) - (-Log[2] + (1/π) - 
              (2/9))

=-(1/π) - (16/9) + Log[2] - 
          (1/π) + (2/9)

=Log[2] - (2/π) - (14/9).

(∫_0^1)((1/(2 - x)) - 
            Sin[π x] - (Sqrt[3  x + 1])) \[DifferentialD]x

Example 7.3.3.

Calculate the area under the following curves.

y = (Sqrt[(r^2) - (x^2)]),  where  -r ≤ x ≤ r.

Plotting the graph will help.

Clear[r, x];
r = 1;
FilledPlot[(Sqrt[(r^2) - (x^2)]), {x, -r, r}, 
        PlotStyle -> {Blue}, 
        Fills -> {GrayLevel[0.75]}];

This is the area of a semicircle with radius r, so the answer is

(∫_(-r)^r)(Sqrt[ (r^2) - 
                  (x^2)]) dx = (1/2) π (r^2).

y = Sin[x],  where  0 ≤ x ≤ π.

This time, plotting the graph won't help much, but let us plot it anyway.

Clear[x];
regionplot = 
        FilledPlot[Sin[x], {x, 0, π}, 
          PlotStyle -> {{Blue, Thickness[0.01]}}, 
          Fills -> {GrayLevel[0.75]}, 
          DisplayFunction -> Identity];
curveplot = 
        Plot[Sin[x], {x, -0.1, π + 0.1}, PlotStyle -> Blue, 
          DisplayFunction -> Identity];
Show[regionplot, curveplot, 
        DisplayFunction -> $DisplayFunction];

\(∫\_0\%π Sin[
                x] dx = \(\([\(-Cos[x]\)]\)\_0\%π = \((\(-Cos[π]\))\) - \((\(-Cos[0]\))\)\)\)
                        =(+1) - (-1) = 
              2.

7.3.4.  Differentiating definite integrals.

By changing some letters, the fundamental theorem of calculus can be written as

(∫_a^x) f(t) dt = 
        F(x) - F(a).

Therefore, the derivative of the above integral is,

\(TraditionalForm\`\(d\/dx\) \(∫\_a\%x\( f(
                t)\) dt\) = \(\(d\/dx\)[F(x) - F(a)] = \(F' \((x)\) - 0 = f(x)\)\)\).

Similarly, we have

\(TraditionalForm\`\(d\/dx\) \(∫\_x\%b\( f(
                t)\) dt\) = \(\(d\/dx\)[F(b) - F(x)] = \(0 - F' \((x)\) = \(-\(f(x)\)\)\)\)\).

If we apply the chain rule to the fundamental theorem of calculus, we have the following general formula.  The proof is left to the readers.

\(TraditionalForm\`\(d\/dx\) \(∫\_\(φ(x)\)\%\(ψ(x)\)\(f(
                t)\) dt\) = 
        f[ψ(x)] ψ' \((x)\) - 
          f[φ(x)] φ' \((x)\)\).

(7.4)  Properties of definite integrals.

The following properties can be easily explained either graphically or from the fundamental theorem.  For the precise proof, however, one needs to go back to Riemann sums and the definition of the definite integral.

(∫_a^b) k dx = 
        k(b - a).			(∫_a^b) 0 dx = 0.

(∫_a^b)[f(x) + 
                g(x)] dx = (∫_b^a) f(
                x) dx + (∫_b^a) g(
                x) dx
	(∫_a^b) k f(x) dx = 
        k (∫_b^a) f(x) dx

(∫_a^b) f(
              x) dx = -(∫_b^a) f(
                x) dx.		(∫_a^a) f(x) dx = 
        0.
	(∫_a^b) f(
                x) dx + (∫_b^c) f(
                x) dx = (∫_a^c) f(
              x) dx

If  f(x) ≤ g(x)  and  a ≤ b  then  (∫_a^b) f(
              x) dx ≤ (∫_a^b) g(
              x) dx.
	In particular,  \(TraditionalForm\`\(\(|\)\(∫\_a\%b\( f(
              x)\) dx\)\(|\)\(\(≤\)\(∫\_a\%b\)\)\(|\)\(f(x)\)\(|\)\(dx\)\)\).
	If  m ≤ f(x) ≤ 
        M  and  a ≤ b  then  m(
          b - a) ≤ (∫_a^b) f(
              x) dx ≤ M(b - a).

Example 7.3.1.

Calculate the following definite integrals.

(∫_0^(((3  π)/2)))|Sin[
              x]|dx = ?

This integral is different from the one without the absolute value sign.

\(TraditionalForm\`∫\_0\%\(\(3  π\)\/2\)Sin[
              x] dx = \(\([\(-Cos[x]\)]\)\_0\%\(3  π/2\) = \(\(-Cos[\(3  π\)\/2]\) + Cos[0] = \(0 + 1 = 1\)\)\)\).

Their graphs are different, too.

Clear[x]
Plot[Abs[Sin[x]], {x, 0, ((3  π)/2)}, 
        PlotStyle -> {Blue}];
Plot[Sin[x], {x, 0, ((3  π)/2)}, 
        PlotStyle -> {Red}];

The first graph is the correct graph of the given function, f(x) = |Sin[x]|.  The second graph is the graph of g(x) = Sin[x].  Since, g gets negative, the signed area of the right hand side (that is, when π ≤ x ≤ 3  π/2) cancels a part of the signed area of the left hand side (the interval 0 ≤ x ≤ π).

Correct way to calculate the given integral is to separate the integral and the integrals piece by piece.

(∫_0^(((3  π)/2)))|Sin[
            x]|dx = (∫_0^π)|Sin[
            x]|dx+(∫_π^(((3  π)/2)))|Sin[
            x]|dx

= (∫_0^π) Sin[x] dx+(∫_π^(((3  π)/2)))(-Sin[
                x]) dx

=  (-Cos[π] + 
            Cos[0]) + (Cos[((3  π)/2)] - Cos[π])

=  (1 + 1) + (0 + 1) = 3

(∫_0^(3  π/2))Abs[Sin[x]] \[DifferentialD]x

\(TraditionalForm\`∫\_\(-2\)\%2\((Sin[
                  x\^3 + x] - \(x\^3\) e\^\(-x\^2\))\) dx = ?\)

This is a trick question.  Attempting to find the antiderivative of the integrand (the inside of the integral) will be futile.  One must note that the integrand is an odd function (f(-x) = -f(x)), so the graph of f is symmetric to the origin.  Hence,

\(TraditionalForm\`∫\_0\%2\((Sin[
                  x\^3 + x] - \(x\^3\) e\^\(-x\^2\))\) dx = \(-\(∫\_\(-2\)\%0\((Sin[
                    x\^3 + x] - \(x\^3\) e\^\(-x\^2\))\) dx\)\)\).

Consequently,

\(TraditionalForm\`∫\_\(-2\)\%2\((Sin[
                x\^3 + x] - \(x\^3\) e\^\(-x\^2\))\) dx\)

\(TraditionalForm\`\(\(=\)\(∫\_0\%2\((Sin[
                      x\^3 + x] - \(x\^3\) e\^\(-x\^2\))\) dx + ∫\_\(-2\)\%0\((Sin[
                      x\^3 + x] - \(x\^3\) e\^\(-x\^2\))\) dx = 0\)\)\)

Clear[f, g, x];
f[x_] = 
        Max[0, Sin[(x^3) + x] - (x^3) 
              (E^(-(x^2)))];
g[x_] = 
        Min[0, Sin[(x^3) + x] - (x^3) 
              (E^(-(x^2)))];
fplot = 
        FilledPlot[f[x], {x, -1.94, 1.94}, PlotStyle -> Blue, 
          Fills -> {RGBColor[0.6, 0.7, 1]}, 
          DisplayFunction -> Identity];
gplot = 
        FilledPlot[g[x], {x, -1.94, 1.94}, PlotStyle -> Red, 
          Fills -> {RGBColor[1, 0.6, 0.7]}, 
          DisplayFunction -> Identity];
Show[fplot, gplot, 
        DisplayFunction -> $DisplayFunction];

8.  Calculating Integrals

(8.1)  Calculating basic integrals.

8.1.1.  Calculating basic indefinite integrals.

Here is a list of basic indefinite integrals that follows immediately from differentiation formulae.

\(TraditionalForm\`∫\(x\^k\) dx = \(1\/\(k\  + \ 1\)\) x\^\(k + 1\) + C\),  if  k ≠ -1.

	∫(1/x) dx = 
        Log | x | +C.

	\(TraditionalForm\`∫\(e\^x\) dx = e\^x + C\).
	
	∫Sin[x] dx = -Cos[x] + 
          C.

	∫Cos[x] dx = Sin[x] + C.

	∫(Sec^2)[x] dx = 
        Tan[x] + C.

	∫(1/(1  +  
                  (x^2))) dx = ArcTan[x] + C.

The above table can be generalized slightly by the chain rule.  Note the recurring factor (1/a).

∫(((a x + 
                    b))^k) dx = (1/(a(
                  k  +  1))) (((a x + b))^(k + 1)) + C,  if  k ≠ -1.

	∫(1/(a x  +  
                  b)) dx = (1/a) Log | 
          a x + b | +C.

	\(TraditionalForm\`∫\(e\^\(\(\ \)\(a\ x\  + \ 
                  b\)\)\) dx = \(1\/a\) e\^\(\(\ \)\(a\ x\  + \ b\)\) + C\).
	
	∫Sin[
              a x + b] dx = -(1/a) Cos[a x + b] + 
          C.

	∫Cos[
              a x + b] dx = (1/a) Sin[a x + b] + C.

	∫(Sec^2)[
              a x + b] dx = (1/a) Tan[a x + b] + C.	

	∫(1/((a^2)  +  
                  (x^2))) dx = (1/a) ArcTan[(x/a)] + C.

8.1.2.  Calculating basic definite integrals.

Definite integrals can be calculated from indefinite integrals.  From the fundamental theorem of calculus,

(∫_a^b) f(x) dx = 
        F(b) - F(a),  where  F(x) = ∫f(x) dx.

Example 8.1.3.

Calculate the following integrals.

∫(Sqrt[2  x + 5]) dx = ?

\(TraditionalForm\`∫\@\(2  x + 5\)\ dx = ∫\(\((2  x + 5)\)\^\(1/2\)\) dx\)
\(TraditionalForm\`\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(\(=\)\(\(2\/3\) \(\((2  x + 5)\)\^\(3/2\)\) 1\/2 + C\)\)\)
\(TraditionalForm\`\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(\(=\)\(\(1\/3\) \((2  x + 5)\)\^\(3/2\) + C\)\)\)

∫(Sqrt[2  x + 5]) \[DifferentialD]x

(∫_0^1)((1/(2  -  x)) - 
                Sin[π x] - (Sqrt[3  x + 1])) dx = ?

\(TraditionalForm\`∫\_0\%1\((\(-\(1\/\(x\  - \ 2\)\)\) - 
              Sin[π\ x] - \((3  x + 1)\)\^\(1/2\))\) dx\)

\(TraditionalForm\`\(\(=\)\(\([\(-Log\) | 
                x\  - \ 2 | \(+\(1\/π\)\) 
                    Cos[π\ x] - \(2\/3\) \(1\/3\) \((3  x + 1)\)\^\(3/2\)]\)\_0\%1\)\)\)

\(TraditionalForm\`\(\(=\)\((\(-Log\) | 
            1\  - \ 2 | \(+\(1\/π\)\) 
                Cos[1  π] - \(2\/3\) \(1\/3\) \((3×1 + 1)\)\^\(3/2\))\)\)\)
\(TraditionalForm\`\ \ \ \ \(-\ \((\(-Log\) | 
            0 - 2 | \(+\(1\/π\)\) 
                Cos[0  π] - \(2\/3\) \(1\/3\) \((3×0 + 1)\)\^\(3/2\))\)\)\)

=(-Log[1] + (1/π) 
              Cos[π] - (2/9) (((4))^(3/2)))
    -(-Log | 
            2 | +(1/π) 
                Cos[0] - (2/9) (((1))^(3/2)))

=(0 - 
              (1/π) - (2/9)×8) - (-Log[2] + (1/π) - 
              (2/9))

=-(1/π) - (16/9) + Log[2] - 
          (1/π) + (2/9)

=Log[2] - (2/π) - (14/9).

(∫_0^1)(-(1/(x  -  2)) - 
            Sin[π x] - (((3  x + 1))^(1/2))) \[DifferentialD]x

∫(1/(4  +  
                  (x^2))) dx = ?

\(TraditionalForm\`∫\(1\/\(4\  + \ 
                  x\^2\)\) dx = \(∫\(\(1/
                    4\)\/\(1\  + \ 
                    x\^2/4\)\) dx = \(1\/4\) \(∫\(1\/\(1\  + \ \((x/2)\)\^2\)\) dx\)\)\)
\(TraditionalForm\`\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(\(=\)\(\(1\/4\) 2  ArcTan[x\/2] + C\)\)\)
\(TraditionalForm\`\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(\(=\)\(\(1\/2\) ArcTan[x\/2] + C\)\)\)

∫(1/(4 + (x^2))) \[DifferentialD]x