Deriving gradient in spherical coordinates

In summary: Cartesian basis.In summary, the professor set up a matrix and said we would just be looking for the inverse matrix. He used Cramer's Rule, but I'm not familiar with it. I think it involves the inverse matrix equaling the adjoint matrix over the determinant of the matrix. The adjoint matrix is the cofactor matrix transpose.
  • #1
Shackleford
1,656
2
I looked at my notes, but they're either incomplete or I simply forgot what the professor did to derive the gradient in spherical coordinates. Once I know that, deriving the divergence and curl given the supplementary equations listed is fairly straightforward. It was a little easier but certainly lengthy to do this for polar coordinates. We started by using the known formula for gradient in Cartesian coordinates and then using the chain rule with the Cartesian-to-polar coordinates equations to derive the polar coordinates gradient formula. However, consider this would be greatly more involved considering the Cartesian-to-spherical coordinates equations, I'm thinking there was a short-cut used that I didn't put in my notes. Thanks for any help.

sph.jpg
 
Physics news on Phys.org
  • #2
Compare what the chain rule gives you:

[tex]df = \frac{\partial f}{\partial r} dr + \frac{\partial f}{\partial \theta} d\theta + \frac{\partial f}{\partial \phi} d\phi[/tex]

with what the gradient gives you

[tex]df = (\nabla f)\cdot d\vec{r}[/tex]

This page goes into more detail:

http://math.mit.edu/classes/18.013A/HTML/chapter09/section04.html
 
  • #3
We didn't take the second approach, the change in distance/dot product one. We've used the chain rule extensively in this class.

Looking at using the chain rule method from Cartesian coordinates, it's going to be a ridiculously nasty process, and, I also don't know how to find ex, ey, and ez in spherical coordinates.
 
Last edited:
  • #4
Well, if you insist on doing it the painful way, there's really no way to avoid the pain. It's really not that bad, though. Just keep everything organized and check your steps along the way.

Going from ex, ey, and ez to er, eϕ, and eθ (or back) is just a change of basis. In other words, you're trying to solve equations like

ex = a1er + a2eϕ + a3eθ

It's just three linear equations and three unknown.
 
Last edited:
  • #5
vela said:
Well, if you insist on doing it the painful way, there's really no way to avoid the pain. It's really not that bad, though. Just keep everything organized and check your steps along the way.

Going from ex, ey, and ez to er, eϕ, and eθ (or back) is just a change of basis. In other words, you're trying to solve equations like

ex = a1er + a2eϕ + a3eθ

It's just three linear equations and three unknown.


Well, I wasn't quite following the other method, honestly.

A few of us met in his office yesterday and he set up a matrix. He said we would just be looking for the inverse matrix. He used Cramer's Rule, but I'm not familiar with it. I think it involves the inverse matrix equaling the adjoint matrix over the determinant of the matrix. The adjoint matrix is the cofactor matrix transpose. That was all new to me. I'm actually going to go out tonight on a Friday after work. I'll have to start this later tonight and scan it when I come to a stopping point. Thanks again for your help.
 
  • #6
vela said:
Well, if you insist on doing it the painful way, there's really no way to avoid the pain. It's really not that bad, though. Just keep everything organized and check your steps along the way.

Going from ex, ey, and ez to er, eϕ, and eθ (or back) is just a change of basis. In other words, you're trying to solve equations like

ex = a1er + a2eϕ + a3eθ

It's just three linear equations and three unknown.

I don't see how it's easier even using linear algebra. Say I do the change of basis into ex, ey, and ez in terms r, phi, and theta, I'll still have to use the chain rule when I write down the gradient equation. The partial of phi with respect to x? theta with respect to theta, etc.? :eek: They're very nasty.
 
  • #7
Actually, I think I found what I'm looking for.

http://planetmath.org/encyclopedia/%3Chttp://planetmath.org/?method=l2h&from=collab&id=76&op=getobj
 
Last edited by a moderator:
  • #8
Shackleford said:
I don't see how it's easier even using linear algebra. Say I do the change of basis into ex, ey, and ez in terms r, phi, and theta, I'll still have to use the chain rule when I write down the gradient equation. The partial of phi with respect to x? theta with respect to theta, etc.? :eek: They're very nasty.
There are two steps to the problem. One is calculating the gradient in terms of the derivatives with respect to r, phi, and theta by using the chain rule. The second is writing it in terms of er, ephi, and etheta; this part is just a change-of-basis problem. I had assumed this was your approach, and that's what I was talking about as well. I didn't mean to suggest a different way to solve the problem.

