# Homework Help: Derivative with respect to a unit vector: is my computation right?

1. Oct 28, 2012

### fairy._.queen

Hi all!
I must compute a derivative with respect to the components of a unit vector $\hat{p}^{i}$. In spherical coordinates,
$\hat{p}^{1}=\hat{p}^{1}(\theta,\phi)=\cos\theta \sin\phi$

I want to express the derivative $\frac{\partial}{\partial\hat{p}^1}$ as a combination of $\frac{\partial}{\partial\theta}$ and $\frac{\partial}{\partial\phi}$.
What I did is:
$\frac{\partial f}{\partial\hat{p}^1}=\frac{\partial f}{\partial\theta}\frac{\partial\theta}{\partial \hat{p}^1}+\frac{\partial f}{\partial\phi}\frac{\partial\phi}{\partial\hat{p}^1}$

Since $\frac{\partial\hat{p}^1}{\partial\theta}=-\sin\theta\sin\phi$ and $\frac{\partial\hat{p}^i}{\partial\phi}=\cos\theta \cos\phi$ I thought
$\frac{\partial\theta}{\partial\hat{p}^1}=-\frac{1}{\sin\theta\sin\phi}$ and $\frac{\partial\phi}{\partial\hat{p}^1}=\frac{1}{ \cos\theta\cos\phi}$

so that the final derivative is
$\frac{\partial f}{\partial\hat{p}^1}=-\frac{1}{\sin\theta\sin\phi}\frac{\partial f}{\partial\theta}+\frac{1}{\cos\theta\cos\phi} \frac{\partial f}{\partial\phi}$

I would like to know if all this is correct. Thanks in advance!

2. Oct 29, 2012

### fairy._.queen

Anybody?

3. Oct 29, 2012

### aralbrec

Your unit vector looks like a scalar with magnitude that isn't 1. It could be I am not familiar with the notation.

But what I spotted was the inverting of a partial derivative. In functions of one variable, it is valid to invert dy/dx to get dx/dy but this is not generally true of partial differentials. Lookup Jacobians to find out how to do it.

4. Oct 29, 2012

### fairy._.queen

$\hat{p}^1$ is the first component of a unit vector, the other two are
$\hat{p}^2=\sin\theta\sin\phi$
$\hat{p}^3=\cos\phi$

Could you please explain further what you mean by looking up the Jacobian to find out how to invert partial derivatives?
Thanks again!

5. Oct 30, 2012

### aralbrec

I saw above you did ∂p/∂θ => ∂θ/∂p . This is not true.

Just for an easy example, consider cartesian and polar in 2d. We have this:

x=r cosθ
y=r sinθ

This tells how to convert from polar to cartesian coordinates and we can use these functions to find all partial derivatives of x or y with respect to r,θ in a straightforward manner. Finding partials of r,θ with respect to x,y would involve first solving for r,θ in terms of x,y and then taking the partials.

Let's do one.

∂x/∂r = cosθ

r=√(x2+y2)
∂r/∂x = x/√(x2+y2) = cosθ
(above I used tanθ = y/x)

Notice ∂x/∂r ≠ (∂r/∂x)-1

So the intuitive guess didn't work, take a closer look at what is happening. The polar to cartesian functions are explicitly defining x,y in terms of r,θ but if we regard x,y as the independent variables, they are also implicity defining r,θ. So rewrite the equations like so:

f1(x,y,r(x,y),θ(x,y)) = 0 = x -rcosθ
f2(x,y,r(x,y),θ(x,y)) = 0 = y -rsinθ

I have decided I want x,y to be independent and r,θ will be the functions I am after; this is like solving the above equations for r,θ in terms of x,y as I did with r=√(x2+y2)

I'm after ∂r/∂x so let's take partial derivatives of those two equations wrt x:

∂f1/∂x = 1 + rsinθ ∂θ/∂x - cosθ ∂r/∂x = 0
∂f2/∂x = -rcosθ ∂θ/∂x - sinθ ∂r/∂x = 0

Arrange this into a matrix with ∂θ/∂x and ∂r/∂x being the unknowns and solve for ∂r/∂x using Cramer's Rule. You'll find ∂r/∂x = cosθ

This prodecure can be generalized and the matrix you get (as I found above) is called the Jacobian. You can then use the Jacobian to compute the inverted partials.

6. Oct 30, 2012

### fairy._.queen

Thank you very much!