# Solving first-order ODE with Dirichlet b.c. using CDS -> singular matrix

I decided to solve using finite differences one of the simplest differential equations which has an analytic solution, notably $\frac{du(x)}{dx}=2x$. The equation is first-order ODE with quadratic equation $u(x)=x^{2}$ as its solution. The problem can be categorized as a boundary problem because we know the value of the solution at arbitrary two boundary points (Dirichlet b.c.). I'm looking for the plot of the function between the two boundary points.

As mentioned, I decided to use finite differences, notably central difference scheme, to solve the equation. However, I quickly discovered that the problem isn't as straightforward as it appears. The coefficient matrix that governs the system of equations appears to be singular Toeplitz matrix of the form

$$A = \left(\begin{array}{ccccc} 0 & 1 & 0 & 0 & 0 \\ -1 & 0 & 1 & 0 & 0 \\ 0 & -1 & 0 & 1 & 0 \\ 0 & 0 & -1 & 0 & 1 \\ 0 & 0 & 0 & -1 & 0 \end{array}\right)$$

for a system of 5 grid points in the domain. In the case of periodic boundary conditions it's also circulant.

Apparently this is a well-known problem when CDS scheme is used for first derivatives. Nevertheless, I haven't found a single textbook on finite differences mentioning it. On the contrary, one gets an impression that the CDS scheme for first derivatives is something used on a daily basis.

Does anyone know answers to the following questions:

• What's the most common approach to solving first-order ODE of boundary problems?
• Is there a way-around the problem of the singularity of a coefficient matrix?
• Is there a reason why this problem hasn't gotten more attention?

EDIT: The first and the last question can be probably explained by the fact that this type of equations can be normally solved analytically.

## 1 Answer

One may well state the general fact that if the problem is well posed and the discretization scheme is reasonable, then the 'coefficient matrix' is invertible. So there is no common way around singular 'coefficient matrices' as they do not commonly appear.

In your particular case, your matrix is ill-posed because the central differences decouple the even and uneven nodes. That is why it is not commonly used for first order differential equations. Btw., this is called numerical dispersion.

One more comment - the problem you state is overdetermined. For a first order differential equation in 1D you only need one boundary condition. And then, you rather use methods for initial value problems for the numerical solution. That is maybe the reason, it is rarely mentioned as an boundary value problem.