How to find interpolating polynomial

조회 수: 20 (최근 30일)
Drake
Drake 2013년 10월 21일
댓글: John D'Errico 2020년 10월 26일
I'm trying to find the interpolating polynomial of degree 20 for the function f(x)=(x^2+1)^-1 using 21 equally spaced nodes on the interval [-5,5]. The syntax matlab says to use is
interpolate(nodes, values, ind, F)
But I only know the amount of nodes, function, and the interval. Thanks for any help!

답변 (1개)

Walter Roberson
Walter Roberson 2013년 10월 21일
interpolate() is not the correct function to extract an interpolating polynomial. See polyfit() and polyval() and linspace().
  댓글 수: 2
Maciej Rzymek
Maciej Rzymek 2020년 10월 26일
polyfit won't give you interpolation, but approximation which is way different. He should use interp1.
John D'Errico
John D'Errico 2020년 10월 26일
@Maciej Rzymek - actually, you are incorrect, on several counts. Hard to do in such a short space. :)
  1. polyfit CAN produce an interpolating polynomial, if you choose the proper order polynomial. Thus with n data points, set the order to be n-1. This will produce a polynomial with n coefficients to estimate, and therefore, an interpolating polynomial.
  2. Since the goal was to produce an interpolating polynomial, interp1 will NOT satisfy that goal.
In fact, this problem is a classical one, chosen to show how poorly an interpolating polynomial can react. That particular function is one that will generate a wildly oscillatory polynomial, with immense swings between the points. You may wish to read about Runge's phenomenon.
The one thing I agree with what you said is that if your goal is purely to interpolate such a function, and to do it well, then there are far better tools than a polynomial. For example, interp1 in this case by use of pchip as the interpolant, will produce a well behaved, non-oscillatory result.
But if the goal is to satisfy the requirements of a homework assignment, then you have no choice.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Polynomials에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by