I'm solving a problem using NURBS and at this moment I have to integrate the basic functions which are recursively defined like
$$ N_{i0}(u) = \begin{cases} 1 \ \ \ \ \mathrm{if} \ u_{i} \le u < u_{i+1} \\ 0 \ \ \ \ \mathrm{else} \end{cases} $$ $$ N_{ij} = \dfrac{u-u_{i}}{u_{i+j} - u_{i}} \cdot N_{i, j-1} + \dfrac{u_{i+j+1} - u}{u_{i+j+1} - u_{i+1}} \cdot N_{i+1, j-1} $$
That implies that $N_{kj}$ is a $j$-polynomial, that is, we can write $N_{kj}$ like $(a_0 + a_1 u + \cdots + a_{j} u^{j})$ in the interval $\left[u_{i}, \ u_{i+1}\right]$
And I would like to calculate the definite integrate $N_{kj}$ in the interval $\left[u_{i}, \ u_{i+1}\right]$ using the definite integrals of $N_{k,j-1}$ and $N_{k+1,j-1}$. So, I tried:
$$ I = \int_{u_{i}}^{u_{i+1}} N_{kj} \ du = \underbrace{\int_{u_i}^{u_{i+1}} \dfrac{u-u_{k}}{u_{k+j} - u_{k}} \cdot N_{k, j-1} \ du}_{I_1} + \underbrace{\int_{u_{i}}^{u_{i+1}}\dfrac{u_{k+j+1} - u}{u_{k+j+1} - u_{k+1}} \cdot N_{k+1, j-1} \ du}_{I_2} $$
using partial decomposition
$$ I_{1} = \left[\dfrac{u-u_{k}}{u_{k+j}-u_{k}} \cdot \int N_{k,j-1} \ du \right]_{u_{i}}^{u_{i+1}} - \dfrac{1}{u_{k+j}-u_{k}}\int_{u_{i}}^{u_{i+1}} \left( \int N_{k+1, j-1} \ du\right) \ du $$
and the same happens for $I_2$. The problem is that I don't have the indefinite integral of $N_{k,j-1}$ (because it's hard to get it), and I can't go any further.
My final objective is to calculate the matrix $M_{ij}$ using $M_{i-1, j-1}$, $M_{i,j-1}$ and $M_{i+1, j-1}$
$$ M_{ij} = \int_{u_{i}}^{u_{i+1}} \begin{bmatrix} N_{i-j}^2 & N_{i-j}N_{i-j+1} & \cdots & N_{i-j}N_{i} \\ N_{i-j+1}N_{i-j} & N_{i-j+1}^2 & \cdots & N_{i-j+1}N_{i} \\ \vdots & \vdots & \ddots & \vdots \\ N_{i}N_{i-j} & N_{i}N_{i-j+1} & \cdots & N_{i}^2 \end{bmatrix}_{(j+1) \times (j+1)} \ du $$
Until now, I got $M_{i0}$, $M_{i1}$, $M_{i2}$, but I'm having problems to find the $M_{i3}$ and so on. $h_i = u_{i+1} - u_{i}$
$$ M_{i0} = h_{i} \cdot \left[1\right] $$ $$ M_{i1} = \dfrac{h_{i}}{6} \begin{bmatrix} 2 & 1 \\ 1 & 2 \end{bmatrix} $$
$M_{i2}$ is more complex, but I got a closed formula for it depending on $h_{i-1}$ and $h_{i+1}$.