Question

In: Computer Science

PLEASE USE PYTHON CODE 7. Use Newton's method to find the polynomial that fits the following...

PLEASE USE PYTHON CODE

7. Use Newton's method to find the polynomial that fits the following points:

x = -3, 2, -1, 3, 1

y = 0, 5, -4, 12, 0

Solutions

Expert Solution

NEWTON'S METHOD

GRAPHICAL INTERPRETATION :Let the given equation be f(x) = 0 and the initial approximation for the root is x0. Draw a tangent to the curve y = f(x) at x0 and extend the tangent until x-axis. Then the point of intersection of the tangent and the x-axis is the next approximation for the root of f(x) = 0. Repeat the procedure with x0 = x1until it converges. If m is the slope of the Tangent at the point x 0 and b is the angle between the tangent and x-axis then

m = tan b = f '(x0 ) =

f(x0)

x 0-x1

(x0-x1) * f '(x0) = f(x0 )


x1 = x0   -

f(x0)

f '(x0)

This can be generalized to the iterative process as

xi+1= xi  -

f(xi)

i = 0, 1, 2, . . .

f '(xi)

Use Newton's method to find the polynomial that fits the following points:

x = -3, 2, -1, 3, 1

y = 0, 5, -4, 12, 0

y=ax4+bx3+cx2+dx+e

y=a(-3)4+b(-3)3+c(-3)2+d(-3)+e

y=-81a-27b+9c-3d+e=0 (first equation)

y= y=ax4+bx3+cx2+dx+e

y=a(2)4+b(2)3+c(2)2+d(2)+e

y=16a+8b+4c+2d+e=5   (second equation)

y=ax4+bx3+cx2+dx+e

y=a(-1)4+b(-1)3+c(-1)2+d(-1)+e

y=a+b+c+d+e =-4 (third equation)

y=ax4+bx3+cx2+dx+e

y=a(3)4+b(3)3+c(3)2+d(3)+e

y=81a+27b+9c+3d+e=12 (fourth equation)

y=ax4+bx3+cx2+dx+e

y=a(1)4+b(1)3+c(1)2+d(1)+e

y=a+b+c+d+e=0 (fifth equation)

Python program to implement Newton’s method:

from scipy import misc
 
def NewtonsMethod(f, x, tolerance=0.000001):
    while True:
        x1 = x - f(x) / misc.derivative(f, x) 
        t = abs(x1 - x)
        if t < tolerance:
            break
        x = x1
    return x
 
def f(x):
    return (1.0/4.0)*x**3+(3.0/4.0)*x**2-(3.0/2.0)*x-2
 
x = 4
 
x0 = NewtonsMethod(f, x)
 
print('x: ', x)
print('x0: ', x0)
print("f(x0) = ", ((1.0/4.0)*x0**3+(3.0/4.0)*x0**2-(3.0/2.0)*x0-2 ))

Related Solutions

Use a python code to solve Use Newton interpolation to find the unique polynomial p2(x) of...
Use a python code to solve Use Newton interpolation to find the unique polynomial p2(x) of degree 2 or less, that agrees with the following data: p2(0) = 1, p2(2) = 5, p2(4) = 17.
Use Newton's method to find a solution for the equation in the given interval. Round your...
Use Newton's method to find a solution for the equation in the given interval. Round your answer to the nearest thousandths. ? 3 ? −? = −? + 4; [2, 3] [5 marks] Answer 2.680 Q6. Use the Taylor Polynomial of degree 4 for ln(1 − 4?)to approximate the value of ln(2). Answer: −4? − 8?2 − 64 3 ? 3 − [6 marks] Q7. Consider the curve defined by the equation 2(x2 + y2 ) 2 = 25(x2 −...
PLEASE USE PYTHON CODE 7. determine the two roots of sinx+3cosx-2 =0 that lie in the...
PLEASE USE PYTHON CODE 7. determine the two roots of sinx+3cosx-2 =0 that lie in the interval (-2,2). use the Newton- Raphson method and solve by the secant formula
IN C++ Using newton's method, Please create a SqRoot function. DO NOT USE sqrt ( )...
IN C++ Using newton's method, Please create a SqRoot function. DO NOT USE sqrt ( ) , If you do I will give you zero points period.   So create a function that takes a double and returns a double that is the square root of the number. You must decide what number to start the calculations with, You must decide how and when to stop computing. For this exercise you must tell me ( use comments in your code: /*...
Please write a python code for the following. Use dictionaries and list comprehensions to implement the...
Please write a python code for the following. Use dictionaries and list comprehensions to implement the functions defined below. You are expected to re-use these functions in implementing other functions in the file. Include a triple-quoted string at the bottom displaying your output. Here is the starter outline for the homework: a. def count_character(text, char): """ Count the number of times a character occurs in some text. Do not use the count() method. """ return 0 b. def count_sentences(text): """...
Please write a python code for the following. Use dictionaries and list comprehensions to implement the...
Please write a python code for the following. Use dictionaries and list comprehensions to implement the functions defined below. You are expected to re-use these functions in implementing other functions in the file. Include a triple-quoted string at the bottom displaying your output. Here is the starter outline for the homework: g. def big_words(text, min_length=10): """ Return a list of big words whose length is at least min_length """ return [] h. def common_words(text, min_frequency=10): """ Return words occurring at...
Use Newton's method to find all solutions of the equation correct to eight decimal places. Start...
Use Newton's method to find all solutions of the equation correct to eight decimal places. Start by drawing a graph to find initial approximations. (Enter your answers as a comma-separated list.) 6e−x2 sin(x) = x2 − x + 1
Use Newton's method to find all solutions of the equation correct to eight decimal places. Start...
Use Newton's method to find all solutions of the equation correct to eight decimal places. Start by drawing a graph to find initial approximations. (Enter your answers as a comma-separated list.) −2x7 − 4x4 + 8x3 + 6 = 0
Use Newton's method to find all solutions of the equation correct to six decimal places. (Enter...
Use Newton's method to find all solutions of the equation correct to six decimal places. (Enter your answers as a comma-separated list.) sqrt(x + 1) = x^2 − x What does x equal?
Use Newton's method to find all solutions of the equation correct to eight decimal places. Start...
Use Newton's method to find all solutions of the equation correct to eight decimal places. Start by drawing a graph to find initial approximations. (Enter your answers as a comma-separated list.) 4e-x2 sin(x) = x2 − x + 1
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT