# Converting a 2D Gaussian in Cylindrical Coordinates

• MathewsMD
In summary, you would substitute r0 and θ0 for x0 and y0, and then use the equation z = f(r0, θ0) to find the corresponding cylindrical coordinates.
MathewsMD
Given the equation for a Gaussian as: ##z = f(x,y) = Ae^{[(x-x0)^2 + (y-y0)^2] /2pi*σ^2 }## , how would I go about converting this into cylindrical coordinates? The mean is non-zero, and this seems to be the biggest hurdle. I believe I read earlier that the answer is ~ ##z = f(r,θ) = Ae^{(r-r0)^2 / σ^2}## but this doesn't quite make sense since it completely neglects the angle (i.e. theta). Would this be the correct solution?

## x = rcosθ##;
##y = rsinθ##;
##x0 = r0cosθ0##;
##y0 = r0sinθ0##; where ##r0## and ##θ0## and ##σ## are constants

##z = f(r,θ) = Ae^{(r^2 + r0^2 - 2rcosθr0cosθ0 - 2rsinθr0sinθ0 / σ^2 }##

This is just a direct substitution, though. Shouldn't there be a change of variable and thus making the solution:

##z = f(r,θ) = rAe^{(r^2 + r0^2 - 2rcosθr0cosθ0 - 2rsinθr0sinθ0 /σ^2 }##

Last edited:
MathewsMD said:
Given the equation for a Gaussian as: ##z = f(x,y) = Ae^{[(x-x0)^2 + (y-y0)^2] /2pi*σ^2 }## , how would I go about converting this into cylindrical coordinates? The mean is non-zero, and this seems to be the biggest hurdle. I believe I read earlier that the answer is ~ ##z = f(r,θ) = Ae^{(r-r0)^2 / σ^2}## but this doesn't quite make sense since it completely neglects the angle (i.e. theta). Would this be the correct solution?
I believe that it would be helpful to change your variables, with u = x - x0, and v = y - y0. Then you would have ##z = f(u, v) = Ae^{\frac{u^2 + v^2}{2\pi \sigma^2}}##
It should be relatively easy to change to cylindrical coordinates in this form.

Not all functions in cylindrical (or polar) coordinates involve an angle. For example, in polar coordinates, the equation of a circle of radius r0, and centered at the pole is r = r0. Here ##\theta## is arbitrary. This equation also represents a circular cylinder in cylinder in cylindrical coordinates, with both ##\theta## and z being arbitrary.
MathewsMD said:
## x = rcosθ##;
##y = rsinθ##;
##x0 = r0cosθ0##;
##y0 = r0sinθ0##; where ##r0## and ##θ0## and ##σ## are constants

##z = f(r,θ) = Ae^{(r^2 + r0^2 - 2rcosθr0cosθ0 - 2rsinθr0sinθ0 / σ^2 }##

This is just a direct substitution, though. Shouldn't there be a change of variable and thus making the solution:

##z = f(r,θ) = rAe^{(r^2 + r0^2 - 2rcosθr0cosθ0 - 2rsinθr0sinθ0 /σ^2 }##

Is it most accurate to leave just as:

## f(r,θ) = A1e^{(r^2 + r0^2 - 2rcosθr0cosθ0 - 2rsinθr0sinθ0 /σ^2) }rdrdθ = f(x,y) = Ae^{[(x-x0)^2 + (y-y0)^2] /σ^2] }dxdy##

I guess I'm just confused on how exactly I would graph the function.

