%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% Klausur Numerische Mathematik I, Sommersemester 2018 %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% Gruppe: Nachklausur %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% Bitte fuegen Sie Ihre Loesungen in die fuer die Aufgabe vorgesehenen %
% Abschnitte ein. Vermeiden Sie die Nutzung von 'function' und achten Sie %
% darauf, dass das Skript ausfuehrbar ist. %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Aufgabe 1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% rueckwaerts besser als vorwaerts:
n = 30;
%format long
I = ones(60,1);
I(1) = (1/4)*(exp(2)+1);
% Vorwaertsiteration:
for i = 2:n
I(i) = exp(2)/2-(i/2)*I(i-1);
end
I
I_v = I(n)
% Rueckwaertsrekursion:
I(60) = 0.1173;
for i = 60:-1:n+1
I(i-1) = (2/i)*(exp(2)/2-I(i));
end
I_r = I(n)
% "Exakter" Wert
%I_e = quad(@(x)x.*log(x).^n,1,exp(1))
I_e = integral(@(x)x.*log(x).^n,1,exp(1))
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Aufgabe 4 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
f = @(x) x.^(4/3);
x0 = 1;
n = 10;
df = @(x) (4/3)*x.^(1/3);
xold = x0;
for i = 1:n
xnew = xold-f(xold)/df(xold);
xold = xnew;
end
x_10 = xnew
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Aufgabe 5 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% symmetrisch und positiv definit
M = gallery('kms',100,0.5);
% Pruefen auf Symmetrie und pos. Def
if issymmetric(M) && min(eig(M)) > 0
L = chol(M,'lower');
else
[L,U,P] = lu(M);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% End of file %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%