# Determine truncation error of PDE discretization

The equation is $$\frac{\partial}{\partial x}\left(u\frac{\partial u}{\partial x}\right)=f(x)\\ 0

I'm discretizing this PDE using FVM as follows: $$0=x_0=x_{1/2}

$$h_i:=x_{i+1/2}-x_{i-1/2}$$

$$h_{i+1/2}:=x_{i+1}-x_i$$

$$\int\limits_{x_{i-1/2}}^{x_{i+1/2}} \frac{\partial}{\partial x}\left(u\frac{\partial u}{\partial x}\right)dx=(uu_x)(x_{i+1/2})-(uu_x)(x_{i-1/2})=\int\limits_{x_{i-1/2}}^{x_{i+1/2}}f(x)dx$$

Using finite differences, obtain

$$u_{i+1/2}\frac{u_{i+1}-u_i}{h_{i+1/2}}-u_{i-1/2}\frac{u_{i}-u_{i-1}}{h_{i-1/2}}=h_if_i$$ where $$u_0=u_{N+1}=0$$, $$f_i:=\frac1h_i\int\limits_{x_{i-1/2}}^{x_{i+1/2}}f(x)dx$$

So now comes the part where I got really stuck. I want to determine the truncation error of this discretization. For this I substitute the Taylor expansion of the exact solution into the equation:

$$r_i:=\frac1h_i\left(u(x_{i+1/2})\frac{u(x_{i+1})-u(x_i)}{h_{i+1/2}}-u(x_{i-1/2})\frac{u(x_{i})-u(x_{i-1})}{h_{i-1/2}}\right)-f_i$$

$$=\frac{1}{h_i}\left(u(x_{i+1/2})\left(u_x(x_i)+\frac{h_{i+1/2}}{2}u_{xx}(x_i)+O(h^2_{i+1/2})\right)-u(x_{i-1/2})\left(u_x(x_i)+\frac{h_{i-1/2}}{2}u_{xx}(x_i)+O(h^2_{i-1/2})\right)\right)-f_i$$

I'm not sure what to do with the terms $$u(x_{i+1/2})$$ and $$u(x_{i-1/2})$$ to arrive at the truncation error, which I think will be $$O(h^2)$$. I'd appreciate some help with this.

I've already tried to expand these terms about $$x_{i-1/2}$$ but that wasn't quite useful.

• You have not specified your scheme completely. You need to write $u_{i+1/2}$ in terms of the $\{ u_j \}$ values. Then you can Taylor expand everything about $x_i$. – cfdlab Mar 24 '19 at 9:25
• @cpraveen Do you mean write $u_{i+1/2}$ as the average of $u_i$ and $u_{i-1}$? – sequence Mar 24 '19 at 13:03
• yes, average would be a reasonable approximation to try. – cfdlab Mar 24 '19 at 13:50
• @cpraveen I did this approximation and expanded about $x_i$, set $h_{i+1/2}=\alpha h_i$, $h_{i-1/2}=\beta h_i$, but then I get this: $u_x(x_i)\left( \frac{(\alpha+\beta)u(x_i)}{2} + \frac{(\alpha^2+\beta^2)h_i}{4}u_{xx}(x_i)+O(h_i) \right)+u_{xx}(x_i)\left( \frac{(\alpha+\beta)h_i}{2}+O(h_i^2) \right)+O(h_i^3)$. Now we can set $\alpha = \beta = 0$, but this gives an $O(h_i)$ truncation instead of $O(h_i^2)$. What could possibly be wrong? – sequence Mar 24 '19 at 16:02