Learning Objectives
By the end of this section you will be able to:
- State the three classical types of boundary conditions for Laplace's equation (Dirichlet, Neumann, Robin) and recognise which one a physical setup demands.
- Explain why a PDE alone — even one as rigid as — has infinitely many solutions, and how boundary data picks out exactly one.
- Use the maximum principle to argue uniqueness and to bound the interior of a harmonic function in terms of its boundary.
- Check the compatibility condition that a pure Neumann problem must satisfy.
- Implement a Jacobi relaxation solver from scratch in Python, and a differentiable version in PyTorch that you can use inside a learning loop.
The Big Picture
In section 28.1 we introduced Laplace's equation and saw that its solutions — harmonic functions — model equilibrium: steady-state heat, electrostatic potential, ideal-fluid streamfunctions, gravitational potential outside masses. Equilibrium is what is left after every transient has died out.
A natural question follows immediately: given that the interior is in equilibrium, what is it in equilibrium with? The answer is the boundary. A drumhead at rest is in equilibrium with the rim it is glued to. A metal plate's steady temperature is in equilibrium with whatever the edges are doing. A capacitor's electric potential is in equilibrium with the voltages on its plates.
Slogan. Laplace's equation is the law of the interior. Boundary conditions are the law of the edge. A Boundary Value Problem (BVP) is the two of them welded together — and only then does the problem have a unique answer.
Why a PDE Needs Boundary Conditions
For an ordinary differential equation, you fix the solution with initial conditions: tell me where the particle is and how fast it is moving at , and I will tell you for all later time.
For Laplace's equation there is no time. Time has already finished — we are sitting in the equilibrium that remains. So we cannot pin the answer down with initial conditions. Instead we pin it down with spatial conditions on the edge of the region.
Here is the most striking demonstration. The function is harmonic. So is . So is . So is . All four solve the same PDE identically. The PDE alone cannot distinguish them — they look different only at the boundary.
The Three Classical Boundary Conditions
On the boundary of our region we can prescribe the value of , the outward normal derivative , or a linear combination of the two. These give the three classical boundary conditions.
Dirichlet: Prescribed Value
A Dirichlet boundary condition prescribes the value of the solution on the boundary:
Physical picture. A metal plate whose edges are welded to ice baths and steam pipes: the temperature on the edge is whatever the bath dictates, no matter what is happening inside. Electrostatically, a Dirichlet boundary is a conductor held at a fixed voltage by a battery.
Neumann: Prescribed Flux
A Neumann boundary condition prescribes the outward normal derivative:
where is the outward unit normal to .
Physical picture. Now we are not specifying the temperature on the edge — we are specifying the rate at which heat flows through it. If , the boundary is perfectly insulated: no heat enters or leaves. If at some point, heat is being pumped out there. Electrostatically, prescribing on a surface is the same as prescribing the surface charge density (up to a constant).
Robin: A Mix of Both
A Robin (or "third-kind") boundary condition is a linear combination:
Physical picture. Newton's law of cooling. Suppose the boundary is a thin wall exchanging heat with surroundings at temperature . Heat flux through the wall is proportional to the temperature difference:
Rearranged, this is exactly the Robin form. As Robin degenerates to Dirichlet (the wall instantly matches the outside temperature). As Robin degenerates to Neumann with (the wall is a perfect insulator).
Mixed vs. Robin — Don't Confuse Them
Two phrases sound similar but mean different things:
| Term | Meaning | Example |
|---|---|---|
| Mixed BVP | Different sides of the boundary carry different types (some Dirichlet, others Neumann). | Top: u = 100 (Dirichlet). Sides: insulated (Neumann, g = 0). |
| Robin BVP | A linear combination of u and ∂u/∂n on the same side of the boundary. | All sides obey α u + β ∂u/∂n = h (Newton cooling). |
What "Well-Posed" Really Means
Jacques Hadamard introduced three criteria a sensible BVP should meet. We call the problem well-posed if all three hold:
- Existence. A solution exists for any reasonable boundary data.
- Uniqueness. No two distinct solutions share the same boundary data.
- Continuous dependence. Small changes in the boundary data produce small changes in the solution. Tiny measurement errors cannot blow up into wildly different temperatures.
The Dirichlet problem for Laplace's equation on a bounded well-behaved domain satisfies all three. The Neumann problem satisfies all three once the compatibility condition holds and we agree to consider solutions modulo an additive constant. Robin is well-posed whenever .
The Maximum Principle (the Secret Weapon)
Harmonic functions have a remarkable shape constraint. The strong maximum principle says:
Theorem. Let be a bounded connected open set in and suppose is harmonic in and continuous on . Then attains its maximum and minimum on the boundary . Moreover, if attains its max or min at any interior point, then is constant.
Why does this happen? Because of the mean-value property: is the average of on any small disk around . If were strictly larger than every value in its neighbourhood, it could not equal their average — a contradiction. So a strict interior maximum is impossible.
Uniqueness from the Maximum Principle
The maximum principle gives a one-line proof of uniqueness for the Dirichlet BVP. Suppose and both solve in with the same boundary data on . Let . Then is harmonic in with on . By the maximum principle, , so in — meaning . The Dirichlet problem has at most one solution.
Interactive: Maximum Principle Demo
Below is a numerical solver for Laplace's equation on the unit square with four piecewise-constant Dirichlet boundaries. Drag the probe around the interior and watch the inequality hold at every point. You can never find an interior point hotter than the hottest edge or colder than the coldest edge.
The Neumann Compatibility Condition
For the pure Neumann problem
the data cannot be arbitrary. Take the PDE and integrate over :
The leftmost integral is zero because in . So:
Physical interpretation. For a steady temperature field, the net heat flux through the entire boundary must vanish — otherwise heat would be accumulating or being lost, and the interior could not be steady. If you try to pump heat into a fully sealed room without letting any out, there is no steady-state temperature; the room just keeps heating up.
Interactive: Compatibility Check
Slide the four normal-derivative values. The widget shows the net flux and turns green only when the data is compatible.
Interactive: Solve a BVP Yourself
The widget below is a full Jacobi relaxation solver on the unit square. You can switch each of the four edges between Dirichlet and Neumann, adjust the boundary values, and press Run to watch the field relax to equilibrium. The red border marks Dirichlet edges; the blue border marks Neumann edges. The iteration counter tells you how many Jacobi sweeps have been applied so far.
Things to try. Pick the first preset (hot top, cold bottom, cold sides) and watch a thermal "dome" develop near the top edge. Switch to the third preset (insulated sides) and notice that the solution becomes purely vertical: . Try the all-Neumann case (set every side to Neumann) — if the four fluxes do not sum to zero, the solver still iterates, but the compatibility warning lights up and the field drifts without settling.
Worked Example (Step by Step)
Let's trace the Jacobi solver by hand on a tiny grid you can fit on a napkin. Take the unit square with grid points per axis (so interior unknowns). Use Dirichlet boundaries: top edge , the other three edges . We start with everywhere in the interior.
Click to expand the hand trace
row i=4 [1 1 1 1 1] <- top boundary (hot)
row i=3 [0 0 0 0 0]
row i=2 [0 0 0 0 0]
row i=1 [0 0 0 0 0]
row i=0 [0 0 0 0 0] <- bottom (cold)
j=0 j=1 j=2 j=3 j=4row i=3 [0 0.25 0.25 0.25 0] row i=2 [0 0 0 0 0] row i=1 [0 0 0 0 0]
row i=3 [0 0.3125 0.375 0.3125 0] row i=2 [0 0.0625 0.0625 0.0625 0] row i=1 [0 0 0 0 0]
row i=3 [0 0.359375 0.421875 0.359375 0] row i=2 [0 0.09375 0.125 0.09375 0] row i=1 [0 0.015625 0.015625 0.015625 0]
u(centre) = 0.25 (exact, by symmetry + linearity) Jacobi after 2048 iterations on a 33x33 grid: 0.24998The numerical value matches the exact answer to four decimals — a satisfying confirmation that Jacobi is solving the right problem.
Python Implementation (Jacobi Relaxation)
Below is the same algorithm we just traced by hand, written in plain Python plus NumPy. Hover the cards on the left to highlight the corresponding code line.
PyTorch Implementation (Differentiable)
Rewriting the solver in PyTorch unlocks something the NumPy version cannot do: backprop through the BVP. If we treat the boundary values as learnable parameters, the gradient of a downstream loss (e.g. desired interior temperature) flows all the way back to the boundary. This is the foundation of physics-informed learning and shape/topology optimisation.
Real-World Applications
| Field | u | Boundary condition | Type |
|---|---|---|---|
| Steady-state heat | Temperature | Fixed temperature on furnace wall | Dirichlet |
| Steady-state heat | Temperature | Insulated surface (no heat flux) | Neumann (g = 0) |
| Steady-state heat | Temperature | Wall cooled by ambient air (Newton cooling) | Robin |
| Electrostatics | Potential V | Conductor at fixed voltage | Dirichlet |
| Electrostatics | Potential V | Surface charge density specified | Neumann |
| Ideal fluid flow | Stream function ψ | Velocity tangent to body surface (no penetration) | Dirichlet (ψ constant on body) |
| Soap-film geometry | Height u | Height fixed by the wire frame | Dirichlet |
| Image inpainting | Pixel intensity | Known pixels around the hole | Dirichlet |
Image inpainting is a fun one: replace a missing region with the solution of Laplace's equation whose Dirichlet data is the surrounding known pixels. The mean-value property smoothly interpolates the hole — colours blend, gradients match, no jarring edges. Modern deep-learning inpainters are more powerful (they can hallucinate structure), but the Laplace-equation inpainter is still the right thing to use for smooth backgrounds.
Common Pitfalls
- Forgetting the compatibility condition. If you set up a pure Neumann problem with , no solution exists. The solver will diverge or drift; the discretised linear system is singular.
- Forgetting the constant freedom in pure Neumann. Even compatible Neumann data leaves defined only up to . Add one additional pin like "average of u over is zero" to make it unique.
- Mixing up ∂u/∂n and ∂u/∂x. The Neumann condition uses the outward normal derivative. On the right edge of a rectangle, this is ; on the left edge it is .
- First-order Neumann in code. The ghost-point trick is only first-order accurate. For high precision, use second-order one-sided differences (Taylor expand a quadratic to confirm).
- Jacobi is slow. Convergence is iterations. For large grids use multigrid, conjugate gradient, or a direct sparse solver.
- Re-entrant corners. On non-convex domains (think of an L-shape) the solution can have a singularity at the inward corner: . The PDE still well-posed in the variational sense, but pointwise convergence near the corner is slow and grid-refinement is essential.
Test Your Understanding
Summary
| Concept | Statement | Why it matters |
|---|---|---|
| Dirichlet BC | u = f on ∂Ω | Pins the value on the edge — well-posed and unique. |
| Neumann BC | ∂u/∂n = g on ∂Ω | Pins the flux — unique up to a constant; needs ∮ g ds = 0. |
| Robin BC | α u + β ∂u/∂n = h | Models Newton cooling; interpolates Dirichlet and Neumann. |
| Mixed BVP | Different sides carry different BC types | Most physical setups (insulated sides + fixed top, etc.). |
| Maximum principle | Max and min of harmonic u live on ∂Ω | Gives one-line uniqueness proof; bounds the interior. |
| Compatibility | ∮ g ds = 0 for pure Neumann | Net flux must balance, or no steady state exists. |
| Jacobi relaxation | u_{i,j} ← (u_N + u_S + u_E + u_W)/4 | Discrete mean-value property; converges to the harmonic field. |
Key Takeaways
- A PDE on its own is under-determined; boundary conditions turn it into a well-posed problem.
- The three classical types — Dirichlet, Neumann, Robin — cover essentially every physical scenario you will meet in heat conduction, electrostatics, fluid flow, and elastic membranes.
- The maximum principle is the secret weapon: it gives uniqueness, monotonicity, and pointwise bounds, all in one stroke.
- Pure Neumann problems need compatibility: . Net flux must vanish, otherwise no steady state exists.
- Jacobi relaxation is the discrete embodiment of the mean-value property — and writing it in PyTorch makes the entire BVP differentiable, which is the foundation of modern physics-informed deep learning.
Coming next. In section 28.3 we leave abstract boundary types behind and solve a concrete problem: Laplace's equation on a rectangle, by separation of variables and Fourier series. The maximum principle and compatibility conditions you have built here will keep guiding us — but the algebra will get specific.