Flow Lab

Syllabus / Module 8: Boundary Value Problems & Fourier Series

Lesson 8.1

Two-Point Boundary Value Problems

BVPs vs IVPs, existence and non-uniqueness, the shooting method, and finite-difference solution of BVPs.

Written byClaude Sonnet

🌊
Why this matters for simulation: Steady flow between plates (Couette/Poiseuille) is a two-point BVP.

By the end of this lesson you can…

  • Show with $y'' = -y$ that a BVP can have exactly one, no, or infinitely many solutions depending on $L$ and $b$, unlike an IVP.
  • Write Dirichlet, Neumann and Robin conditions with a physical reading, and derive the Poiseuille and Couette profiles for plate flow.
  • Turn a BVP into an IVP with an unknown launch slope, define the residual $F(s) = y(L;s) - b$, and find its roots with the secant method and RK4, including two solutions of one nonlinear BVP.
  • Discretize $u'' = f$ with the second difference, assemble the tridiagonal system (ghost point for Neumann and Robin) and solve it with the Thomas algorithm.
  • Read measured tables to state the cost of Thomas against dense elimination, the second-order error, the damage of a one-sided boundary row, and why shooting fails on $y'' = 100y$.
On this page
·
  1. Initial versus boundary conditions
  2. Three kinds of boundary condition
  3. Worked example: flow between plates
  4. The shooting method
  5. Where shooting fails: growing solutions
  6. Finite differences and the tridiagonal system
  7. Neumann and Robin conditions
  8. Try it
  9. Computing it
  10. Concept checks
  11. Problems
  12. Key Takeaways

Every method so far marched forward in time: give Euler, RK4 or RK45 the state at t=0t = 0 and it walks on. Steady flow between two plates is different: the velocity is known at both walls and nowhere in between, so there is nothing to march from. Such a boundary value problem (BVP) is how the diffusion step and pressure projection of Stam’s fluid solver look from the inside. We attack the second-order equation of 5.2 Constant Coefficients & the Characteristic Equation in two ways: shooting, which reuses the integrator of 4.3 Runge–Kutta Methods & Butcher Tableaux, and finite differences, which give a matrix problem that is cheap to solve.

▶ Video Trajectories fired from the left wall miss or hit a target on the right wall; then the same problem becomes a tridiagonal matrixcaptions only
Transcript
  1. An initial value problem gives everything at one point, and marching finds the unique solution. A boundary value problem gives one condition at each end, and no such theorem holds. For y double prime equals minus y, the solution is s sine x, and the far condition says s sine L equals b. One solution, unless L is pi: then every slope works, or none does.
  2. Three kinds of condition. Dirichlet fixes the value: a wall temperature, or the no-slip velocity. Neumann fixes the derivative: insulation, or a symmetry plane so you can compute half a channel. Robin mixes the two: Newton cooling, where conducted heat equals convected heat. With Neumann at both ends the solution is only fixed up to an added constant.
  3. Steady flow between plates is a boundary value problem. Pressure drop balances viscous shear: mu u double prime equals minus G, with no-slip walls. Integrating twice gives a parabola, G over two mu times y times H minus y. For water, 1 centimeter apart, the peak is 0.01 meters per second. If the top plate slides at 0.005 instead, with no pressure drop, the profile is a straight line: Couette.
  4. Shooting turns the unknown into a guess. Fire the initial value problem from the left wall with launch slope s, and measure the miss at the right wall: F of s equals y of L minus b. A solution is a root of F, found with the secant method. For a linear equation, F is a straight line, so one secant step lands exactly: slope 1.188395.
  5. Nonlinear equations can have several answers. For y double prime equals minus e to the y, with both ends at zero, the residual F crosses zero twice. Secant from 0 and 1 finds slope 0.549353, a shallow arc. Secant from 8 and 12 finds 10.846899, a tall arc, launched steeply so the restoring force turns it around. Same equation, same walls: you must know to look for both.
  6. Shooting has a weak spot. For y double prime equals 100 y, the wanted solution decays like e to the minus 10 x, but any launch error excites e to the plus 10 x. The secant method finds s equal minus 10 to double precision, yet the integration cannot hold the decay: at L equals 3, the end value is wrong by a factor of 10 to the 9. Finite differences stay near 10 to the minus 3.
  7. Finite differences cut the interval into cells and demand the equation at every interior node. The second difference approximates u double prime with error of order h squared. For plate flow with five cells, each row touches only its neighbors: a tridiagonal matrix, with minus 0.0032 on the right. The four dots are the solution, largest 0.0096. A parabola has no fourth derivative, so this answer is exact up to round-off.
  8. The Thomas algorithm is Gaussian elimination written for three diagonals: one forward sweep, one backward sweep, 8 N minus 7 operations. Dense elimination costs two thirds N cubed. At N equals 100 that is 793 against 681550, a factor of 859; at 200, a factor of 3385. Doubling N doubles Thomas, and multiplies dense by 7.8.
  9. Does it converge? For a manufactured sine solution, the maximum error drops by 4 each time h is halved: second order. Neumann with a ghost point keeps that. Replace the ghost row by a one-sided difference and the ratio falls to 2. One first-order row spoils the whole grid: at N equals 128 its error is larger than the ghost-point error at N equals 8.
  10. Stam's fluid solver ends every step with a pressure projection: a Poisson equation with Neumann walls, then subtract the gradient. Diffusion is a boundary value problem too. In one dimension these are exactly this lesson's tridiagonal systems. In two, each row has five non-zeros, and solvers use iterative sweeps instead. Next: the eigenvalues and eigenfunctions of the same operator.

