Expression of a function in spherical coordinates I want to get the expression for a function in cartesian coordinates. 
The function should have the following properties: 


*

*It should have a minimum at r=R (in spherical coordinates)

*It should increase like a parabola in both x and y direction away from R. 
How do I go about constructing such a function?
 A: So you would like a function of the form $(r-R)^2$ in spherical coordinate.
Since $r^2 = x^2 + y^2$, you can consider 
$$
f(x,y) = (\sqrt{x^2 + y^2} - R)^2
$$
See WA for the plot at $R=2$.
Note also that you can smooth the peak at the origin by removing the square root. This will however make the function grow as "$x^4$" away from the origin.

Ok maybe something too complicated. The idea is to use the simple $f(x,y) = x^2 + y^2$ but dig a trench at radius $R$.
The "trench"-function can be $-De^{-(x^2 + y^2- R^2)^2}$ where $D$ is the depth of the hole. (Try to plot it !), it is mostly zero except in the annulus of radius $R$ where is goes to $-D$. Then we define :
$$
f(x,y) = -De^{-(x^2 + y^2- R^2)^2}+(x^2 + y^2)
$$
To make sure that the minimum is indeed achieved in the annulus and not at the origin, we need to make the hole deep enough, for example setting $D=R^2 + 1$.
Plot here (with $R=2$). We see that the function reaches $-1$ in the hole and no ugly peak at the origin. Also this function has the advantage that it is really close $x^2 + y^2$ everywhere (before and after the trench).
