Professional Documents
Culture Documents
Experiment 1
Experiment 1
Experiment 1
ALGORITHM:
• Defined the function f(x) = xn - number and its
derivative f’(x) = n.xn-1.
• Initialize x with the initial guess.
• Iterate using the Newton-Rephson formula
until the difference between successive
approximations is less than the tolerance.
• Return the approximate nth root.
FORMULA USE:
In the Newton-Raphson method implementation
provided in the code, the main formula used for iteration
is as follows:
Xnext = x – f(x)/f’(x)
Where :
• X is the current approximation of the root .
• Xnext is the next approximation of the root.
• F(x) is the value of the function at x , defined as x n –
number.
SHWETA MEENA 23/36057
PYTHON CODE :
def newton_rephson_nth_root(number , n , initial_guess
, tolerance):
# Define the function whose root we want to find
def f(x):
return x**n - number
return x_next