Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

MATLAB 1. Consider the computation of y 1 2a a) There is no cancellation error i

ID: 2902550 • Letter: M

Question

MATLAB

1. Consider the computation of y 1 2a a) There is no cancellation error if is not close to 1. To demonstrate this, plot y for E 2, 2.1 with increment h le 6. Zoom in several times on any section of the plot to see that the graph is smooth no cancellation. Copy the zoomed in figure and paste it into a Word document. b) Cancellation does occur, however, if a is close to 1. Plot y for E le 6, 1e-6) with increment h le 10. You'll zoom in at two places. First, zoom in somewhere near either edge (zooming twice should reveal a roughness in the graph that is indica- tive of mild cancellation paste a copy into your Word document). Second, reset the plot and zoom in at the center, 0. Zooming 3 or 4 times should show a jagged plot indicative of strong cancellation. Paste a copy of this plot, too. c) Rewrite the expression for y algebraically and simplify as much as possible. Plot this expression as in part b, and zoom in the center, ac 0, 4 times to see that cancellation error does not occur. Paste a copy of this plot, too. Submit a copy of your code, shrunken copies of the 4 plots (1 from a, 2 from b 1 from c making sure that your algebraically simplified expression for y appears prominently. The 4 plots should be resized so they all fit on one page.

Explanation / Answer

x=2:1e-6:2.1;
y=(1./(2*x+1))-((1-x)./(1+x));
figure(1)
plot(x,y)
grid on


x=-1e-6:1e-10:1e-6;
y=(1./(2*x+1))-((1-x)./(1+x));
figure(2)
plot(x,y)
grid on

x=-1e-6:1e-10:1e-6;
y=2*x.^2./(2*x.^2+3*x+1);
figure(3)
plot(x,y)
grid on

-------------------------------------------------


i have created all the plots..just zoom in and take a snapshot. right now i dont have MATLAB avaialbe with me ,so could not do so..