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
icon
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

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
Transcribed Image Text: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
Expert Solution
Step 1

The algorithm for code 1 can be described as follows:

  1.  Initialize the coefficients list and append the first y value to it.
  2.  Loop through the range of 1 to the length of the x values (len(x)).
  3. 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.
  4. 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]).
  5. Update the current coefficient in the coefficients list with the calculated value.
  6. Repeat steps 3-5 until all coefficients have been calculated and stored in the coefficients list.
  7. 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:

  1. Define the x and y data points.
  2. Initialize an empty list to store the coefficients.
  3. Loop through the x data points and append the corresponding y value to the coefficients list.
  4. 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])
  5. Initialize a variable to store the result.
  6. 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.
  7. Print the result.
 
steps

Step by step

Solved in 7 steps with 4 images

Blurred answer
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
Bartleby Expert
SEE SOLUTION
Knowledge Booster
Probability Problems
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
Recommended textbooks for you
Database System Concepts
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)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education