# Comparison between of higher order interpolations

A while ago I came up with an algorithm which can be used to numerically solve optimal control problems, which basically came down to discretizing the control input $u(t)$ and interpolating this to get a continuous function. I tried to optimize the cost function for each discrete value by using the golden search method and because of the interpolation this would mean I only have to integrate this over a small section in time. The fact that each discrete value of $u(t)$ only affects a small number of elements also allows to use parallel computing.

For the initial problem, I tried to optimize, I used linear interpolation, since the cost function was only a function of $u(t)$ and $u'(t)$. However recently I tried to expand on this, such that I would also be able to use higher order derivatives of $u(t)$. For linear interpolation you only need the discrete points at the start and end of an element,

$$f_{i}(\xi) = u_{i} (1 - \xi) + u_{i+1} \xi,$$

where the $u(t)$ from $t_i$ to $t_{i+1}$ is defined as,

$$u(t) = f_i\left(\frac{t - t_i}{t_{i+1} - t_i}\right).$$

In order to ensure that $u'(t)$ is continuous (such that second derivative exists) I had to set the slope at the end of an element equal to the slope at the beginning of the next element. I decided on defining this slope using the central difference method, which meant using two extra points, one before and one after the element,

$$f'_i(0) = \frac{u_{i+1} - u_{i-1}}{2},$$

$$f'_i(1) = \frac{u_{i+2} - u_{i}}{2}.$$

Using these additional constraints yields the following function for an element,

$$f_i(\xi) = u_{i-1} \frac{-\xi^3 + 2\xi^2 - \xi}{2} + u_i \frac{3\xi^3 - 5\xi^2 + 2}{2} + u_{i+1} \frac{-3\xi^3 + 4\xi^2 + \xi}{2} + u_{i+2} \frac{\xi^3 - \xi^2}{2}.$$

Instead of the central difference method I also could have used backward or forward difference method, which would require one less point to be used, but I would think that interpolation ought to be symmetrical. These points can also used in the central difference method for the second derivative. Using this as a constraint for the initial and final second derivative yields the following function for an element,

$$f_i(\xi) = u_{i-1} \frac{2\xi^5 - 5\xi^4 + 3\xi^3 + \xi^2 - \xi}{2} + u_i \frac{-3\xi^5 + 15\xi^4 - 9\xi^3 - 2 \xi^2 + 2}{2} + u_{i+1} \frac{3\xi^5 - 15\xi^4 + 9\xi^3 + \xi^2 + \xi}{2} + u_{i+2} \frac{-\xi^5 + 5\xi^4 - 3\xi^3}{2}.$$

However will this function have any disadvantages compared to the previous function? For example would the higher order polynomial make it harder to approximate sections of the cost function integral?