Page 1 of 1

= = = 12 4. Newton's Method Implement Newton's method to find a zero of a polynomial. (a) Apply Newton's Method to appro

Posted: Sat Feb 19, 2022 3:21 pm
by answerhappygod
12 4 Newton S Method Implement Newton S Method To Find A Zero Of A Polynomial A Apply Newton S Method To Appro 1
12 4 Newton S Method Implement Newton S Method To Find A Zero Of A Polynomial A Apply Newton S Method To Appro 1 (95.73 KiB) Viewed 54 times
***USE STARTER CODE***
= = = 12 4. Newton's Method Implement Newton's method to find a zero of a polynomial. (a) Apply Newton's Method to approx a root to f(x) = x2 – 2 using xo = 10 accurate to 10-6. (b) Can you use it to find the root of f(x) = x2 – 2x + 1 for xo = 0? How iterations until you get |f(x*)] < 10-6 where x* is the approximated root? (c) Consider the loan amortization formula as follows: P(2)(1 + i)12m A (1) (1 + 1212m - 1 where A monthly payment, P = principal, m number of years of loan, r = annual percentage rate. Suppose a business wants to take out a loan of 10,000,000 to be paid back over a 30 year span. The business has budgeted 42,000 a month to pay back the loan. While searching for loans, what would be the interest rate needed to stay within budget? Use Newton's Method to approximate the interest rate. The method would be to turn equation (1) into a root-finding problem. That is to transform it into a function f(r) such that f(r) = 0. Then apply Newton's method to it. The following = = 1 derivative may be useful: d P(a)(1+ i)12m dr (1 + 1-2)12m – 1 = (2) + P (12 +1)12m 12 (612 + 1)12m – 1) P (mr(12 + 1)12m-1) 12 ( 12 + 1)12m – 1) P (mr(12 + 1)24m-1) 12 ((2 + 1)12m – 1)2 (3) (4)
#Newton's Method import numpy as np f = lambda x: X**2 -2 # replace with APR function df = lambda x: 2*x # replace with derivative of APR function po = 10 N_its = 10 tol = 1E-6 for i in range(1, N_its+1): p1 po - f(po)/df(po) print(f'lp_{i}-p|| {abs (p1-np.sqrt(2)):0.5e}') if abs(p1-np.sqrt(2)) < tol: print(f'tol {tol} is reached, pn = {p1:0.5e} at iteration n = {i}') break po = p1