gl/ripetizioni

Numerical analysis exam: the methods that always come up

Newton, interpolation, quadrature and ODE methods for the numerical analysis exam: where marks are lost, and three exercises worked through step by step.

by Gaetano Livornese

Read the original in Italian

Numerical analysis (calcolo numerico, or Numerical Methods, depending on the university) is one of those exams that look “easy” because it does not have the heavy theory of first-year Calculus, and that is exactly why many students underestimate it. The problem is not understanding what a method does. It is carrying it out correctly by hand, with a calculator, in limited time, without MATLAB to check every step.

I have worked with several Politecnico (Italian engineering university) students on this exam, and the pattern is always the same. They understand the idea of Newton or Simpson perfectly well in lectures, and then in the written test they lose marks on mechanical details: a badly written stopping criterion, a forgotten Jacobian, a sign error in a table of iterations. Here I give you the method I use to get ready: what the exam really asks, where most marks are lost, and three exercises worked all the way down to the numbers.

What the exam asks

The typical structure, at almost every Italian university, is a written paper with exercises to solve by hand (often with a scientific calculator, sometimes with a laptop and MATLAB/Octave for the programming part) on four families of problems:

  1. Roots of a function: solving with an iterative method (Newton, bisection, fixed point), with a stopping criterion and an error estimate.
  2. Interpolation: building the polynomial that passes through a set of points (Lagrange or Newton with divided differences) and using it to estimate a value.
  3. Numerical integration (quadrature): approximating with the trapezium rule or Simpson’s rule, with an error estimate.
  4. Ordinary differential equations (ODEs): solving with explicit Euler or Runge-Kutta, again with error analysis.

On top of all this, the course puts two cross-cutting ideas that come back in every chapter: conditioning (how much a small error in the data is amplified in the result) and stability (whether a method amplifies or damps rounding errors step after step). A well-set exam always asks, in at least one exercise, for a comment on one of these two aspects — not only for the number to come out right.

Where the marks are lost, in practice

After correcting and reviewing dozens of exercises with my students, the mistakes almost always cluster in the same places:

  1. A stopping criterion written at random. “Iterate until it converges” is not a criterion. You need an explicit threshold: or , declared before you start iterating, not after seeing where the number stops.

  2. Forgetting the derivative in Newton. Newton’s method needs at every iteration. If is close to zero, the method can diverge or oscillate: examiners often ask you to discuss this, not just to apply the method.

  3. Interpolation: confusing the degree of the polynomial with the number of points. With points the interpolating polynomial has degree (at most) , not . It is a trivial mistake, but it throws off the whole calculation of the Lagrange coefficients.

  4. Quadrature: applying Simpson with an odd number of intervals. Composite Simpson needs an even number of sub-intervals (so an odd number of nodes). With an odd number of intervals the composite formula does not apply — and yet it is the most common mistake when is chosen at random without checking the parity.

  5. Quadrature error: forgetting that it depends on the fourth derivative (Simpson) or the second (trapezium), not on the function itself. The error estimate asks you to bound or on the interval, not to recompute the integral with a more precise method.

  6. ODEs: using Euler and expecting the accuracy of Runge-Kutta. Explicit Euler is first order — the local error is , the global one . With a step that is not very small, the error is visible by eye after just two or three steps, and that is normal: it is not a sign that you got the calculation wrong.

  7. Not commenting on conditioning and stability when asked. An exercise that asks “is the problem well conditioned?” is not answered with “yes” or “no”: you estimate quantitatively how much a relative error in the data is amplified in the result.

The method, step by step

Newton’s method for

You start from an initial point close to the root you are looking for, and iterate:

Geometrically: you approximate the function with the tangent line at and take as the new estimate the point where that line meets the -axis. When the root is simple (that is, ) and you start close enough, convergence is quadratic: the number of correct digits roughly doubles at every iteration. Stop when (or on ), and always state the tolerance you chose.

Interpolation: Lagrange and Newton with divided differences

Given points with distinct , there is a unique polynomial of degree at most that passes through all of them. The Lagrange form writes it as a combination of the basis polynomials:

