Gradient derivation

RoySalinas1 770 views 7 slides Apr 07, 2020
Slide 1
Slide 1 of 7
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7

About This Presentation

The derivation of the spherical gradient from an intuitive perspective. We begin from Cartesian coordinates and work our way through to spherical coordinates.


Slide Content

DERIVING THEGRADIENT INSPHERICALCOORDINATES
Roy Salinas
Abilene Christian University
Abilene, Texas 79601
[email protected]
April 7, 2020
1 Introduction
You have wandered here because you are either:
trying to derive the spherical gradient
are bored
nd this cool
all of the above
If any of those apply to you, hopefully this document will help you with alleviate your troubles! This is meant to be an
introductory level document with a bit of prior knowledge in calculus that describes how one can go to deriving the
spherical gradient starting out in Cartesian coordinates.

2 Vectors
This section is to familiarize yourself with vectors but if you are already comfortable with vectors, you can go ahead
and go to the next section. Otherwise, feel free to start here!
2.1 What is a Vector?
My rst assumption will be that my audience is familiar are familiar with some math. A vector representssome amount
in acertain direction. A very simple vector is shown below
x=(some scalar)^x
where the scalar denotes the magnitude in the x direction. The direction towards the x axis is represented with the
"carrot top" or "hat" symbol, choose your favorite. That's all a vector is! We can now create a three dimensional vector
in Cartesian coordinates using this simple example
r=x^x+y^y+z^z (1)
xyzr
That's all there is to vectors!
2.2 Basis Vectors
Having established what vectors are, you might have wondered to yourself what are basis vectors and if they're any
different from the vectors we have already established? They are similar to regular vectors with the caveat of basis
vectors being the constituents of a "regular" vector. Let's say we have a setBthat contains elements - basis vectors in
this case - of a vector spaceV. If we can write any element of this vector space in terms of the linearly independent set
B, our setBis said to be a basis for the vector spaceV. This is to say that the vector spaceVspans the setB. Let's break
down what that means:

set of elements B: Just a set that contains objects that are vectors. Think of it in terms of[u1u2u3] where in
this caseu1=^x,u2=^y,u3=^z
Vector spaceV: A Euclidean space that can be represented by a collection of objects such as vectors.

Spans the set of basis vectorsB: the vector spaceVcan be represented with a linear combination of the basis
vectors that are in setB. Any vector in the vector spaceVcan be written in terms of elements in setB
2

3 Derivation of Gradient in Spherical Coordinates
3.1 Spherical Coodinates
We begin this endeavor with spherical coordinates :,r, and.
Figure 1:Differential element in spherical coordinates
We want to go from the gradient in Cartesian coordinates to the gradient in spherical coordinates.
r=^x
@
@x
+^y
@
@y
+^z
@
@z
! r=^r
@
@r
+
^

1
r
@
@
+
^

1
rsin
@
@
We begin our journey by expressing our Cartesian coordinates in terms of their spherical cousins. In the following set
of equations,Ais a line that is orthogonal to the z axis and creates the arc in thedirection. It can be viewed as an
intermediate variable.
cos=
z
r
!z=rcos
cos=
x
A
!x=Acos!x=rsincos
sin=
y
A
!y=Asin!y=rsinsin
"
x
y
z
#
=
"
sincos
sinsin
cos
#
r
We can also express our spherical coordinates in terms of our Cartesian coordinates
r=
p
x
2
+y
2
+z
2
= tan
1
y
x
= tan
1
p
x
2
+y
2
z
3

