# Question on comparing the accuracy of numerical schemes

This is a follow up to my previous post here

I'm solving the following 1D transport equation .

$$\frac{\partial C}{\partial t} = D\frac{\partial ^2 C}{\partial x^2}-v\frac{\partial C}{\partial x}$$

At the inlet (left boundary), Dirichlet boundary condition is applied $$C(1) = C_L$$ . (1 is the inlet node number)

At the outlet (right boundary), diffusive flux is ignored. $$-D \frac{dC}{dx} = 0$$

I'm comparing the absolute errors computed from the following implementations,

1. Discretizing the convection term using backward difference and diffusion using central difference approximation.

2. Discretizing the convection term using central difference and diffusion using central difference approximation.

After discretization in the spatial direction, the pde translates to a set of odes. The odes are solved using a stiff equation solver.

The results from the above 2 implementations are compared against the solution obtained from MATLAB's pdepe solver and absolute errors are computed.

The absolute error for the first implementation is illustrated in the following image (using a spatial discretization step of 0.25). The complete code can be found in the solution posted here

The absolute error for the second implementation is of the order 10^-13.

From what I understand, the truncation error of the backward difference is $$O( \Delta x)$$ and that of centered difference is $$O(\Delta x^2)$$ from Taylor series approximations of the first derivative. The errors obtained from the numerical scheme is of the order 0.04 for backward + central difference and 1e-13 for central alone. I am not able to clearly understand what leads to this drastic difference and how to check the errors computed to the truncation orders from the Taylor series.

I'd like to request for explanations on why this drastic difference occurs in absolute errors.

• You're plotting what appear to be the error as a function of time, when the level of error is dependent on the mesh size. Also, how are you measuring the absolute error? – EMP Feb 11 '20 at 17:38
• @EMP Yes, I'm plotting error as a function of time. The errors are compared for the two implementations using the same mesh size. This is how the absolute error is computed : solutionDifference=abs(sol-C), where C contains the transient values of C obtained at every node from my implementation of backward + central/ central + central difference scheme ; sol contains the results from MATLAB's pdepe solver. – Natasha Feb 12 '20 at 3:15