Find the value of interpolation polynomial
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
Voss
le 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 commentaires
Voir également
Catégories
En savoir plus sur Polynomials dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!