2. Using Newton's forward method, print out the polynomial approximations for degrees 1, 2, and 3 using the following set of data a. Hint, create the table first b. X 7.2 7.4 7.5 7.6 3. Using the results from 3, approximate f(7.3)? f(x) 23.5492 25.3913 26.8224 27.4589
2. Using Newton's forward method, print out the polynomial approximations for degrees 1, 2, and 3 using the following set of data a. Hint, create the table first b. X 7.2 7.4 7.5 7.6 3. Using the results from 3, approximate f(7.3)? f(x) 23.5492 25.3913 26.8224 27.4589
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
Please help me solve this using python. Add the code used to solve it.
The expected output is
Question 2:
[9.210500000000001, 17.00166666666675, -141.82916666666722]
Question 3:
24.016574999999992
Expert Solution
Step 1
The algorithm for code 1 can be described as follows:
- Initialize the coefficients list and append the first y value to it.
- Loop through the range of 1 to the length of the x values (len(x)).
- In the inner loop, go through the range of len(x) - 1 down to the current j value minus 1 (j-1) in decrements of -1.
- Calculate the current coefficient by subtracting the previous coefficient (coefficients[i-1]) from the current coefficient (coefficients[i]) and dividing the result by the difference between the current x value (x[i]) and the previous x value (x[i-j]).
- Update the current coefficient in the coefficients list with the calculated value.
- Repeat steps 3-5 until all coefficients have been calculated and stored in the coefficients list.
- Print the final coefficients list, which contains the calculated coefficients of the polynomial approximation of the function represented by the data points.
The algorithm for code 2 can be described as follows:
- Define the x and y data points.
- Initialize an empty list to store the coefficients.
- Loop through the x data points and append the corresponding y value to the coefficients list.
- Nested loop to calculate the coefficients using Newton's Forward Method formula: a. The outer loop ranges from 1 to the length of x. b. The inner loop ranges from the length of x to the value of the outer loop variable minus 1, decrementing by 1. c. For each iteration of the inner loop, calculate the coefficient using the formula: coefficients[i] = (coefficients[i]-coefficients[i-1])/(x[i]-x[i-j])
- Initialize a variable to store the result.
- Loop through the coefficients list, multiply each coefficient with the product of (7.3 - x[j]) for all j less than i, and add the result to the result variable.
- Print the result.
Step by step
Solved in 7 steps with 4 images
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question
How do I omit "23.5492" from the ouput of the first code? It is supposed to print out [9.210500000000001, 17.00166666666675, -141.82916666666722]
but it is printing:
[23.5492, 9.210500000000001, 17.00166666666675, -141.82916666666722]
Solution
by Bartleby Expert
Knowledge Booster
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.Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education