# Gradient Vector

## Linear approximations

In single variable calculus we had:
\[\Delta f\approx f^{\prime}\cdot \Delta x.\]
The previous expression can be made precise but we won’t do that. This is a motivational paragraph, so we’ll talk about how calculators and computers handle the calculation of \(\sin x\), \(e^{x^3}\) and similar functions.

The electronic devices are quite good at adding, subtracting, and multiplying numbers. The electricity can be tricked into doing basic operations using

*logic gates*. However, it is not easy to make a logic gate that calculates \(e^{x\cos x}\). In general, for non-linear functions \(f\) calculators use approximation techniques.

The memories of calculators are manufactured already with the list of values

*f*(0),

*f*(0.00001),

*f*(0.00002), and a few other values of

*f*. The derivatives of

*f* at these points are also stored in the memory. When a user asks for evaluation of \(f(x)\), the calculator posses the value some \(x_0\) that is close to \(x\). This means that the difference \(\Delta x=x-x_0\) is small, and the approximation \(f(x)-f(x_0)=\Delta f\approx f^{\prime}(x_0)\cdot \Delta x\) is quite accurate. The calculator returns \(f(x_0)+\Delta f\) and the user is left impressed and recommends the calculator to friends and family.

Assume that we now have a function \(g\) of two variables and that we know the value of \(g\) at \((x_0,y_0)\) as well as \(g_x(x_0,y_0)\) and \(g_y(x_0,y_0)\). Let us assume that \((x,y)\) is close to \((x_0,y_0)\). Denote \(\Delta g=g(x,y)-g(x_0,y_0)\), \(\Delta x=x-x_0\), and \(\Delta y=y-y_0\). Then we have:
\[\Delta g= \Big(g(x,y)-g(x_0,y)\Big)+\Big(g(x_0,y)-g(x_0,y_0)\Big).\]
Let us examine the difference: \(g(x,y)-g(x_0,y)\). The value of \(y\) does not change. This is really good news, because we may consider this difference as a function of \(x\) and apply our knowledge from single variable calculus. Since \(y\) is fixed, the appropriate derivative that we will use is the derivative with respect to \(x\). We obtain: \(g(x,y)-g(x_0,y)=g_x(x_0,y)\Delta x\). Similarly, we have \(g(x_0,y)-g(x_0,y_0)=g_y(x_0,y_0)\Delta y\).
We also notice that \(g_x(x_0,y)\approx g_x(x_0,y_0)\).

Please believe in this, and forgive for the lack of precision. The entire paragraph is far from being rigorous. One day, when you start learning analysis, you will see the way in which the previous paragraph can be rewritten to avoid using the symbol \(\approx\).

\[
\Delta g\approx g_x\Delta x+ g_y\Delta y=\langle g_x(x_0,y_0),g_y(x_0,y_0)\rangle \cdot \langle \Delta x, \Delta y\rangle.\]
The last expression is written in the form of dot product of vectors \(\langle g_x,g_y\rangle\) and \(\langle \Delta x, \Delta y\rangle\). In this form it is analogous to the formula from the beginning of this section.

**Example**
Find a function \(f\) such that \(\nabla f=\langle x^2+y,x+y^3\rangle\).

Since \(\nabla f=\langle f_x,f_y\rangle\) we get \(f_x(x,y)=x^2+y\). Since \(f_x(x,y)\) is the derivative of the function \(\psi(x)=f(x,y)\) in which \(y\) is regarded as a constant, our task is to find a function \(\psi(x)\) such that \(\psi^{\prime}(x)=x^2+y\). The important thing to keep in mind is that when we wrote \(\psi^{\prime}(x)\) we did not regard \(y\) as a variable. In this business, \(y\) is no better than 17 or any other number.

Hence \(\psi(x)\) is an anti-derivative of \(x^2+y\), therefore \(\psi(x)=\frac{x^3}3+xy+C(y)\).
This means that \[f(x,y)=\frac{x^3}3+xy+C(y).\] Our goal is to find all possible functions \(C(y)\). We do this from the equation \(f_y=x+y^3\). The equation now becomes:
\[x+C^{\prime}(y)=x+y^3.\]
The last equation implies that \(C^{\prime}(y)=y^3\) and \(C(y)=\frac{y^4}4+D\), where \(D\) is any real number. Therefore
\[f(x,y)=\frac{x^3}3+xy+\frac{y^4}4+D,\] where \(D\) can be any real number.

