# Plotting Laplace's Equation

Currently, I am trying to plot out the below equation using Mathematica.

$$Z(\rho, \phi) = 50 +\frac{200}{\pi} \sum_{odd \; m}^\infty \bigg(\frac{\rho}{a} \bigg)^m \frac{\sin (m\phi) }{m}$$

Or, if one wants, I could also rewrite the above equation as the one shown below.

$$Z(\rho, \phi) = 50 +\frac{200}{\pi} \sum_{m=0}^\infty \bigg(\frac{\rho}{a} \bigg)^{2m+1} \frac{\sin ((2m+1)\phi) }{2m+1}$$

Note that the $$a$$ value in the equations above stands for the radius (i.e. $$\rho$$) specific to my given circle.

I have attempted to write the below Mathematica code to plot out the distribution shown in the equation but to no avail.

nmax=40;
f[n_] := 50 + 200/Pi +
Sum[ (Rho/a)^(2n+1) Sin[(2n+1)Phi]/(2n+1), {n, 0, nmax}];

Plot[{f[nTerms, a]}, {a, 0, 2}]


Note that I made the minor substitution of $$m$$ to $$n$$ for my above code. That aside, I am quite certain that I did the Plot section very incorrectly.

If possible, I would greatly appreciate it if anybody in the community could show and help me correctly plot for the given distribution shown in the equations above. Thank you very much!

## 1 Answer

Clear["Global*"]

\$Assumptions = a > 0 && ρ > 0;

z[ρ_, ϕ_, a_ : 1, nmax_ : 40] :=
50 + 200/Pi +
Sum[(ρ/a)^(2 n + 1) Sin[(2 n + 1) ϕ]/(2 n + 1), {n, 0, nmax}];

Plot3D[z[ρ, ϕ], {ρ, 0, 1}, {ϕ, 0, Pi},
WorkingPrecision -> 20,
PlotPoints -> 75,
MaxRecursion -> 5] // Quiet If the number of terms is infinite

f = z[ρ, ϕ, a, Infinity] //
ComplexExpand[#, TargetFunctions -> {Re, Im}] & // Simplify

(* (1/(4 π))(800 +
200 π - π ArcTan[
a - ρ Cos[ϕ], -ρ Sin[ϕ]] + π ArcTan[
a - ρ Cos[ϕ], ρ Sin[ϕ]] - π ArcTan[
a + ρ Cos[ϕ], -ρ Sin[ϕ]] + π ArcTan[
a + ρ Cos[ϕ], ρ Sin[ϕ]]) *)

Plot3D[Evaluate[
f /. a -> 1], {ρ, 0, 1}, {ϕ, 0, Pi},
WorkingPrecision -> 20,
PlotPoints -> 75,
MaxRecursion -> 5] • Thank you so much for the help! I did try copying your line of code onto the Mathematica on my device to see how it worked out; however, the plot refused to show up - only allowing an empty but interactive box to show on the screen. I did try to retype the entire code while writing ϕ as \[CurlyPhi] and ρ as "esc" rho "esc"`. Unfortunately, the problem persists. Do you perhaps have any idea why this "empty plot" problem exists? Is it perhaps due to the fact that I only have a "basic" plan on Mathematica? – Athenian Sep 30 '20 at 19:26
• Try restarting Mathematica then copy and paste the code into a new notebook. – Bob Hanlon Sep 30 '20 at 19:29
• Thank you for the suggestion! While it did take a couple more attempts, I was able to get it working once more. Beyond that, thank you for your comprehensive post! – Athenian Sep 30 '20 at 19:40