Laplace’s Equation

In this code we present solutions of Laplace’s equation on a square and annular domains

Laplace’s Equation on a Square

We plot the solution of the equation
u_xx+u_yy=0
u(0,y)=sin^3(y)
u(x,0)=0
u(x,π)=0
u(π,y)=sin(y)

u[x_,y_]:=-3/(4*Sinh[3*π])*Sinh[3*(x-π)]*Sin[3*y]+1/(4*Sinh[π])*Sinh[x-π]*Sin[y]+Sinh[x]/Sinh[π]*Sin[y]

Plot3D[u[x,y],{x,0,π},{y,0,π},PlotRange->{-1,1},LabelStyle->Directive[Bold,Black, Large],AxesStyle->{{Black,Thick},{Black,Thick}},AxesLabel->{"x","y","u(x,y)"},AxesStyle->{{Black,Thick},{Black,Thick},{Black,Thick}},ColorFunction->"Rainbow",Mesh->False]

ContourPlot[u[x,y], {x, 0, π}, {y, 0, π}, PlotRange->{-1,1}, PlotLegends->Automatic, PlotPoints-> 10, FrameLabel->{"x","y"}, LabelStyle->Directive[Bold, Black, Medium],ColorFunction->"Rainbow"]

Laplace’s Equation on an Annular Domain

We plot the solution of the equation
u_rr+1/ru_r+1/r^2u_θθ=0
u(1,θ)=sin(3θ)
u(2,θ)=cos(5θ)

a1=-1/63;
b1=64/63;
a2=(32/1023);
b2=-(32/1023);

u[r_,θ_]:=(a1*r^3+b1*r^(-3))*Sin[3θ]+(a2*r^5+b2*r^(-5))*Cos[5θ];

ParametricPlot3D[{r*Cos[θ],r*Sin[θ],u[r,θ]},{r,1,2},{θ,0,2*π},LabelStyle->Directive[Bold,Black, Large],AxesStyle->{{Black,Thick},{Black,Thick}},AxesLabel->{"x","y","u(x,y)"},AxesStyle->{{Black,Thick},{Black,Thick},{Black,Thick}},ColorFunction->"Rainbow",Mesh->False,PlotPoints->40]

ContourPlot[u[Sqrt[x^2+y^2],ArcTan[x,y]], {x, -2,2}, {y, -2, 2}, PlotRange->{-1,1}, PlotLegends->Automatic, PlotPoints-> 40, FrameLabel->{"x","y"}, LabelStyle->Directive[Bold, Black, Medium],ColorFunction->"Rainbow",RegionFunction->Function[{x,y,z},1<x^2+y^2<4]]

Laplace’s Equation on Wedge

We plot the solution of the equation
u_rr+1/ru_r+1/r^2u_θθ=0
u(1,θ)=sin(8θ)
u(r,0)=0
u(r,π/4)=0

u[r_,θ_]:=r^8*Sin[8*θ];

ParametricPlot3D[{r*Cos[θ],r*Sin[θ],u[r,θ]},{r,0,1},{θ,0,π/4},LabelStyle->Directive[Bold,Black, Large],AxesStyle->{{Black,Thick},{Black,Thick}},AxesLabel->{"x","y","u(x,y)"},AxesStyle->{{Black,Thick},{Black,Thick},{Black,Thick}},ColorFunction->"Rainbow",Mesh->False,PlotPoints->40,PlotRange->All]

ContourPlot[u[Sqrt[x^2+y^2],ArcTan[x,y]], {x, 0,1}, {y, 0, 1}, PlotRange->{-1,1}, PlotLegends->Automatic, PlotPoints-> 40, FrameLabel->{"x","y"}, LabelStyle->Directive[Bold, Black, Medium],ColorFunction->"Rainbow",RegionFunction->Function[{x,y,z},0<ArcTan[x,y]<π/4&&x^2+y^2<1]]