Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Write a function: function [Px] = MyLagrange Interpolater (x, nodes_x, nodes_fx) that returns the Lagrange interpolating polynomial's value, PN(2), at a given point x

image text in transcribed

1. Write a function: function [Px] = MyLagrange Interpolater (x, nodes_x, nodes_fx) that returns the Lagrange interpolating polynomial's value, PN(2), at a given point x where the Lagrange polynomial Pn uses sample points (x, f(2) defined by the values in nodes_x and nodes_fx respectively. The pseudocode on the previous page should give a good start on writing this function. Hint: See Examples 1 and 2 in the examples file for more information on double for-loops and on how to skip iterations in a for-loop. Now, consider the function f(0) = cos(x) on the interval (-1,A]. Use your MyLagrange Interpolater function and N+1 equally spaced points on the interval as nodes for polynomials of degree N = 1, 2, 3, 4, 5 to evaluate Px(x) at 1000 x values in the interval. Plot the resulting polynomials of each degree N on a single plot. Include in your plot a legend showing which curve represents which degree polynomial. See Examples 3 and 4 for additional guidance on getting equally spaced node points on the interval, plotting with legends, and using Matlab's built in polynomial interpolation functions to check your answer. For each degree N, print the max error on the interval: En = max \f (2) - PN(2). 2. Consider the population of the united states from 1920 to 1990: Year Population (Millions) 1920 106.46 1930 123.08 1940 132.12 1950 152.27 1960 180.27 1970 205.05 1980 227.30 1990 248.46 Use your function from Problem 1 to interpolate the data with a 7th degree Lagrange polynomial Pevaluated at r = 2000 to get an approximation of the population in the year 2000. The true value of the population in 2000 was 281.42 million. Does your polynomial give a reasonable approximation of the true population? Why or why not is it valid to use your polynomial to estimate the population in 2000

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

C++ Database Development

Authors: Al Stevens

1st Edition

1558283579, 978-1558283572

More Books

Students also viewed these Databases questions

Question

11. What does it mean when someone refers to I/O as bursty?

Answered: 1 week ago