Legendre Polynomials and the Steady State temperature in a sphere subject to a surface distribution with axial symmetry.

Separation of variables led to an Euler-Cauchy equation for the radial dependence (that has solutions proportional to powers of r) and a Legendre equation for the φ dependence. Let's take a look at the solutions, i.e. Legendre Polynomials, and their orthogonality relation.

Table[LegendreP[n,x], {n,0,4}]

Plot[Evaluate[%], {x,-1.1, 1.1}, PlotStyle -> AbsoluteThickness[3], AspectRatio -> 1,
AxesLabel -> {x, (Subscript[P, n])[x]}]

Orthogonality and Normalization

Table[Integrate[LegendreP[m,x]*LegendreP[n,x], {x,-1,1}], {m,0,5}, {n,0,5}] //MatrixForm

Recompute in terms of w=Cos[φ]:

Table[Integrate[LegendreP[m,Cos[φ]]*LegendreP[n,Cos[φ]], {φ,0,π}], {m,0,5}, {n,0,5}] //MatrixForm

Note the the result was not diagonal because the dw was not properly transformed to Sin[φ]dφ. Fix that and try again:

Table[Integrate[LegendreP[m,Cos[φ]]*LegendreP[n,Cos[φ]]*Sin[φ], {φ,0,π}], {m,0,5}, {n,0,5}] //MatrixForm

So the Legendre Polynomials are orthogonal and the squared magnitude is 2/(2n+1).

Basis for expressing nonhomogeneous boundary condition

Construct the Legendre expansion for the function that is 0 on [0,π/2) and 1 on (π/2, π] (so the nontrivial contribution to the integral occurs on (π/2, π] ).

a[n_] := Integrate[100*LegendreP[n,Cos[φ]]*Sin[φ],{φ,0,Pi/2}]*(2n+1)/2

coeffs = Table[a[n],{n,1,30}];

fns = Table[r^n*LegendreP[n, Cos[φ]],{n,1,30}];

coeffs.fns

Note that the mess below was not entered by hand. The first line was typed into the preceding output cell to create the input cell.

soln[r_, φ_] :=75 r Cos[φ]-(175/8) (r^3) (-3 Cos[φ]+5 ((Cos[φ])^3))+(275/64) (r^5) (15 Cos[φ]-70 ((Cos[φ])^3)+63 ((Cos[φ])^5))-(1/1024)1875 (r^7) (-35 Cos[φ]+315 ((Cos[φ])^3)-693 ((Cos[φ])^5)+429 ((Cos[φ])^7))+(1/16384)3325 (r^9) (315 Cos[φ]-4620 ((Cos[φ])^3)+18018 ((Cos[φ])^5)-25740 ((Cos[φ])^7)+12155 ((Cos[φ])^9))-(1/131072)12075 (r^11) (-693 Cos[φ]+15015 ((Cos[φ])^3)-90090 ((Cos[φ])^5)+218790 ((Cos[φ])^7)-230945 ((Cos[φ])^9)+88179 ((Cos[φ])^11))+(1/1048576)22275 (r^13) (3003 Cos[φ]-90090 ((Cos[φ])^3)+765765 ((Cos[φ])^5)-2771340 ((Cos[φ])^7)+4849845 ((Cos[φ])^9)-4056234 ((Cos[φ])^11)+1300075 ((Cos[φ])^13))-(1/33554432)332475 (r^15) (-6435 Cos[φ]+255255 ((Cos[φ])^3)-2909907 ((Cos[φ])^5)+14549535 ((Cos[φ])^7)-37182145 ((Cos[φ])^9)+50702925 ((Cos[φ])^11)-35102025 ((Cos[φ])^13)+9694845 ((Cos[φ])^15))+(1/1073741824)625625 (r^17) (109395 Cos[φ]-5542680 ((Cos[φ])^3)+81477396 ((Cos[φ])^5)-535422888 ((Cos[φ])^7)+1859107250 ((Cos[φ])^9)-3650610600 ((Cos[φ])^11)+4071834900 ((Cos[φ])^13)-2404321560 ((Cos[φ])^15)+583401555 ((Cos[φ])^17))-(1/8589934592)2370225 (r^19) (-230945 Cos[φ]+14549535 ((Cos[φ])^3)-267711444 ((Cos[φ])^5)+2230928700 ((Cos[φ])^7)-10039179150 ((Cos[φ])^9)+26466926850 ((Cos[φ])^11)-42075627300 ((Cos[φ])^13)+39671305740 ((Cos[φ])^15)-20419054425 ((Cos[φ])^17)+4418157975 ((Cos[φ])^19))+(1/68719476736)4513925 (r^21) (969969 Cos[φ]-74364290 ((Cos[φ])^3)+1673196525 ((Cos[φ])^5)-17210021400 ((Cos[φ])^7)+97045398450 ((Cos[φ])^9)-328189892940 ((Cos[φ])^11)+694247850450 ((Cos[φ])^13)-925663800600 ((Cos[φ])^15)+755505013725 ((Cos[φ])^17)-344616322050 ((Cos[φ])^19)+67282234305 ((Cos[φ])^21))-(1/1099511627776)34536775 (r^23) (-2028117 Cos[φ]+185910725 ((Cos[φ])^3)-5019589575 ((Cos[φ])^5)+62386327575 ((Cos[φ])^7)-429772478850 ((Cos[φ])^9)+1805044411170 ((Cos[φ])^11)-4859734953150 ((Cos[φ])^13)+8562390155550 ((Cos[φ])^15)-9821565178425 ((Cos[φ])^17)+7064634602025 ((Cos[φ])^19)-2893136075115 ((Cos[φ])^21)+514589420475 ((Cos[φ])^23))+(1/17592186044416)66303825 (r^25) (16900975 Cos[φ]-1825305300 ((Cos[φ])^3)+58227239070 ((Cos[φ])^5)-859544957700 ((Cos[φ])^7)+7091245901025 ((Cos[φ])^9)-36100888223400 ((Cos[φ])^11)+119873462177700 ((Cos[φ])^13)-267146572853160 ((Cos[φ])^15)+402684172315425 ((Cos[φ])^17)-405039050516100 ((Cos[φ])^19)+260382246760350 ((Cos[φ])^21)-96742811049300 ((Cos[φ])^23)+15801325804719 ((Cos[φ])^25))-(255371875 (r^27) (-35102025 Cos[φ]+4411154475 ((Cos[φ])^3)-164094946470 ((Cos[φ])^5)+2836498360410 ((Cos[φ])^7)-27577067392875 ((Cos[φ])^9)+166966608033225 ((Cos[φ])^11)-667866432132900 ((Cos[φ])^13)+1825501581163260 ((Cos[φ])^15)-3463083881912655 ((Cos[φ])^17)+4556689318306125 ((Cos[φ])^19)-4079321865912150 ((Cos[φ])^21)+2370198870707850 ((Cos[φ])^23)-805867616040669 ((Cos[φ])^25)+121683714103007 ((Cos[φ])^27)))/140737488355328+(493099875 (r^29) (145422675 Cos[φ]-21037813650 ((Cos[φ])^3)+902522205585 ((Cos[φ])^5)-18050444111700 ((Cos[φ])^7)+204070298707275 ((Cos[φ])^9)-1447043936287950 ((Cos[φ])^11)+6845630929362225 ((Cos[φ])^13)-22427590854291480 ((Cos[φ])^15)+51946258228689825 ((Cos[φ])^17)-85665759184155150 ((Cos[φ])^19)+99943385714847675 ((Cos[φ])^21)-80586761604066900 ((Cos[φ])^23)+42710983650155457 ((Cos[φ])^25)-13385208551330770 ((Cos[φ])^27)+1879204156221315 ((Cos[φ])^29)))/1125899906842624

Does the solution evaluated on the boundary provide a good approximation of the specified boundary conditions?

Plot[soln [1,φ], {φ,0,Pi}, PlotStyle -> AbsoluteThickness[3]]

Almost, but the mean term u=50 (which is picked up by considering zero as the value of the separation constant) needs to be included:

Plot[50+soln [1,φ], {φ,0,Pi}, PlotStyle -> AbsoluteThickness[3]]

What does the solution look like in the interior of the sphere?

Plot3D[soln[r,φ], {r,0,1},{φ,0,Pi},AxesLabel->{R,φ,u}]

How do we show the actual circular geometry of the cross-section of the sphere? Lacking a "PolarPlot3D" function, do the transformation to rectangular coordinates by hand, and just show the relevant regions using the RegionFunction option in DensityPlot. (Look at the details of ArcTan[z,y]. What happens if you use ArcTan[y/z]?) Note that we avoid the point at the very center of the sphere. Why?

temp[y_,z_] := 50+soln[Sqrt[y^2+z^2], ArcTan[z,y] ]

DensityPlot[temp[y,z], {y,-1,1}, {z,-1,1}, AspectRatio -> 1, RegionFunction -> (0.01<#1^2+#2^2<1&),FrameLabel-> {"Y","Z"}]

Let's try an alternative color mapping. Numerous built-in choies are available:

ColorData["Gradients"]

DensityPlot[temp[y,z], {y,-1,1}, {z,-1,1}, AspectRatio -> 1, RegionFunction -> (0.01<#1^2+#2^2<1&),FrameLabel-> {"Y","Z"},ColorFunction -> "ThermometerColors"]

Surface temperature ~φ.

Explore the range of Legendre polynomials by fitting another boundary condition.

b[n_] := Integrate[t*LegendreP[n,Cos[t]]*Sin[t],{t,0,Pi}]*(2n+1)/2

Sum[b[n]*LegendreP[n, Cos[t]],{n,0,5}];

Plot[{t,Evaluate[%]}, {t,0,Pi}, PlotStyle -> AbsoluteThickness[3],
AxesLabel -> {"φ", "u(ρ,φ)"}]