# Solving Laplace PDE in mathematica

I'm trying to get the general solution for the Laplace equation: $$\frac{\partial^2 V}{\partial x^2} + \frac{\partial^2 V}{\partial y^2} = 0$$ on the domain $$\mathbb{R_0}\times\mathbb{R^+}\backslash\{(0,0)\}$$ with the following boundary conditions: $$V(x,0) = 0$$ if $$x>0$$ and $$V(x,0) = \pi$$ if $$x<0$$.

Here is my code:

pde = D[V[x,y],{x,2}] + D[V[x,y],{y,2}] == 0
ic = {V[x > 0,0] == 0, V[x < 0,0] == Pi}
sol = Refine[DSolve[{pde,ic}, {V[x, y]}, {x, y}],{x,y} != {0,0} && y >= 0]


But I am not getting anything (the output is just showing the input with no solving whatsoever). Also, if I try to plot it I get the following error message: "... is neither a list of replacement rules nor a valid dispatch table and so cannot be used for replacing. "

What am I doing wrong ?

(I am very new to mathematica so I apologize if the answer is obvious)

Clear["Global*"]

pde = D[V[x, y], {x, 2}] + D[V[x, y], {y, 2}] == 0;
ic = V[x, 0] == Piecewise[{{Pi, x < 0}}];
sol = Assuming[y >= 0,
DSolve[{pde, ic}, V[x, y], {x, y}][[1]] // Simplify]


Activate[
Inactive[D][V[x, y], {x, 2}] + Inactive[D][V[x, y], {y, 2}] == 0 /.
sol] // Simplify

(* True *)

Plot3D[V[x, y] /. sol, {x, -1, 2}, {y, 0, 2},
AxesLabel -> (Style[#, 14] & /@ {x, y}),
PlotPoints -> 100]
`

• Thank you very much! Could you just let me know which part makes $V(x,0) = 0$ if $x>0$ ? And how could I solve the same PDE with other boundary conditions ? Dec 11, 2022 at 12:59
• The documentation for Piecewise says that when none of the predicates are true, the value defaults to zero. Dec 11, 2022 at 13:24
• Which brings to my second question, how could I solve the same PDE with other boundary conditions ? (non zero) Dec 12, 2022 at 23:39
• @c.leblanc - post a new question showing what you have tried and explain what problems you are having. Dec 13, 2022 at 0:41
• Thanks to your help, I don't have a problem on this one anymore. I just would like to understand (in general), how to write 2 boundary conditions (ie: of any value, not only a second one that is equal to zero if the other is not true) Dec 16, 2022 at 21:08