Question: USE PYTHON CODE PLEASE! Write a function which computes, and returns, the interpolation polynomial. Input: x: a list of x coordinates y: a list of
USE PYTHON CODE PLEASE!
Write a function which computes, and returns, the interpolation polynomial. Input: x: a list of x coordinates y: a list of y cooridantes Output: a function f which returns values of the interpolation polynomial Python lets you return functions on the fly and return them - so, for instance, here's how you might convert a list of coefficients into a polynomial function. You probably won't want to do this exact thing, but you could do something similar. def make_polynomial(a): def result(x): return sum(a[k] * X**k for k in range(len(a))) return result Write a function which computes, and returns, the interpolation polynomial. Input: x: a list of x coordinates y: a list of y cooridantes Output: a function f which returns values of the interpolation polynomial Python lets you return functions on the fly and return them - so, for instance, here's how you might convert a list of coefficients into a polynomial function. You probably won't want to do this exact thing, but you could do something similar. def make_polynomial(a): def result(x): return sum(a[k] * X**k for k in range(len(a))) return result
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
