ArticleslgStudy

mathematics

Five-point stencil

Five-point stencil is a mathematics topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Five-point stencil rather than just read about it. In short: In numerical analysis, given a square grid in one or two dimensions, the five-point stencil of a point in the grid is a stencil made up of the point itself together with its four "neighbors". It is used to write finite difference approximations to derivatives at grid points.

Five-point stencil — main illustration
Five-point stencil — illustration

Key takeaways

  • Five-point stencil belongs to mathematics; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Five-point stencil to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Five-point stencil from memory before moving on to harder problems.

Reference excerpt

In numerical analysis, given a square grid in one or two dimensions, the five-point stencil of a point in the grid is a stencil made up of the point itself together with its four "neighbors". It is used to write finite difference approximations to derivatives at grid points. It is an example of numerical differentiation.

In one dimension In one dimension, if the spacing between points in the grid is h, then the five-point stencil of a point x in the grid is

{x−2h,x−h,x,x+h,x+2h}.

1D first derivative The first derivative of a function f of a real variable at a point x can be approximated using a five-point stencil as:

f′(x)≈−f(x+2h)+8f(x+h)−8f(x−h)+f(x−2h)12h The center point f(x) itself is not involved, only the four neighboring points.

Derivation This formula can be obtained by writing out the four Taylor series of f(x±h) and f(x±2h) at the point a, up to terms of h3 (or up to terms of h5 to get an error estimation as well), evaluating each series at a=x∓h and a=x∓2h respectively (to get everything in common terms of f(k)(x)), and solving this system of four equations to get f ′(x). Actually, we have at points x + h and x − h:

f(x±h)=f(x)±hf′(x)+h22f″(x)±h36f(3)(x)+O1±(h4).(E1±). Evaluating (E1+)−(E1−) gives us

f(x+h)−f(x−h)=2hf′(x)+h33f(3)(x)+O1(h4).(E1). The residual term O1(h4) should be of the order of h5 instead of h4 because if the terms of h4 had been written out in (E1+) and (E1−), it can be seen that they would have canceled each other out by f(x + h) − f(x − h). But for this calculation, it is left like that since the order of error estimation is not treated here (cf below). Similarly, we have

f(x±2h)=f(x)±2hf′(x)+4h22!f″(x)±8h33!f(3)(x)+O2±(h4).(E2±) and (E2+)−(E2−) gives us

f(x+2h)−f(x−2h)=4hf′(x)+8h33f(3)(x)+O2(h5).(E2). In order to eliminate the terms of ƒ(3)(x), calculate 8 × (E1) − (E2)

8f(x+h)−8f(x−h)−f(x+2h)+f(x−2h)=12hf′(x)+O(h5) thus giving the formula as above. Note: the coefficients of f in this formula, (8, -8,-1,1), represent a specific example of the more general Savitzky–Golay filter.

Error estimate The error in this approximation is of order h 4. That can be seen from the expansion

−f(x+2h)+8f(x+h)−8f(x−h)+f(x−2h)12h=f′(x)−130f(5)(x)h4+O(h5) which can be obtained by expanding the left-hand side in a Taylor series. Alternatively, apply Richardson extrapolation to the central difference approximation to f′(x) on grids with spacing 2h and h.

1D higher-order derivatives The centered difference formulas for five-point stencils approximating second, third, and fourth derivatives are

f″(x)≈−f(x+2h)+16f(x+h)−30f(x)+16f(x−h)−f(x−2h)12h2f(3)(x)≈f(x+2h)−2f(x+h)+2f(x−h)−f(x−2h)2h3f(4)(x)≈f(x+2h)−4f(x+h)+6f(x)−4f(x−h)+f(x−2h)h4 The errors in these approximations are O(h4), O(h2) and O(h2) respectively.

Relationship to Lagrange interpolating polynomials As an alternative to deriving the finite difference weights from the Taylor series, they may be obtained by differentiating the Lagrange polynomials

ℓj(ξ)=∏i=0,i≠jkξ−xixj−xi, where the interpolation points are

x0=x−2h,x1=x−h,x2=x,x3=x+h,x4=x+2h. Then, the quartic polynomial p4(x) interpolating f(x) at these five points is

p4(x)=∑j=04f(xj)ℓj(x) and its derivative is

p4′(x)=∑j=04f(xj)ℓ'j(x). So, the finite difference approximation of f ′(x) at the middle point x = x2 is

f′(x2)=ℓ0′(x2)f(x0)+ℓ1′(x2)f(x1)+ℓ2′(x2)f(x2)+ℓ3′(x2)f(x3)+ℓ4′(x2)f(x4)+O(h4) Evaluating the derivatives of the five Lagrange polynomials at x = x2 gives the same weights as above. This method can be more flexible as the extension to a non-uniform grid is quite straightforward.

In two dimensions In two dimensions, if for example the size of the squares in the grid is h by h, the five point stencil of a point (x, y) in the grid is

{(x−h,y),(x,y),(x+h,y),(x,y−h),(x,y+h)}, forming a pattern that is also called a quincunx. This stencil is often used to approximate the Laplacian of a function of two variables:

∇2f(x,y)≈f(x−h,y)+f(x+h,y)+f(x,y−h)+f(x,y+h)−4f(x,y)h2. The error in this approximation is O(h 2), which may be explained as follows: From the 3 point stencils for the second derivative of a function with respect to x and y:

∂2f∂x2=f(x+Δx,y)+f(x−Δx,y)−2f(x,y)Δx2−2f(4)(x,y)4!Δx2+⋯∂2f∂y2=f(x,y+Δy)+f(x,y−Δy)−2f(x,y)Δy2−2f(4)(x,y)4!Δy2+⋯ If we assume Δx=Δy=h:

∇2f=∂2f∂x2+∂2f∂y2=f(x+h,y)+f(x−h,y)+f(x,y+h)+f(x,y−h)−4f(x,y)h2−4f(4)(x,y)4!h2+⋯=f(x+h,y)+f(x−h,y)+f(x,y+h)+f(x,y−h)−4f(x,y)h2+O(h2)

See also Finite difference coefficient – Coefficient used in numerical approximation Iterative Stencil Loops – Class of data processing algorithmsPages displaying short descriptions of redirect targets Nine-point stencil Stencil (numerical analysis) Stencil jumping Symmetric difference quotient

References

Abramowitz, Milton; Stegun, Irene A. (1970), Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables, Dover. Ninth printing. Table 25.2.

Illustrations

Five-point stencil: An illustration of the five-point stencil in one and two dimensions (top, and bottom, respectively).
An illustration of the five-point stencil in one and two dimensions (top, and bottom, respectively).

Worked examples

Example 1 — a first encounter with Five-point stencil

Start with the simplest possible case. Write down what Five-point stencil claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In mathematics, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Five-point stencil before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Five-point stencil ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Five-point stencil

In research
Five-point stencil appears in mathematics research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Five-point stencil in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Five-point stencil is common in secondary-school and first-year university syllabi. It links to neighbouring topics Numerical differential equations, so understanding it makes those chapters shorter.
In everyday life
Look for Five-point stencil outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Five-point stencil” →

How to study Five-point stencil in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Five-point stencil means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Five-point stencil out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Five-point stencil in simple terms?

In numerical analysis, given a square grid in one or two dimensions, the five-point stencil of a point in the grid is a stencil made up of the point itself together with its four "neighbors". It is used to write finite difference approximations to derivatives at grid points.

Why does Five-point stencil matter?

Because it connects several mathematics ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Five-point stencil?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Five-point stencil.

Tags

  • Numerical differential equations

Keep exploring