Financial programming for Quants

Category: Numerical methods

Cubic Splines Interpolation


A quadratic polynomial \(p(x)=ax^2+bx+c\) has only three degrees of freedom \((a,b,c)\). If you want your quadratic function to run through two points, you already have only one degree of freedom left. If the the slope of the curve at one of the end-points is fixed, this uses up the last degree of freedom, leaving no choice of slope at the other end. A cubic polynomial \(ax^3+bx^2+cx+d\) has four degrees of freedom, thus allowing to prescribe four conditions – passing through two points and having specific slopes at the two end points.

Quadratic functions are more ringed. It’s because, a quadratic has a fixed degree of bentness. If we glue together a few quadratics, to interpolate a set of points, a passenger roller-coaster travelling on this curve would experience long ascents and descents. Cubics are more relaxed. Unlike cubics, quadratics can’t have a point of inflexion. Intuitively, this is why, cubic polynomials are used for interpolating a set of points.

However, quadratic splines also have many applications, for example, they are used while designing true type fonts.

Cubic splines are also use to construct cubic Bezier curves used in car designing.

I have put together the intuition, the math behind cubic splines and a python code snippet implementing the algorithm in this notebook.

Gaussian Elimination

A system of linear equations can be solved by using Gaussian elimination. For example, I have three equations:

4u&-6v& &=-2 \\

The problem is to find the unknown values of \(u\), \(v\) and \(w\) that satisfies the three equations.

Gaussian Elimination

I start by subtracting multiples of the first equation from the other equations.

The coefficient \(2\) is the first pivot. Elimination is constantly finding the right multiplier \(l\) by dividing the pivot into the members below it, so that one of the variables is eliminated from the equation. To eliminate \(u\) from \(4u-6v =-2\), I must subtract \(2(2u+v+w=5)\) from it. The multiplier \(l=4/2\). Similarly, to eliminate \(u\) from \(-2u+7v+2w=9\), the multiplier is \(l=-2/2=-1\).

So, the operations

1. Subtract \(2\) times equation 1 from equation 2.
2. Subtract \(-1\) times equation 1 from equation 3.

result in :

&-8v&-2w &=-12 \\

Continue reading

© 2019 Quantophile

Theme by Anders NorenUp ↑