Consider the polynomial \(p(x) = (x-7)^{15}\text{.}\) Expand this formula in the monomial basis and try using it to plot the polynomial on the interval \([6, 8]\text{.}\) Also plot the original formula for comparison.
Answer.
c…c = [1, -105, 5145, -156065, 3277365, -50471421, 588833245, -5299499205, ...
37096494435, -201969803035, 848273172747, -2699051004195, 6297785676455, ...
-10173346092735, 10173346092735, -4747561509943];
d = 15;
x = linspace(6, 8, 1000);
p = zeros(size(x));
for k=1:d+1
p = p + c(k)*x.^(d+1-k);
end
subplot(1, 2, 1)
plot(x, p)
subplot(1, 2, 2)
plot(x, (x-7).^15)
There is a catastrophic loss of significance here. If one uses
p = polyval(c, x), the result is not much better, even though this command tries to avoid the loss of significance. Expanding this polynomial in the monomial basis is numerically unwise.
