diff options
author | LordMcFungus <mceagle117@gmail.com> | 2021-03-22 18:05:11 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-22 18:05:11 +0100 |
commit | 76d2d77ddb2bed6b7c6b8ec56648d85da4103ab7 (patch) | |
tree | 11b2d41955ee4bfa0ae5873307c143f6b4d55d26 /buch/chapters/40-eigenwerte/images/spbeispiel.m | |
parent | more chapter structure (diff) | |
parent | add title image (diff) | |
download | SeminarMatrizen-76d2d77ddb2bed6b7c6b8ec56648d85da4103ab7.tar.gz SeminarMatrizen-76d2d77ddb2bed6b7c6b8ec56648d85da4103ab7.zip |
Merge pull request #1 from AndreasFMueller/master
update
Diffstat (limited to '')
-rw-r--r-- | buch/chapters/40-eigenwerte/images/spbeispiel.m | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/buch/chapters/40-eigenwerte/images/spbeispiel.m b/buch/chapters/40-eigenwerte/images/spbeispiel.m new file mode 100644 index 0000000..81160b9 --- /dev/null +++ b/buch/chapters/40-eigenwerte/images/spbeispiel.m @@ -0,0 +1,51 @@ +# +# spbeispiel.m +# +# (c) 2020 Prof Dr Andreas Müller, Hochschule Rapperswil +# +N = 30 +R = 0.05 * rand(N,N); +R = R + R'; +A = eye(N) + R; +L = tril(A,-1) +U = tril(A',-1)' +D = diag(diag(A)) + +A + +function r = spektralradius(A) + r = max(abs(eig(A))); +end + +gaussseidel = spektralradius(inverse(L+D)*U) +jacobi = spektralradius(inverse(D)*(L+U)) +richardson = spektralradius(A - eye(N)) + +fd = fopen("sppaths.tex", "w"); + +fprintf(fd, "\\def\\richardson{\n") +tau = 0.1; +r = spektralradius((1/tau) * A - eye(N)) +fprintf(fd, "\\draw[line width=1.4pt,color=red] ({\\sx*0.1},{\\sy*%.5f})", r); +for tau = (11:300) / 100 + r = spektralradius((1/tau) * A - eye(N)); + fprintf(fd, "\n--({\\sx*%.5f},{\\sy*%.5f})", tau, r); +end +fprintf(fd, "\n;}\n"); + +fprintf(fd, "\\def\\sor{\n"); +omega = 1/100 +B = (1/omega) * D + L; +C = (1-1/omega) * D + U; +r = spektralradius(inverse(B) * C) +fprintf(fd, "\\draw[line width=1.4pt,color=red] ({\\sx*%.3f},{\\sy*%.3f})", omega, r); +for omega = (2:200) / 100 + B = (1/omega) * D + L; + C = (1-1/omega) * D + U; + r = spektralradius(inverse(B) * C); + fprintf(fd, "\n--({\\sx*%.5f},{\\sy*%.5f})", omega, r); +end +fprintf(fd, ";\n}\n"); + +fclose(fd); + |