% m13_stability.m - unstable and stable calculations of exp(-40). x = -40; exp(x) I = 0:150; taylor = x.^I ./ factorial(I); sum(taylor) % unstable taylor = (-x).^I ./ factorial(I); 1/sum(taylor) % stable