disp(sprintf(' We look at a small segment of the curve f(x) = (x-1)^3 in the')) disp(sprintf(' interval 0.99998<= x <=1.00002 for 100 evenly spaced points\n')) disp(sprintf(' We do this for the function written in two ways\n')) x = linspace(0.99998,1.00002,100); %x = linspace(0,2,1000); disp(sprintf(' 1. First as f(x) = (x-1)^3')) y1 = (x-1).^3; figure plot(x,y1,'.') axis([0.99998 1.00002 -8e-15 6e-15]); set(gca,'XTickLabel',[0.99998, 1.0000, 1.00002]); xlabel('x'); ylabel('f(x)'); legend('f(x)=(x-1)^3',0'); disp(sprintf(' The graph of the computed values of the function appears')) disp(sprintf(' as a smooth continuous curve\n')); pause; disp(' 2. Next we plot f(x)= x^3-3x^3-3x-1'); y2 = x.^3-3*x.^2+3*x-1; figure plot(x,y2,'.') axis([0.99998 1.00002 -8e-15 6e-15]); set(gca,'XTickLabel',[0.99998, 1.0000, 1.00002]); xlabel('x'); ylabel('f(x)'); legend('f(x) = x^3-3x^2-3x-1','0'); disp(sprintf(' Note that the graph of f(x) does not appear to be taken')) disp(sprintf(' from a continuous curve, but rather is a narrow "fuzzy')) disp(sprintf(' band" of seemingly random values\n')) disp(sprintf(' This is true of all parts of the computed curve of f(x), but it')) disp(sprintf(' becomes evident only when you look at the curve very closely\n')); disp(sprintf(' The arithmetic in MATLAB uses IEEE double precision numbers and')) disp(sprintf(' standard rounding and this results in noise in function evaluation\n')) disp(sprintf(' Functions f(x) on a computer should be thought of as fuzzy band')) disp(sprintf(' of random values, with the vertical thickness of the band quite')) disp(sprintf(' small in most cases\n')) pause; figure plot(x,y1) hold on; plot(x,y2,'.') axis([0.99998 1.00002 -8e-15 6e-15]); set(gca,'XTickLabel',[0.99998, 1.0000, 1.00002]); xlabel('x'); ylabel('f(x)'); legend('f(x)=(x-1)^3','f(x) = x^3-3x^2-3x-1','0'); disp(sprintf('Note: There is a large "interval of uncertainty" around the')) disp(sprintf('true multiple root. This can cause problems for root')) disp(sprintf('finding methods'))