Find the value of interpolation polynomial
9 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
Voss
am 15 Mai 2022
"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 Kommentare
Siehe auch
Kategorien
Mehr zu Polynomials finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!