f(x) = 1/(1+25x?) This is a somewhat famous function in numerical analysis because it displays interesting behavior when approximated using polynomial interpolation on uniformly spaced nodes. You are going write your own code for polynomial interpolation and investigate the accuracy of two approximations. Task: Do the following: 1. Write a function that takes an array containing n +1 distinct points and returns the coefficients a, k 0, 1,...,n for the Newton form of the interpolating polynomial for an arbitrary function. You can pass in either the function f(x) or an array of function values at the points. 2. Write a function that takes the Newton coefficients of the polynomial and a point x and evaluates P(x). This should be the nested product form that is similar to Horner's method. 3. Write a program that calls your two functions to compute the interpolating polynomial for the specific function f(x) given above and does the following: (a) Using the 21 uniformly spaced nodes Xk = -1+ k(.1), k = 0, 1, ... , 20 have your program compute the error at r = .985 and also at r = 0.1. (b) Using 21 nodes given by 2k + 1 Ik = Cos k = 0, 1, ..., 20. 2(20+1) have your program compute the error at x = 0.985 and also at x = 0.1.

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter6: Modularity Using Functions
Section6.1: Function And Parameter Declarations
Problem 11E
icon
Related questions
Question
**Function Approximation Task Using Polynomial Interpolation**

**Function Definition:**

\[ f(x) = \frac{1}{1 + 25x^2} \]

This function is notable in numerical analysis for its behavior when approximated using polynomial interpolation on uniformly spaced nodes. You will develop code for polynomial interpolation to study the accuracy of two different approximations.

**Task Instructions:**

1. **Newton Coefficients Function:**

   Write a function that takes an array of \( n + 1 \) distinct points and outputs the coefficients \( a_k \), where \( k = 0, 1, \ldots, n \), for the Newton form of the interpolating polynomial for any given function. You can pass in either the function \( f(x) \) or an array of function values at the points.

2. **Polynomial Evaluation Function:**

   Write a function that accepts the Newton coefficients and a point \( x \), then evaluates \( P_n(x) \). This should be in the nested product form similar to Horner’s method.

3. **Program Implementation:**

   Develop a program that invokes your functions to compute the interpolating polynomial for the specific function \( f(x) \). The program should accomplish the following:

   a. **Uniformly Spaced Nodes:**

      Use 21 uniformly spaced nodes:

      \[ x_k = -1 + k \cdot (0.1), \quad k = 0, 1, \ldots, 20 \]

      Have your program compute the error at \( x = 0.985 \) and \( x = 0.1 \).

   b. **Chebyshev Nodes:**

      Use 21 nodes given by:

      \[ x_k = \cos\left( \frac{2k + 1}{2(20 + 1)}\pi \right), \quad k = 0, 1, \ldots, 20 \]

      Have your program compute the error at \( x = 0.985 \) and \( x = 0.1 \).
Transcribed Image Text:**Function Approximation Task Using Polynomial Interpolation** **Function Definition:** \[ f(x) = \frac{1}{1 + 25x^2} \] This function is notable in numerical analysis for its behavior when approximated using polynomial interpolation on uniformly spaced nodes. You will develop code for polynomial interpolation to study the accuracy of two different approximations. **Task Instructions:** 1. **Newton Coefficients Function:** Write a function that takes an array of \( n + 1 \) distinct points and outputs the coefficients \( a_k \), where \( k = 0, 1, \ldots, n \), for the Newton form of the interpolating polynomial for any given function. You can pass in either the function \( f(x) \) or an array of function values at the points. 2. **Polynomial Evaluation Function:** Write a function that accepts the Newton coefficients and a point \( x \), then evaluates \( P_n(x) \). This should be in the nested product form similar to Horner’s method. 3. **Program Implementation:** Develop a program that invokes your functions to compute the interpolating polynomial for the specific function \( f(x) \). The program should accomplish the following: a. **Uniformly Spaced Nodes:** Use 21 uniformly spaced nodes: \[ x_k = -1 + k \cdot (0.1), \quad k = 0, 1, \ldots, 20 \] Have your program compute the error at \( x = 0.985 \) and \( x = 0.1 \). b. **Chebyshev Nodes:** Use 21 nodes given by: \[ x_k = \cos\left( \frac{2k + 1}{2(20 + 1)}\pi \right), \quad k = 0, 1, \ldots, 20 \] Have your program compute the error at \( x = 0.985 \) and \( x = 0.1 \).
The output of your program should be the errors in each case. Your program should run without any additional input from me to generate the data you use in your report.

4. Give an explanation of whether your results are consistent with the error bounds for each interpolation and an explanation of why you might have observed relatively large or small errors in each case. If you are using a programming language in which it is relatively easy to generate plots, you might find it informative to plot the error on the interval \([-1, 1]\). Plots are, however, not a required part of the project.
Transcribed Image Text:The output of your program should be the errors in each case. Your program should run without any additional input from me to generate the data you use in your report. 4. Give an explanation of whether your results are consistent with the error bounds for each interpolation and an explanation of why you might have observed relatively large or small errors in each case. If you are using a programming language in which it is relatively easy to generate plots, you might find it informative to plot the error on the interval \([-1, 1]\). Plots are, however, not a required part of the project.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Arrays
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning