# Calculating a Multivariable derivative.

I'm trying to work through Spivak's Calculus on Manifolds and I've arrived at Differentiation. While I can usually follow his steps, I find myself lost or stuck when I try to do something on my own. So I decided to work through one of his first examples using $Df$ notation instead of $f'$ notation.

My main point, I have confused myself. My question is clearly asked only at the very bottom of this post.

As for the example, I need to calculate the derivative of $f:\mathbb{R}^{2}\to \mathbb{R}$, where $$f(x,y) = \sin(xy^2).$$

The following rules are available to me:

1) For a point $a$ in the domain of $f$ such that $f(a)$ is in the domain of $g$, $$D(g\circ f)(a) = Dg(f(a))\circ Df(a).$$

2) For two functions $f,g:\mathbb{R}^{n}\to \mathbb{R}$, $$D(fg)(a) = g(a)Df(a) + f(a)Dg(a)$$ and $$D(f+g)(a) = Df(a) + Dg(a).$$

If I have stated either of these rules even slightly incorrectly please be brutally in my face about it.

I'm trying to carefully apply this rules to my function.

If I let $p,s:\mathbb{R}^{2}\to \mathbb{R}$ denote the product function and $s:\mathbb{R}\to \mathbb{R}$ represent the squaring function, I can write:

$f = \sin\circ p\circ (\pi_{1}, s\circ \pi_{2})$, where $\pi_{1}$ and $\pi_{2}$ are the coordinate functions.

Now my derivative of $f$, denoted $Df$, should be a map from $\mathbb{R}^{2}\to \mathbb{R}$, just like $f$ is.

So at a point $(a,b)\in \mathbb{R}^{2}$, I can write

\begin{align*} Df(a,b) &= D\left(\sin\circ p\circ (\pi_{1}, s\circ \pi_{2})\right)(a,b)\\ &= D(\sin)(p\circ (\pi_{1}, s\circ \pi_{2})(a,b))\circ Dp((\pi_{1}, s\circ \pi_{2})(a,b))\circ D(\pi_{1}, s\circ \pi_{2})(a,b) \end{align*}

So I try to calculate this in separate blocks:

\begin{align*} D(\sin)(p\circ (\pi_{1}, s\circ \pi_{2})(a,b)) &= \cos(p\circ (\pi_{1}, s\circ \pi_{2})(a,b))\\ &= \cos(p\circ (\pi_{1}(a,b), [s\circ \pi_{2}](a,b)))\\ &= \cos(p\circ (a, s(b)))\\ &= \cos(p\circ (a, b^2)))\\ &= \cos(ab^2). \end{align*}

But this brings me to my first (among several) points of confusion.

In the equation: $$Df(a,b) = D(\sin)(p\circ (\pi_{1}, s\circ \pi_{2})(a,b))\circ Dp((\pi_{1}, s\circ \pi_{2})(a,b))\circ D(\pi_{1}, s\circ \pi_{2})(a,b)$$ it appears $D(\sin)(p\circ (\pi_{1}, s\circ \pi_{2})(a,b))$ should be a function, not a number. Can someone point out what my error in thinking is? (answered below)

Continuing on to compute the 3rd block,

\begin{align*} D(\pi_{1}, s\circ \pi_{2})(a,b) &= (D\pi_{1}(a,b), D(s\circ \pi_{2})(a,b))\\ &= (\pi_{1}(a,b), Ds(\pi_{2}(a,b))\circ D\pi_{2}(a,b))\\ &= (a, Ds(b)\circ \pi_{2}(a,b))\\ &= (a, 2b\circ b)\\ &= (a, 2b^2) \end{align*}

Now the middle one:

