I am struggling understanding a discretization of a nonlinear term from the Burgers equation. The term is
$$Z(u) = \int_0^1 \frac{du}{dx}u v dx$$
where $u$ is the solution of the PDE and $v$ is the test function. The assumtion is that $u = \sum_{j = 1}^n u_j \phi_j(x)$ and $v = \phi_i$ where for the moment we can assume the $\phi$ are the standard hat functions
$$\phi (x) = \begin{cases} (x - (i - 1)h)/h & \text{if } x \in [ (i-1)h , ih]\\ (-x + (i +1)h)/h & \text{if } x \in [ih, (i + 1)h)]\\ 0 & \text{otherwise} \end{cases} $$ In the notes where I got this from assuming the PDE had homogeneous Dirichlet boundary $(u(0) = u(1) = 0)$ , then the following discretization was given
\begin{align} Z(u) = \frac{1}{6} \begin{bmatrix} u_1 u_2 + u_2^2 \\ -u_1 - u_1 u_2 + u_2 u_3 + u_3^2\\ \vdots \\ -u_{i -1} - u_{i-1} u_{i} + u_i u_{i+1} + u_{i+1}^2\\ \vdots \\ -u_{n -2} - u_{n-2} u_{n-1} + u_{n-1}+ u_{n} + u_{n}^2\\ -u_{n}^2 - u_{n-1} u_{n} \\ \end{bmatrix} \end{align}
My issue is that I am not following this at all. What I tried was to look at a generic component and algebra form there
\begin{align} \left (Z(u) \right)_i &= \int_0^1 \frac{d}{dx}\left( \sum_{j = 1}^n u_j \phi_j(x)\right)\left( \sum_{k = 1}^n u_k \phi_k(x) \right ) \phi_i(x) dx\\ &= \int_0^1 \left( \sum_{j = 1}^n u_j \phi_j'(x)\right)\left( \sum_{k = 1}^n u_k \phi_k(x) \right ) \phi_i(x) dx \end{align}
braking this into subintervals
\begin{align} \left (Z(u) \right)_i &= \sum_{i=1}^n \int_{x_{i-1}}^ {x_{i+1}} \left( \sum_{j = 1}^n u_j \phi_j'(x)\right)\left( \sum_{k = 1}^n u_k \phi_k(x) \right ) \phi_i(x) dx \end{align}
then each local contribution will only depend on $i-1,i,i+1$. I guess what I am trying to then I look at each integral \begin{align} \int_{x_{i-1}}^ {x_{i+1}} \left( \sum_{j = 1}^n u_j \phi_j'(x)\right)\left( \sum_{k = 1}^n u_k \phi_k(x) \right ) \phi_i(x) dx = \int_{x_{i-1}}^ {x_{i+1}} \left( u_{i-1} \phi_{i-1}'(x) + u_i \phi_i'(x) + u_{i+1} \phi_{i+1}'(x) \right)\left( u_{i-1} \phi_{i-1}(x) + u_i \phi_i(x) + u_{i+1} \phi_{i+1}(x) \right) \phi_i(x)dx \end{align}
then I guess we have to split the integral again to look at $[x_{i-1},x_i]$ and $[x_i,x_{i+1}]$.
\begin{align} \int_{x_{i-1}}^ {x_{i}} \left( u_{i-1} \phi_{i-1}'(x) + u_i \phi_i'(x) + u_{i+1} \phi_{i+1}'(x) \right)\left( u_{i-1} \phi_{i-1}(x) + u_i \phi_i(x) + u_{i+1} \phi_{i+1}(x) \right) \phi_i(x)dx &= \\ \int_{x_{i-1}}^ {x_{i}} \left( 0 + u_i/h - u_{i+1}/h \right)\left( u_{i-1} \phi_{i-1}(x) + u_i \phi_i(x) + u_{i+1} \phi_{i+1}(x) \right) \phi_i(x)dx \end{align}
where in the above I took the derivative of the basis functions then it think there are standard formulas $\int_0^1 \phi_i \phi_i = 2/3$ and $\int_0^1 \phi_i \phi_i = 1/6$ , I think that because we are computing this on a shorter domain $[x_{i-1},x_i]$ we will have a multiplication by by an $h$ where that is the length of the domain, but my derivation does not seem like that was given as the correct discritization. I would really appreciate some help here.