Skip to content

Latest commit

 

History

History
32 lines (22 loc) · 1.87 KB

README.md

File metadata and controls

32 lines (22 loc) · 1.87 KB

Newton-Raphson method of solving an equation

It is a quite simple method of solving an equation numerically in cases where the exact solution is difficult to find. In this method we use an initial guess value. Unlike bisection method, only one guess is required. Then the subsequent values are given by the Newton-Raphson equation.

Newton-Raphson

I have used the equation x^2 - 612 = 0 as a demonstration. Incidentally, this equation also means you can use this method to find square root! You can edit the source to use any equation of your choice. But remember the general rules for solving numerically using this method, especially this:

  • poor initial guess value will lead to quick convergence and generally faulty estimates thereafter.

double was used because float turned too imprecise for many calculations. 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! vim_setup

Here's the code running. The value obtained after 5 iterations can be verified with other sources too. vim_running

LICENSE

GNU_GPL_v3.0

Totally RMS approved! Make sure to check out GNU and Free Software Foundation as well!