Project

Newton Ralphson s method

Newton Ralphson\'s method was implemented to get the pressure for corresponding height of the ice to break it.

import matplotlib.pyplot as plt 

def f(p,h):
	return (pow(p,3)*(1-pow(beta,2))) + (((0.4*h*pow(beta,2))-(sigma*pow(h,2)/pow(r,2)))*pow(p,2)) + (((pow(sigma,2)*pow(h,4))/(3*pow(r,4)))*p) - (pow((sigma*pow(h,2)/(3*pow(r,2))),3))

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

\"\"\"
	Performing newton iteration
\"\"\"

beta = 0.5
height = [0.6,1.2,1.8,2.4,3.0,3.6,4.2]
r = 40
sigma = 150



p_guess = 0.15
alpha = 0.8
tol = 1e-4

pressure = []
count = []

itera = 1
for h in height :
	while(abs(f(p_guess,h))>tol):
		p_guess = p_guess - alpha*(f(p_guess,h)/fprime(p_guess,h))
		itera=itera +1
	pressure.append(p_guess)
	count.append(itera)




for i in range(0,6) :
	if i==0 :
		print (\'height pressure 			iterations\')

	print(height[i], \" \" , pressure [i], \" \", count[i])
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.