# Differentiation - Examples

In this page we display several examples to illustrate the concepts and theorems discussed in the Differentiation theme.

## Showing that a function is differentiable

Problem
Show that the following function is differentiable: $f(x) = \begin{cases} x^2 \sin(1/x) & \ x \neq 0\\ 0 & \ x=0. \end{cases}$

Solution
Observe first that f is differentiable at all points outside the origin; a consequence of the theorems stating that products and composites of differentiable functions are differentiable. To examine the origin, we have to go back to the definition.

We want to determine if $\lim_{h \to 0} \frac{f(0+h)-f(0)}{h}$ exists. Now for $h \neq 0$ we have

$\frac{f(0+h)-f(0)}{h} = \frac{h^2 \sin(1/h)}{h} = h \sin(1/h).$

The limit of this expression as h tends to 0 is 0. This can be seen, for example, by observing that $-|h| \le h \sin(1/h) \le |h|.$
and applying the Squeeze Theorem. Hence $f'$ exists at all points, and we conclude that f is differentiable.

## Using differentiation to solve a geometric problem

Problem
We want to find the point on the curve $y = x^2$ that is closest to the point $(3,0)$.

Solution
Call the closest point on the parabola $Q=(a,a^2)$. The straight line $L$ going through $(3,0)$ and $Q$ has to be normal to the tangent of the parabola at $Q$. Recall that if two straight lines are normal, the product of their slopes is -1. Since the tangent of the parabola has slope $2a$ at $Q$, $L$ has to have slope $-1/2a$. But the slope can also be found using that we know two points on it: $\frac{a^2-0}{a-3} = -\frac{1}{2a}$ Simplifying this yields a third degree equation in a, easily solved in Maple, giving $a=1$ as the unique solution. The closest point is therefore $(1,1)$.

Another way to go about it is this: parametrize the curve and minimize the distance function from $(3,0)$. The smallest distance between an arbitrary point $(t,t^2)$ on the graph and the point $(3,0)$ can be found by minimizing $||(t-3,t^2-0)||^2 = t^4+t^2-6t+9$. Minimizing the function can be done with differentiation by using the Critical Point Theorem.

## Approximating Small Changes

Assume that a quantity $y$ is a function of another quantity $x$, that is $y = f(x)$. If $f(x)$ is easy to calculate for a specific $x$, then it is often possible to calculate, by hand, a good approximation of $y$ for other numbers near $x$.

If we, in the general case, change the value of $x$ by an amount of $\Delta x$, then the (exact) change in $y$ is given by $\Delta y = f(x+\Delta x) - f(x)$. If the change $\Delta x$ is not zero, then of course $\Delta y = \frac{\Delta y}{\Delta x}\Delta x$, and if the change is small, then this first factor is an approximation of $f'(x)$. That is $\Delta y \approx f'(x)\Delta x.$
Problem
Calculate an approximation to $\sqrt{17}$.
Solution
Define the function $f$ as $f(x) = \sqrt{x}$. The derivative of $f$ is known to be $f'(x) = \frac{1}{2\sqrt{x}}.$ Let $x = 16$ and $\Delta x = 1$. Then $\sqrt{17} = f(x + \Delta x) = f(x) + \Delta y.$ Which implies that $\sqrt{17} \approx f(x) + f'(x)\Delta x = \sqrt{x} + \frac{1}{2\sqrt{x}}\Delta x.$ Substituting for $x$ and $\Delta x$, we find that $\sqrt{17} \approx 4 + \frac{1}{8} = 4.125,$ which is not a bad approximation since the value of $\sqrt{17}$ to three decimal places is $4.123$.

## Implicit differentiation

Problem
Consider the curve given by $\tan(x y^2) = \frac{2xy}{\pi}.$ Find the slope of the line tangent to the curve at the point $(-\pi,\frac12)$.

Solution

To find the derivative, we assume $y = y(x)$ is a differentiable function of $x$, and differentiate both sides of the equation wrt $x$. $\frac{d}{dx} \tan\left(x y(x)^2\right) - \frac{d}{dx} \frac{2xy(x)}{\pi} = 0$ $\frac{y(x)^2+2xy(x)y'(x)}{\cos^2\left(xy(x)^2\right)} - \frac{2y(x)+2xy'(x)}{\pi} = 0$

Now substitute in $x = -\pi$ and $y(x) = \frac12$, and solve for $y'(x)$:

$\frac12- \frac{1}{\pi} + (2-2\pi)y'(-\pi) = 0$ $y'(-\pi) = \frac{\pi-2}{4 \pi (\pi-1)}.$

## Using the Critical Point Theorem

Problem
A company produces cylinder shaped tin cans. To achieve optimal cost-efficiency, they wish to maximize the volume of the cylinder compared to the material used. The sides, top and bottom all have the same thickness which is fixed, and the material to be used per can is fixed. What is the optimal relation between height $h$ and radius $r$ of the cylinder to maximize the volume?

Solution
The formula for volume is $V=\pi r^2 h$. We may safely assume that the thickness of the walls are thin, and thus the material used is proportional to the surface area, which is $A=2\pi rh+2\pi r^2$ (cylinder + top + bottom). This implies $h=\frac{A}{2\pi r}-r.$ Inserting this into the formula for volume yields $V(r)=\frac{Ar}{2}-\pi r^3.$ Differentiating $V(r)$ with respect to $r$ gives $V'(r)=\frac{A}{2}-3\pi r^2$. Solving $V'(r)=0$ will yield two roots, one positive and one negative. Since we are talking about radius, we discard the negative one. As $V(r)$ at first increases as $r$ increases from $r=0$ and tends to $-\infty$ as $r\to\infty$, the positive root is a (local) maximum and not a minimum or saddle point.

## Functions having the same derivative

Problem
Suppose $f$ and $g$ are differentiable functions on some open interval $(a,b)$ such that $f' = g'$. Show that $f-g$ is a constant function.

Solution
Define the function $h = f-g$, then $h'$ is the zero function on $(a,b)$. Given any two distinct points $x_1, x_2$ in $(a,b)$, $h$ satisfies the assumptions of the the Mean-Value Theorem on $[x_1,x_2]$, and applying it gives $\frac{h(x_1)-d(x_2)}{x_1-x_2} = 0.$ Hence $h(x_1) = h(x_2)$. Since $x_1$ and $x_2$ were arbitrary, we conclude that $h$ is a constant function.