A finite-difference method replaces the derivatives of a differential equation by difference quotients of the values on a grid of nodes. The method of lines discretises space first, turning the equation into a system of ordinary differential equations U˙=LhU in time, then applies a time-stepping scheme. On a non-uniform grid the spacings hi−=xi−xi−1 and hi+=xi+1−xi differ; the three-point formulas
uxx≈h−(h−+h+)2ui−1−h−h+2ui+h+(h−+h+)2ui+1,
ux≈h−(h−+h+)−h+ui−1+h−h+(h+−h−)ui+h+(h−+h+)h−ui+1
are exact on quadratics.