フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

How do you make a function that returns the Lagrange interpolating polynomial?

1 回表示 (過去 30 日間)
Seungryul Lee
Seungryul Lee 2022 年 2 月 24 日
閉鎖済み: John D'Errico 2022 年 2 月 24 日
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.

回答 (0 件)

この質問は閉じられています。

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by