Consider this linear differential equation: with boundary conditions and . Nothing looks particularly scary here. Just one nonconstant coefficient, and it’s a simple one. Entering this problem into Wolfram Alpha produces the following explicit solution:
I am not sure how anyone could use this formula for any purpose.
Let us see what simple linear algebra can do here. The differential equation can be discretized by placing, for example, equally spaces interior grid points on the interval: , . The yet-unknown values of at these points are denoted . Standard finite-difference formulas provide approximate values of and :
where is the step size, in our case. Stick all this into the equation: we get 4 linear equations, one for each interior point. Namely, at it is
(notice how the condition is used above), at it is
and so on. Clean up this system and put it in matrix form:
This isn’t too hard to solve even with pencil and paper. The solution is
It can be visualized by plotting 4 points :
Not particularly impressive is it? And why are all these negative y-values in a problem with boundary condition ? They do not really look like they want to approach at the left end of the interval. But let us go ahead and plot them together with the boundary conditions, using linear interpolation in between:
Or better, use cubic spline interpolation, which only adds another step of linear algebra (see Connecting dots naturally) to our computations.
This begins to look believable. For comparison, I used a heavier tool: BVP solver from SciPy. Its output is the red curve below.
Those four points we got from a 4-by-4 system, solvable by hand, pretty much tell the whole story. At any rate, they tell a better story than the explicit solution does.
Graphics made with: SciPy and Matplotlib using Google Colab.