# Linear Spline Interpolation

Can someone explain to me how linear splines work and what formulas are used. I can only seem to find information on cubic splines. Which I don't really understand either

Specifically, if I were given 5 data points how would i make a linear and cubic spline?

You're correct that a linear spline is just a sequence of straight lines. So, in between the data points $P_{i-1} = (x_{i-1}, y_{i-1})$ and $P_{i} = (x_{i}, y_{i})$, the equation of the spline is just $$y = \frac{x_i - x}{x_i - x_{i-1}}y_{i-1} + \frac{x - x_{i-1}}{x_i - x_{i-1}}y_{i}$$ You can easily confirm that $y(x_{i-1}) = y_{i-1}$ and $y(x_{i}) = y_{i}$, so the linear pieces join properly, with no discontinuity.
Computing cubic splines is much easier if you express each segment in Hermite form, rather than algebraic form. This ensures from the outset that values and first derivatives match, and you only have to solve a linear system that forces second derivatives to match, too. The size of your system of equations is much smaller -- you have roughly $N$ unknowns, instead of $4N$.