Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

( 5 ) You will write a Python code that generates and evaluates Newton's Divided Differences polynomials. This code should have two functions, with names

(5) You will write a Python code that generates and evaluates Newton's Divided Differences
polynomials. This code should have two functions, with names and inputs as shown
below. The first function calculates the coefficients and the second define and evaluates
the polynomial. Upload your code to a file named HW4_Question5.py
def divided_differences(node_x: np.ndarray, node_y: np.ndarray)
np.ndarray:
t
Calculates the coefficients of a Newton's Divided Difference
polynomial using
divided differences via the recurrence relation
:param node_x: x values for the nodes
:param node_y: y values for the nodes
:return: array of coefficients
def newtons polynomial (x data: np.ndarray, node x : np.ndarray, coeffs:
np.ndarray) np.ndarray:
"n"
Defines and evaluates the Newton's Divided Difference Polynomial
:param x data: x values of the data on which we will evaluate the
polynomial
:param node_x: x values for the nodes
:param coeffs: array of coefficients
return: polynomial evaluated on x data
"n"
(a) Generate a set of x and y values using the code below. These will be the nodes. Use
the code you wrote to generate a Newton's Divided Difference polynomial that fits to
these nodes, and evaluate that polynomial for 1000 values of x between 0 and 3.
Plot this polynomial evaluation and also plot the node points (using a scatter plot).
Upload this plot to a file named "HW4_Question5a_plot.png".
import numpy asnp
x=np*linspace(0,3**np*,10)
y=np*sin(x)
(b) Evaluate this polynomial for the value of x=3.2. What is the result and what is the
absolute error in this result?
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Management Databases And Organizations

Authors: Watson Watson

5th Edition

0471715360, 978-0471715368

Students also viewed these Databases questions