xyzrA
Figure 2:Spherical Coordinate system with A component represented in blue
3.2 Transforming partial derivatives
Now we are getting to the gritty part of this where we are transforming the partial derivatives using the relationships we
have established. Please, hold onto your hats and pencils! We begin by using the chain rule for each partial derivative in
Cartesian coordinates and expressing them in terms of our partials in spherical coordinates.
@
@x
=
@r
@x
@
@r
+
@
@x
@
@
+
@
@x
@
@
@
@y
=
@r
@y
@
@r
+
@
@y
@
@
+
@
@y
@
@
@
@z
=
@r
@z
@
@r
+
@
@z
@
@
+
@
@z
@
@
If you are wondering to yourself why was the chain rule invoked here and how does this help at all??? The following
explanation should help but if you are already comfortable with why it is used here, you can merry along.
3.2.1 Why use the chain rule?
The reason we utilize the chain rule here is due to having our coordinatesx,y, andzin terms ofr,,. Let's take a
look atxfor example:
x=rsincos!x=f(r; ; )
Herexis a function ofr,,and to represent the partial derivative in terms of our spherical coordinates requires
including all of the components to nd the partial in respect to x.
3.3 Calculating each partial derivative
I really hope you are still holding onto your pencil and hat. We now begin calculating each partial derivative that was
established in3.2with the relationships that we found in3.1. The following will outline the important steps in each
partial derivative but won't work out every detail. I do recommend working out the partial derivatives yourself to
familiarize yourself with the process. There will be a link towards the end of this document with the details of how this
was calculated so you can check your work!
4

3.3.1
@
@x
term
@r
@x
=
@
@x
p
x
2
+y
2
+z
2
= (x
2
+y
2
+z
2
)
1=2
x=
x
r
= cossin
@
@x
=
@
@x
tan
1
(
p
x
2
+y
2
z
)!
@
@x
tan
1
() =
1
1 +
2
@
@x
=
zx
r
2
(x
2
+y
2
)
1=2
=
coscos
r
@
@x
=
@
@x
tan
1
(
y
x
)!
@
@x
tan
1
() =
1
1 +
2
@
@x
=
sin
rsin
3.3.2
@
@y
term
@r
@y
=
@
@y
p
x
2
+y
2
+z
2
= (x
2
+y
2
+z
2
)
1=2
y=
y
r
= sinsin
@
@y
=
@
@y
tan
1
(
p
x
2
+y
2
z
)!
@
@y
tan
1
() =
1
1 +
2
@
@y
=
zy
r
2
(x
2
+y
2
)
1=2
=
cossin
r
@
@y
=
@
@y
tan
1
(
y
x
)!
@
@y
tan
1
() =
1
1 +
2
@
@y
=
cos
rsin
3.3.3
@
@z
term
@r
@z
=
@
@z
p
x
2
+y
2
+z
2
= (x
2
+y
2
+z
2
)
1=2
z=
z
r
= cos
@
@z
=
@
@z
tan
1
(
p
x
2
+y
2
z
)!
@
@z
tan
1
() =
z
2
rsin
r
2
z
2
=
sin
r
@
@x
=
@
@z
tan
1
(
y
x
) = 0
3.4 Finishing up (almost)
We have now derived the partial for each Cartesian coordinate in terms ofr,,. Before you move on, make sure you
understand why we have used the chain rule, the relationship between the Cartesian and spherical coordinates, and that
it is ok to nd this grueling. Now we begin to plug into our Cartesian gradient.
^x
@
@x
=^x(cossin
@
@r
+
coscos
r
@
@

sin
rsin
@
@
)
^y
@
@y
=^y(sinsin
@
@r
+
cossin
r
@
@
+
cos
rsin
@
@
)
^z
@
@z
=^z(cos
@
@r

sin
r
@
@
)
r=
2
6
4
cossin
@
@r
coscos
r
@
@
sin
rsin
@
@
sinsin
@
@r
cossin
r
@
@
cos
rsin
@
@
cos
@
@r
sin
r
@
@
0
3
7
5
T
"
^x
^y
^z
#
One can see how this can become a lengthy expression if it were to placed in one single line (thankfully we can use a
matrix).We won't place it in a single line to save the electronic trees from getting cut down by the electronic corporations
5

