ex05c.m

function ex05c()
% Lösung von Aufgabe 5c
% Ergebnis wird gleich geplottet
f = @(x) sin(1./x);
a = 0.107; b = 0.28;  

x = 0.1:0.0001:0.4;
y = f(x);
set(0,'defaultfigurecolor','white');
plot(x, y, 'b-', x, 0*x, 'k-', [a b], f([a b]), 'k*')
hold('on')

% 3. Punkt durch Sekantenschritt
c = sekantenSchritt(f, a, b);
plot(c, f(c), 'k*')

while (abs(c-b) > 1e-5)
  d = iqiSchritt(f, a, b,c);
  a = b;
  b = c;
  c = d;
  fprintf('%10.6f %10.6f %10.6f\n', a, b, c);
  plot(c, f(c), 'r*')
end
xlim([0.1 0.4]);
hold('off')

F = getframe(gcf);
imwrite(F.cdata, 'bild83.png');