(Should the denominator in the exponential be 2pi*σ^2 for both cases instead of just σ^2 for ny particular reason? I believe I've seen that convention but have not seen an explanation as for why.)

Last edited:
Mark44 said:
I believe that it would be helpful to change your variables, with u = x - x0, and v = y - y0. Then you would have ##z = f(u, v) = Ae^{\frac{u^2 + v^2}{2\pi \sigma^2}}##
It should be relatively easy to change to cylindrical coordinates in this form.

Not all functions in cylindrical (or polar) coordinates involve an angle. For example, in polar coordinates, the equation of a circle of radius r0, and centered at the pole is r = r0. Here ##\theta## is arbitrary. This equation also represents a circular cylinder in cylinder in cylindrical coordinates, with both ##\theta## and z being arbitrary.

The only problem with this method (I left out this piece of information) is that I would want to graph this function on the same set of axes for numerous values of x0 and y0 (or r0 and theta0). That is, these values would be constant for any given situation, but I would like to generalize this function so that these constants can take on any arbitrary value when I graph them in the future, but remain on the same set of axes. For example, my mean position for the gaussian could be r0 = 2, theta0 = 0.5 for one run, but it would r0 = 2.5, theta0 = 0.8 for another run.

MathewsMD said:
The only problem with this method (I left out this piece of information) is that I would want to graph this function on the same set of axes for numerous values of x0 and y0 (or r0 and theta0). That is, these values would be constant for any given situation, but I would like to generalize this function so that these constants can take on any arbitrary value when I graph them in the future, but remain on the same set of axes.

All that's happening with the substitutions I listed is that the origin in the x-y plane is translated to the point (x0, y0), which is the origin in the u-v plane. Different values of x0 and y0 simply move the location of the origin in the u-v plane.

Mark44 said:
All that's happening with the substitutions I listed is that the origin in the x-y plane is translated to the point (x0, y0), which is the origin in the u-v plane. Different values of x0 and y0 simply move the location of the origin in the u-v plane.

Okay. This would then change the function itself, no? Essentially what's being done is that I have a function, and I input these constants before running them to get the plot. Wouldn't this substitution then have to be applied for each function? It definitely seems like the sensible approach, but I'm not quite sure if its application would work when I'm trying to input different values and trying to get the functions displayed on the same graph.

Last edited:
MathewsMD said:
Okay. This would then change the function itself, no?
Yes, but all you would be doing is translating one coordinate system rigidly so that the new origin is at a different point. As a simpler example, if you know what the graph of y = f(x) = sin(x) looks like, the graph of f(x - ##\pi/4##) is nothing more than a translation to the right of the graph of sin(x) by ##\pi/4## units.

The situation is similar in the substitutions I recommended, except that there would be two translations.
MathewsMD said:
Essentially what's being done is that I have a function, and I input these constants before running them to get the plot. Wouldn't this substitution then have to be applied for each function? It definitely seems like the sensible approach, but I'm not quite sure if its application would work when I'm trying to input different values and trying to get the functions displayed on the same graph.

To go back to your original equation, ##z = f(x,y) = Ae^{\frac{(x - x_0)^2 + (y - y_0)^2}{2\pi*σ^2} }##, and disregarding the thing about switching to cylindrical coordinates, the graph of this surface looks just like the graph of ##z = e^{\frac{x^2 + y^2}{2\pi*σ^2}}##, but with the high point of the mound translated so that it's above (x0, y0) instead of being above (0, 0). If you change the value of either x0 or y0 (or both), it simply moves the high point around.

It's not clear to me what you're trying to do: change the equation to cylindrical form or graph the family of surfaces with different values of x0 and y0. These seem like different goals to me.

Mark44 said:
Yes, but all you would be doing is translating one coordinate system rigidly so that the new origin is at a different point. As a simpler example, if you know what the graph of y = f(x) = sin(x) looks like, the graph of f(x - ##\pi/4##) is nothing more than a translation to the right of the graph of sin(x) by ##\pi/4## units.

The situation is similar in the substitutions I recommended, except that there would be two translations.To go back to your original equation, ##z = f(x,y) = Ae^{\frac{(x - x_0)^2 + (y - y_0)^2}{2\pi*σ^2} }##, and disregarding the thing about switching to cylindrical coordinates, the graph of this surface looks just like the graph of ##z = e^{\frac{x^2 + y^2}{2\pi*σ^2}}##, but with the high point of the mound translated so that it's above (x0, y0) instead of being above (0, 0). If you change the value of either x0 or y0 (or both), it simply moves the high point around.

It's not clear to me what you're trying to do: change the equation to cylindrical form or graph the family of surfaces with different values of x0 and y0. These seem like different goals to me.

Thank you. Yes, the two graphs should look the same, regardless of the coordinates. I guess I'm trying to verify if my steps are correct or not. I've inserted an image file with this that explains the function itself and what I did to convert it. I can now integrate over this function, correct? Integration over that circle would be correct using the equations found for z either in cartesian or polar coordinates, correct?

I guess my main question is due to lack of familiarity and being unable to plot both graphs. Would the two functions of z, the one in dxdy and the other in rdrdtheta be the same if i removed ONLY dxdy and drdtheta from both of them? If I'm not mistaken, it should simply be multipled by the Jacobian (i.e. r x drdtheta/dxdy) to achieve the same function back. That is, since I have z1dxdy (original cartesian function) = z2rdrdtheta (polar), shouldn't it be z1 = rz2 x drdtheta/dxdy? Where z1 is in x and y and z2 is simply the same function but with x and y directly subsituted with the appropriate rcostheta and rsintheta change.

#### Attachments

• Photo on 2015-05-21 at 10.47 AM.jpg
62.5 KB · Views: 735
You want to send the coordinates to polar?
$e^{\frac{(x-x_0)^2}{2\sigma^2}} e^{\frac{(y-y_0)^2}{2\sigma^2}}$ ?

One way to achieve this before you go to polar coordinates, to make a small transposition to your axis. In explicitly say that you move your $x$ axis by $x_0$ to : $x \rightarrow x'= x -x_0$ and your $y$ axis by $y_0$ to : $y \rightarrow y'= y-y_0$.
After doing that you have:
$e^{\frac{x^{\prime 2}}{2\sigma^2}} e^{\frac{y^{\prime 2}}{2\sigma^2}}$

$e^{\frac{x^{\prime 2} + y^{\prime 2}}{2\sigma^2}}$

Which immediately can be written in polar coordinates as:

$e^{- \frac{r^2}{2 \pi \sigma^2} }$

Where $r^2 = x^{\prime 2} + y^{\prime 2} = (x-x_0)^2 + (y-y_0)^2$
That's a circle equation, with radius $r$ and center at $(x_0 ,y_0 )$

Now if you want to integrate it, you can do it either in x,y or in r,theta...

ChrisVer said:
You want to send the coordinates to polar?
$e^{\frac{(x-x_0)^2}{2\sigma^2}} e^{\frac{(y-y_0)^2}{2\sigma^2}}$ ?

One way to achieve this before you go to polar coordinates, to make a small transposition to your axis. In explicitly say that you move your $x$ axis by $x_0$ to : $x \rightarrow x'= x -x_0$ and your $y$ axis by $y_0$ to : $y \rightarrow y'= y-y_0$.
After doing that you have:
$e^{\frac{x^{\prime 2}}{2\sigma^2}} e^{\frac{y^{\prime 2}}{2\sigma^2}}$

$e^{\frac{x^{\prime 2} + y^{\prime 2}}{2\sigma^2}}$

Which immediately can be written in polar coordinates as:

$e^{- \frac{r^2}{2 \pi \sigma^2} }$

Where $r^2 = x^{\prime 2} + y^{\prime 2} = (x-x_0)^2 + (y-y_0)^2$
That's a circle equation, with radius $r$ and center at $(x_0 ,y_0 )$

Now if you want to integrate it, you can do it either in x,y or in r,theta...

Yep, that definitely makes sense. I'm just trying to get the analytical solution for the Gaussian if it is not centred at $(x_0 ,y_0 )$ but still in polar coordinates (i.e. the coordinate system is centred at the origin).

I think I've been a little unclear (possibly an understatement) in what I've asked above so hopefully I can try to clarify what exactly it is I'm trying to do.
This is the solution I've got so far to plot:

(see attached image file)

My questions are stated in the image, but to state them again:

Is ##z_{xy}## equivalent to ##z_{rθ}## when plotted in Cartesian and Cylindrical coordinates, respectively? Also, when integrating over equivalent surfaces (e.g. r: [0,4] and θ: [0,2pi] in cylindrical coordinates or a circle of radius 4 centred at the origin in cartesian coordinates), is dxdy simply replaced by rdrdθ for ##z_{rθ}## or are there additional substitutions I am missing?

What I'm trying to do doesn't seem too difficult so sorry if I overcomplicated a simple problem. I actually have been plotting the graphs now and it does seem to be working, but I just want to confirm my methods are correct.

#### Attachments

• Photo on 2015-05-22 at 10.37 AM.jpg
30.1 KB · Views: 755
Last edited:
What do you mean by asking whether the $z_{r\theta} , z_{xy}$ are equivalent? They are the same thing expressed in different coordinates...
Whether I write $f(x,y)=x^2+y^2$ or $f(r,\theta)=r^2$ with $r^2=x^2+y^2$, it's the same thing.

Then about the integration. It's still fine. You have been able to write the integrand function in different coordinates, and you also need to transform (through the jacobian) the integral's measure $dxdy$ which is done by $rdr d\theta$. Where would the additional substitutions come from? (equivalent question, what is confusing you?)

MathewsMD
ChrisVer said:
What do you mean by asking whether the $z_{r\theta} , z_{xy}$ are equivalent? They are the same thing expressed in different coordinates...
Whether I write $f(x,y)=x^2+y^2$ or $f(r,\theta)=r^2$ with $r^2=x^2+y^2$, it's the same thing.

Then about the integration. It's still fine. You have been able to write the integrand function in different coordinates, and you also need to transform (through the jacobian) the integral's measure $dxdy$ which is done by $rdr d\theta$. Where would the additional substitutions come from? (equivalent question, what is confusing you?)

I guess I was just looking for confirmation that what I did was right. It really is simple but I thought it never hurts to ask. Thank you! :)

## 1. What is a 2D Gaussian in Cylindrical Coordinates?

A 2D Gaussian in Cylindrical Coordinates is a mathematical function that describes a distribution of values in a cylindrical coordinate system. It is often used to model physical phenomena such as heat distribution or particle motion.

## 2. How do you convert a 2D Gaussian from Cartesian to Cylindrical Coordinates?

To convert a 2D Gaussian from Cartesian to Cylindrical Coordinates, you can use the following equations:r = √(x^2 + y^2)θ = tan^-1(y/x)z = zWhere r is the radial distance, θ is the azimuthal angle, and z is the height or depth. These equations will transform the x and y coordinates into the r and θ coordinates.

## 3. What are the advantages of using Cylindrical Coordinates for a 2D Gaussian?

Cylindrical Coordinates can be advantageous for a 2D Gaussian because they align with natural physical systems, such as cylindrical objects or rotational motion. This can make it easier to interpret and analyze data in these systems.

## 4. Can a 2D Gaussian in Cylindrical Coordinates be converted back to Cartesian Coordinates?

Yes, a 2D Gaussian in Cylindrical Coordinates can be converted back to Cartesian Coordinates using the inverse equations:x = rcosθy = rsinθz = zWhere r is the radial distance, θ is the azimuthal angle, and z is the height or depth. These equations will transform the r and θ coordinates back into the x and y coordinates.

## 5. Are there any limitations to using Cylindrical Coordinates for a 2D Gaussian?

One limitation of using Cylindrical Coordinates for a 2D Gaussian is that it assumes symmetry around the z-axis. This may not accurately represent all physical systems. Additionally, the conversion process from Cartesian to Cylindrical Coordinates can be complex and may introduce errors if not done accurately.

• Differential Equations
Replies
1
Views
742
• Calculus
Replies
1
Views
2K
• Calculus
Replies
10
Views
2K
• Linear and Abstract Algebra
Replies
6
Views
1K
• Calculus
Replies
4
Views
3K
• Calculus
Replies
10
Views
3K
• Calculus
Replies
18
Views
18K
• Calculus
Replies
4
Views
2K
• Calculus
Replies
5
Views
983
• Calculus
Replies
3
Views
2K