Source: https://en.wikibooks.org/wiki/Calculus/Differentiation/Differentiation_Defined
Converted to Jupyter notebook and augmented with Mathematica evaluations.
Differentiation is a process of finding a function that outputs the rate of change of one variable with respect to another variable.
Informally, we may suppose that we're tracking the position of a car on a two-lane road with no passing lanes. Assuming the car never pulls off the road, we can abstractly study the car's position by assigning it a variable, $x$ . Since the car's position changes as the time changes, we say that $x$ is dependent on time, or $x=\text{f}(t)$ . This tells where the car is at each specific time. Differentiation gives us a function $\frac{\text{d}x}{\text{d}t}$ which represents the car's speed, that is the rate of change of its position with respect to time.
Equivalently, differentiation gives us the slope at any point of the graph of a non-linear function. For a linear function, of form $\text{f}(x) = a x +b$, $a$ is the slope. For non-linear functions, such as $\text{f}(x) = 3 x^2$ , the slope can depend on $x$; differentiation gives us a function which represents this slope.
Historically, the primary motivation for the study of differentiation was the tangent line problem: for a given curve, find the slope of the straight line that is tangent to the curve at a given point. The word tangent comes from the Latin word tangens, which means touching. Thus, to solve the tangent line problem, we need to find the slope of a line that is "touching" a given curve at a given point, or, in modern language, that has the same slope. But what exactly do we mean by "slope" for a curve?
The solution is obvious in some cases: for example, a line $y = a x +b$ is its own tangent; the slope at any point is $a$ . For the parabola $y = x^2$ , the slope at the point $(0, 0)$ is $0$; the tangent line is horizontal.
But how can you find the slope of, say, $y = \sin(x) + x^2$ at $ x = 1.5$? This is in general a nontrivial question, but first we will deal carefully with the slope of lines.
Three lines with different slopes:
f[x_]:= x;
g[x_]:= x/4 + 2;
h[x_]:= -2 x;
lineStyle = {Thick, Red, Dashed};
lines = {Line[{ {-3.6, f[-1.6]}, {-1.6, f[-1.6]}}], Line[{{-3.6, f[-3.6]}, {-3.6, f[-1.6]}}],
Line[{{1, g[1]}, {1, g[3]}}], Line[{{1, g[3]}, {3, g[3]}}],
Line[{{0.2, h[0.2]}, {0.2, h[1.6]}}], Line[{{0.2, h[1.6]}, {1.6, h[1.6]}}]
};
Plot[{f[x], g[x], h[x]}, {x, -4, 4}, PlotRange->{-4, 4},
PlotLabels->{"f", "g", "h"},
Epilog -> {Directive[lineStyle],
Sequence@@lines, Text[Style["\[CapitalDelta] x", Gray], {-2.6, -1.2}],
Sequence@@lines, Text[Style["\[CapitalDelta] f(x)", Gray], {-3.2, -2.5}],
Sequence@@lines, Text[Style["\[CapitalDelta] x", Gray], {1.9, 3.1}],
Sequence@@lines, Text[Style["\[CapitalDelta] g(x)", Gray], {0.5, 2.5}],
Sequence@@lines, Text[Style["\[CapitalDelta] x", Gray], {0.8, -3.5}],
Sequence@@lines, Text[Style["\[CapitalDelta] h(x)", Gray], {0.64, -2.4}]
}]
The slope of a line, also called the gradient of the line, is a measure of its inclination. A line that is horizontal has slope 0, a line from the bottom left to the top right has a positive slope and a line from the top left to the bottom right has a negative slope.
The slope can be defined in two (equivalent) ways. The first way is to express it as how much the line climbs for a given motion horizontally. We denote a change in a quantity using the symbol $\Delta$ (pronounced "delta"). Thus, a change in $x$ is written as $\Delta x$. We can therefore write this definition of slope as:
Alternatively, we can define slope trigonometrically , using the tangent function:
The graphs of most functions we are interested in are not straight lines (although they can be), but rather curves. We cannot define the slope of a curve in the same way as we can for a line. In order for us to understand how to find the slope of a curve at a point, we will first have to cover the idea of tangency. Intuitively, a tangent is a line which just touches a curve at a point, such that the angle between them at that point is 0. Consider the following four curves and lines:
A secant is a line drawn through two points on a curve. We can construct a definition of a tangent as the limit of a secant of the curve taken as the separation between the points tends to zero. Consider the diagram below.
As the distance $h$ tends to 0, the secant line becomes the tangent at the point $x_0$. The two points we draw our line through are:
The definition of the tangent line we gave was not rigorous, since we've only defined limits of numbers — or, more precisely, of functions that output numbers — not of lines. But we can define the slope of the tangent line at a point rigorously, by taking the limit of the slopes of the secant lines from the last paragraph. Having done so, we can then define the tangent line as well. Note that we cannot simply set $h$ to 0 as this would imply division of 0 by 0 which would yield an undefined result. Instead we must find the limit of the above expression as $h$ tends to 0:
Definition: (Slope of the graph of a function)
The slope of the graph of $\text{f}(x)$ at the point $(x_0, \text{f}(x_0))$ is
If the slope is defined, say $m$, then the tangent line to the graph of $\text{f}(x)$ at the point !$(x_0, \text{f}(x_0))$ is the line with equation
Consider the formula for average velocity in the !$x$ direction, $\frac{\Delta x}{\Delta t}$ , where $\Delta x$ is the change in $x$ over the time interval $\Delta t$. This formula gives the average velocity over a period of time, but suppose we want to define the instantaneous velocity. To this end we look at the change in position as the change in time approaches 0. Mathematically this is written as: $\lim_{\Delta t \rightarrow 0}{\frac{\Delta x}{\Delta t}}$ , which we abbreviate by the symbol $\frac{\text{d}x}{\text{d}t}$. (The idea of this notation is that the letter $d$ denotes change.) Compare the symbol $\text{d}$ with $\Delta$. The idea is that both indicate a difference between two numbers, but $\Delta$ denotes a finite difference while $\text{d}$ denotes an infinitesimal difference. Please note that the symbols $\text{d} x$ and $\text{d} t$ have no rigorous meaning on their own, since $\lim_{\Delta t \rightarrow 0}{\Delta t}$ , and we can't divide by 0.
(Note that the letter $s$ is often used to denote distance, which would yield $\frac{\text{d}s}{\text{d}t}$ . The letter $d$ is often avoided in denoting distance due to the potential confusion resulting from the expression $\frac{\text{d}d}{\text{d}t}$.)
You may have noticed that the two operations we've discussed — computing the slope of the tangent to the graph of a function and computing the instantaneous rate of change of the function — involved exactly the same limit. That is, the slope of the tangent to the graph of $y=\text{f}(x)$ is $\frac{\text{d}y}{\text{d}x}$. Of course, $\frac{\text{d}y}{\text{d}x}$ can, and generally will, depend on $x$ , so we should really think of it as a function of $x$. We call this process (of computing $\frac{\text{d}y}{\text{d}x}$) differentiation. Differentiation results in another function whose value for any value $x$ is the slope of the original function at $x$ . This function is known as the derivative of the original function.
Since lots of different sorts of people use derivatives, there are lots of different mathematical notations for them. Here are some:
The first notation has the advantage that it makes clear that the derivative is a function. That is, if we want to talk about the derivative of $\text{f}(x)$ at $x = 2$ , we can just write $\text{f}'(2)$.
In any event, here is the formal definition:
Definition: (derivative) Let $\text{f}(x)$ be a function. Then
Example 1
The derivative of $\text{f}(x) = \frac{x}{2}$ is
f[x_]:= x/2;
Limit[(f[x+dx]-f[x])/(dx), dx->0]
g[x_] = D[f[x], x]
Plot[{f[x], g[x]}, {x, 0, 10}]
no matter what $x$ is. This is consistent with the definition of the derivative as the slope of a function.
Example 2
What is the slope of the graph of $y = 3 x^2$ at $(4, 48)$? We can do it "the hard (and imprecise) way", without using differentiation, as follows, using a calculator and using small differences below and above the given point:
When $x=3.999, y = 47.976003$.
When $x=4.001, y = 48.024003$.
Then the difference between the two values of $x$ is $\Delta x = 0.002$.
Then the difference between the two values of $y$ is $\Delta y = 0.048$.
Thus, the slope $\frac{\Delta y}{\Delta x} = 24$ at the point of the graph at which $x = 4$.
But, to solve the problem precisely, we compute
We were lucky this time; the approximation we got above turned out to be exactly right. But this won't always be so, and, anyway, this way we didn't need a calculator.
In general, the derivative of $\text{f}(x) = 3 x ^2$ is
f[x_]:= 3 x^2;
Limit[(f[x+dx]-f[x])/(dx), dx->0]
g[x_] = D[f[x], x]
Plot[{f[x], g[x]}, {x, 0, 10}]
Example 3
If $\text{f}(x) = |x|$ (the absolute value function) then $\text{f}(x) = \frac{x}{|x|}$, which can also be stated as
Here, $\text{f}(x)$ is not smooth (though it is continuous) at $x = 0$ and so the limits $\lim _{x\to 0^{+}}\text{f'}(x)$ and $\lim _{x\to 0^{-}}\text{f'}(x)$ (the limits as 0 is approached from the right and left respectively) are not equal. From the definition, $\text{f'}(0) = \lim _{x\to 0} \frac{x}{|x|}$, which does not exist. Thus, $\text{f'}(0)$ is undefined, and so $\text{f'}(x)$ has a discontinuity at 0. This sort of point of non-differentiability is called a cusp. Functions may also not be differentiable because they go to infinity at a point, or oscillate infinitely frequently.
f[x_]:= If[x<0, -x, x];
Limit[(f[x+dx]-f[x])/(dx), dx->0]
g[x_] = D[f[x], x]
Plot[{f[x], g[x]}, {x, -10, 10}]
The derivative notation is special and unique in mathematics. The most common notation for derivatives you'll run into when first starting out with differentiating is the Leibniz notation, expressed as $\frac{\text{d}y}{\text{d}x}$. You may think of this as "rate of change in $y$ with respect to $x$. You may also think of it as "infinitesimal value of $y$ divided by infinitesimal value of $x$. Either way is a good way of thinking, although you should remember that the precise definition is the one we gave above. Often, in an equation, you will see just $\frac{\text{d}}{\text{d}x}$, which literally means "derivative with respect to x". This means we should take the derivative of whatever is written to the right; that is, $\frac{\text{d}}{\text{d}x}(x + 2)$ means $\frac{\text{d}y}{\text{d}x}$ where $y + x + 2$.
As you advance through your studies, you will see that we sometimes pretend that $\text{d}y$ and $\text{d}x$ are separate entities that can be multiplied and divided, by writing things like $\text{d}y = x^4 \text{d}x$. Eventually you will see derivatives such as $\frac{\text{d}x}{\text{d}y}$, which just means that the input variable of our function is called $y$ and our output variable is called $x$; sometimes, we will write $\frac{\text{d}}{\text{d}x}$, to mean the derivative with respect to $y$ of whatever is written on the right. In general, the variables could be anything, say $\frac{\text{d}\theta}{\text{d}r}$.
All of the following are equivalent for expressing the derivative of $y = x^2$.
Using the definition of the derivative find the derivative of the function $\text{f}(x) = 2 x + 3$.
Using the definition of the derivative find the derivative of the function $\text{f}(x) = x^3$. Now try $\text{f}(x) = x^4$. Can you see a pattern? In the next section we will find the derivative of $\text{f}(x) = x^n$for all $n$.
The text states that the derivative of $| x |$ is not defined at $x = 0$ . Use the definition of the derivative to show this.
Graph the derivative to $y = 4 x^2$ on a piece of graph paper without solving for $\frac{\text{d}y}{\text{d}x}$. Then, solve for $\frac{\text{d}y}{\text{d}x}$ and graph that; compare the two graphs.
Use the definition of the derivative to show that the derivative of $\sin(x)$ is $\cos(x)$. Hint: Use a suitable sum to product formula and the fact that $\lim _{t\to 0}{\frac {\sin(t)}{t}}=1$ and $\lim _{t\to 0}{\frac {\cos(t)-1}{t}}=0$.
The process of differentiation is tedious for complicated functions. Therefore, rules for differentiating general functions have been developed, and can be proved with a little effort. Once sufficient rules have been proved, it will be fairly easy to differentiate a wide variety of functions. Some of the simplest rules involve the derivative of linear functions.
For any fixed real number $c$,
The graph of the function $\text{f}(x)=c$ is a horizontal line, which has a constant slope of 0. Therefore, it should be expected that the derivative of this function is zero, regardless of the values of $x$ and $x$.
The definition of a derivative is
$\lim_{\Delta x \rightarrow 0} \frac{\text{f}(x + \Delta x) - \text{f}(x)}{\Delta x}$
Let $\text{f}(x) = c$ for all $x$. (That is, $f$ is a constant function.) Then $\lim_{\Delta x \rightarrow 0} \text{f}(x + \Delta x) = c$. Therefore
$ \frac{\text{d}}{\text{d} x}[c] = \lim_{\Delta x \to 0}\frac{c - c}{\Delta x} = \lim_{\Delta x \to 0}\frac{0}{\Delta x}. $
Let $\text{g}(\Delta x) = \frac{0}{\Delta x}$. To prove that $\lim_{\Delta \to 0}\text{g}(\Delta x) = 0$, we need to find a positive $\delta$ such that, for any given positive $\varepsilon$, $\big|\text{g}(\Delta x) - 0\big| < \varepsilon$ whenever $0 < |\Delta x - 0| < \delta$. But $\big|\text{g}(\Delta x) - 0\big| = 0$, so $\big|\text{g}(\Delta x) - 0\big| < \varepsilon$ for any choice of $\delta$.
$\frac{\text{d}}{\text{d}x}[3] = 0$
$\frac{\text{d}}{\text{d}x}[z] = 0$
Note that, in the second example, $z$ is just a constant.
For any fixed real numbers $m$ and $c$,
The special case $\frac{\text{d}x}{\text{d}x} = 1$ shows the advantage of the $\frac{\text{d}}{\text{d}x}$ notation — rules are intuitive by basic algebra, though this does not constitute a proof, and can lead to misconceptions to what exactly $\text{d}x$ and $\text{d}y$ actually are.
The graph of $y = mx +c$ is a line with constant slope $m$.
If $\text{f}(x) = mx +c$ , then $\text{f}(x + \Delta x) = m(x + \Delta x)$. So,
$ \begin{aligned} \text{f'}(x) &= \lim_{x \to 0}\frac{m(x+\Delta x) + c - m x - c}{\Delta x}\\ &= \lim_{x \to 0}\frac{m(x+\Delta x) - m x}{\Delta x}\\ &= \lim_{x \to 0}\frac{m x + m \Delta x - m x}{\Delta x}\\ &= \lim_{x \to 0}\frac{m \Delta x}{\Delta x}\\ &= m. \end{aligned} $
Since we already know the rules for some very basic functions, we would like to be able to take the derivative of more complex functions by breaking them up into simpler functions. Two tools that let us do this are the constant multiple rule and the addition rule.
For any fixed real number $c$,
The reason, of course, is that one can factor $c$ out of the numerator, and then of the entire limit, in the definition. The details are left as an exercise.
Example
We already know that
$ \frac{\text{d}}{\text{d}x}\big[x^2 \big] = 2 x. $
Suppose we want to find the derivative of $3 x^2$
$ \begin{aligned} \frac{\text{d}}{\text{d}x}\big[3 x^2 \big] &= 3 \frac{\text{d}}{\text{d}x}\big[x^2 \big]\\ &= 3 \cdot 2 x\\ &= 6 x. \end{aligned} $
Another simple rule for breaking up functions is the addition rule.
Proof
From the definition:
$ \begin{aligned} \lim_{\Delta x \rightarrow 0}\big[ \frac{ (\text{f}(x + \Delta x) \pm \text{g}(x + \Delta x)) - (\text{f}(x) \pm \text{g}(x)) }{\Delta x} \big ] &= \lim_{\Delta x \rightarrow 0}\big[ (\frac{ \text{f}(x + \Delta x) - \text{f}(x)) \pm (\text{g}(x + \Delta x) - \text{g}(x)) }{\Delta x} \big ] \\ &= \lim_{\Delta x \rightarrow 0}\big[ (\frac{ \text{f}(x + \Delta x) - \text{f}(x)) \big] \pm \lim_{\Delta x \rightarrow 0}\big[(\text{g}(x + \Delta x) - \text{g}(x)) }{\Delta x} \big ] \end{aligned} $
By definition then, this last term is $\frac{\text{d}}{\text{d}x}\big[\text{f}(x) \big] \pm \frac{\text{d}}{\text{d}x}\big[\text{g}(x) \big]$.
Example
What is the derivative of $3 x^2 + 5x$?
$ \begin{aligned} \frac{\text{d}}{\text{d} x}\big[ 3 x^2 + 5 x \big] &= \frac{\text{d}}{\text{d} x}\big[ 3 x^2 \big] + \frac{\text{d}}{\text{d} x}\big[ 5 x \big]\\ &= 6 x + 5 \end{aligned} $
D[3 x^2 + 5x, x]
The fact that both of these rules work is extremely significant mathematically because it means that differentiation is linear. You can take an equation, break it up into terms, figure out the derivative individually and build the answer back up, and nothing odd will happen.
We now need only one more piece of information before we can take the derivatives of any polynomial.
This has been proved in an example in Derivatives of Exponential and Logarithm Functions where it can be best understood.
For example, in the case of $x^2$ the derivative is $2 x^1 = 2 x$ as was established earlier. A special case of this rule is that $\frac{\text{d} x}{\text{d} x} = \frac{\text{d} x^1}{\text{d} x} = 1 x^0 = 1$.
Since polynomials are sums of monomials, using this rule and the addition rule lets you differentiate any polynomial. A relatively simple proof for this can be derived from the binomial expansion theorem.
This rule also applies to fractional and negative powers. Therefore
$ \begin{aligned} \frac{\text{d}}{\text{d} x}\big[ \sqrt{x} ] &= \frac{\text{d}}{\text{d} x}\big[ x^{\frac{1}{2}} ]\\ &= \frac{1}{2} x^{-\frac{1}{2}}\\ &= \frac{1}{2 \sqrt{x}}. \end{aligned} $
With these rules in hand, you can now find the derivative of any polynomial you come across. Rather than write the general formula, let's go step by step through the process.
$\frac{\text{d}}{\text{d} x}\big[ 6 x^5 + 3 x^2 + 3 x + 1 ]$
The first thing we can do is to use the addition rule to split the equation up into terms:
$\frac{\text{d}}{\text{d} x}\big[ 6 x^5 ] + \frac{\text{d}}{\text{d} x}\big[ 3 x^2 ] + \frac{\text{d}}{\text{d} x}\big[ 3 x] + \frac{\text{d}}{\text{d} x}\big[ 1 ]$
We can immediately use the linear and constant rules to get rid of some terms:
$\frac{\text{d}}{\text{d} x}\big[ 6 x^5 ] + \frac{\text{d}}{\text{d} x}\big[ 3 x^2 ] + 3 + 0$
Now you may use the constant multiplier rule to move the constants outside the derivatives:
$6 \frac{\text{d}}{\text{d} x}\big[ x^5 ] + 3 \frac{\text{d}}{\text{d} x}\big[ x^2 ] + 3 + 0$
Then use the power rule to work with the individual monomials:
$6 ( 5 x^4 ) + 3 ( 2 x ) + 3$
And then do some algebra to get the final answer:
$30 x^4 + 6 x + 3$
These are not the only differentiation rules. There are other, more advanced, differentiation rules, which will be described in a later chapter.
D[6 x^5 + 3 x^2 + 3 x + 1, x]