Project

Newton-Raphson Method

NEWTON RAPHSON METHOD

The Newton-Raphson method (also known as Newton\'s method) is a way to quickly find a good approximation for the root of a real-valued function f(x) = 0f(x)=0. It uses the idea that a continuous and differentiable function can be approximated by a straight line tangent to it.

HOW IT WORKS?

Suppose you need to find the root of a continuous, differentiable function f(x)f(x), and you know the root you are looking for is near the point x = x_0x=x0​. Then Newton\'s method tells us that a better approximation for the root isx_1 = x_0 - \\frac{f(x_0)}{f\'(x_0)}.x1​=x0​−f′(x0​)f(x0​)​.This process may be repeated as many times as necessary to get the desired accuracy. In general, for any xx-value x_nxn​, the next value is given byx_{n+1} = x_n - \\frac{f(x_n)}{f\'(x_n)}.xn+1​=xn​−f′(xn​)f(xn​)​.

Note: the term \"near\" is used loosely because it does not need a precise definition in this context. However, x_0x0​ should be closer to the root you need than to any other root (if the function has multiple roots).

In this program we need to compute minimum value of Cusion Pressure for Breaking ice

The relationship between the pressure, h the thickness of the ice field, R the size of the air
cushion, σ the tensile strength of the ice, and β is related to the width of the ice wedge is given above in question.

for different values of h we need to solve this equation with newton-raphson method and find P & hence show results in tabular form

Modules imported - matplotlib for plotting

numpy for dealing with arrays

plotly for tablular presentation

import matplotlib.pyplot as plt
import numpy as np
import plotly.graph_objects as go

def function(p,h,beta,r,sigma):
    term1 = pow(p,3)*(1-pow(beta,2))
    term2 = (0.4*h*pow(beta,2) - (sigma*pow(h,2))/pow(r,2))*pow(p,2)
    term3 = (pow(sigma,2)*pow(h,4)*p)/(3*pow(r,4))
    term4 = pow((sigma*pow(h,2)/(3*pow(r,2))),3)
    return term1 + term2 + term3 - term4

def fprime(p,h,beta,r,sigma):
    term1 = 3*pow(p,2)*(1-pow(beta,2))
    term2 = (0.4*h*pow(beta,2) - (sigma*pow(h,2))/pow(r,2))*2*p
    term3 = (pow(sigma,2)*pow(h,4))/(3*pow(r,4))
    return term1 + term2 + term3

# inputs
p_guess = 100000
h = [0.6,1.2,1.8,2.4,3.0,3.6,4.2]
beta = 0.5
r = 40
sigma = 150*144 # convert into fps units
tol = 1e-2
iter = 1
alpha = 1
minimum_pressure = []
for i in range(len(h)):
    while(abs(function(p_guess,h[i],beta,r,sigma)) > tol):
        p_guess = p_guess - alpha*function(p_guess,h[i],beta,r,sigma)/fprime(p_guess,h[i],beta,r,sigma)
        iter += 1
    minimum_pressure.append(p_guess)
    # print(p_guess)
    # print(iter)
# Table Generation
fig = go.Figure(data=[go.Table(header=dict(values=[\'Thickness of ice field (in feet)\', \'Minimum Cusion Pressure (in psf)\']),
                 cells=dict(values=[h,minimum_pressure]))
                     ])
fig.show()

# Choosing optimum relaxation factor- i.e alpha value which gives result in lesser iterations(since it will take lesser time to compute)
h=0.6
alpha = np.linspace(0.1,1.9,19)
tol = 1e-4
no_of_iteration = []
for i in range(len(alpha)):
    p_guess = 50
    iter = 1
    while(abs(function(p_guess,h,beta,r,sigma)) > tol):
        p_guess = p_guess - alpha[i]*(function(p_guess,h,beta,r,sigma)/fprime(p_guess,h,beta,r,sigma))
        iter += 1

    #print(p_guess)
    no_of_iteration.append(iter)
print(no_of_iteration)
# plotting graph
plt.plot(alpha,no_of_iteration)
plt.xlabel(\"Relaxation Factor\")
plt.ylabel(\"No. of Iteration occurs\")
plt.show()

OUTPUT:----------------------------------------------------------------------------------------------

TABLE

From the table we see that as the thickness of ice field increases, the Cusion pressure required to break the ice increases, so we conclude that Thickness of Ice is Directly Proportinal to Cusion Pressure.

*Choosing optimum relaxation factor with the help of graph

h = 0.6 feet

From the Graph we conclude that in both the cases in which we under-relax the alpha and case in which we over-relax the value of alpha, the No of iteration required to find minimum value of pressure using Newton Raphson Method increases.So, Optimum Value for Relaxation factor can be assumed to be equal to \'1\'.Since it requires least time to compute the results, and in porgramming time saving techniques are of prime importance.

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.