Initial versus boundary conditions

An initial value problem gives all its data at one point: y′′=g(x,y,y′)y'' = g(x, y, y') with y(0)y(0) and y′(0)y'(0) prescribed. For smooth gg the theorem of 3.7 Existence & Uniqueness says there is exactly one solution near that point, and RK4 finds it by marching. A two-point BVP gives one condition at each end: y(0)=0y(0) = 0 and y(L)=by(L) = b. No such theorem holds, and the next example shows why.

Take y′′=−yy'' = -y with y(0)=0y(0) = 0. The general solution is Acos⁡x+Bsin⁡xA\cos x + B\sin x and y(0)=0y(0) = 0 forces A=0A = 0, so y=ssin⁡xy = s\sin x, where s=y′(0)s = y'(0) is the launch slope. As an IVP, ss is a number you choose: unique solution. As a BVP, the second condition demands

s sin⁡L=b.s\,\sin L = b .

This is a one-by-one linear system (sin⁡L) s=b(\sin L)\,s = b, which fails the way any linear system can (see the kernel in 1.3 Linear Systems, Kernel & Column Space):

  • sin⁡L≠0\sin L \ne 0: exactly one solution, s=b/sin⁡Ls = b/\sin L. For b=1b = 1 the required slope is 1.1881.188 at L=1L = 1, 1.1001.100 at L=2L = 2, 7.0867.086 at L=3L = 3, 24.0524.05 at L=3.1L = 3.1 and 627.9627.9 at L=3.14L = 3.14: it explodes as L→πL \to \pi.
  • L=πL = \pi, b=0b = 0: 0⋅s=00\cdot s = 0, so every slope works, infinitely many solutions.
  • L=πL = \pi, b≠0b \ne 0: 0⋅s=b0\cdot s = b, no solution.

The sim’s shooting panel shows this as the residual F(s)=y(L;s)−bF(s) = y(L;s) - b, the miss distance at the right wall for launch slope ss. At L=πL = \pi, b=0b = 0 the computed F(1)=1.6×10−9F(1) = 1.6\times10^{-9} and F(5)=8.0×10−9F(5) = 8.0\times10^{-9}: zero up to RK4’s truncation error, for every ss. At L=πL = \pi, b=1b = 1 both are −1.00-1.00: a flat line that never crosses zero. The trouble sits at L=πL = \pi because there the homogeneous problem (b=0b = 0) already has the nonzero solution sin⁡x\sin x: the eigenvalue problem of 8.2 Eigenvalue Problems & Sturm–Liouville Theory. Nonlinear BVPs add a fourth outcome, several solutions (two, below).

Three kinds of boundary condition

At an end x=Lx = L one scalar condition is imposed:

  • Dirichlet: the value, u(L)=βu(L) = \beta. A wall with fixed temperature; a no-slip wall where the fluid velocity equals the wall velocity.
  • Neumann: the derivative, u′(L)=βu'(L) = \beta. A fixed heat flux, the insulated case being β=0\beta = 0. In a fluid, a symmetry plane has u′=0u' = 0, so you can compute half a channel.
  • Robin: a mix, u′(L)+κu(L)=βu'(L) + \kappa u(L) = \beta. Newton cooling: heat conducted to the surface, −ku′-k u', equals the heat convected away, hc(u−T∞)h_c(u - T_\infty), giving u′+(hc/k) u=(hc/k) T∞u' + (h_c/k)\,u = (h_c/k)\,T_\infty. A slip wall with friction is also Robin.

Neumann at both ends fixes uu only up to an added constant, since uu and u+cu + c have the same derivatives.

Worked example: flow between plates

For steady, fully developed flow of a viscous fluid between plates at y=0y = 0 and y=Hy = H (standard reduction of the Navier–Stokes momentum equation, not re-derived here), only the streamwise velocity u(y)u(y) survives and pressure drop along the channel G=−dp/dxG = -dp/dx balances viscous shear: μ u′′=−G\mu\,u'' = -G. With no-slip walls u(0)=u(H)=0u(0) = u(H) = 0, integrate twice:

u′′=−Gμ,u=−G2μy2+c1y+c2.u'' = -\frac{G}{\mu},\qquad u = -\frac{G}{2\mu}y^2 + c_1 y + c_2 .

The conditions give c2=0c_2 = 0, c1=GH/2μc_1 = GH/2\mu, so

u(y)=G2μ y (H−y),umax⁡=u(H/2)=GH28μ.u(y) = \frac{G}{2\mu}\,y\,(H - y), \qquad u_{\max} = u(H/2) = \frac{G H^2}{8\mu}.

Numbers. Water (μ=10−3\mu = 10^{-3} Pa s), H=1H = 1 cm, G=0.8G = 0.8 Pa/m: G/μ=800G/\mu = 800, so u=400 y(0.01−y)u = 400\,y(0.01 - y) and umax⁡=400⋅0.005⋅0.005=0.01u_{\max} = 400\cdot0.005\cdot0.005 = 0.01 m/s. The sim’s “Poiseuille” problem solves this numerically and prints largest u=0.010000u = 0.010000 m/s. If instead the top plate slides at UU and there is no pressure drop, u′′=0u'' = 0 gives the Couette profile u=Uy/Hu = Uy/H: with U=0.005U = 0.005 m/s the sim’s largest uu is 0.0050.005, at the moving plate.

The shooting method

Idea: replace the unknown by a guess. Fire the IVP y′′=gy'' = g, y(0)=y0y(0) = y_0, y′(0)=sy'(0) = s with RK4 to x=Lx = L and measure the miss F(s)=y(L;s)−bF(s) = y(L;s) - b. A BVP solution is a root of FF, a scalar root-finding problem. Bisection needs a bracket (a sign change of FF); the secant method needs two guesses,

sk+1=sk−F(sk) sk−sk−1F(sk)−F(sk−1).s_{k+1} = s_k - F(s_k)\,\frac{s_k - s_{k-1}}{F(s_k) - F(s_{k-1})}.

Linear case: one step. For linear gg the solution is y(x;s)=y(x;0)+s w(x)y(x;s) = y(x;0) + s\,w(x) (superposition), so FF is a straight line and the secant formula lands exactly on its root. For y′′=−yy'' = -y, L=1L = 1, b=1b = 1: F(0)=−1F(0) = -1, F(1)=−0.159F(1) = -0.159, and one secant step gives s=1.188395s = 1.188395, with F=2×10−16F = 2\times10^{-16} (lab block A).

Nonlinear case: several roots. Take y′′=−eyy'' = -e^{y}, y(0)=y(1)=0y(0) = y(1) = 0. (This Bratu-type problem is a standard test; that it has exactly two solutions at this parameter is quoted from memory, and the experiment below finds both.) The residual (lab block B, 1000 RK4 steps):

ss00.51581112
F(s)F(s)−0.463-0.463−0.041-0.041+0.363+0.363+2.238+2.238+1.551+1.551−0.095-0.095−0.740-0.740

FF changes sign twice, once in (0.5,1)(0.5, 1) and once in (8,11)(8, 11), so two brackets for bisection. Secant started at (0,1)(0, 1) gives s=0.549353s = 0.549353 in five steps (F=3×10−16F = 3\times10^{-16}) with midpoint value y(12)=0.140539y(\tfrac12) = 0.140539; started at (8,12)(8, 12) it gives s=10.846899s = 10.846899 in five steps (F=−1×10−14F = -1\times10^{-14}) with y(12)=4.091467y(\tfrac12) = 4.091467. Same equation, same walls, two different solutions: a shallow arc, and a tall arc launched so steeply that the strong restoring force eye^{y} turns it around in time. Which one shooting finds depends on where you start, so you must know to look for both.

Where shooting fails: growing solutions

Consider y′′=100 yy'' = 100\,y, y(0)=1y(0) = 1, y(L)=e−10Ly(L) = e^{-10L}. Every solution is Ae−10x+Be10xAe^{-10x} + Be^{10x}; the wanted one has B=0B = 0. A launch slope ss gives B=(s+10)/20B = (s + 10)/20, and the unwanted piece grows by e10Le^{10L} while the wanted one shrinks by e−10Le^{-10L}. The slope is a double with about sixteen digits, so even the best slope carries a rounding error that is amplified into a wrong end value. Lab block C (RK4, h=0.005h = 0.005, secant from −5-5 and −15-15):

LL∣s+10∣\lvert s + 10\rvertshooting y(L)y(L)exact e−10Le^{-10L}relative errorFD worst relative error
12×10−142\times10^{-14}4.54×10−54.54\times10^{-5}4.54×10−54.54\times10^{-5}1.7×10−81.7\times10^{-8}8.3×10−48.3\times10^{-4}
2007.0×10−97.0\times10^{-9}2.06×10−92.06\times10^{-9}2.42.41.8×10−31.8\times10^{-3}
3001.1×10−41.1\times10^{-4}9.4×10−149.4\times10^{-14}1.2×1091.2\times10^{9}2.9×10−32.9\times10^{-3}

The secant method found s=−10s = -10 to double precision in every row; it is the integration that cannot hold the decaying solution against the growing one. Roundoff-driven digits depend on the machine (the sim and Python agree on orders of magnitude). At L=1L = 1 shooting beats finite differences, which is honest: its trouble starts when e20Le^{20L} (the growing-to-decaying ratio, printed by the sim) outruns 101610^{16}. Finite differences solve for all values at once and the diagonal of the system is dominant, so their error stays near 10−310^{-3} (from the h2h^2 truncation, next section) and grows only mildly with LL.

Finite differences and the tridiagonal system

Cut [0,L][0, L] into NN cells of width h=L/Nh = L/N with nodes xi=ihx_i = ih. Adding the Taylor expansions of u(x±h)u(x \pm h),

u(x−h)−2u(x)+u(x+h)h2=u′′(x)+h212u′′′′(x)+⋯ ,\frac{u(x - h) - 2u(x) + u(x + h)}{h^2} = u''(x) + \frac{h^2}{12}u''''(x) + \cdots,

so the second difference approximates u′′u'' with error O(h2)O(h^2). Demand u′′=fu'' = f at each interior node:

ui−1−2ui+ui+1=h2f(xi),i=1,…,N−1.u_{i-1} - 2u_i + u_{i+1} = h^2 f(x_i), \qquad i = 1, \dots, N-1 .

The wall values u0u_0, uNu_N are known and move to the right side, leaving N−1N - 1 equations in N−1N - 1 unknowns. Each row has three non-zero entries: a tridiagonal matrix. For Poiseuille with N=5N = 5 (h=0.002h = 0.002 m, h2f=−0.0032h^2 f = -0.0032, as the sim prints):

(−21001−21001−21001−2)(u1u2u3u4)=(−0.0032−0.0032−0.0032−0.0032).\begin{pmatrix} -2 & 1 & 0 & 0 \\ 1 & -2 & 1 & 0 \\ 0 & 1 & -2 & 1 \\ 0 & 0 & 1 & -2 \end{pmatrix} \begin{pmatrix} u_1 \\ u_2 \\ u_3 \\ u_4 \end{pmatrix} = \begin{pmatrix} -0.0032 \\ -0.0032 \\ -0.0032 \\ -0.0032 \end{pmatrix}.

The solution is the four dots in the sim, with largest value 0.00960.0096 (the grid has no node at the centre, where the exact value is 0.010.01). For this problem the numerical answer is exact: u′′′′=0u'''' = 0 for a parabola, so the h2h^2 term above vanishes, and the measured error is round-off only, between 10−1810^{-18} and 10−1610^{-16} for N=4,10,50N = 4, 10, 50 (lab, sim). A parabola therefore cannot test convergence.

Convergence test: a manufactured solution. Choose u=sin⁡2xu = \sin 2x on [0,1][0, 1], so f=u′′=−4sin⁡2xf = u'' = -4\sin 2x and the boundary data come from uu (u(1)=sin⁡2u(1) = \sin 2). Lab block D, maximum error over the nodes:

NN8163264128
error2.02×10−32.02\times10^{-3}5.09×10−45.09\times10^{-4}1.27×10−41.27\times10^{-4}3.18×10−53.18\times10^{-5}7.96×10−67.96\times10^{-6}
ratio3.974.004.004.00

Halving hh divides the error by 44 (up to 3.973.97 at the coarsest step): second order, as the Taylor series said.

The Thomas algorithm is Gaussian elimination written for three diagonals. With sub-diagonal aa, diagonal bb, super-diagonal cc and right side dd:

m=aibi−1,bi←bi−m ci−1,di←di−m di−1;ui=di−ciui+1bi (backwards).m = \frac{a_i}{b_{i-1}},\quad b_i \leftarrow b_i - m\,c_{i-1},\quad d_i \leftarrow d_i - m\,d_{i-1};\qquad u_i = \frac{d_i - c_i u_{i+1}}{b_i}\ \text{(backwards)}.

Each row is touched once forward and once backward, about 8N8N operations (exactly 8N−78N - 7, counted) against 23N3\tfrac23N^3 for dense elimination. The sim’s counter runs both on the same matrix: N=25N = 25: 193193 against 1132511325; N=50N = 50: 393393 against 8702587025; N=100N = 100: 793793 against 681550681550 (a factor 859859); N=200N = 200: 15931593 against 53931005393100 (33853385). Doubling NN doubles the Thomas cost (393→793393 \to 793) and multiplies the dense cost by 7.87.8. No row exchanges are needed because the diagonal (22) is at least the two off-diagonals together (1+11 + 1) (stated from memory).

Neumann and Robin conditions

With u′(L)=βu'(L) = \beta the value uNu_N is unknown too, so row NN must use the boundary condition. The ghost point trick: pretend a node uN+1u_{N+1} exists, impose the centred difference (uN+1−uN−1)/2h=β(u_{N+1} - u_{N-1})/2h = \beta, so uN+1=uN−1+2hβu_{N+1} = u_{N-1} + 2h\beta, and substitute into the ordinary equation at node NN:

2uN−1−2uN=h2fN−2hβ.2u_{N-1} - 2u_N = h^2 f_N - 2h\beta .

(Robin adds −2hκ uN-2h\kappa\,u_N to the diagonal.) The matrix stays tridiagonal; its last row is (2,−2)(2, -2). The cheaper choice is a one-sided difference (uN−uN−1)/h=β(u_N - u_{N-1})/h = \beta, but it is the derivative at the midpoint xN−1/2x_{N-1/2}, off by O(h)O(h) from the node. Same sine problem, maximum error (lab block D):

right endN=8N = 8N=16N = 16N=32N = 32N=64N = 64N=128N = 128ratios
Neumann, ghost2.25×10−32.25\times10^{-3}5.66×10−45.66\times10^{-4}1.41×10−41.41\times10^{-4}3.53×10−53.53\times10^{-5}8.83×10−68.83\times10^{-6}3.97, 4.00, 4.00, 4.00
Neumann, one-sided2.27×10−12.27\times10^{-1}1.14×10−11.14\times10^{-1}5.68×10−25.68\times10^{-2}2.84×10−22.84\times10^{-2}1.42×10−21.42\times10^{-2}2.00 each
Robin, ghost2.12×10−32.12\times10^{-3}5.38×10−45.38\times10^{-4}1.34×10−41.34\times10^{-4}3.36×10−53.36\times10^{-5}8.39×10−68.39\times10^{-6}3.95, 4.00, 4.00, 4.00
Robin, one-sided1.13×10−11.13\times10^{-1}5.68×10−25.68\times10^{-2}2.84×10−22.84\times10^{-2}1.42×10−21.42\times10^{-2}7.10×10−37.10\times10^{-3}2.00 each

One first-order row in a second-order scheme makes the whole solution first order: the boundary error is O(h)O(h) and the solve spreads it across the grid. At N=128N = 128 the one-sided Neumann error (1.4×10−21.4\times10^{-2}) is larger than the ghost-point error at N=8N = 8 (2.3×10−32.3\times10^{-3}). For the half-channel Poiseuille problem (u(0)=0u(0) = 0, symmetry u′=0u' = 0 at H/2H/2) the ghost version is exact (round-off below 10−1510^{-15}), while the one-sided version gives a centre velocity of 0.00750.0075, 0.008750.00875, 0.0093750.009375 for N=4,8,16N = 4, 8, 16 against the exact 0.010.01: the error halves each time.

Try it

◆ Interactive Finite differences with N, the convergence plot and the assembled matrix; shooting with the residual curve F(s)

Loading simulation…

What to try. (1) Poiseuille: round-off error for every NN; set N=5N = 5 and read the matrix. (2) Sine problems: N=8N = 8 then 1616; for Neumann untick the ghost box and watch the ratio fall to 2.002.00. (3) Press “count operations”. (4) Shooting, y′′=−yy'' = -y: L=2L = 2 and 3.13.1, then “L = pi” with b=0b = 0 and b=1b = 1. (5) Bratu: both secant starts. (6) y′′=100yy'' = 100y, L=1,2,3L = 1, 2, 3: the blue curve peels away from the exact decay.

Computing it

🐍 PythonLab: residuals and secant shooting (blocks A to C), finite differences with a ghost point or a one-sided end (block D)
⌘/Ctrl + Enter

Now build the finite-difference solver yourself: the tridiagonal solve, then the plate-flow problem on top of it.

🧪 Coding exerciseExercise: Thomas algorithm and the Poiseuille profile, checked against 400 y (0.01 - y)
⌘/Ctrl + Enter

Concept checks

✅ Concept check

For $y'' = -y$ with $y(0) = 0$ and $y(\pi) = 1$, how many solutions are there?

✅ Concept check

A second-order finite-difference scheme with ghost-point Neumann conditions has maximum error $5.66\times10^{-4}$ at $N = 16$. Predict the error at $N = 32$ to one significant figure, in units of $10^{-4}$.

✅ Concept check

You replace the ghost-point row by the one-sided $(u_N - u_{N-1})/h = \beta$ and the error stops falling by a factor $4$ per halving of $h$. Why?

✅ Concept check

In $y'' = 100y$, $y(0) = 1$, $y(3) = e^{-30}$, shooting returns $y(3) = 1.1\times10^{-4}$ even though the secant method found $s = -10$ to double precision. The reason is:

Problems

✏️ Pen & paperCount the solutions●○○

For y′′=−yy'' = -y, y(0)=0y(0) = 0, y(L)=by(L) = b, find the launch slope or say why none exists: (a) L=2L = 2, b=1b = 1; (b) L=3.1L = 3.1, b=1b = 1; (c) L=πL = \pi, b=0b = 0; (d) L=πL = \pi, b=1b = 1.

Show worked solution

y=ssin⁡xy = s\sin x, so ssin⁡L=bs\sin L = b. (a) s=1/sin⁡2=1.0997s = 1/\sin 2 = 1.0997 (sim: b/sin⁡L=1.099750b/\sin L = 1.099750). (b) s=1/sin⁡3.1=24.05s = 1/\sin 3.1 = 24.05: nearly resonant, so a tiny change in bb or LL moves ss a lot. (c) 0⋅s=00\cdot s = 0: infinitely many, one for every ss. (d) 0⋅s=10\cdot s = 1: none.

✏️ Pen & paperA two-cell half channel●●○

Take the half-channel Poiseuille problem u′′=−800u'' = -800 on [0,0.005][0, 0.005] with u(0)=0u(0) = 0 and u′(0.005)=0u'(0.005) = 0, and use N=2N = 2 cells (h=0.0025h = 0.0025) with the ghost-point row. Write the two equations, solve them, and compare with the exact u=400 y(0.01−y)u = 400\,y(0.01 - y).

Show worked solution

Unknowns u1,u2u_1, u_2; h2f=6.25×10−6⋅(−800)=−0.005h^2 f = 6.25\times10^{-6}\cdot(-800) = -0.005. Row 1: −2u1+u2=−0.005-2u_1 + u_2 = -0.005. Row 2 (ghost point, β=0\beta = 0): 2u1−2u2=−0.0052u_1 - 2u_2 = -0.005. From row 2, u1=u2−0.0025u_1 = u_2 - 0.0025; into row 1: −u2+0.005=−0.005-u_2 + 0.005 = -0.005, so u2=0.01u_2 = 0.01 and u1=0.0075u_1 = 0.0075. The exact values are 400(0.0025)(0.0075)=0.0075400(0.0025)(0.0075) = 0.0075 and 400(0.005)(0.005)=0.01400(0.005)(0.005) = 0.01: exact, because the profile is quadratic. (Set N=2N = 2 and the half-channel problem in the sim: error at round-off.)

✏️ Pen & paperWhy not dense?●●○

The sim counts 53931005393100 operations for the dense solve and 15931593 for Thomas at N=200N = 200. Using 23N3\tfrac23N^3 and 8N8N, estimate the ratio at N=1000N = 1000, and say what it means for a 2D grid of 1000×10001000 \times 1000 unknowns.

Show worked solution

Formula check at N=200N = 200: 23⋅8×106=5.3×106\tfrac23\cdot8\times10^6 = 5.3\times10^6, within 1%1\% of the count. At N=1000N = 1000: dense ≈6.7×108\approx 6.7\times10^8, Thomas ≈8000\approx 8000, ratio about 8×1048\times10^4 (an estimate from the formula; the sim only counts up to N=200N = 200). In 2D the unknowns number 10610^6, a dense matrix would be 106×10610^6 \times 10^6 and could not even be stored, which is why sparse structure and iterative solvers matter.

Key Takeaways

  • A BVP gives conditions at two points and cannot be marched. For y′′=−yy'' = -y, y(0)=0y(0) = 0, y(L)=by(L) = b the count depends on sin⁡L\sin L: one solution (s=1.188s = 1.188 at L=1L = 1), none, or infinitely many (at L=πL = \pi).
  • Dirichlet fixes the value (temperature, no-slip), Neumann the flux or slope (insulation, symmetry plane), Robin a mix (convective cooling).
  • Plate flow is μu′′=−G\mu u'' = -G: Poiseuille u=G2μy(H−y)u = \tfrac{G}{2\mu}y(H - y), with umax⁡=0.01u_{\max} = 0.01 m/s for G/μ=800G/\mu = 800 and H=1H = 1 cm; Couette is linear.
  • Shooting: secant on F(s)=y(L;s)−bF(s) = y(L;s) - b; one step when linear, and y′′=−eyy'' = -e^y has two solutions (s=0.549353s = 0.549353 and 10.84689910.846899) from different starts. Growing modes break it: on y′′=100yy'' = 100y the end value is wrong by a factor 2.42.4 at L=2L = 2 and 10910^9 at L=3L = 3, while finite differences stay near 10−310^{-3}.
  • Finite differences give a tridiagonal system, solved in 8N−78N - 7 operations (dense: 681550681550 against 793793 at N=100N = 100), with error ratio 4.004.00 per halving of hh.
  • Ghost points keep Neumann and Robin second order; a one-sided row drops the ratio to 2.002.00.
  • Next: the eigenvalues and eigenfunctions of the same operator, 8.2 Eigenvalue Problems & Sturm–Liouville Theory.
Finished this lesson?

Mark it complete to track your progress (saved in this browser). Reading every section does this for you.

Where this leads

These later lessons build directly on this one: