Practical No. 10
Practical No. 10
Input :
def func(x):
return (x*np.log(x)-12.34)
def derivfunc(x):
return (1 + np.log(x))
def newtonRaphson(x):
h = func(x)/derivfunc(x)
while abs(h) >= 1.17 :
h = func(x)/derivfunc (x)
x = x-h
print("The value of the root is : ", "%.4f"% x)
x0 = 10
newtonRaphson(x0)
Output :
The value of the root is : 6.5613
3. Using newton-Raphson method find approximate value of √5
correct to ten decimal places.
Input :
import numpy as np
def func(x):
return ((x*x)-5)
def derivfunc(x):
return (2*x)
def newtonRaphson(x):
h = func(x)/derivfunc(x)
while abs(h) >= 0.00001 :
h = func(x)/derivfunc (x)
x = x-h
print("The value of the root is : ", "%.10f"% x)
x0 = 2.2
newtonRaphson(x0)
Output :
The value of the root is : 2.2360679775
a = 0
b = 1
regulaFalsi(a,b)
Output :
The value of root is : 0.5178