(a) f(x) = sqrt(abs(x-1)) +1 at x=1.00001
(b) f(x) = e ^ -x at x=10
(c) f(x) = sqrt(x^2 +1) - x at x=300
(d) f(x) = (e^-x - 1)/x at x=0.001
(e) f(x) = sin(x)/1+cos(x) at x=1.0001pi
Matlab Code:
e = exp(1);
%(a) f(x) = sqrt(abs(x-1)) +1
xa = -2:.001:2;
fa = sqrt(abs(xa-1)) +1;
derfa = (-1+xa)/(2 .*((-1+xa).^2).^(3/4));
cna = xa .* derfa ./fa;
figure(1);
hold on
plot(xa,fa)
plot(xa,cna, 'r')
hold off
%(b) f(x) = e ^ -x
xb = -10:1:10;
fb = e .^ -xb;
derfb = -e .^ -xb;
cnb = xb .* derfb ./fb;
figure(2);
hold on
plot(xb,fb)
plot(xb,cnb, 'r')
hold off
%(c) f(x) = sqrt(x^2 +1) - x
xc = 0:10:300;
fc = sqrt(xc .^2 +1) - xc;
derfc = -1+xc ./sqrt(1+xc .^2);
cnc = xc .* derfc ./ fc;
figure(3);
hold on
plot(xc, fc)
plot(xc,cnc,'r')
hold off
%(d) f(x) = (e^-x - 1)/x;
xd = -.5:0.001:.05;
fd = (e.^-xd - 1)./xd;
derfd = -e .^(-1 - xd);
cnd = xd .* derfd ./ fd;
figure(4);
hold on
plot(xd, cnd, 'r')
plot(xd,fd)
hold off
%(e) f(x) = sin(x)/1+cos(x);
xe = -1 * pi: .0001 * pi: 2 * pi;
fe = sin(xe) ./(1+cos(xe));
derfe = 1 ./(1+cos(xe));
cne = xe .* derfe ./ fe;
figure(5);
hold on
plot(xe,fe)
plot(xe, cne, 'r')
hold off
The results of the code are these graphs:
A:
B:
C:
D:
E:
As shown, the cn(conditional number) for a is about -.25, meaning the error is attenuated. The cn for b is about 0, so it is attenuated. The cn for c is -1, meaning the relative error is identical in x and f(x). The cn for d is about 0, so it is attenuated. The cn for e appears to be 0 at first, but upon closer inspection,
it becomes apparent that at ~3.1419, the point at which we are evaluating the condition number, there is a discontinuity which goes to infinity, showing that at that point, the error is magnified enormously