Info
Questa domanda è chiusa. Riaprila per modificarla o per rispondere.
How do you make a function that returns the Lagrange interpolating polynomial?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
1. Write a function: function [P] = MyLagrangeInterpolater(nodes_x, nodes_y) that returns the Lagrange interpolating polynomial, P(x), as a Matlab function using sample points (x, f(x)) 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.
(a) Consider the function f(x) = cos(x) on the interval [−π, π]. Use your MyLagrangeInterpolater function to generate a degree N = 1, 2, 3, 4, 5, 6 polynomial function PN (x) using equally spaced nodes on the interval. Evaluate both f(xi) and PN (xi) on 1000 equally spaced xi values on the interval and print the max error: EN = max xi |f(xi) − PN (xi)| for these points.
1 Commento
Risposte (0)
Questa domanda è chiusa.
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!