CE update

This commit is contained in:
Michael Scholz 2013-02-20 16:20:56 +01:00
parent 78a9fb587b
commit 0fe686245c
201 changed files with 13898 additions and 0 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,22 @@
{\rtf1\ansi\ansicpg1252\cocoartf1187\cocoasubrtf340
{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
{\colortbl;\red255\green255\blue255;}
\paperw11900\paperh16840\margl1440\margr1440\vieww10800\viewh8400\viewkind0
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\pardirnatural
\f0\fs24 \cf0 \
- Berechnen einer L\'f6sung einer DGL (allgemeine und spezielle L\'f6sung)\
- Formeln f\'fcr Zeitcharakteristika (-> Steifheitsma\'df)\
- Formeln f\'fcr alle m\'f6glichen Approximationsverfahren (Euler-, Runge-Kutta und co.)\
-> explizites / implizites Euler-Verfahren mit mehrdimensionalem System\
(vgl. \'dcbung 7 Aufgabe 2 d)\
- PD-Regelung linearer System (\'fcberkritisch ged\'e4mpft, kritisch ged\'e4mpft, unterkritisch ged\'e4mpft)\
(vgl. \'dcbung 12 Aufgabe 2)\
- R\'e4uber-Beute-Modell -> Probeklausur Aufgabe 3\
- PQ-Formel / ABC-Formel\
- Schritte einer Simulationsstudie\
- Regeln f\'fcr die automatische Modellgenerierung\
- unklare MC-Fragen\
- Fragen aus Probeklausur zur Modellierung und Simulation\
- Formel zu Pseudozufallszahlengenerator\
- Formel zu Mittelwert und Varianz}

View File

@ -0,0 +1,55 @@
{\rtf1\ansi\ansicpg1252\cocoartf1187\cocoasubrtf340
{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
{\colortbl;\red255\green255\blue255;}
\paperw11900\paperh16840\margl1440\margr1440\vieww11560\viewh11700\viewkind0
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\pardirnatural
\f0\b\fs24 \cf0 \'dcbungen 4 Aufgabe 1b):
\b0 \
- Warum ist die erste Ruhelage stabil obwohl der Realteil von Eigenwert lambda_3/4 = 0 ist ?\
Es hei\'dft doch hier, dass bei Re(EW) = 0 keine Aussage \'fcber Stabilit\'e4t getroffen werden kann\'85\
=> 3,0151i = 3 + 151i laut Wolframalpha.\
\
\b Was ist eine Referenztrajektorie?
\b0 \
=> Eine Referenztrajektorie gibt einen Ruhebereich in Abh\'e4ngigkeit von der Zeit t an. (z.B. eine stabile/instabile Umlaufbahn um einen Planeten). Daher ist das Einsetzen von expliziten t_s nicht notwendig (-> durch das Einsetzen von t_s erh\'e4lt man eine Ruhelage, falls die Referenztrajektorie stabil ist.) Deshalb setzt man immer die allgemeinen Referenztrajektorie ein!! Vgl. \'dcbung 4 Aufgabe 2 a)\
\
\
\
\b Probleklausur WS10/11:
\b0 \
letzte Aufgabe: Mechanik\
\
\b Probleklausur WS11/12:
\b0 \
Aufgabe 4c): Eigenwert f\'fcr d=0 m\'fcsste doch 0 sein und somit keine Aussage \'fcber Stabilit\'e4t m\'f6glich?\
Aufgabe 5d): Warum kann hier nur t_2 schalten. Laut Definition kann eine Transition schalten, wenn ihre Eing\'e4nge belegt sind.\
Aufgabe 6 c): Komische Umformung in autonomes System.\
-> Schaltfunktion bestimmen.\
-> Richtungsfelder zeichnen\
\
\
\b \'dcbung 5 Aufgabe 2a)
\b0 Addition von Gleitkommazahlen letzte Schritt "Anpassen an die Mantisse"\
\
\b \'dcbung 6 Aufgabe 2a):
\b0 hier wird von der "einfachen Form" des Newton-Verfahren gesprochen. Was ist die komplizierte Form? Die Form mit der Matrixschreibweise? \
\
\b \'dcbung 8 Aufgabe 1c):
\b0 Heun-Verfahren zeichnerisch L\'f6sen\
\
\b \'dcbung 12 Aufgabe 2:
\b0 Verschiedene Schwingungstypen. Wie kommt man von den Eigenwerten auf den Schwingungstyp? PD-Regelung ?!\
\
\
\
\
\
}

View File

@ -0,0 +1 @@
232391711

Binary file not shown.

View File

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 645 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 MiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 138 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 137 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 132 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 137 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@ -0,0 +1,2 @@
q1 = x-22
q2 = x-18

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1 @@
207435091

View File

View File

Binary file not shown.

View File

@ -0,0 +1,36 @@
function [N,x] = fixpoint (x0)
% Function fixpoint
% In: Start value
% Out: number of iteration steps, vector of solution
N=1;
xCur = x0;
xOld = x0;
epsilon = 10^(-8);
A = [3,4;1,6];
function [y] = f(x)
yTemp = (A - x(3)*eye(2))*[x(1);x(2)];
lambda = x(1)^2+x(2)^2-1;
y = [ yTemp ; lambda];
end
function [y] = jacobi(x)
y1 = [A(1,1)-x(3) , A(1,2) , -x(1)];
y2 = [A(2,1) , A(2,2)-x(3) , -x(2)];
y3 = [2*x(1) , 2*x(2) , 0];
y = [y1;y2;y3];
end
function [y] = fixpoint_next(x)
y = x - inv(jacobi(x0)) * f(x);
end
xCur = fixpoint_next(xOld);
x(:,N) = xCur;
while(norm(xCur-xOld) > epsilon && N < 60)
N = N + 1;
xOld = xCur;
xCur = fixpoint_next(xOld);
x(:,N) = xCur;
end
end

View File

@ -0,0 +1,63 @@
function main();
% Main function for iteration of static values in
% eigenvalue problem
%
%
% Grundlagen der Modellierung und Simulation
% WiSe 2012/13
%%%%%%%%%%%%%%%%%%%%%% Start Values %%%%%%%%%%%%%%%%%%%%
x = [-3; 0; 0]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
x_fixpunkt = x;
x_newton = x;
x_qnewton = x;
%%%%%%%%%%%%%%%%%%% Fixpunkt %%%%%%%%%%%%%%%%%%%%%%%%%%%
[it_f, x_f] = fixpoint(x_fixpunkt);
%%%%%%%%%%%%%%%%%%% Newton %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[it_n, x_n] = newton(x_newton);
%%%%%%%%%%%%%%%%%%% Quasi-Newton %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[it_qn, x_qn] = quasi_newton(x_qnewton);
%%%%%%%%%%%%%%%%%%% Output %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
disp('Startwert x');
x
disp('Anzahl Iterationen bei Fixpunkt:');
it_f
disp('Loesung:');
x_f(:,it_f)
%x_f
disp('Anzahl Iterationen bei Newton:');
it_n
disp('Loesung:');
x_n(:,it_n)
%x_n
disp('Anzahl Iterationen bei Quasi-Newton:');
it_qn
disp('Loesung:');
x_qn(:,it_qn)
semilogy(1:it_n, abs(x_n(3,:)-2), ...
1:it_f, abs(x_f(3,:)-2), ...
1:it_qn, abs(x_qn(3,:)-2))
title('Iterationsverfahren');
legend('error (Newton) ','error (FixP)','error (Quasi-Newton)')
xlabel('Anzahl Iterationen');
ylabel('Fehler in lambda');

View File

@ -0,0 +1,10 @@
function [out] = fmyeigen(x)
% Defines a function which has eigenvector/eigenvalue as roots
% x(1) : first component of eigenvector
% x(2) : second component of eigenvector
% x(3) : eigenvalue
out=[(3-x(3))*x(1)+4*x(2); x(1)+(6-x(3))*x(2); x(1)*x(1)+x(2)*x(2)-1];
end

View File

@ -0,0 +1,36 @@
function [N, x] = newton(x0)
% Function newton
% In: Start value
% Out: number of iteration steps, vector of solution
N=1;
xOld = x0;
xCur = x0;
epsilon = 10^(-8);
A = [3,4;1,6];
function [y] = f(x)
yTemp = (A - x(3)*eye(2))*[x(1);x(2)];
lambda = x(1)^2+x(2)^2-1;
y = [ yTemp ; lambda];
end
function [y] = jacobi(x)
y1 = [A(1,1)-x(3) , A(1,2) , -x(1)];
y2 = [A(2,1) , A(2,2)-x(3) , -x(2)];
y3 = [2*x(1) , 2*x(2) , 0];
y = [y1;y2;y3];
end
function [y] = newton_next(x)
y = x - jacobi(x)\f(x);
end
xCur = newton_next(xOld);
x(:,N) = xCur;
while(norm(xCur-xOld) > epsilon && N < 60)
N = N + 1;
xOld = xCur;
xCur = newton_next(xOld);
x(:,N) = xCur;
end
end

View File

@ -0,0 +1,48 @@
function [N,x] = quasi_newton(x0)
% Function quasi_newton
% In: Start value
% Out: number of iteration steps, vector of solution
N=1;
xCur = x0;
xOld = x0;
epsilon = 10^(-8);
A = [3,4;1,6];
function [y] = f(x)
yTemp = (A - x(3)*eye(2))*[x(1);x(2)];
lambda = x(1)^2+x(2)^2 - 1;
y = [ yTemp ; lambda];
end
function [y] = jacobi(x)
y1 = [A(1,1)-x(3) , A(1,2) , -x(1)];
y2 = [A(2,1) , A(2,2)-x(3) , -x(2)];
y3 = [2*x(1) , 2*x(2) , 0];
y = [y1;y2;y3];
end
function [y] = newton_next(x)
y = x + getDeltaX(x);
end
function [y] = getDeltaX(x)
y = jac\(-f(x));
end
jac = jacobi(x0);
xCur = newton_next(xOld);
x(:,N) = xCur;
while(abs(norm(xCur)-norm(xOld)) > epsilon && N < 60)
N = N + 1;
xOld = xCur;
% anpassen der angenäherten jacobi matrix
% ---------------------------------------
% Schritt 1 - delta X ausrechnen
delta = getDeltaX(xOld);
% Schritt 2 - x^k ausrechnen
xCur = newton_next(xOld);
% Schritt 3 & 4 - f(x^k) = f(xCur) und anpassen der Jacobi Matrix
jac = jac + (1/norm(delta)^2)*(f(xCur) - f(xOld) - jac*delta) * delta';
x(:,N) = xCur;
end
end

View File

@ -0,0 +1,71 @@
Gruppe:
- Michael Scholz (Matr.# 1576630)
- David Kaufmann (Matr.# 1481864)
- Dennis Werner (Matr.# 1513509)
Ausgabe der main-Funktion in Matlab:
1. Aufruf von main liefert:
==============================
>> main
x =
-3
0
0
Startwert x
x =
-3
0
0
Anzahl Iterationen bei Fixpunkt:
it_f =
47
Loesung:
ans =
-0.9701
0.2425
2.0000
Anzahl Iterationen bei Newton:
it_n =
6
Loesung:
ans =
-0.9701
0.2425
2.0000
Anzahl Iterationen bei Quasi-Newton:
it_qn =
14
Loesung:
ans =
-0.9701
0.2425
2.0000
>>

View File

@ -0,0 +1,37 @@
function [N,x] = fixpoint (x0)
// Function fixpoint
// In: Start value
// Out: number of iteration steps, vector of solution
N=1;
xCur = x0;
xOld = x0;
epsilon = 10^(-8);
A = [3,4;1,6];
function [y] = f(x)
// eye(A) muss in matlab durch eye(2) ersetzt werden
yTemp = (A - x(3)*eye(A))*[x(1);x(2)];
lambda = x(1)^2+x(2)^2-1;
y = [ yTemp ; lambda];
endfunction
function [y] = jacobi(x)
y1 = [A(1,1)-x(3) , A(1,2) , -x(1)];
y2 = [A(2,1) , A(2,2)-x(3) , -x(2)];
y3 = [2*x(1) , 2*x(2) , 0];
y = [y1;y2;y3];
endfunction
function [y] = fixpoint_next(x)
y = x - inv(jacobi(x0)) * f(x);
endfunction
xCur = fixpoint_next(xOld);
x(:,N) = xCur;
while(abs(norm(xCur)-norm(xOld)) > epsilon & N < 60)
N = N + 1;
xOld = xCur;
xCur = fixpoint_next(xOld);
x(:,N) = xCur;
end
endfunction

View File

@ -0,0 +1,65 @@
function main();
// Main function for iteration of static values in
// eigenvalue problem
//
//
// Grundlagen der Modellierung und Simulation
// WiSe 2012/13
//%%%%%%%%%%%%%%%%%%%%%% Start Values %%%%%%%%%%%%%%%%%%%%
x = [-3; 0; 0]
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
x_fixpunkt = x;
x_newton = x;
x_qnewton = x;
//%%%%%%%%%%%%%%%%%%% Fixpunkt %%%%%%%%%%%%%%%%%%%%%%%%%%%
[it_f, x_f] = fixpoint(x_fixpunkt);
//%%%%%%%%%%%%%%%%%%% Newton %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[it_n, x_n] = newton(x_newton);
//%%%%%%%%%%%%%%%%%%% Quasi-Newton %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[it_qn, x_qn] = quasi_newton(x_qnewton);
//%%%%%%%%%%%%%%%%%%% Output %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
disp('Startwert x');
x
disp('Anzahl Iterationen bei Fixpunkt:');
it_f
disp('Loesung:');
x_f(:,it_f)
%x_f
disp('Anzahl Iterationen bei Newton:');
it_n
disp('Loesung:');
x_n(:,it_n)
%x_n
disp('Anzahl Iterationen bei Quasi-Newton:');
it_qn
disp('Loesung:');
x_qn(:,it_qn)
semilogy(1:it_n, abs(x_n(3,:)-2), ...
1:it_f, abs(x_f(3,:)-2), ...
1:it_qn, abs(x_qn(3,:)-2))
title('Iterationsverfahren');
legend('error (Newton) ','error (FixP)','error (Quasi-Newton)')
xlabel('Anzahl Iterationen');
ylabel('Fehler in lambda');
endfunction

View File

@ -0,0 +1,10 @@
function [out] = fmyeigen(x)
// Defines a function which has eigenvector/eigenvalue as roots
// x(1) : first component of eigenvector
// x(2) : second component of eigenvector
// x(3) : eigenvalue
out=[(3-x(3))*x(1)+4*x(2); x(1)+(6-x(3))*x(2); x(1)*x(1)+x(2)*x(2)-1];
endfunction

View File

@ -0,0 +1,37 @@
function [N, x] = newton(x0)
// Function newton
// In: Start value
// Out: number of iteration steps, vector of solution
N=1;
xOld = x0;
xCur = x0;
epsilon = 10^(-8);
A = [3,4;1,6];
function [y] = f(x)
// eye(A) muss in matlab durch eye(2) ersetzt werden
yTemp = (A - x(3)*eye(A))*[x(1);x(2)];
lambda = x(1)^2+x(2)^2-1;
y = [ yTemp ; lambda];
endfunction
function [y] = jacobi(x)
y1 = [A(1,1)-x(3) , A(1,2) , -x(1)];
y2 = [A(2,1) , A(2,2)-x(3) , -x(2)];
y3 = [2*x(1) , 2*x(2) , 0];
y = [y1;y2;y3];
endfunction
function [y] = newton_next(x)
y = x - jacobi(x)\f(x);
endfunction
xCur = newton_next(xOld);
x(:,N) = xCur;
while(abs(norm(xCur)-norm(xOld)) > epsilon & N < 60)
N = N + 1;
xOld = xCur;
xCur = newton_next(xOld);
x(:,N) = xCur;
end
endfunction

View File

@ -0,0 +1,46 @@
function [N, x] = quasi_newton(x0);
// Function quasi_newton
// In: Start value
// Out: number of iteration steps, vector of solution
N=1;
xCur = x0;
xOld = x0;
epsilon = 10^(-8);
A = [3,4;1,6];
function [y] = f(x)
// eye(A) muss in matlab durch eye(2) ersetzt werden
yTemp = (A - x(3)*eye(A))*[x(1);x(2)];
lambda = x(1)^2+x(2)^2 - 1;
y = [ yTemp ; lambda];
endfunction
function [y] = jacobi(x)
y1 = [A(1,1)-x(3) , A(1,2) , -x(1)];
y2 = [A(2,1) , A(2,2)-x(3) , -x(2)];
y3 = [2*x(1) , 2*x(2) , 0];
y = [y1;y2;y3];
endfunction
function [y] = newton_next(x)
y = x + getDeltaX(x);
endfunction
function [y] = getDeltaX(x)
y = jac\(-f(x));
endfunction
jac = jacobi(x0);
xCur = newton_next(xOld);
x(:,N) = xCur;
while(abs(norm(xCur)-norm(xOld)) > epsilon & N < 60)
N = N + 1;
xOld = xCur;
// anpassen der angenäherten jacobi matrix
delta = getDeltaX(xOld); //schritt 1
xCur = newton_next(xOld); //schritt 2
//delta'*delta in matlab evtll durch norm(delta,2) austauschen
jac = jac + (1/(delta'*delta))*(f(xCur) - f(xOld) - jac*delta) * delta'; //schritt 4
x(:,N) = xCur;
end
endfunction

View File

@ -0,0 +1,59 @@
-->[N, X] = newton([-3;0;0])
X =
- 1.6666667 - 1.1121653 - 0.9790265 - 0.9701824 - 0.9701425 - 0.9701425
0.2777778 0.265897 0.2443321 0.2425437 0.2425356 0.2425356
1.2962963 1.7950236 1.976989 1.9998 2. 2.
N =
6.
-->[N, X] = fixpoint([-3;0;0])
X =
column 1 to 7
- 1.6666667 - 1.3575103 - 1.2033799 - 1.1161244 - 1.0636206 - 1.0308881 - 1.0100171
0.2777778 0.2862654 0.2746085 0.2632281 0.2551597 0.2499909 0.2468379
1.2962963 1.5519547 1.6869252 1.7754082 1.8382905 1.8841094 1.917574
column 8 to 14
- 0.9965065 - 0.9876671 - 0.9818386 - 0.9779729 - 0.9753975 - 0.9736757 - 0.9725214
0.2449727 0.2438948 0.2432839 0.2429434 0.2427563 0.2426548 0.2426001
1.941856 1.9593059 1.9717187 1.980464 1.986573 1.9908095 1.9937297
column 15 to 21
- 0.9717459 - 0.9712241 - 0.9708726 - 0.9706355 - 0.9704755 - 0.9703675 - 0.9702945
0.2425708 0.2425551 0.2425466 0.2425420 0.2425394 0.2425379 0.2425371
1.995733 1.9971018 1.9980344 1.9986683 1.9990984 1.99939 1.9995874
column 22 to 28
- 0.9702453 - 0.9702119 - 0.9701894 - 0.9701742 - 0.9701639 - 0.970157 - 0.9701523
0.2425366 0.2425362 0.2425360 0.2425359 0.2425358 0.2425357 0.2425357
1.999721 1.9998114 1.9998725 1.9999138 1.9999417 1.9999606 1.9999734
column 29 to 35
- 0.9701491 - 0.9701470 - 0.9701455 - 0.9701445 - 0.9701439 - 0.9701434 - 0.9701431
0.2425357 0.2425357 0.2425357 0.2425356 0.2425356 0.2425356 0.2425356
1.999982 1.9999878 1.9999918 1.9999944 1.9999962 1.9999975 1.9999983
column 36 to 42
- 0.9701429 - 0.9701428 - 0.9701427 - 0.9701426 - 0.9701426 - 0.9701426 - 0.9701425
0.2425356 0.2425356 0.2425356 0.2425356 0.2425356 0.2425356 0.2425356
1.9999988 1.9999992 1.9999995 1.9999996 1.9999998 1.9999998 1.9999999
column 43 to 46
- 0.9701425 - 0.9701425 - 0.9701425 - 0.9701425
0.2425356 0.2425356 0.2425356 0.2425356
1.9999999 1.9999999 2. 2.
N =
46.

View File

@ -0,0 +1,37 @@
function [N,x] = fixpoint (x0)
// Function fixpoint
// In: Start value
// Out: number of iteration steps, vector of solution
N=1;
xCur = x0;
xOld = x0;
epsilon = 10^(-8);
A = [3,4;1,6];
function [y] = f(x)
// eye(A) muss in matlab durch eye(2) ersetzt werden
yTemp = (A - x(3)*eye(A))*[x(1);x(2)];
lambda = x(1)^2+x(2)^2-1;
y = [ yTemp ; lambda];
endfunction
function [y] = jacobi(x)
y1 = [A(1,1)-x(3) , A(1,2) , -x(1)];
y2 = [A(2,1) , A(2,2)-x(3) , -x(2)];
y3 = [2*x(1) , 2*x(2) , 0];
y = [y1;y2;y3];
endfunction
function [y] = fixpoint_next(x)
y = x - inv(jacobi(x0)) * f(x);
endfunction
xCur = fixpoint_next(xOld);
x(:,N) = xCur;
while(norm(xCur-xOld) > epsilon & N < 60)
N = N + 1;
xOld = xCur;
xCur = fixpoint_next(xOld);
x(:,N) = xCur;
end
endfunction

View File

@ -0,0 +1,65 @@
function main();
// Main function for iteration of static values in
// eigenvalue problem
//
//
// Grundlagen der Modellierung und Simulation
// WiSe 2012/13
//%%%%%%%%%%%%%%%%%%%%%% Start Values %%%%%%%%%%%%%%%%%%%%
x = [-3; 0; 0]
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
x_fixpunkt = x;
x_newton = x;
x_qnewton = x;
//%%%%%%%%%%%%%%%%%%% Fixpunkt %%%%%%%%%%%%%%%%%%%%%%%%%%%
[it_f, x_f] = fixpoint(x_fixpunkt);
//%%%%%%%%%%%%%%%%%%% Newton %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[it_n, x_n] = newton(x_newton);
//%%%%%%%%%%%%%%%%%%% Quasi-Newton %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[it_qn, x_qn] = quasi_newton(x_qnewton);
//%%%%%%%%%%%%%%%%%%% Output %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
disp('Startwert x');
x
disp('Anzahl Iterationen bei Fixpunkt:');
it_f
disp('Loesung:');
x_f(:,it_f)
%x_f
disp('Anzahl Iterationen bei Newton:');
it_n
disp('Loesung:');
x_n(:,it_n)
%x_n
disp('Anzahl Iterationen bei Quasi-Newton:');
it_qn
disp('Loesung:');
x_qn(:,it_qn)
semilogy(1:it_n, abs(x_n(3,:)-2), ...
1:it_f, abs(x_f(3,:)-2), ...
1:it_qn, abs(x_qn(3,:)-2))
title('Iterationsverfahren');
legend('error (Newton) ','error (FixP)','error (Quasi-Newton)')
xlabel('Anzahl Iterationen');
ylabel('Fehler in lambda');
endfunction

View File

@ -0,0 +1,10 @@
function [out] = fmyeigen(x)
// Defines a function which has eigenvector/eigenvalue as roots
// x(1) : first component of eigenvector
// x(2) : second component of eigenvector
// x(3) : eigenvalue
out=[(3-x(3))*x(1)+4*x(2); x(1)+(6-x(3))*x(2); x(1)*x(1)+x(2)*x(2)-1];
endfunction

View File

@ -0,0 +1,46 @@
function [N, matrixX] = newton(x0)
// Function newton
// In: Start value
// Out: number of iteration steps, vector of solution
// Todo: Replace below code with Newton method
bool=1;
N=1;
x=x0;
xTmp = x0;
e = 10^(-8);
matrixX = []; //matrix we use for iterations
matrixA = [3 4;1 6];
//define function f(x) as vectorfunction:
function [y] = f(x)
y = [(matrixA(1,1)-x(3))*x(1) + matrixA(1,2)*x(2) ;
matrixA(2,1)*x(1) + (matrixA(2,2)-x(3))*x(2) ;
(x(1)^2-1) + (x(2)^2 -1)];
endfunction
while(bool == 1)
//calculate x (of current iteration)
jac = numdiff(f, x); //jacobi-matrix
deltaX = jac\(-f(x));
x = x + deltaX;
//add x to output matrix
matrixX(:,N) = x;
//check criteria
if(N == 60 | (abs(norm(xTmp)-norm(x)) < e & N >1))
bool = 0; //-> will cancel the while-loop
end
N = N+1; //increase N
xTmp = x;
end
N = N-1;
endfunction

View File

@ -0,0 +1,56 @@
function [N, matrixX] = quasi_newton(x0);
// Function quasi_newton
// In: Start value
// Out: number of iteration steps, vector of solution
// Todo: Replace below code with quasi-Newton method
bool=1;
N=1;
x=x0;
xTmp = x0;
e = 10^(-8);
matrixX = []; //matrix we use for iterations
matrixA = [3 4;1 6];
a = 1;
//define function f(x) as vectorfunction:
function [y] = f(x)
y = [(matrixA(1,1)-x(3))*x(1) + matrixA(1,2)*x(2) ;
matrixA(2,1)*x(1) + (matrixA(2,2)-x(3))*x(2) ;
(x(1)^2) + (x(2)^2) - 1];
endfunction
jac = numdiff(f, x); //jacobi-matrix
while(bool == 1)
//calculate x (of current iteration)
deltaX = jac\(-f(x));
x = x + deltaX;
//add x to output matrix
matrixX(:,N) = x;
//calculate jacobi-matrix for next iteration
deltaF = f(x) - f(x-deltaX);
incr = 1 / (norm(deltaX)^2)*(deltaF-jac*a*deltaX)*(a.*deltaX)';
jac = jac + incr;
//check criteria
if(N == 30 | (abs(norm(xTmp)-norm(x)) < e & N >1))
bool = 0; //-> will cancel the while-loop
end
N = N+1; //increase N
xTmp = x;
end
N = N-1;
endfunction

Binary file not shown.

View File

@ -0,0 +1 @@
219911329

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More