CoCalc Public Filesprojects_F20 / bis_Proj8 / Project 8 .ipynb
Author: Sharalee Jones
Views : 75
Compute Environment: Ubuntu 20.04 (Default)

#### The idea Newton-Raphson method is that in order to make it easier to find the interest we pretend that the equation is a line and then find the root of the line with the hope that the lines crossing is an excellent approximation to the root we actually need.

##### We define the function newton that takes on the f=function, df= derivative of function, x= intial guess, n=how many times we are will run the function (more accuurate the more it runs), err = your current approxiation.The loop approximately
In [4]:
import numpy as np

def newton(f, df,x,n,err):
i=0
while abs(f(x))> err and i<=n:
x= x-f(x)/df(x)
i +=1
if i > n:
return false
else:
return x

In [5]:
def f(x):
return 8.26*x+(1+x)**(-19)-1
def df(x):
return 8.26-19*(1+x)**(-20)

r = newton(f,df,1,40,0.0001)
print (r)
print (787.50 * r)

0.12106321628112304 95.33728282138439
In [2]:


--------------------------------------------------------------------------- NameError Traceback (most recent call last) <ipython-input-2-5b6d19fa7902> in <module> ----> 1 Fridge_loan(0.0001) <ipython-input-1-210fc1b4c415> in Fridge_loan(x) 3 R = 95.30 4 n = 19 ----> 5 for i in range(t*n): 6 A = r/x[1-(r/n)**-n] 7 return x NameError: name 't' is not defined