0% found this document useful (0 votes)
9 views2 pages

New Raphson

Uploaded by

Raji Majeed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views2 pages

New Raphson

Uploaded by

Raji Majeed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Question 2:Use New -Raphson method to find a root of the function f(x)=e^x-3x^2

to an accuracy of 5 digits, taking the starting value of x as x0=1.0.


Using Python program implementation:
# Raphson Method for solving equations

# An example function whose solution


# is determined using Bisection Method.
# The function is e^x-3x^2
import math
def func( x ):
return math.exp(x)-3*x**2

# Derivative of the above function


# which is e^x-6x
import math
def derivFunc( x ):
return math.exp(x)-6*x

# Function to find the root


def newtonRaphson( x ):
h = func(x) / derivFunc(x)
while abs(h) >= 0.00001:
h = func(x)/derivFunc(x)

# x(i+1) = x(i) - f(x) / f'(x)


x=x-h
print("The value of the root is : ",
"%.4f"% x)

# Driver program to test above


x0 = 1.0 # Initial values assumed
newtonRaphson(x0)

You might also like