To use the chain rule, you're going to have to calculate those derivatives. Tedious, yes. Nasty, not so much. As you have seen on that page you found, the derivatives expressed in spherical coordinates are actually pretty simple in form.

The matrix A whose columns are er, ephi, and etheta is the one that takes you from coordinates in the spherical basis to coordinates in the Cartesian basis. What you need is its inverse. If you note that A is also a rotation matrix, you should realize A is an orthogonal matrix; therefore, its inverse is just its transpose.
Shackleford said:
Actually, I think I found what I'm looking for.

http://planetmath.org/encyclopedia/%3Chttp://planetmath.org/?method=l2h&from=collab&id=76&op=getobj
This page is actually deriving the Laplacian, not the gradient.
 
Last edited by a moderator:
  • #9
To elaborate a bit more, after the chain rule step, you'll have

[tex]\nabla f = (\textrm{stuff})\hat{e}_x + (\textrm{stuff})\hat{e}_y + (\textrm{stuff})\hat{e}_z[/tex]

where the stuff is expressed in terms of the spherical coordinates. To get your final answer, you want to change basis by multiplying the vector by A-1.

If you're not comfortable with the matrix stuff, you can solve equations like

ex = a1er + a2eϕ + a3eθ

to express the Cartesian basis vectors in terms of the spherical basis vectors and then substitute the results into your expression for the gradient and then simplify.
 
  • #10
vela said:
There are two steps to the problem. One is calculating the gradient in terms of the derivatives with respect to r, phi, and theta by using the chain rule. The second is writing it in terms of er, ephi, and etheta; this part is just a change-of-basis problem. I had assumed this was your approach, and that's what I was talking about as well. I didn't mean to suggest a different way to solve the problem.

To use the chain rule, you're going to have to calculate those derivatives. Tedious, yes. Nasty, not so much. As you have seen on that page you found, the derivatives expressed in spherical coordinates are actually pretty simple in form.

The matrix A whose columns are er, ephi, and etheta is the one that takes you from coordinates in the spherical basis to coordinates in the Cartesian basis. What you need is its inverse. If you note that A is also a rotation matrix, you should realize A is an orthogonal matrix; therefore, its inverse is just its transpose.

This page is actually deriving the Laplacian, not the gradient.

Yeah, sorry. As for that page, I meant that (2), (7), and (8) are very helpful. Now, I can plow through the chain rule less painfully. The rest, as you noted, is unrelated to what I'm doing.
 
  • #11
vela said:
To elaborate a bit more, after the chain rule step, you'll have

[tex]\nabla f = (\textrm{stuff})\hat{e}_x + (\textrm{stuff})\hat{e}_y + (\textrm{stuff})\hat{e}_z[/tex]

where the stuff is expressed in terms of the spherical coordinates. To get your final answer, you want to change basis by multiplying the vector by A-1.

If you're not comfortable with the matrix stuff, you can solve equations like

ex = a1er + a2eϕ + a3eθ

to express the Cartesian basis vectors in terms of the spherical basis vectors and then substitute the results into your expression for the gradient and then simplify.

Yeah, d/dx, d/dy, and d/dz will be in terms of r, phi, and theta. I'm familiar with the process in polar coordinates, but it was just a bit easier.

Is this the correct system I want to solve? This is what the professor wrote down. I want the inverse of the large matrix. And are you saying its inverse is its transpose? I've taken linear algebra, by the way. It was in fall 2008, though, so I am a bit rusty but still confident in doing linear algebra.

sph-1.jpg
 
  • #12
That's the matrix you want already. It converts vectors in the cartesian basis and gives you their coordinates in the spherical basis. You might notice that its rows are equal to the spherical basis vectors. Also, if you multiply it by its transpose, you'll get the identity matrix, so yes, its inverse is its transpose.

If you multiply the hybrid gradient by the matrix you have there, you should get the answer you shooting for.
 
  • #13
vela said:
That's the matrix you want already. It converts vectors in the cartesian basis and gives you their coordinates in the spherical basis. You might notice that its rows are equal to the spherical basis vectors. Also, if you multiply it by its transpose, you'll get the identity matrix, so yes, its inverse is its transpose.

If you multiply the hybrid gradient by the matrix you have there, you should get the answer you shooting for.

Yeah, I know the rows are the spherical basis vectors. That's where I got it. Hybrid gradient? If I'm understanding this correctly, then