who are responsible for electronic deforestation. Do keep in mind that these partialsdoget plugged into the following
gradient
r=^x
@
@x
+^y
@
@y
+^z
@
@z
Now that we have the gradientalmostto where we want it, we now need to nd the correct unit vectors. Why do we
need the correct unit vectors you may ask yourself? Unit vectors are signicant because theypointyou in the direction
that isincreasing. Finding a unit vector is very similar to nding a regular vector except that you have to normalize it.
^e=
~e
jj~ejj
~e=^
@
@
Whereis a dummy variable that takes the place of any other coordinate. If you nd yourself wonderingWhy do we
have to take the partial in respect of the coordinate that is in question?Your answer is just a few words away! It can
be best explained by understanding that going in any particular direction requires one to know in which way is that
direction increasing. If I wanted to go North, I would go in the direction who's change is positive (positively increasing
because that impliesthat isis North). We now do this forr,,.
~=x^x+y^y+z^z!rcossin^x+rsinsin^y+rcos^z
^er=
~er
jj~erjj
e=
~e
jj~ejj
e=
~e
jj~ejj
All we have to do is calculate the partial in respect to each coordinate and nd the magnitude to arrive at our new basis
vectors!
~er=
@
@r
= cossin^x+ sinsin^y+ cos^z
~e=
@
@
= coscos^x+ sincos^ysin^z
~e=
@
@
=sin^x+ cos^y
jj~erjj=jj~ejj=jj~ejj= 1
We now need to nd what the Cartesian unit vectors are. We have two options in front of us: turn this into a system of
linear of equations and solve for^x,^y,^zORuse the orthogonality of the Cartesian coordinates to our advantage. I prefer
the latter as it will be much faster. To nd each Cartesian coordinate, we need to nd the projection of each Cartesian
coordinate unit vectors to our new spherical unit vectors.
3.4.1 Cartesian Unit Vectors
^x^er= cossin ^y^er= sinsin ^z^er= cos
^x^e= coscos ^y^e= sincos ^z^e= cos
^x^e=sin ^y^e= cos ^z^e= 0
^x=
"
cossin
coscos
sin
#T
2
4
^r
^

^

3
5^y=
"
sinsin
cossin
cos
#T
2
4
^r
^

^

3
5^z=
"
cos
sin
0
#T
2
4
^r
^

^

3
5
6

3.5 We have now arrived
We have specied our basis vectors, derived the partial derivatives of our Cartesian coordinates, and have held onto our
hats (and pencils). The last thing we have to do is plug in! If we take at what the gradient is, we can begin looking at
each individual part.
r=
"
^x
^y
^z
#
2
6
4
cossin
@
@r
coscos
r
@
@
sin
rsin
@
@
sinsin
@
@r
cossin
r
@
@
cos
rsin
@
@
cos
@
@r
sin
r
@
@
0
3
7
5
T
^x
h
cossin
@
@r
coscos
r
@
@
sin
rsin
@
@
i
T
=

cossin^rcoscos
^
sin
^


2
4
cossin
@
@r
coscos
r
@
@
sin
rsin
@
@
3
5
^y
h
sinsin
@
@r
cossin
r
@
@
cos
rsin
@
@
i
T
=

sinsin^rcossin^cos^

2
4
sinsin
@
@r
cossin
r
@
@
cos
rsin
@
@
3
5
^z

cos
@
@r
sin
r
@
@
0

T
=

cos^rsin
^
0

2
4
cos
@
@r
sin
r
@
@
0
3
5
You perform the matrix operations for each Cartesian coordinate, collect like terms - which a lot of the like terms will
go to one due to trigonometric identities - and then "organize" it in terms of the spherical unit vectors. Carrying each
calculation is tedious and that is ok. However, it is important for it to be carried out due it allowing you to see what is
actually happening. I recommend doing them ONLY when you have 15 minutes to spare. Once that is all completed,
you arrive at the spherical gradient!
r=^r
@
@r
+
^

1
r
@
@
+
^

1
rsin
@
@
If you are curious to see the actual white board work, you can nd it here.
7