Vector calculus

Now if you know what calculus is (the study of the diff and int operations on functions), and you know what a vector is \[ \vec{w} = (w_1, w_2), \] then you already know all there is to know about vector calculus.

But since you have never actually taken derivatives with vectors, you will be like…. WTF? What is this gibberish this with the arrows, triangles and Greek letters. This is just some notation and we can get through all of that real quick. The gibberish is necessary to define exactly which derivative you mean…

If you have a vector function $Q(\vec{w})$, which is just like a regular function $f(x)$, but now there are two inputs: $w_1$ and $w_2$, \[ Q(w_1,w_2) \equiv Q(\vec{w}). \] This is what we are really talking about. This is why the other name for vector calculus is multivariable calculus.

So let us resume now with the main actor, this is the function which we will be using in this running example: \[ Q(\vec{w}) = \left(w_1 + w_2 x - y\right)^2, \] where $x$ and $y$ are some constants.

Confusing I know – why didn't I just call it $F(x,y)$ you are asking, but trust me, it is better if think of vector functions as functions of two coordinates. So the input $w_1,w_2$ makes it explicit: “the first coordinate” and “the second coordinate”. The “signature” of the function, tells us what kind of inputs it takes and what kind of outputs it gives us. For this function we have: \[ Q:\mathbb{R}^2 \to \mathbb{R}, \] which is the mathematically precise way of indicating the domain and the range of the function: $f:D \to R$.

Ok so what is this vector calulus all about? Let's look at what you know from differential calculus. If you are given a regular “single variable” function \[ f:\mathbb{R} \to \mathbb{R}, \] you know how to find the derivative function \[ f':\mathbb{R} \to \frac{\mathbb{R}}{\mathbb{R}} \equiv \mathbb{R}. \] If give you $f(x)=(x+20-7)^2$ and you know that $f'(x)=2(x+20-7)$, and if I give you $f(x)=(1+Cx-7)^2$ you know that $f'(x)=2(1+Cx-7)C$.

To take the derivative of a vector function, your derivative skills will have to be used twice – once for the $w_1$ coordinate treating $w_2$ as constant and once for the $w_2$ derivative, keeping $w_1$ constant. \[ Q'(w_1,w_2) \equiv \left(\frac{d Q(w_1\mathbf{;w_2})}{dw_1},\frac{d Q(w_2;w_1)}{dw_2} \right) \equiv \left(\frac{\partial Q}{\partial w_1},\frac{\partial Q}{\partial w_1} \right) \equiv \nabla Q(w_1,w_2). \] The notations on the left-hand side are not used in practice. You can't just say $Q'$, because it is ambiguous with respect to which variable(s) you are taking the derivative. The semicolon notation is sometimes used to indicate which are the variables and which are the parameters (constants specified by the problem).

The notations on the right you must remember, understand and get used to. We use $d$ for single variable derivatives $\frac{df}{dx}$, but we use $\partial$ for partial derivatives. Whenever you see $\frac{\partial}{\partial x}$, it means that you are taking the derivative with respect to $x$ (the slope in the $x$ direction) and you are keeping all other variables constant.

Finally, there is the inverted delta symbol, nabla$=\nabla$, which we read as gradient of $Q(w_1,w_2)$. The gradient is the slope vector of a function of two variables.

Let's be clear about the \[ \nabla Q:(\mathbb{R},\mathbb{R}) \to (\mathbb{R},\mathbb{R}) \ \ \equiv \ \ \left( \frac{\partial Q}{\partial w_1}:(\mathbb{R},\mathbb{R}) \to \mathbb{R}, \frac{\partial Q}{\partial w_2}:(\mathbb{R},\mathbb{R}) \to \mathbb{R} \right). \]

We can say that $\nabla$ is a vector-maker (acts on a function to produce a vector), or a vector operator: \[ \vec{\nabla} \equiv \left( \frac{\partial }{\partial w_1}, \frac{\partial }{\partial w_2} \right). \] when applied to the function \[ Q(\vec{w}) = \left(w_1 + w_2 x - y\right)^2, \] we get \[ \nabla Q = \left( 2 (w_1 + w_2 x - y) , 2 (w_1 + w_2 x - y)x\right) = 2 (w_1 + w_2 x - y)\left( 1,x\right). \]

We can show the same formula as a column vector too: \[ \nabla Q = \begin{pmatrix} 2 (w_1 + w_2 x - y) \nl 2 (w_1 + w_2 x - y)x \end{pmatrix} = 2 (w_1 + w_2 x - y)\begin{pmatrix} 1 \nl x \end{pmatrix}. \]

Examples

Uphill

Suppose you are on the side of a mountain, and the map says that if you walk North you will be climbing at 20m every 100m (20% slope), and if you walk Easy the slope is 10m every 100m. What is the direction maximum slope up the mountain? What is this maximum slope?

ANS1: the direction is $(2,1)$
ANS2: the maximum slope is $\sqrt{20^2+10^2}$ metres per 100.

Change of point of view

\[ Q(w_1,w_2;x,y) = \left(w_1 + w_2 x - y\right)^2, \]

\[ Q(x,y;w_1,w_2) = \left(w_1 + w_2 x - y\right)^2, \]