What Actually Happens When You Try This

I picked up a copy of Introduction To Partial Differential Equations With Matlab a few years back after a colleague recommended it for our team's transient thermal modeling work. What I found was not a bad book, but also not the magic wand it gets credit for. It walks through the basics cleanly—finite difference discretization, method of lines, some basic explicit and implicit schemes—but the real value shows up when you stop at the chapters on boundary handling and numerical stability. Everything else is textbook material you can find free online. The heat equation in two dimensions is where most people start, and where most people run into trouble. Let me show you what I mean.

Introduction To Partial Differential Equations With Matlab

The book uses pdepe extensively, which is MATLAB's built-in solver for parabolic and elliptic PDEs in one spatial dimension. It's a reasonable entry point because the syntax is compact and you get results fast. But pdepe only handles one spatial dimension directly. If you're working on anything two-dimensional or three-dimensional—like a square plate with temperature gradients across both axes—you have to either restructure the problem or switch tools entirely. I spent an afternoon trying to shoehorn a 2D problem into pdepe before someone pointed out that the pdetool interface, now part of the PDE Toolbox, was the right call. That's the first thing the book doesn't emphasize enough: the gap between pdepe demos and real engineering problems. Real problems rarely live in 1D. Here's a stripped-down example from my own work. We had a rectangular domain, 0.1 meters by 0.1 meters, with a fixed temperature on one edge and insulation on the rest. The governing equation was the standard 2D heat equation:

du/dt = alpha * (d²u/dx² + d²u/dy²) Where alpha is the thermal diffusivity. In MATLAB, the cleanest way to tackle this isn't pdepe. It's the Method of Lines. You discretize space first using finite differences, leaving you with a system of ODEs in time, then hand that off to ode15s. The setup looks like this. You create a grid with meshgrid, set up the Laplacian operator using a five-point stencil, then integrate.

Get the Full Details

Introduction to Partial Differential Equations with MATLAB Paperback ...
Introduction to Partial Differential Equations with MATLAB Paperback ...
T0 = 300;
Lx = 0.1; Ly = 0.1;
nx = 50; ny = 50;
dx = Lx/(nx-1); dy = Ly/(ny-1);
alpha = 1e-5;

[Tx,Ty] = meshgrid(linspace(0,Lx,nx), linspace(0,Ly,ny));
U = T0 * ones(ny,nx);
U(:,1) = 400;

lap = @(U) ( circshift(U,[0,-2]) - 2*U + circshift(U,[0,2]) )./dx^2 ...
           + ( circshift(U,[-1,0]) - 2*U + circshift(U,[1,0]) )./dy^2;

options = odeset('RelTol',1e-4,'AbsTol',1e-6);
[t,Us] = ode15s(@(t,U) alpha*lap(U), [0 100], U(:), options);

That ran in about twelve seconds on a standard laptop. Not blazing, but acceptable for a first pass at the physics. The biggest mistake I see is ignoring the stability constraint on explicit schemes. If you're rolling your own forward-Euler time stepping—which you shouldn't, but some tutorials suggest—the time step has to satisfy dt = dx²/(4*alpha) in 2D. For the grid above, that works out to roughly dt = 2.5e-7 seconds per step. You'd need tens of thousands of steps to reach t=100. That's why I switched to ode15s, which handles the stiff system automatically. Another issue that caught me off guard: the boundary condition treatment in the Laplacian. The five-point stencil near the edges references points outside the domain. My first implementation just left them as zero, which amounted to fixing the temperature at zero degrees everywhere at the boundary. That's wrong unless you actually want zero-degree boundaries. I fixed it by constructing the Laplacian as a sparse matrix and embedding the boundary conditions directly into the matrix structure, which eliminated the ghost-point ambiguity entirely.

N = nx*ny;
S = spdiags([ones(N,1), -4*ones(N,1), ones(N,1)], [0,-1,1], N,N);
S = S + spdiags([ones(N-ny,1)], -ny, N,N) + spdiags([ones(N-ny,1)], ny, N,N);

for i = 1:N
    if mod(i,nx)==1; S(i,i) = S(i,i) + 1; end
    if mod(i,nx)==0; S(i,i) = S(i,i) + 1; end
end

U0 = T0 * ones(N,1);
U0(1:ny) = 400;
[t,Us] = ode15s(@(t,U) alpha*S*U, [0 100], U0, options);

This sparse-matrix version runs in about three seconds instead of twelve. The difference is significant when you're running parametric sweeps. The early chapters on classification—hyperbolic, parabolic, elliptic—are accurate and concise. The walkthroughs of finite difference derivations are solid. If you need a refresher on why the central difference approximation for the second derivative is second-order accurate, this book delivers that without fluff. But the coverage of numerical methods beyond basic finite differences is thin. There's almost nothing on finite element approaches, no discussion of adaptive mesh refinement, and the treatment of nonlinear PDEs is practically nonexistent. For a linear diffusion problem, the book is fine. Once you introduce temperature-dependent conductivity or radiation boundary conditions—things that show up in any real project—you're on your own.

Also worth noting: the book assumes you're working within MATLAB's base environment. If you're using the PDE Toolbox, many of the approaches described become redundant. The toolbox handles mesh generation, boundary condition application, and solver selection for you. It has its own learning curve, but for complex geometries it's the faster path.

An Introduction to Partial Differential Equations with MATLAB eBook by ...
An Introduction to Partial Differential Equations with MATLAB eBook by ...

A Practical Workflow I Recommend

Start simple. Get a 1D problem working with pdepe so you understand the expected output format. Then move to the Method of Lines with a structured grid for 2D problems. Only bring in the PDE Toolbox when your geometry can't be represented on a rectangular grid. Keep the finite difference approach as your diagnostic tool—even when you're using the toolbox for production runs, a quick FD model will tell you whether your FEM results are in the right ballpark within minutes. The tradeoff is clarity versus capability. pdepe and the Method of Lines on a regular grid give you transparency into exactly what's happening at each step. The PDE Toolbox abstracts away the discretization details, which is convenient until something goes wrong and you need to debug it. I've lost two hours once to a silent mesh-quality issue in the toolbox that a manual finite difference implementation would have revealed immediately. If you're coming at this from a mathematics background and want rigorous error analysis, this book won't satisfy you. If you're an engineer who needs to get a working simulation running today, it's a decent reference. Just don't expect it to carry you past the basics.