# 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.