Invertable matrix representation for 2nd order differentiation or integration of non-equidistant data

158 Views Asked by At

I am looking for a second order differentiation-matrix to numerically differentiate a non-equidistant data vector using simple matrix multiplication.

$$ f(t)=y=\begin{bmatrix}f(t_1)\\ \vdots\\ f(t_n)\end{bmatrix}, \Delta t_i=t_{i+1}-t_i, My=\left(\frac{d}{d t}\right)^2f(t),M=? $$

However this matrix needs to be invertable and should result in a good estimate for double integration in that regard as well. For that reason an invertable second order integration-matrix answers the same question.

$$ (M)^{-1}y=\int\int f(t) dtdt $$

I tried a number of approaches but have trouble with the boundary cases. To illustrate the issues here are some examples:

  • Trapezoidal double integration: The matrix representation starts with an all zero row, which makes it singular and as such, not invertable. Using a minimal value for the first entry instead results in a good estimate for the 1st order derivative, but with the 2nd order differentiation $T^{-1}$ the estimate heavily oscilates around the actual values. $$ T= \begin{bmatrix} 10^{-50} & 0 & 0 & 0 & \dots \\ \frac{\Delta t_1}2 & \frac{\Delta t_1}2 & 0 & 0 & \dots \\ \frac{\Delta t_1}2 & \frac{\Delta t_1+\Delta t_2}2 & \frac{\Delta t_2}2 & 0 & \dots \\ \frac{\Delta t_1}2 & \frac{\Delta t_1+\Delta t_2}2 & \frac{\Delta t_2+\Delta t_3}2 & \frac{\Delta t_3}2 & \\ \vdots &\vdots &\vdots & & \ddots \end{bmatrix} $$ and $M_{doubleInt}=T^2$. So $T^{-1}$ gives good results, but $M_{doubleInt}^{-1}$ does not.

  • Double central difference: The results depend heavily on the choice for the ?s. $$ C= \begin{bmatrix} ? & ? & 0 & 0 & \dots & 0\\ \frac2{\Delta t_1 (\Delta t_1+ \Delta t_2)} & -\frac2{\Delta t_1 \Delta t_2} & -\frac2{\Delta t_2 (\Delta t_1 + \Delta t_2)} & 0 & \dots & 0 \\ 0 & \frac2{\Delta t_2 (\Delta t_2+ \Delta t_3)} & -\frac2{\Delta t_2 \Delta t_3} & -\frac2{\Delta t_3 (\Delta t_2 + \Delta t_3)} & \dots & 0 \\ \vdots & &\ddots & \ddots & \ddots & \vdots \\ 0 & 0 & \dots & 0 & ? & ? \end{bmatrix} $$

  • Back difference: This is the only one that worked so far with both $B^2$ and $(B^2)^{-1}$, despite having poor accuracy compared to the other two approaches.

$$ B = \begin{bmatrix} ? & 0 & 0 &0& \\ -\frac1{\Delta t_1} & \frac1{\Delta t_1} & 0 &0&\dots\\ 0 & -\frac1{\Delta t_2}& \frac1{\Delta t_2} &0& \\ 0 & 0 & -\frac1{\Delta t_3}& \frac1{\Delta t_3}& \\ & \vdots & &\ddots &\ddots \end{bmatrix} $$

Note that all ?s are undetermined by the common descriptions of the approaches. I tested them with variable numbers, but I could not find a good setting for those edge cases. If one could find a good setup for those, it might also solve my problem.

Is there a better matrix that provides good estimates and is invertable?

Edit:

My question really is simple but I find it hard to express it with the correct mathematical wording since most terms are highly ambiguous. They seem to be rarely used in this way, too, so I could need some help to reword my question.