Question: ) Where indicated below, complete the function, lagrange ( ) , which takes two input vectors of data points x and y , of any

) Where indicated below, complete the function, lagrange(), which takes two input vectors of data points x and y, of any length n (either both column or row vectors), along with input scalar, a, and computes output, p, which is , the Lagrange interolating polynomial, , evaluated at a:
(In the formula, ,, and refer to elements in vectors x and y.)
Use one outer for-loop with one inner for-loop with an if-statement (or two successive inner for-loops without an if statement). You may need to initialize a running sum before the outer loop, and initialize a running product just before the inner loop.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!