Find the value of interpolation polynomial
조회 수: 6 (최근 30일)
이전 댓글 표시
On the interval [−2,2] I have the given function f (x) = (8 *a^3) / (x^2 + 4*a^2), where is parameter a = 1 / 2.80. I would like to approximate the function by interpolation polynomial. Use the polyfit command to find the interpolation polynomial written in standard base interpolating f in x = −2,0,2. What is the value of interpolation polynomial in x = 1?
Is this alright or I have to change something?
format long
a = 1./2.80;
f = @(x) (8.*a.^3)./(x.^2+4.*a.^2);
p = polyfit(-2:2,f(-2:2),2)
댓글 수: 0
답변 (1개)
Voss
2022년 5월 15일
"interpolating f in x = −2,0,2"
To me that sounds like you should use f(x) at x = -2, 0, and 2, rather than x = -2:2, which is x = -2, -1, 0, 1, and 2.
format long
a = 1./2.80;
f = @(x) (8.*a.^3)./(x.^2+4.*a.^2);
p = polyfit([-2 0 2],f([-2 0 2]),2)
And don't forget about "What is the value of interpolation polynomial in x = 1?"
polyval(p,1)
% visual aid:
% rational function f:
plot(-2:0.01:2,f(-2:0.01:2))
hold on
% polynomial fit from x = [-2 0 2]:
plot(-2:0.01:2,polyval(p,-2:0.01:2),'--r')
% also plot the polynomial fit from x = [-2 -1 0 1 2], for reference:
p_old = polyfit(-2:2,f(-2:2),2);
plot(-2:0.01:2,polyval(p_old,-2:0.01:2),':m')
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Polynomials에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!