%% Annotated Matlab transcript -- 2/1 %% CS 323 - Doug DeCarlo % LOS example from last time: the value can actually be zero... x = 0:1e13:1e16; plot(x,x.*(sqrt(x+1)-sqrt(x)),'g',x,x./(sqrt(x+1)+sqrt(x)),'b'); % another LOS example: computing exp(-5) via taylor series: % Looking at terms in its taylor series n = 0:20; (-5).^n ./ factorial(n) plot(n,(-5).^n ./ factorial(n)) % And when we add them up and plot the result up to term n: for n = 1:20 x = 0:n; a(n) = sum((-5).^x ./ factorial(x)); end plot(1:20,a) %% Function noise - example from book x = linspace(0.99998, 1.00002, 100); f1 = (x-1).^3; f2 = x.^3 -3*x.^2 + 3*x - 1; f3 = -1 + x .* (3 + x .*(-3 + x)); plot(x,f1,'r',x,f2,'g',x,f3,'b',x,0)