5.7 Partial derivatives, differentiation and the gradient
Our next goal is to extend the notion of differentiability of functions in one variable \(f:\R \to \R\) to functions in two variables \(f:\R^2 \to \R\).
Let us recall first the notion of differentiability
Let \(f: (a, b) \to \R\) be a function. We say that \(f\) is differentiable at \(x_0 \in (a, b)\) if the following limit exists \(\lim_{h \to 0} \frac{f(x_0 + h) - f(x_0)}{h} = \ell\). In such a case we write \(f'(x_0) = \ell\).
Another way of writing this limit is \(\ell = \lim_{x \to x_0} \frac{f(x) - f(x_0)}{x - x_0}\)
Note that if such a limit exists, then \(\lim_{x \to x_0} \frac{f(x) - (f(x_0) + \ell(x - x_0))}{x - x_0} = 0\)
So, one may say that the function \(f\) is differentiable at \(x_0 \in (a, b)\) if there exists \(\ell \in \R\) such that the limit above is 0.
The function: \(y = f(x_0) + f'(x_0)(x - x_0)\) is the tangent line of \(f\) at \(x_0\).
Here we can approximate \(f(x)\) by a tangent line
When trying to understand what happens to a function on two variables, one may try to look at one variable at the time.
Example
Let's analyze what happens at \(p=(0,0)\) where \(f(x,y)=x^2+y^2\) and \(y=0\). We are looking at the intersection of these two
Then we want the intersection of \((x,y,x^2+y^2)\) and \((x,0,z)\), that is \((x,0,x^2)\), that is \(f(x,0)=g(x)=x^2\)
The intersection formula is differentiable since \(g'(0)=\lim_{x\to 0}\frac{g(x)-g(0)}{x-0}=\lim_{x\to0}\frac{x^2}{x}=0\Rightarrow g'(0)=0\)
Then \(y=g(0)+g'(0)(x-0)=0\)
Actually, we can do this for any \(x_0\), \(g'(x_{0})=\lim_{x\to x_0}\frac{g(x)-g(x_0)}{x-x_0}=\lim_{x\to x_0}\frac{x^2-x_0^2}{x-x_0}=2x_0\Rightarrow g'(x_0)=2x_0\)
As \(x_0\) was arbitrary, we get a function \(g'(x)=2x\)
For \(f(x,y)=x^2+y^2\) and \(x=0\), the intersection function is \((0,y,y^2)\), that is \(f(0,y)=g(y)=y^{2}\)
Same process, we get \(g'(y)=2y\)
Then we have \(y=0\), then we have \((x,0,0)\) and \((0,y,0)\), this is \(z=0\) plane, that is the derivative of \((0,0)\)
Questions:
-
Does this mean that our function is differentiable at \((0,0)\)?
We have at least two tangent lines. Are all possible tangent lines in the same plane? -
Our intuition says that a function \(f(x, y)\) is differentiable at \((x_0, y_0)\) if there is a tangent plane at the point \((x_0, y_0, f(x_0, y_0))\) on the graph of \(f(x, y)\) in \(\R^3\).
How do we formalize this notion?
Let us start by formalizing the derivatives with respect to one variable:
Partial derivatives
Definitions:
The partial derivative of a function \(f:\R^2 \to \R\) with respect to the variable \(x\) at the point \((x_0, y_0)\) is the limit
If it exists, we write: \(\ell = \frac{\partial f}{\partial x}(x_0, y_0)\)
The partial derivative of a function \(f:\R^2 \to \R\) with respect to the variable \(y\) at the point \((x_0, y_0)\) is the limit
If it exists, we write: \(\ell = \frac{\partial f}{\partial y}(x_0, y_0)\)
Example
-
\(f(x, y) = x^2 + y^2\)
Let \(p = (0,0) = (x_0, y_0)\)
Then \(\frac{\partial f}{\partial x}(0,0) = 0 \quad , \quad \frac{\partial f}{\partial y}(0,0) = 0\)
When taking \(y = y_0\), we are fixing the variable.
For any point, we may compute \(\frac{\partial f}{\partial x}(x,y)\) by considering \(y\) as a number (scalar)Then \(\frac{\partial f}{\partial x}(x, y) = 2x \quad , \quad \frac{\partial f}{\partial y}(x, y) = 2y\)
-
\(f(x,y)=x^2-y^2\)
\(p=(x_{0},y_{0})=(0,0)\), then \(\frac{\partial f}{\partial x}(x_0,y_0)=\lim_{x\to x_0}\frac{f(x,y_0)-f(x_0,y_0)}{x-x_0}=\lim_{x\to x_0}\frac{x^2-y_0^2-x_0^2+y_0^2}{x-x_0}=\lim_{x\to x_0}\frac{x^2-x_0^2}{x-x_0}=2x_0\)
Then \(\frac{\partial f}{\partial x}(x,y)=2x,\frac{\partial f}{\partial x}(0,0)=0\)
\(\frac{\partial f}{\partial y}(x_{0},y_{0})=\lim_{y\to y_0}\frac{f(x_{0},y)-f(x_{0},y_{0})}{y-y_{0}} =\lim_{y\to y_0}\frac{x_{0}^{2}-y^{2}-x_{0}^{2}+y_{0}^{2}}{y-y_{0}}=\lim_{y\to y_0} \frac{y_{0}^{2}-y^{2}}{y-y_{0}}=-2y_{0}\)
Then \(\frac{\partial f}{\partial y}(x,y)=-2y,\frac{\partial f}{\partial y}(0,0)=0\)
-
\(f(x,y)=\begin{cases} \frac{xy}{x^2+y^2} \quad \text{ if }(x,y)\neq (0,0)\\ 0\quad \quad \text{ if } (x,y)= (0,0) \end{cases}\)
Line \(y=0,p=(0,0)\), then \(f(x,0)=0\), then \(\frac{\partial f}{\partial x}(0,0)=0\)
Line \(x=0,p=(0,0)\), then \(f(0,y)=0\), then \(\frac{\partial f}{\partial y}(0,0)=0\), thus then plane is \(z=0\)
But we proved that this function is not continuous at \(p=(0,0)\), so it should not be differentiable
The linear or affine approximation
The geometrical idea behind differentiation is that a function is differentiable at a point \((x_0, y_0)\) if the function can be approximated by a linear (or affine) function at that point.
For functions \(f:\R \to \R\), the linear function is the tangent line. In case of functions \(f:\R^2 \to \R\), the tangent line should be replaced by a tangent plane.
The general equation of a non-vertical plane passing through a point \((x_0, y_0, f(x_0, y_0))\) is:
\(z = a(x - x_0) + b(y - y_0) + f(x_0, y_0)\) with \(a, b \in \R\).
This plane gives a good approximation of the function at \((x_0, y_0)\) if \(\lim_{(x,y) \to (x_0, y_0)} \frac{f(x, y) - (a(x - x_0) + b(y - y_0) + f(x_0, y_0))}{\| (x, y) - (x_0, y_0) \|} = 0\)
Note that here we are using the distance in \(\R^2\)
Let us determine the constants \(a, b \in \R\). We assume the limit exists, then approach the point \((x_0,y_0)\) using the line \(y=y_0\), we should get the same limit
\(0=\lim_{(x,y_0)\to(x_0,y_0)}\frac{f(x,y_{0})-(a(x-x_{0})+b(y_{0}-y_{0})+f(x_{0},y_{0}))}{\sqrt{\left(x-x_{0}\right)^{2}+\left(y_{0}-y_{0}\right)^{2}}} =\lim_{x\to x_0}\frac{f(x,y_{0})-\left(a(x-x_{0})+f\left(x_{0},y_{0}\right)\right)}{x-x_{0}}\)
\(=\lim_{x\to x_0^{+}}\frac{f(x,y_{0})-f\left(x_{0},y_{0}\right)-a(x-x_{0})}{x-x_{0}} =\lim_{x\to x_0^{+}}\frac{f(x,y_{0})-f\left(x_{0},y_{0}\right)}{x-x_{0}}-a\)
Then \(a=\lim_{x\to x_0^{+}}\frac{f(x,y_{0})-f\left(x_{0},y_{0}\right)}{x-x_{0}}=\frac{\partial f}{\partial x}\left(x_{0},y_{0}\right)\)
Analogously, \(b=\frac{\partial f}{\partial y}(x_0,y_0)\)
Definition
Differentiable
Let \(f:\R^2 \to \R\) be a function. We say that \(f\) is differentiable at \((x_0, y_0)\) if both partial derivatives exist at that point and
Tangent Plane
Let \(f:\R^2 \to \R\) be differentiable at \((x_0, y_0)\). Then the plane
is called the tangent plane of the graph of \(f\) at the point \((x_0, y_0, f(x_0, y_0))\).
Gradient Vector
If both partial derivatives of \(f\) exist at a point \(p = (x_0, y_0)\), the vector in \(\R^2\):
is called the gradient of \(f\) at \(p\).
Example
-
\(f(x,y)=x^2+y^2\) is differentiable for all \((x,y)\in \R^2\)
But let's check it at \(p=(0,0)\), then \(\frac{\partial f}{\partial x}(0,0)=0,\frac{\partial f}{\partial y}(0,0)=0\)
Then \(\lim_{(x,y)\to(0,0)}\frac{f(x,y)-\left(0(x-0)+0(y-0)+f(0,0)\right)}{\sqrt{(x-0)^{2}+(y-0)^{2}}} =\lim_{(x,y)\to(0,0)}\frac{x^{2}+y^{2}}{\sqrt{x^{2}+y^{2}}}=\lim_{(x,y)\to(0,0)}\sqrt{x^{2}+y^{2}} =0\)
Then tangent plane is \(z=f(0,0)+0(x-0)+0(y-0)=0\)
-
\(f(x,y)=x^{2}-y^{2}\)
At \(p=(0,0)\), then \(\frac{\partial f}{\partial x}(0,0)=0,\frac{\partial f}{\partial y}(0,0)=0\)
Then \(\lim_{(x,y)\to(0,0)}\frac{f(x,y)-\left(0(x-0)+0(y-0)+f(0,0)\right)}{\sqrt{(x-0)^{2}+(y-0)^{2}}} =\lim_{(x,y)\to(0,0)}\frac{x^{2}-y^{2}}{\sqrt{x^{2}+y^{2}}}=\lim_{(x,y)\to(0,0)}\frac{x^{2}-y^{2}}{\sqrt{x^{2}+y^{2}}}\)
Then use comparison test, since \(0\leq \frac{x^{2}}{\sqrt{x^2+y^2}}\leq \frac{x^2+y^2}{\sqrt{x^2+y^2}}\) and \(\lim_{(x,y)\to(0,0)}\frac{x^{2}+y^{2}}{\sqrt{x^{2}+y^{2}}}=0\)
Then \(\lim_{(x,y)\to(0,0)}\frac{x^{2}-y^{2}}{\sqrt{x^{2}+y^{2}}}=0\)
Then tangent plane is \(z=f(0,0)+0(x-0)+0(y-0)=0\)
-
\(f(x,y)= \begin{cases} \frac{xy}{x^{2}+y^{2}} \quad \text{ if }(x,y)\neq (0,0) \\ 0\quad \quad \text{ if } (x,y)= (0,0) \end{cases}\)
At \(p=(0,0)\), then \(\frac{\partial f}{\partial x}(0,0)=0,\frac{\partial f}{\partial y}(0,0)=0\)
Then \(\lim_{(x,y)\to(0,0)}\frac{f(x,y)-\left(0(x-0)+0(y-0)+f(0,0)\right)}{\sqrt{(x-0)^{2}+(y-0)^{2}}} =\lim_{(x,y)\to(0,0)}\frac{\frac{xy}{x^{2}+y^{2}}}{\sqrt{x^{2}+y^{2}}}=\lim_{(x,y)\to(0,0)} \frac{xy}{\left(x^{2}+y^{2}\right)^{\frac{3}{2}}}=\nexists\)
We can take \(y=x\), then \(\lim_{(x,y)\to(0,0)}\frac{x^2}{\left(2x^{2}\right)^{\frac{3}{2}}}=\infty\)
Thus it is not differentiable at \((0,0)\)
Remarks
-
Using the dot product, the equation of the tangent plane can be written as:
\(z = f(x_0, y_0) + \nabla f(x_0, y_0) \cdot (x - x_0, y - y_0)\)
Or more compactly, if \(p = (x_0, y_0)\) and \(x = (x, y)\): \(z = f(p) + \nabla f(p) \cdot (x - p)\)
-
If \(f:\R^2 \to \R\) is differentiable at \(p = (x_0, y_0)\), then the vector: \(\left( \frac{\partial f}{\partial x}(x_0, y_0), \frac{\partial f}{\partial y}(x_0, y_0), -1 \right)\)is orthogonal to the tangent plane at \(p\).