필터 지우기
필터 지우기

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