ArticleslgStudy

mathematics

Numerical differentiation

Numerical differentiation 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 Numerical differentiation rather than just read about it. In short: In numerical analysis, numerical differentiation algorithms estimate the derivative of a mathematical function or subroutine using values of the function. Unlike analytical differentiation, which provides exact expressions for derivatives, numerical differentiation relies on the function's values at a set of discrete points to estimate the derivative's value at those points or at intermediate points.

Numerical differentiation — main illustration
Numerical differentiation — illustration

Key takeaways

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

Reference excerpt

In numerical analysis, numerical differentiation algorithms estimate the derivative of a mathematical function or subroutine using values of the function. Unlike analytical differentiation, which provides exact expressions for derivatives, numerical differentiation relies on the function's values at a set of discrete points to estimate the derivative's value at those points or at intermediate points. This approach is particularly useful when dealing with data obtained from experiments, simulations, or situations where the function is defined only at specific intervals.

Finite differences

The simplest method is to use finite difference approximations. A simple two-point estimation is to compute the slope of a nearby secant line through the points (x, f(x)) and (x + h, f(x + h)). Choosing a small number h, h represents a small change in x, and it can be either positive or negative. The slope of this line is f(x+h)−f(x)h. This expression is Newton's difference quotient (also known as a first-order divided difference). To obtain an error estimate for this approximation, one can use Taylor expansion of f(x) about the base point x to give f(x+h)=f(x)+hf′(x)+h22f″(c) for some c between x and x+h. Rearranging gives f′(x)=f(x+h)−f(x)h⏟Slope of secant line−h2f″(c)⏟Error term. The slope of this secant line differs from the slope of the tangent line by an amount that is approximately proportional to h. As h approaches zero, the slope of the secant line approaches the slope of the tangent line and the error term vanishes. Therefore, the true derivative of f at x is the limit of the value of the difference quotient as the secant lines get closer and closer to being a tangent line: f′(x)=limh→0f(x+h)−f(x)h. Since immediately substituting 0 for h results in 00 indeterminate form, calculating the derivative directly can be unintuitive. Equivalently, the slope could be estimated by employing positions x − h and x. Another two-point formula is to compute the slope of a nearby secant line through the points (x − h, f(x − h)) and (x + h, f(x + h)). The slope of this line is f(x+h)−f(x−h)2h. This formula is known as the symmetric difference quotient. In this case the first-order errors cancel, so the slope of these secant lines differ from the slope of the tangent line by an amount that is approximately proportional to h2. Hence for small values of h this is a more accurate approximation to the tangent line than the one-sided estimation. However, although the slope is being computed at x, the value of the function at x is not involved. The estimation error is given by R=−f(3)(c)6h2, where c is some point between x−h and x+h. This error does not include the rounding error due to numbers being represented and calculations being performed in limited precision. The symmetric difference quotient is employed as the method of approximating the derivative in a number of calculators, including TI-82, TI-83, TI-84, TI-85, all of which use this method with h = 0.001.

Step size

An important consideration in practice when the function is calculated using floating-point arithmetic of finite precision is the choice of step size, h. To illustrate, consider the two-point approximation formula with error term: f′(x)=f(x+h)−f(x−h)2h−f(3)(c)6h2 where c is some point between x−h and x+h. Let e(x) denote the roundoff error encountered when evaluating the function f(x) and f̂(x) denote the computed value of f(x). Therefore, f(x)=f̂(x)+e(x). The total error in the approximation is f′(x)−f̂(x+h)−f̂(x−h)2h=e(x+h)−e(x−h)2h⏟Roundoff error−f(3)(c)6h2⏟Truncation error. Assuming that the roundoff errors are bounded by some number ε>0 and the third derivative of f(x) is bounded by some number M>0, we get |f′(x)−f̂(x+h)−f̂(x−h)2h|≤εh+h26M. To reduce the truncation error h26M, we must reduce h. But as h is reduced, the roundoff error εh increases. Due to the need to divide by the small value h, all the finite-difference formulae for numerical differentiation are similarly ill-conditioned. If instead the derivative is approximated using f′(x)=f(x+h)−f(x)h and we assume the relative approximation error due to rounding is bounded by machine epsilon and the values |f″(x)| and |f(x)| are bounded on [x0,x0+h] by M1and M2 respectively it can be shown that:|f′(x0)−f̂(x0+h)−f̂(x0)h|≤h2M1+2εhM2By minimizing this upper bound an estimate for the optimal step size can be obtained. However, employing this method would require the knowledge of the bounds M1 and M2. Instead, if an approximate upper bound is used - one where M1and M2 are replaced by |f″(x0)| and |f(x0)| the error can be estimated as:e(h)=h2|f″(x0)|+2εh|f(x0)|By minimizing e(h) an estimate for the optimal step size h can be found: h=2ε|f(x)f″(x)|(though not when f″(x)=0). If no information about the function f is known, sometimes the approximation |f(x)f″(x)|≈x is used giving a choice for h that is small without producing a large rounding error: εx, where the machine epsilon ε is typically of the order of 2.2×10−16 for double precision. In practice, one cannot compute the value that minimizes the above error bounds and therefore cannot compute an approximation of the optimal step size without information about higher-order derivatives.

Example To demonstrate this difficulty, consider approximating the derivative of the function f(x)=2x1+x at the point x0=9. In this case, we can calculate f′(x)=2+x(1+x)2 which gives f′(9)=2+9(1+9)2=2+3(1+3)2=516=0.3125. Using 64-bit floating point numbers, the following approximations are generated with the two-point approximation formula and increasingly smaller step sizes. The smallest absolute error is produced for a step size of 10−4, after which the absolute error steadily increases as the roundoff errors dominate calcuations.

For computer calculations the problems are exacerbated because, although x necessarily holds a representable floating-point number in some precision (32 or 64-bit, etc.), x + h almost certainly will not be exactly representable in that precision. This means that x + h will be changed (by rounding or truncation) to a nearby machine-representable number, with the consequence that (x + h) − x will not equal h; the two function evaluations will not be exactly h apart. In this regard, since most decimal fractions are recurring sequences in binary (just as 1/3 is in decimal) a seemingly round step such as h = 0.1 will not be a round number in binary; it is 0.000110011001100...2 A possible approach is as follows:

… excerpt ends here. Continue reading the full article.

Illustrations

Numerical differentiation: Finite difference estimation of derivative
Finite difference estimation of derivative
Numerical differentiation: Example showing the difficulty of choosing h due to both rounding error and formula error
Example showing the difficulty of choosing h due to both rounding error and formula error

Worked examples

Example 1 — a first encounter with Numerical differentiation

Start with the simplest possible case. Write down what Numerical differentiation 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 Numerical differentiation 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 Numerical differentiation 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 Numerical differentiation

In research
Numerical differentiation 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 Numerical differentiation 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
Numerical differentiation is common in secondary-school and first-year university syllabi. It links to neighbouring topics Differential calculus, Numerical analysis, so understanding it makes those chapters shorter.
In everyday life
Look for Numerical differentiation 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 “Numerical differentiation” →

How to study Numerical differentiation in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Numerical differentiation 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 Numerical differentiation out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Numerical differentiation in simple terms?

In numerical analysis, numerical differentiation algorithms estimate the derivative of a mathematical function or subroutine using values of the function. Unlike analytical differentiation, which provides exact expressions for derivatives, numerical differentiation relies on the function's values a…

Why does Numerical differentiation 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 Numerical differentiation?

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 Numerical differentiation.

Tags

  • Differential calculus
  • Numerical analysis

Keep exploring