Each and for : that is why the sum passes exactly through all the points. Let us do a small concrete example: with the points , , , you want . You compute the three basis polynomials at :

The Newton form (divided differences) is algebraically equivalent but more convenient when you have to add one more point without redoing the whole calculation: it is the one to prefer if the exercise asks you to “update” an existing interpolation.

Quadrature: trapezium and Simpson

The composite trapezium rule on divided into sub-intervals of width :

with error for a suitable . Composite Simpson ( even) uses a parabola over every two intervals:

with error : it converges much faster than the trapezium rule (the error scales as instead of ) for the same computational effort.

Euler and Runge-Kutta for ODEs

For , , explicit Euler moves forward in a straight line with the current slope:

Fourth-order Runge-Kutta (RK4) averages four estimates of the slope inside the step (one at the start, two at the midpoint, one at the end):

Euler is first order (global error ), RK4 fourth order (): with the same step , RK4 is orders of magnitude more accurate, which is why exercises almost always ask you to compare them.

Conditioning and stability

Conditioning is about the problem, not the method: an ill-conditioned problem amplifies errors in the data even with a perfect algorithm (classic example: solving a nearly singular linear system). Stability is about the method: an unstable method amplifies rounding errors at every step, however well posed the starting problem is. Keeping the two apart is almost always asked for explicitly in at least one question of the exam.

Three worked exercises

Exercise 1 — Newton for a cubic root

Find the zero of starting from , with , stopping when .

02.00000010.0000002.100000
12.1000000.06100011.2300002.094568
22.0945680.00018611.1616472.094551
32.09455111.1614382.094551

Between and the difference is already below : the root is . Note the speed: from to you gain three correct digits, from to you gain another five — that is quadratic convergence in action.

Exercise 2 — Simpson for

The exact value is . With sub-intervals, :

weight
01.001.0000001
11.250.8000004
21.500.6666672
31.750.5714294
42.000.5000001

Actual error: . The theoretical bound, with and maximum on (reached at ):

The actual error sits well inside the theoretical bound, as it should: the bound is (rightly) pessimistic, not an exact value. For comparison, the composite trapezium rule with the same would give — an error of about , almost forty times worse with the same number of function evaluations.

Exercise 3 — Euler vs RK4 on ,

Exact solution: . With step , two steps:

Euler:

(Euler)exacterror
10.11.1000001.1103420.010342
20.21.2200001.2428060.022806

RK4, same step:

(RK4)exacterror
10.11.1103421.110342
20.21.2428051.242806

With the same step, RK4 is about fifty thousand times more accurate than Euler after two steps — the difference between order 1 and order 4 is not a theoretical nuance, you can see it even on a small exercise.

How we work in the lessons

On numerical analysis I work almost always on paper and with a calculator, not on MATLAB — because that is how you will be asked at the exam, and because carrying out one or two Newton iterations or a Simpson quadrature by hand is what makes you really understand what happens inside the method (and where the error hides when something does not add up). We start from the exercises of your course’s tutorial sessions and redo them together with the table of iterations written out in full — not just the final result — and when the mechanism is solid we move on to past exam papers, timed as if it were the real test.

If your course also includes a MATLAB lab part, we cover that separately: you will find the dedicated path on the computer science page, with an eye to writing vectorised code instead of explicit loops.

Part of what is used here comes from other exams: matrices and linear systems are in linear algebra: rank, kernel and image, the convergence of an iteration is read with the same tools as sequences in Calculus 1, and if your course moves straight on to dynamical systems, the link is with the automatic control exam.

For the general picture of how I work on university maths, see the maths page; if you are still preparing an entrance test and have not yet met these topics, look at the admission tests section.

Do you want to test yourself before writing to your university? You will find the university exam practice tests on Calculus 1 and 2, Linear algebra, Physics 1 and 2 — the correct answer is free, the guided solution comes with the first lesson. If you just want a quick second opinion on an exercise that does not add up, write to me through the contact page: a 30-minute introductory call is usually enough to tell whether the problem is the method or the execution.

Keep reading

Want to put what you read into practice?

Let's talk for 30 minutes, free: we look together at where you are stuck and I tell you honestly how I can help.

Or message me on WhatsApp.