ex = cos(theta)sin(phi)-er +cos(theta)cos(phi) e-theta + -sin(theta) e-phi
ey = sin(theta)sin(phi)-er +sin(theta)cos(phi) e-theta + cos(theta) e-phi
ez = cos(phi)-er -sin(phi) e-theta + 0 e-phi

I hope that's right. lol.
 
  • #14
Shackleford said:
Hybrid gradient?
:smile: Well, you have the gradient in Cartesian coordinates

[tex]\nabla = \textbf{e}_x \frac{\partial}{\partial x} + \textbf{e}_y \frac{\partial}{\partial y} + \textbf{e}_z \frac{\partial}{\partial z}[/tex]

and in spherical coordinates

[tex]\nabla = \textbf{e}_r \frac{\partial}{\partial r} + \textbf{e}_\phi \frac{1}{r} \frac{\partial}{\partial \phi} + \textbf{e}_\theta \frac{1}{r \sin \phi} \frac{\partial}{\partial \theta}[/tex]

but

[tex]\nabla = (\textrm{spherical stuff})\hat{e}_x + (\textrm{spherical stuff})\hat{e}_y + (\textrm{spherical stuff})\hat{e}_z[/tex]

is like a cross, or hybrid, between the two.
If I'm understanding this correctly, then

ex = cos(theta)sin(phi)-er +cos(theta)cos(phi) e-theta + -sin(theta) e-phi
ey = sin(theta)sin(phi)-er +sin(theta)cos(phi) e-theta + cos(theta) e-phi
ez = cos(phi)-er -sin(phi) e-theta + 0 e-phi

I hope that's right. lol.
Yeah, that's right.
 
  • #15
Well, I've worked out dr/dx, dr/dy, dr/dz, d(phi)/dx, d(phi)/dy, d(phi)/dz.

I'm having trouble with d(theta)/dx, d(theta)/dy, and for d(theta)/dz, I get

-1/[r*sin(theta)]
 
  • #16
I'm not sure how you're getting that. You have θ=cos-1(y/x), so ∂θ/∂z=0 by inspection.
 
  • #17
vela said:
I'm not sure how you're getting that. You have θ=cos-1(y/x), so ∂θ/∂z=0 by inspection.

Well, d(phi)/dz is 0.
 
  • #18
Oh, so you're not following the convention used in your initial post, where theta and phi were backwards (mathematicians would disagree)?
 
  • #19
vela said:
Oh, so you're not following the convention used in your initial post, where theta and phi were backwards (mathematicians would disagree)?

Oh, damn, I didn't even notice that. I was checking my work with the website I posted earlier. I just need to switch theta and phi from that website to be consistent with our (original) notation - r, phi, theta, not r, theta, phi.
 

What is the formula for calculating gradient in spherical coordinates?

The formula for calculating gradient in spherical coordinates is given by:
∇f = (∂f/∂r)er + (1/r)(∂f/∂θ)eθ + (1/rsinθ)(∂f/∂ϕ)eϕ

How do you derive the gradient in spherical coordinates?

To derive the gradient in spherical coordinates, we use the chain rule to express the partial derivatives with respect to r, θ, and ϕ in terms of the Cartesian coordinates x, y, and z. Then, we substitute these expressions into the formula for gradient in spherical coordinates.

What is the significance of gradient in spherical coordinates?

The gradient in spherical coordinates represents the rate of change of a function in all three directions (r, θ, and ϕ) at a given point. It is an important concept in physics and engineering, as it helps us understand the direction and magnitude of change in a scalar or vector field.

What are the limitations of using gradient in spherical coordinates?

The main limitation of using gradient in spherical coordinates is that it can only be applied to functions that are defined in terms of spherical coordinates. It is not applicable to functions defined in Cartesian coordinates or other coordinate systems.

How is gradient in spherical coordinates related to other coordinate systems?

The gradient in spherical coordinates is related to the gradient in other coordinate systems through transformation equations. For example, the gradient in Cartesian coordinates can be expressed in terms of the gradient in spherical coordinates using the inverse transformation equations.

Similar threads

  • Calculus and Beyond Homework Help
Replies
7
Views
690
  • Calculus and Beyond Homework Help
Replies
1
Views
1K
Replies
33
Views
3K
Replies
2
Views
890
  • Electromagnetism
Replies
4
Views
791
  • Calculus and Beyond Homework Help
Replies
3
Views
1K
  • Advanced Physics Homework Help
Replies
9
Views
2K
  • Calculus and Beyond Homework Help
Replies
8
Views
1K
Replies
8
Views
1K
  • Linear and Abstract Algebra
Replies
1
Views
759
Back
Top