# Numerical solution when we have the analytical one?

I am dealing with some PDE and ODE and have the following doubt:

I know that for many equations I do not have an analitical solution, so the numerical solution is a great manner to study them. However, I've already seen numerical solution in presence of the analitical one.

Why would this be important? I mean, if I have an analitical solution of a PDE, ODE, why I would like to have a numerical solution?

Moreover, all the numerical solution must be similar to the analitical one? Is it possible that not?

Many thanks.

• Checking a numerical method against a problem with an analytic solution is pretty standard, e.g. to verify the numerical method converges with precise tolerance to the exact solution. Aug 13, 2019 at 14:47
• Thank you very much. Aug 13, 2019 at 15:16

## 2 Answers

Usually, you don't need a numerical solution if you have the analytical solution. Occasionally, your analytical solution may contain special functions, and comparison with a numerical solution could be used to validate the implementation of the special functions, but this is a stretch.

Typically, numerical solutions depend on a parameter (mesh size, time step,...) which must be chosen small enough, and only if it is small enough will the numerical solution approximate the true solution. Is it possible for numerical solution software to spit out a "solution" that does not approximate the true solution? Yes, and this happens all the time, but it means that something has gone wrong somewhere.

• Right... Many thanks. Aug 13, 2019 at 15:18

Not all formulas are useful for practical purposes. For example, Leibnitz's formula states that $$\frac{\pi}{4} = \sum_{k=0}^\infty \frac{(-1)^k}{2k+1} = 1 - \frac{1}{3} + \frac{1}{5} - \frac{1}{7} \cdots,$$ but the series converges very slowly. A much faster method for computing $$\pi$$ is the fixed point iteration given by $$x_{n} = g(x_{n-1}), \quad n = 1,2,3$$ where $$g(x) = x + \sin(x)$$ and $$x_0 = 3$$.

Not all formula replicate essential features of the exact solution. For example, consider the problem of approximating the solution of a initial value problem on an interval. This can be done as follows. First, apply Euler's method to approximate the solution on a set of distinct points. Use linear interpolation to cover the interval between two points. Our approximation will be accurate, but it will be piecewise linear. This might not be good enough.

In particular, if we simulating the trajectory of a spacecraft, then we want the trajectory to have continuous derivatives of order 0, 1 and 2, i.e., no abrupt changes in position, velocity and acceleration, because this would violate classical physics.

• Yes, many thanks. Aug 13, 2019 at 15:18