Newton Raphson Algorithm

In numerical analysis, Newton's method, also known as the Newton – Raphson method, named after Isaac Newton and Joseph Raphson, is a root-finding algorithm which produces successively better approximations to the beginnings (or zeroes) of a real-valued function. The most basic version begins with a individual-variable function f specify for a real variable X, the function's derivative F   ′, and an initial guess x0 for a root of f. 

Raphson again viewed Newton's method purely as an algebraic method and restricted its purpose to polynomials, but he describes the method in terms of the successive approximations xn instead of the more complicated sequence of polynomials used by Newton. The name" Newton's method" is derived from Isaac Newton's description of a special case of the method in De analysi per aequationesFinally, in 1740, Thomas Simpson described Newton's method as an iterative method for solve general nonlinear equations use calculus, essentially give the description above.
#include <iostream.h>
#include <conio.h>
#include <math.h>

float eq(float i)
{
	return (pow(i, 3) - (4 * i) - 9); // original equation
}
float eq_der(float i)
{
	return ((3 * pow(i, 2)) - 4); // derivative of equation
}

void main()
{
	float a, b, z, c, m, n;
	clrscr();
	for (int i = 0; i < 100; i++)
	{
		z = eq(i);
		if (z >= 0)
		{
			b = i;
			a = --i;
			goto START;
		}
	}

START:

	cout << "\nFirst initial: " << a;
	cout << "\nSecond initial: " << b;
	c = (a + b) / 2;

	for (i = 0; i < 100; i++)
	{
		float h;
		m = eq(c);
		n = eq_der(c);

		z = c - (m / n);
		c = z;

		if (m > 0 && m < 0.009) // stoping criteria
		{
			goto END;
		}
	}

END:
	cout << "\n\nRoot: " << z;
	getch();
}

LANGUAGE:

DARK MODE: