
ns = 2.^[2:7];
%ns = 2.^[2:3];

for k = 1:length(ns)
  n = ns(k)
  x = linspace(0, 1, n+1);

  % f(x) = x, f'(x) = 1
  [ev(k, 1), ez(k, 1)] = aufgabe3_1(x, ones(1, length(x)), x);

  % f(x) = x^2, f'(x) = 2 x
  f = x.^2;
  a = 2*x;
  [ev(k, 2), ez(k, 2)] = aufgabe3_1(f, a, x);

  % f(x) = x^3, f'(x) = 3 x^2
  f = x.^3;
  a = 3*x.^2;
  [ev(k, 3), ez(k, 3)] = aufgabe3_1(f, a, x);

  % f(x) = sin(3 pi x), f'(x) = 3 pi cos(3 pi x)
  f = sin(3*pi*x);
  a = 3*pi* cos(3*pi*x);
  [ev(k, 4), ez(k, 4)] = aufgabe3_1(f, a, x);

  % f(x) = exp((5*x - 5/2)^2), f'(x) = (50*x - 25) * exp((5*x - 5/2)^2)
  f = exp((5*x - 5/2).^2);
  a = 10*(5*x - 5/2) .* f;
  [ev(k, 5), ez(k, 5)] = aufgabe3_1(f, a, x);
end

ev
qv = ev(1:5, 2:5) ./ ev(2:6, 2:5)
ov = log2(qv)

ez
qz = ez(1:5, 3:5) ./ ez(2:6, 3:5)
oz = log2(qz)
