0

Reasons to use numerical methods, if analytic solution exists?

Particularly,

I've discovered that the so-called mass-spring equation has both an analytic solution and it's also solvable by e.g. RK4.

But why would one want to use RK4 then?

mavavilj
  • 7,270
  • During your studies, you need to learn about numerical methods that you will probably use more often than explicit solutions (which probably do not exist). – Claude Leibovici Jul 26 '19 at 11:08
  • 1
    A problem with an analytic solution often makes a great benchmark, especially if it has some difficult feature like a boundary layer. Also sometimes an analytic solution exists but it is harder to get numbers out of it then it would be to use numerical methods on the underlying problem in the first place (see e.g. a generic quadratic equation). – Ian Jul 26 '19 at 11:23
  • 2
    Also in practice an analytic solution is often basically a recipe to convert the underlying problem into another problem that ultimately requires a numerical solution. For example, a solution to a problem involving Bessel functions will probably be evaluated by quadrature. That doesn't make it useless, because the method for Bessel functions may run faster or have more robust error estimates than a black box numerical method for your problem. – Ian Jul 26 '19 at 12:49
  • (My first comment has a typo, I meant to say "generic quartic equation".) – Ian Jul 31 '19 at 13:23

1 Answers1

1

Analytic solutions are simply one useful method of representing solutions. For your example, your analytic solution tells you that the system has sinusoidal oscillation, and all your knowledge of sinusoids can be brought to bear on further understanding of the problem.

But other analytic solutions might tell you less. What do you know about the behavior of $_2F_1(a, b, z)$ for many different arguments? Probably less. So even if you do have an analytic solution, it might not be a useful representation for further understanding.

Another representation useful for understanding is a graph. In this case, even the analytic solution must be evaluated by some numerical method in order to draw the plot. Arguably the numerical methods for evaluating special functions are more advanced than those of ODE steppers (though some special functions are evaluated by ODE steppers!) and you'd probably prefer the blazing fast x86 sine instruction to the laborious process of setting up RK4 and interpolating it to create a plot.

user14717
  • 4,902