# Simple partial differentiation $x = r\cos\theta$ and $y = r\sin\theta$

If

\begin{align} x &= r\cos\theta,\\ y &= r\sin\theta, \end{align}

find

$$\dfrac{\partial^2\theta}{\partial{x}\partial{y}}.$$

How can I find this partial derivative?

I need to prove that

$$\frac{\partial^2\theta}{\partial{x}\partial{y}} = -\frac{\cos2\theta}{r^2}.$$

-
Please try to write $\theta$ as a function of $x$ and $y$ first. –  Shuhao Cao Sep 7 '12 at 17:27
Use $\arccos$ and $\arcsin$ derivatives. You can find them using $\cos(\arccos(x))=x$ and $\cos^2(x)+\sin^2(x)=1$. –  vanna Sep 7 '12 at 17:28
@vanna Inverse trig functions should be avoided unless OP knows for a fact that all angles are in the first quadrant. –  alex.jordan Sep 7 '12 at 17:43
@alex.jordan OP deserve an elegant solution. –  vanna Sep 7 '12 at 17:59
@vanna Any complete solution that makes use of inverse trig functions will not be elegant. It will necessarily involve cases for at least two halves of the plane, plus a separate argument for the boundary of those two halves. –  alex.jordan Sep 7 '12 at 18:16

I'll assume that $x$ and $y$ are independent. All we need do is carefully differentiate both sides of relations making use of the chain rule and the product rule. (Inverse trig functions are not continuous as $\theta$ crosses major axes on the plane, so their use in this kind of differentiation problem should be avoided, unless say you have extra information that $(x,y)$ will be confined to quadrant I.)

Since $\tan(\theta)={y\over x}$, we can use this as a starting point with no $r$ involved. Applying ${\partial\over\partial y}$ and ${\partial\over\partial x}$: \begin{align} \sec^2(\theta)\frac{\partial \theta}{\partial y}&=\frac{1}{x}\\ \sec^2(\theta)\frac{\partial \theta}{\partial x}&=-\frac{y}{x^2}\\ \end{align} Differentiating the first equation with respect to $x$ gives: \begin{align} 2\,\sec^2(\theta)\tan(\theta)\frac{\partial \theta}{\partial y}\frac{\partial \theta}{\partial x}+\sec^2(\theta)\frac{\partial^2 \theta}{\partial x\partial y}&=-\frac{1}{x^2}\\ \end{align} Substituting in from the first equation, \begin{align} \frac{2}{x}\tan(\theta)\frac{\partial \theta}{\partial x}+\sec^2(\theta)\frac{\partial^2 \theta}{\partial x\partial y}&=-\frac{1}{x^2}\\ \end{align} Multiplying be $\sec^2(\theta)$ and subbing in using the second equation: \begin{align} -\frac{2y}{x^3}\tan(\theta)+\sec^4(\theta)\frac{\partial^2 \theta}{\partial x\partial y}&=-\frac{1}{x^2}\sec^2(\theta)\\ \end{align} So we have \begin{align} \frac{\partial^2 \theta}{\partial x\partial y}&=-\frac{1}{x^2}\cos^2(\theta)+\frac{2y}{x^3}\tan(\theta)\cos^4(\theta)\\ \end{align}

Now there are many alternative expressions for this, if you sub in the original relations between $x$, $y$, $\theta$, and $r$. Here is one: \begin{align} \frac{\partial^2 \theta}{\partial x\partial y}&=-\frac{1}{r^2}+\frac{2y}{x^3}\frac{y}{x}\frac{x^4}{r^4}\\ &=-\frac{1}{r^2}+\frac{2y^2}{r^4}\\ &=\frac{1}{r^2}\left(-1+\frac{2y^2}{r^2}\right)\\ &=\frac{1}{r^2}\left(-1+2\sin^2(\theta)\right)\\ \end{align}

And then a double-angle formula for cosine gives the desired result.

-
thnx a lot, but i have added a small extension to original issue –  AppDeveloper Sep 7 '12 at 17:43
how can this be worked out ? prove that $\dfrac{\partial{^2\theta}}{\partial{x}\,\partial{y}}$ = $-cos2\theta\over r^2$ –  AppDeveloper Sep 7 '12 at 17:48
@classic.programmer So edited. Also, I had $x$ and $y$'s roles reversed earlier. –  alex.jordan Sep 7 '12 at 18:00

