# Tutorial for basic numerical methods for PDEs

I'm afraid this is probably not going to be a "good" question, but I'd like to use Mathematica to learn about basic numerical schemes for solving pdes. For example, I'd like to compute the solution of a 2D heat equation initial value problem using finite differences and Euler timestepping, and then look at how big errors are or stability (not interested in using NDSolve directly).

My question is, are there any resources that already do this the "right" way? I'm just getting acquainted with Mathematica and don't know the language well, but I do know I want to use packed arrays and avoid loops. There's lots of language-agnostic references for the numerical methods themselves, but I can't find good clean examples of Mathematica implementations of these methods.

Edit:

One of the books recommended in the answers suggest doing stuff like (1d heat equation IVP):

Clear["Global*"];
gridX = 10; (* num interior points *)
dx = 1./gridX;
dt = .005; (*cfl: dt/dx^2 <= .5 *)

T[i_, j_] := T[i, j] = T[i, j - 1] +
(dt/dx^2) (T[i + 1, j - 1] - 2 T[i, j - 1] + T[i - 1, j - 1]);

T[i_, 0] := 1. (* initial value *)

T[0,         j_] := 0.; (* boundaries *)
T[gridX + 1, j_] := 0.;

TFinal[t_] := Table[T[i, IntegerPart[t/ dt]], {i, 1, gridX}];
ListLinePlot[TFinal]
`

But I suspect that it's not the best way, because as soon as I crank up the grid size and shrink down the time step, I get a recursion limit error. The code above is storing the solution at all time steps, which I definitely don't want. I'm sure there are clean, non-recursive sample implementations of this method out there, just can't seem to find.

• trott's books are very good:Trott Apr 10, 2013 at 4:35
• a book is not a resource? in any case, i'm just interested in seeing some code, don't care if it's in a book, a website, or a stone tablet. what i'm definitely not interested in are comments like yours. just move along. Apr 10, 2013 at 16:21