**Example**
Let \(f(x,y)=(x^4+y^2)\ln(x^2+y^4)\). Find an approximate value of \(f(0.98,0.3)\).

Notice that \(f(1,0)=1\cdot \ln 1=0\). We will use that
\[f(0.98,0.3)-f(1,0)\approx \nabla f(1,0)\cdot \langle 0.98-1, 0.3-0\rangle.\]
We have that
\[\nabla f(x,y)=\left\langle 4x^3\ln(x^2+y^4)+\frac{x^4+y^2}{x^2+y^4}\cdot 2x,\; 2y\ln(x^2+y^4)+\frac{x^4+y^2}{x^2+y^4}\cdot 4y^3\right\rangle\]
and consequently \(\nabla f(1,0)=\langle 2,0\rangle\). Therefore
\[f(0.98,0.3)\approx \langle 2,0\rangle\cdot\langle -0.02,0.3\rangle=-0.04.\]

## Practice problems

**Problem** 1. Let \(f(x,y)=x^3y^2\). Find \(\nabla f(2,3)\).

We first find \(f_x(x,y)\): \[f_x(x,y)=3x^2y^2.\]
In the same way we get
\[f_y(x,y)=2x^3y.
\]
We can now evaluate \(f_x(2,3)=108\) and \(f_y(2,1)=48\). Thus, \(\nabla f(2,3)=\langle108,48\rangle\).

**Problem** 2. Let \(f(x,y)=\frac{x+y}{x^2-y}\). Find \(\nabla f(2,1)\).

Using the quotient rule we obtain \[f_x(x,y)=\frac{-x^2-2xy-y}{(x^2-y)^2}.\]
In the same way we get
\[f_y(x,y)=\frac{x^2+x}{(x^2-y)^2}.
\]
We can now evaluate \(f_x(2,1)=-1\) and \(f_y(2,1)=\frac23\). Thus, \(\nabla f(2,1)=\langle-1,\frac23\rangle\).

**Problem** 3.
Let \(f(x,y)=\sin(x+y^2)+e^{x^2+7y}\). Using linear approximation of \(f\) at (0,0), find an approximate value for \(f(-0.1,0.2)\).

We will use that
\[f(0.1,-0.2)\approx f(0,0)+\nabla f(0,0)\cdot
\langle \Delta x,\Delta y\rangle.\]
We have that \(\Delta x=x-x_0=-0.1\), while \(\Delta y=y-y_0=0.2\). Moreover, _br__br_
\[f_x(x,y)=\cos(x+y^2)+2xe^{x^2+7y};\;\;\; f_x(0,0)=1,\]
\[f_y(x,y)=2y\cos(x+y^2)+7e^{x^2+7y};\;\;\; f_y(0,0)=7.\]
We also have \(f(0,0)=1\) hence
\[f(0.1,-0.2)\approx 1+\langle 1,7\rangle\cdot\langle-0.1,0.2\rangle = 1-0.1+1.4=2.3.\]

**Problem** 4.
Find all functions \(f\) such that \(\nabla f=\langle x+y^2, 2xy+y^2\rangle\).

From the given condition we have \(f_x=x+y^2\). Then we have \[f(x,y)=
\frac{x^2}2+xy^2+C(y),\]
where \(C(y)\) is a function that does not depend on \(x\). Placing this into the equation \(f_y=2xy+y^2\) gives us:
\[2xy+C^{\prime}(y)=y^2+2xy,\]_br__br_ therefore
\(C(y)=\frac13y^3+D\), hence
\[f(x,y)=\frac{x^2}2+xy^2+\frac{y^3}3+D,\] where \(D\) can be any real number.

**Problem** 5.
Which of the following vector-valued functions can be a gradient of a scalar-valued function?

**(A)** \(\overrightarrow a(x,y)=\langle xy, xy\rangle\)
**(B)** \(\overrightarrow b(x,y)=\langle x^2y, x^3\rangle\)
**(C)** \(\overrightarrow c(x,y)=\langle 3x^2y^2, 2x^3y\rangle\)
**(D)** \(\overrightarrow d(x,y)=\langle 2x,3x\rangle\)
**(E)** \(\overrightarrow e(x,y)=\langle\sin y, \cos x\rangle\)

Since \(\nabla f=\langle f_x,f_y\rangle\) and \(f_{xy}=f_{yx}\), then \(\langle P, Q\rangle\) can be a gradient of a function if and only if \(P_y=Q_x\). The function \(\overrightarrow c(x,y)\) is the only vector-valued function among the given ones that satisfies the above condition. Therefore, the correct answer is C.