Be $f(x,y)$ a real function and be

$$\bar{f}(r,\theta)=f(r\cos\theta,r\sin\theta)=f(x,y)$$

its corresponding function after the change of variables. We have by the chain rule

\left\{ \begin{align} \frac{\partial{\bar{f}}}{\partial{r}}&= \cos\theta\frac{\partial{f}}{\partial{x}} +\sin\theta\frac{\partial{f}}{\partial{y}},\\ \frac{\partial{\bar{f}}}{\partial{\theta}}&= -r\sin\theta\frac{\partial{f}}{\partial{x}} +r\cos\theta\frac{\partial{f}}{\partial{y}}. \end{align} \right.

Solving this system with respect to $\partial{f}/\partial{x}$, $\partial{f}/\partial{y}$, we have

\left\{ \begin{align} \frac{\partial{f}}{\partial{x}}&= \cos\theta\frac{\partial{\bar{f}}}{\partial{r}} -\frac{\sin\theta}{r}\frac{\partial{\bar{f}}}{\partial{\theta}},\\ \frac{\partial{f}}{\partial{y}}&= \sin\theta\frac{\partial{\bar{f}}}{\partial{r}} +\frac{\cos\theta}{r}\frac{\partial{\bar{f}}}{\partial{\theta}}. \end{align} \right.

Applying $\partial/\partial{y}$ to $\partial{f}/\partial{x}$ we have

\begin{align} &\frac{\partial^2{f}}{\partial{x}\partial{y}} =\frac{\partial}{\partial{y}}\frac{\partial{f}}{\partial{x}} =\left(\sin\theta\frac{\partial{}}{\partial{r}} +\frac{\cos\theta}{r}\frac{\partial{}}{\partial{\theta}}\right) \left(\cos\theta\frac{\partial{\bar{f}}}{\partial{r}} -\frac{\sin\theta}{r}\frac{\partial{\bar{f}}}{\partial{\theta}}\right)\\ &\qquad=\frac{\sin2\theta}{2} \frac{\partial^2{\bar{f}}}{\partial{r^2}} +\frac{\cos2\theta}{r} \frac{\partial^2{\bar{f}}}{\partial{r}\partial\theta} -\frac{\sin2\theta}{2r^2} \frac{\partial^2{\bar{f}}}{\partial{\theta^2}} -\frac{\sin2\theta}{2r} \frac{\partial{\bar{f}}}{\partial{r}} -\frac{\cos2\theta}{r^2} \frac{\partial{\bar{f}}}{\partial{\theta}}. \end{align}

If we take $\bar{f}=\theta$ and take into account

$$\frac{\partial^2\theta}{\partial{r^2}} =\frac{\partial^2\theta}{\partial{r}\partial\theta} =\frac{\partial^2\theta}{\partial\theta^2} =\frac{\partial\theta}{\partial{r}}=0, \qquad\frac{\partial\theta}{\partial\theta}=1,$$

only the last term remains, and we have

$$\frac{\partial^2\theta}{\partial{x}\partial{y}}=-\frac{\cos2\theta}{r^2}.$$

-

Use $$\frac{y}{x} = \tan \theta \Rightarrow \theta = \tan^{-1}\left(\frac{y}{x}\right) + 2 \pi n,$$ where $n$ is an integer, $$\frac{d}{dx} \tan^{-1} x = \frac{1}{1+x^2},$$ and $$\frac{\partial}{\partial u} f\left(g\left(u,v\right)\right) = \frac{df}{dg} \frac{\partial g}{\partial u}.$$

-
Careful. $\frac{y}{x}=\tan(\theta)$ does not imply $\theta=\tan^{-1}\left(\frac{y}{x}\right)$. –  alex.jordan Sep 7 '12 at 17:40
I updated my solution to incorporate the point I think you were getting at, though it has no consequence in this problem. Correct me if you think that is wrong. –  Eric Angle Sep 7 '12 at 17:48
The problem I am getting at is that any method for finding these partial derivatives that uses inverse trig functions is invalid for certain critical $\theta$. Since you are using $\arctan$, this method will not be valid for $\theta$ crossing over from say $\pi-\epsilon$ to $\pi+\epsilon$. And yet partial derivatives of $\theta$ when $\theta=\pi$ should be defined here. This method will lead to the same final result as other methods, but only because two points of neglect in the argument will "cancel each other out". –  alex.jordan Sep 7 '12 at 18:11
With more thought, I have another criticism that also applies to my own solution: Any solution that tries to eliminate $r$ from consideration by using $\tan(\theta)=y/x$ is inherently flawed, in that we are immediately removing all points with $x=0$ from valid consideration. A better solution would just use partial derivatives and the chain rule carefully on the original two relations and never potentially divide by $0$. –  alex.jordan Sep 7 '12 at 18:36

Using $\theta = \arcsin\left(\frac{y}{r}\right)$ and $\arcsin'(t) = \frac{1}{\sqrt{1-t^2}}$ we get $$\frac{\partial \theta}{\partial y} = \frac{1}{r} \frac{1}{\sqrt{1- \left(\frac{y}{r}\right)^2}} = \frac{1}{x}$$ using $r^2 = x^2 + y^2$. Hence $$\frac{ \partial \theta}{\partial x\partial y} = -\frac{1}{x^2} = -\frac{\cos^2(\theta)}{r^2}$$

-
And what if OP wants to know the value of the partial for some point with $\theta\in(\pi/2,\pi)$? Your initial premise that $\theta =\arcsin\left(y\over r\right)$ is then false. This is the point that I am trying to make why inverse trig functions should be avoided in problems like these. –  alex.jordan Sep 7 '12 at 18:14
Just translate your $\theta$ by a constant to make my statement true. Differentiation won't see a difference. –  vanna Sep 8 '12 at 10:56
Firstly, you'd need to reflect, not translate, if $\theta\in(\pi/2,\pi)$. And what if $\theta=\pi/2$, right on the boundary where $\sin$ is two-to-one? No translation/reflection will help if you want to keep using $\arcsin$. You'd probably switch to $\arccos$, which gives outputs surrounding $\pi/2$. This necessary case-wise approach is why in my feeling, the inverse trig functions should be avoided for doing calculus on the plane in polar coordinates. It's not as elegant as you claim if you give a complete solution. –  alex.jordan Sep 8 '12 at 16:10
Got your point. My proof holds for cases where $\theta\in(0,\frac{\pi}{2})$. –  vanna Sep 8 '12 at 16:21

Note that the following argument never involves division by any variable other than $r$, nor does it use inverse trig functions. This makes the argument valid everywhere except at the origin, which is OK since the partial derivative is clearly undefined there anyway, since at the origin $\theta$ can be any angle. These features distinguish this answer from other answers, including my own earlier answer.

First we can take the first relation and apply $\partial\over\partial x$ and then we can take the first relation and apply $\partial\over\partial y$. Lastly, we can apply both. \begin{align} x & = r\cos(\theta)& (1)\\ 1 & = r_x\cos(\theta)-r\sin(\theta)\,\theta_x & (2)\\ 0 & = r_y\cos(\theta)-r\sin(\theta)\,\theta_y & (3)\\ 0 & = r_{xy}\cos(\theta)-r_x\sin(\theta)\theta_y-r_y\sin(\theta)\,\theta_x-r\cos(\theta)\,\theta_x\theta_y-r\sin(\theta)\,\theta_{xy}&(4) \end{align}

If we treat the second relation the same way: \begin{align} y & = r\sin(\theta)& (5)\\ 0 & = r_x\sin(\theta)+r\cos(\theta)\,\theta_x&(6)\\ 1 & = r_y\sin(\theta)+r\cos(\theta)\,\theta_y&(7)\\ 0 & = r_{xy}\sin(\theta)+r_x\cos(\theta)\theta_y+r_y\cos(\theta)\,\theta_x-r\sin(\theta)\,\theta_x\theta_y+r\cos(\theta)\,\theta_{xy}&(8) \end{align}

Equation (6) helps us simplify equation (4), and then equation (3) helps us simplify equation (8): \begin{align} 0 & = r_{xy}\cos(\theta)-r_y\sin(\theta)\,\theta_x-r\sin(\theta)\,\theta_{xy}&(9)\\ 0 & = r_{xy}\sin(\theta)+r_x\cos(\theta)\theta_y+r\cos(\theta)\,\theta_{xy}&(10) \end{align} Multiplying the above by $-\sin(\theta)$ and $\cos(\theta)$ respectively, and adding equations lets us eliminate the second derivatives of $r$: \begin{align} 0 & = r_y\sin^2(\theta)\,\theta_x+r_x\cos^2(\theta)\,\theta_y+r\,\theta_{xy}&(11)\\ \end{align} Multiplying by $r$, then subbing in equations (7) and (2), and then expanding and simplifying: \begin{align} 0 & = r_y\sin(\theta)r\sin(\theta)\,\theta_x+r_x\cos(\theta)r\cos(\theta)\,\theta_y+r^2\,\theta_{xy}&(12)\\ 0 & = r_y\sin(\theta)(r_x\cos(\theta)-1)+r_x\cos(\theta)(1-r_y\sin(\theta))+r^2\,\theta_{xy}&(13)\\ 0 & = -r_y\sin(\theta)+r_x\cos(\theta)+r^2\,\theta_{xy}&(14)\\ \end{align} The partials $r_x$ and $r_y$ are easy to establish in terms of $x$ and $y$, unlike $\theta_x$ and $\theta_y$, which don't have clear formulas because of the issues regarding discontiunity of inverse trig functions. Basically, $r^2=x^2+y^2\implies2rr_x=2x$ and $2rr_y=2y\implies r_x=x/r$ and $r_y=y/r$. \begin{align} 0 & = -\frac{y}{r}\sin(\theta)+\frac{x}{r}\cos(\theta)+r^2\,\theta_{xy}&(15)\\ 0 & = -\sin^2(\theta)+\cos^2(\theta)+r^2\,\theta_{xy}&(16)\\ 0 & = \cos(2\theta)+r^2\,\theta_{xy}&(17)\\ \end{align} Which implies the desired result $$\theta_{xy}=-\frac{\cos(2\theta)}{r^2}$$

-

Here's another method in which we avoid any risk of accidentally dividing by $0$, I'm assuming here that $x,y$ are not dependent--that is, neither is a function with the other as a variable, and so $\frac{\partial x}{\partial y}=\frac{\partial y}{\partial x}=0$. Let me know if that's incorrect, and I'll adapt my answer accordingly.

We may first observe that $r^2=x^2+y^2$, so since $\frac{\partial x}{\partial y}=0$ and $y=r\sin\theta$, then $$2r\frac{\partial r}{\partial y}=2x\frac{\partial x}{\partial y}+2y=2y=2r\sin\theta.$$ Now, there are two ways this can happen: either (i) $r=0$ (in which case your given expression for the mixed partial cannot hold) or (ii) $r\neq 0$ and $\frac{\partial r}{\partial y}=\sin\theta$. Similarly, either (i) $r=0$ or (ii) $r\neq 0$ and $\frac{\partial r}{\partial x}=\cos\theta$.

Let's see what happens in the case that $r\neq 0$, $\frac{\partial r}{\partial y}=\sin\theta$, and $\frac{\partial r}{\partial x}=\cos\theta$. Since $x=r\cos\theta$, $\frac{\partial x}{\partial y}=0$, and $\frac{\partial r}{\partial y}=\sin\theta$, then by product and chain rules, we have $$0=\cos\theta\frac{\partial r}{\partial y}-r\sin\theta\frac{\partial\theta}{\partial y}=\cos\theta\sin\theta-r\sin\theta\frac{\partial\theta}{\partial y}.\tag{1}$$ Similarly, since $y=r\sin\theta$ and $\frac{\partial r}{\partial y}=\sin\theta$, then $$1=\sin^2\theta+r\cos\theta\frac{\partial\theta}{\partial y}.\tag{2}$$ With some rearrangement, dividing through by $r\neq 0$, and an application of the Pythagorean Identity, we have $$\frac1r\cos\theta\sin\theta=\sin\theta\frac{\partial\theta}{\partial y},\tag{1'}$$ $$\frac1r\cos^2\theta=\cos\theta\frac{\partial\theta}{\partial y}.\tag{2'}$$ Now, since $\frac{\partial r}{\partial x}=\cos\theta$, then differentiating $(2')$ with respect to $x$, we have again by chain and product rules, and by substitution using $(1')$, that

$\begin{eqnarray*} -2\cos\theta\sin\theta\frac{\partial\theta}{\partial x} & = & \cos\theta\frac{\partial\theta}{\partial y}\frac{\partial r}{\partial x}-r\sin\theta\frac{\partial\theta}{\partial y}\frac{\partial\theta}{\partial x}+r\cos\theta\frac{\partial^2\theta}{\partial x\partial y}\\ & = & \cos^2\theta\frac{\partial\theta}{\partial y}-r\sin\theta\frac{\partial\theta}{\partial y}\frac{\partial\theta}{\partial x}+r\cos\theta\frac{\partial^2\theta}{\partial x\partial y}\\ & = & \cos^2\theta\frac{\partial\theta}{\partial y}-\cos\theta\sin\theta\frac{\partial\theta}{\partial x}+r\cos\theta\frac{\partial^2\theta}{\partial x\partial y}, \end{eqnarray*}$

and so $$0=\left(\cos\theta\frac{\partial\theta}{\partial y}+\sin\theta\frac{\partial\theta}{\partial x}+r\frac{\partial^2\theta}{\partial x\partial y}\right)\cos\theta.\tag{3}$$

Since $\frac{\partial r}{\partial x}=\cos\theta$, then differentiating $(1')$ with respect to $x$, we have again by chain and product rules, and by substitution using $(2')$, that

$\begin{eqnarray*} (\cos^2\theta-\sin^2\theta)\frac{\partial\theta}{\partial x} & = & \sin\theta\frac{\partial\theta}{\partial y}\frac{\partial r}{\partial x}+r\cos\theta\frac{\partial\theta}{\partial y}\frac{\partial\theta}{\partial x}+r\sin\theta\frac{\partial^2\theta}{\partial x\partial y}\\ & = & \cos\theta\sin\theta\frac{\partial\theta}{\partial y}+r\cos\theta\frac{\partial\theta}{\partial y}\frac{\partial\theta}{\partial x}+r\sin\theta\frac{\partial^2\theta}{\partial x\partial y}\\ & = & \cos\theta\sin\theta\frac{\partial\theta}{\partial y}+\cos^2\theta\frac{\partial\theta}{\partial x}+r\sin\theta\frac{\partial^2\theta}{\partial x\partial y}, \end{eqnarray*}$

and so $$0=\left(\cos\theta\frac{\partial\theta}{\partial y}+\sin\theta\frac{\partial\theta}{\partial x}+r\frac{\partial^2\theta}{\partial x\partial y}\right)\sin\theta.\tag{4}$$

Now, $\cos\theta$ and $\sin\theta$ are never simultaneously $0$, so by $(3)$ and $(4)$, it follows that $$\cos\theta\frac{\partial\theta}{\partial y}+\sin\theta\frac{\partial\theta}{\partial x}+r\frac{\partial^2\theta}{\partial x\partial y}=0$$ in any case, so since $r\neq 0$, then $$\frac{\partial^2\theta}{\partial x\partial y}=-\frac1r\cos\theta\frac{\partial\theta}{\partial y}-\frac1r\sin\theta\frac{\partial\theta}{\partial x},$$ whence substitution using $(2')$ yields $$\frac{\partial^2\theta}{\partial x\partial y}=-\frac{\cos^2\theta}{r^2}-\frac1r\sin\theta\frac{\partial\theta}{\partial x}.\tag{5}$$ Since $x=r\cos\theta$ and $\frac{\partial r}{\partial x}=\cos\theta$, then in a similar fashion to our development of $(2')$ we find that $$\frac1r\sin^2\theta=-\sin\theta\frac{\partial\theta}{\partial x},\tag{6}$$ and subbing this into $(5)$ gives us $$\frac{\partial^2\theta}{\partial x\partial y}=-\frac{\cos^2\theta-\sin^2\theta}{r^2}.\tag{5'}$$ Finally, a double angle identity for cosine gives us the desired result.

-