\begin{align*} Dp((\pi_{1}, s\circ\pi_{2})(a,b)) &= Dp((\pi_{1}(a,b), (s\circ \pi_{2})(a,b))\\ &= Dp(a, b^2) \end{align*}

Now substituting these smaller calculations, the whole thing simplifies down to: \begin{align*} Df(a,b) &= D(\sin)(p\circ (\pi_{1}, s\circ \pi_{2})(a,b))\circ Dp((\pi_{1}, s\circ \pi_{2})(a,b))\circ D(\pi_{1}, s\circ \pi_{2})(a,b)\\ &= \cos(ab^2)\circ \underbrace{Dp(a, b^2)\circ (a, 2b^2)}_{= a\cdot 2b^2 + b^2\cdot a}\\ &= \cos(ab^2)(3ab^2) \end{align*}

Now I will insist that I have something wrong. $Df(a,b)$ should be a map from $\mathbb{R}^{2}\to \mathbb{R}$. But it has collapsed into a single real number.

Spivak calculates the derivative using Jacobian notation, arriving at the conclusion that $f'(a,b) = (b^2\cdot\cos(ab^2), 2ab\cdot \cos(ab^2))$, which naturally is the transformation matrix for a map $\mathbb{R}^{2}\to \mathbb{R}$.

Sorry this problem is so long winded, but I wanted to show all my steps so as to be able to identify the one that went awry.

-

If $f: \mathbb{R}^m \longrightarrow \mathbb{R}^n$ is differentiable at $p \in \mathbb{R}^n$, then its derivative $Df(p)$ is the linear map $$Df(p) : \mathbb{R}^n \longrightarrow \mathbb{R}^m$$ such that $$\lim_{h \to 0} \frac{\|f(p + h) - f(p) - Df(p)h\|}{\|h\|} = 0.$$

For what you are asking, $\sin: \mathbb{R} \longrightarrow \mathbb{R}$ is differentiable everywhere, so at $p\circ (\pi_{1}, s\circ \pi_{2})(a,b) = ab^2 \in \mathbb{R}$, its derivative is a linear map $$D(\sin)(p\circ (\pi_{1}, s\circ \pi_{2})(a,b)): \mathbb{R} \longrightarrow \mathbb{R}.$$ Linear maps from $\mathbb{R}$ to $\mathbb{R}$ are just multiplication by scalars. In this case, for any vector $v \in \mathbb{R}$, we have $$D(\sin)(p\circ (\pi_{1}, s\circ \pi_{2})(a,b))(v) = \cos(ab^2)v.$$ This is how $D(\sin)(p\circ (\pi_{1}, s\circ \pi_{2})(a,b))$ is defined as a function from $\mathbb{R}$ to $\mathbb{R}$.

$(\pi_1, s \circ \pi_2)$ is a map from $\mathbb{R}^2$ to $\mathbb{R}^2$: $$(\pi_1, s \circ \pi_2)(x,y) = (x, y^2).$$ Then $D(\pi_1, s \circ \pi_2)(a,b)$ should be a linear map from $\mathbb{R}^2$ to $\mathbb{R}^2$. You obtained $(a, 2b^2)$ for this derivative, which is a map from $\mathbb{R}^2$ to $\mathbb{R}$. You should instead find $$D(\pi_1, s \circ \pi_2)(a,b) = \begin{pmatrix} 1 & 0 \\ 0 & 2b \end{pmatrix}.$$

You didn't write out what $Dp$ is either. You should find that $$Dp(a,b) = (b,a).$$

Putting this all together, you have that \begin{align*} Df(a,b) & = D(\sin)(p\circ (\pi_{1}, s\circ \pi_{2})(a,b)) \circ Dp((\pi_{1}, s\circ \pi_{2})(a,b)) \circ D(\pi_1, s \circ \pi_2)(a,b) \\ & = D(\sin)(ab^2) \circ Dp(a,b^2) \circ D(\pi_1, s \circ \pi_2)(a,b) \\ & = \cos(ab^2) (b^2, a) \begin{pmatrix} 1 & 0 \\ 0 & 2b \end{pmatrix} \\ & = \cos(ab^2) (b^2, 2ab) \\ & = (b^2 \cos(ab^2), 2ab \cos(ab^2)), \end{align*} as desired.

-
So this confirms it. Thanks Henry. –  roo Aug 9 '12 at 22:49
But this leads me to another issue which I will edit my post with momentarily. –  roo Aug 9 '12 at 23:00
Sorry that took so long. I hope my question is still clear. –  roo Aug 9 '12 at 23:38

This is a typo in the book. You can see in the Remark after the chain rule theorem $2$-$2$ that that composition symbol was supposed to be a multiplication dot.

-
I interpreted that remark in the following way: $Df$ is a linear transformation satisfying the equation (in place of $\lambda$) in the general definition of derivative on page 16. But $f'$ is the Jacobian matrix, or the transformation matrix corresponding to this linear transformation. So in $f'$ notation, multiplication is the operation that makes sense since we're talking about matrices. Where as in $Df$ notation, $\circ$ really should mean function composition. –  roo Aug 9 '12 at 22:33
@Kyle: Then I don't understand your problem in the question. If you're thinking of the composition symbol that way, then it's OK to have a "number" as its first operand, since that's just a linear transformation from $\mathbb R^1$ to $\mathbb R^1$, no? –  joriki Aug 9 '12 at 22:43
That may very well be the case. I'm confused though still because I went to great pains to be pedantic with symbols in order to avoid any sort of "interpret ... as ..." or "identify ... as ...". Perhaps this is just unavoidable, however. –  roo Aug 9 '12 at 22:48

Sorry to have wasted anyone's time. My error was the following, misquoting a previous theorem about $Df(a)$ for a linear transformation $f$:

When I say $D\pi_{1}(a,b) = \pi_{1}(a,b)$, this is false. The corrected version of the statement is $D\pi_{1}(a,b) = \pi_{1}$. This fixes the problem I think.

-
Notice that $f'(a, b) = \pmatrix{\frac{\partial f}{\partial x}(a, b)& \frac{\partial f}{\partial y}(a,b)}$, and $Df(a, b)$ is just left multiplication by $f'(a, b)$ –  Vectk Aug 10 '12 at 0:43