%% Annotated Matlab transcript -- 3/6 %% CS 323 - Doug DeCarlo % Perturbation analysis % Let's plot example 3.5.4 on page 112 of the text x = 0.9:0.01:7.3; f = (x-1).*(x-2).*(x-3).*(x-4).*(x-5).*(x-6).*(x-7); plot(x,f,x,0); % Here is the perturbed version, too F = f - 0.002*x.^6; plot(x,f,x,F,x,0); % We can see that the perturbed term does get quite big plot(x,f,x,F,x,0,x,0.002*x.^6); % - - - % after class, I also decided to plot the predicted scale of the % perturbation: -g/f' (you just do this at the roots...) r = 1:7; % I did this in maple.. :) dF = 7*r.^6-168*r.^5+1610*r.^4-7840*r.^3+20307*r.^2-26264*r+13068; % and now plot the size of the perturbation as a red dot plot(x,f,x,F,x,0,r,-r.^6./dF,'.r')