Professional Documents
Culture Documents
localhost:8891/nbconvert/html/Problem5NewtonRaphsonMethod.ipynb?download=false 1/3
22/10/2019 Problem5NewtonRaphsonMethod
if __name__ == "__main__":
def function(x):
return (9.8*x/14)*(1 - np.exp(-1*14*10.22/x)) - 48.7564 # The main fun
ction
def derivative(x):
return (9.8/14)*(1 - (np.exp(-1*14*10.22/x)*(1 + (14*10.22/x)))) # The
derivative
x0 = x1
k = k + 1
plt.plot(x0, function(x0), 'or')
# Plotting configuration
u = np.arange(1.0, 2.0, 0.0001) # Setting up values for x in the plot
w = (9.8*x/14)*(1 - np.exp(-1*14*10.22/x)) - 48.7564 # Define the main functio
n again
plt.plot(u, w)
plt.axhline(y=0.0, color='black', linestyle='-')
plt.title('Newton-Raphson Graphics for' + ' y = (9.8*x/14)*(1 - np.exp(-1*14*1
0.22/x)) - 48.7564')
plt.xlabel('X')
plt.ylabel('Y')
plt.grid(True)
plt.legend(['Xn'], loc='upper left')
plt.show()
localhost:8891/nbconvert/html/Problem5NewtonRaphsonMethod.ipynb?download=false 2/3
22/10/2019 Problem5NewtonRaphsonMethod
k x0 function(x0)
x1 6.965200e+01 -6.250266e+00
x2 8.432646e+01 -5.466393e-01
x3 8.587055e+01 -5.180202e-03
x4 8.588547e+01 -4.755761e-07
x5 8.588547e+01 0.000000e+00
x6 8.588547e+01 0.000000e+00
The approximate value of x is: 85.88546897608387
localhost:8891/nbconvert/html/Problem5NewtonRaphsonMethod.ipynb?download=false 3/3