It is a quite simple method of solving an equation numerically in cases where the exact solution is difficuilt to find. In this method we repetedly bisect an interval into halves until we reach the desired accuracy. It is a consequence of well known mean value theorem of calculus.
I have used the equation x - cos(x) = 0
as a demonstration. This problem is also on the book "Quantum Mechanics" of Schaum Outlines page 256. They have done that in FORTRAN though while my code is on C. My Python
code for this method can be found here.
The code was written under Debian GNU/Linux in vim
and compiled using GCC
.
$ gcc --version
gcc (Debian 7.2.0-4) 7.2.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Here's my vim. Pretty comfy I tell you. I shall never have the privilige to use 2 GiB just to print a blinking cursor though!
Here's the code running. The value obtained after 16 iterations can be verified with the book or other sources as well.
Totally RMS approved! While you're at it, please check out GNU and Free Software Foundation as well!