From 50d4a6fb4adb0a24acdb987a3e5108de66187651 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=BCller?= Date: Wed, 13 Oct 2021 11:32:58 +0200 Subject: add ellipsenumfang --- buch/chapters/110-elliptisch/images/Makefile | 8 +++- .../110-elliptisch/images/ellipsenumfang.m | 14 +++++++ .../110-elliptisch/images/ellipsenumfang.pdf | Bin 0 -> 16542 bytes .../110-elliptisch/images/ellipsenumfang.tex | 44 +++++++++++++++++++++ 4 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 buch/chapters/110-elliptisch/images/ellipsenumfang.m create mode 100644 buch/chapters/110-elliptisch/images/ellipsenumfang.pdf create mode 100644 buch/chapters/110-elliptisch/images/ellipsenumfang.tex (limited to 'buch/chapters/110-elliptisch/images') diff --git a/buch/chapters/110-elliptisch/images/Makefile b/buch/chapters/110-elliptisch/images/Makefile index ef2e6fc..e366988 100644 --- a/buch/chapters/110-elliptisch/images/Makefile +++ b/buch/chapters/110-elliptisch/images/Makefile @@ -3,8 +3,14 @@ # # (c) 2021 Prof Dr Andreas Müller, OST Ostschweizer Fachhochschule # -all: lemniskate.pdf +all: lemniskate.pdf ellipsenumfang.pdf lemniskate.pdf: lemniskate.tex pdflatex lemniskate.tex +ellipsenumfang.pdf: ellipsenumfang.tex ekpath.tex + pdflatex ellipsenumfang.tex + +ekpath.tex: ellipsenumfang.m + octave ellipsenumfang.m + diff --git a/buch/chapters/110-elliptisch/images/ellipsenumfang.m b/buch/chapters/110-elliptisch/images/ellipsenumfang.m new file mode 100644 index 0000000..84022bc --- /dev/null +++ b/buch/chapters/110-elliptisch/images/ellipsenumfang.m @@ -0,0 +1,14 @@ +# +# ellipsenumfang +# +# (c) 2021 Prof Dr Andreas Müller, OST Ostschweizer Fachhochschule +# +f = fopen("ekplot.tex", "w"); +fprintf(f, "\\def\\ekpath{\n"); +fprintf(f, "(0,{\\dy*%.4f})\n", pi / 2); +for epsilon = (1:100) / 100 + [k, e] = ellipke(epsilon^2); + fprintf(f, "--({\\dx*%.4f},{\\dy*%.4f})\n", epsilon, e); +endfor +fprintf(f, "\n}\n"); +fclose(f); diff --git a/buch/chapters/110-elliptisch/images/ellipsenumfang.pdf b/buch/chapters/110-elliptisch/images/ellipsenumfang.pdf new file mode 100644 index 0000000..b52d5f3 Binary files /dev/null and b/buch/chapters/110-elliptisch/images/ellipsenumfang.pdf differ diff --git a/buch/chapters/110-elliptisch/images/ellipsenumfang.tex b/buch/chapters/110-elliptisch/images/ellipsenumfang.tex new file mode 100644 index 0000000..9f7c788 --- /dev/null +++ b/buch/chapters/110-elliptisch/images/ellipsenumfang.tex @@ -0,0 +1,44 @@ +% +% ellipsenumfang.tex -- template for standalon tikz images +% +% (c) 2021 Prof Dr Andreas Müller, OST Ostschweizer Fachhochschule +% +\documentclass[tikz]{standalone} +\usepackage{amsmath} +\usepackage{times} +\usepackage{txfonts} +\usepackage{pgfplots} +\usepackage{csvsimple} +\usetikzlibrary{arrows,intersections,math} +\begin{document} +\input{ekplot.tex} +\def\skala{1} +\begin{tikzpicture}[>=latex,thick,scale=\skala] + +\def\dx{10} +\def\dy{4} + +\draw[->] (0,-0.1) -- (0,6.8) coordinate[label={right:$E(\varepsilon)$}]; +\draw[->] (-0.1,0) -- (10.5,0) coordinate[label={$\varepsilon$}]; +\draw[line width=0.4pt] (0,\dy) -- (10,\dy); +\draw[line width=0.4pt] (\dx,0) -- (10,\dy); + +\draw[color=red,line width=1.4pt] \ekpath; +\fill[color=red] (\dx,\dy) circle[radius=0.05]; + +\foreach \y in {2,4,...,16}{ + \draw (-0.1,{\dy*\y/10}) -- (0.1,{\dy*\y/10}); + \pgfmathparse{\y/10} + \xdef\v{\pgfmathresult} + \node at (0,{\dy*\y/10}) [left] {$\v$}; +} +\foreach \i in {1,...,9}{ + \draw (\i,-0.1) -- (\i,0.1); + \node at (\i,0) [below] {$0.\i$}; +} +\draw (10,-0.1) -- (10,0.1); +\node at (10,0) [below] {$1.0$}; + +\end{tikzpicture} +\end{document} + -- cgit v1.2.1 From a27efc4b9657ace8e18fbf58db4dc3c31cb73514 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=BCller?= Date: Wed, 13 Oct 2021 20:53:37 +0200 Subject: ellipsenumfang komplett --- buch/chapters/110-elliptisch/images/Makefile | 4 +- .../110-elliptisch/images/ellipsenumfang.m | 7 ++ .../110-elliptisch/images/ellipsenumfang.pdf | Bin 16542 -> 22986 bytes .../110-elliptisch/images/ellipsenumfang.tex | 71 ++++++++++++++++----- 4 files changed, 64 insertions(+), 18 deletions(-) (limited to 'buch/chapters/110-elliptisch/images') diff --git a/buch/chapters/110-elliptisch/images/Makefile b/buch/chapters/110-elliptisch/images/Makefile index e366988..327fed1 100644 --- a/buch/chapters/110-elliptisch/images/Makefile +++ b/buch/chapters/110-elliptisch/images/Makefile @@ -8,9 +8,9 @@ all: lemniskate.pdf ellipsenumfang.pdf lemniskate.pdf: lemniskate.tex pdflatex lemniskate.tex -ellipsenumfang.pdf: ellipsenumfang.tex ekpath.tex +ellipsenumfang.pdf: ellipsenumfang.tex ekplot.tex pdflatex ellipsenumfang.tex -ekpath.tex: ellipsenumfang.m +ekplot.tex: ellipsenumfang.m octave ellipsenumfang.m diff --git a/buch/chapters/110-elliptisch/images/ellipsenumfang.m b/buch/chapters/110-elliptisch/images/ellipsenumfang.m index 84022bc..9ac8fe2 100644 --- a/buch/chapters/110-elliptisch/images/ellipsenumfang.m +++ b/buch/chapters/110-elliptisch/images/ellipsenumfang.m @@ -11,4 +11,11 @@ for epsilon = (1:100) / 100 fprintf(f, "--({\\dx*%.4f},{\\dy*%.4f})\n", epsilon, e); endfor fprintf(f, "\n}\n"); +fprintf(f, "\\def\\punkte{\n"); +for epsilon = (0.05:0.1:0.95) + [k, e] = ellipke(epsilon^2); + fprintf(f, "\\fill[color=blue] ({\\dx*%.4f},{\\dy*%.4f}) circle[radius=0.08];\n", epsilon, e); + fprintf(f, "\\draw[color=blue,line width=0.2pt] ({\\dx*%.4f},{\\dy*%.4f}) -- ({\\dx*%.4f},{\\dy*1.85});\n", epsilon, e, epsilon); +endfor +fprintf(f,"}\n"); fclose(f); diff --git a/buch/chapters/110-elliptisch/images/ellipsenumfang.pdf b/buch/chapters/110-elliptisch/images/ellipsenumfang.pdf index b52d5f3..fc27f21 100644 Binary files a/buch/chapters/110-elliptisch/images/ellipsenumfang.pdf and b/buch/chapters/110-elliptisch/images/ellipsenumfang.pdf differ diff --git a/buch/chapters/110-elliptisch/images/ellipsenumfang.tex b/buch/chapters/110-elliptisch/images/ellipsenumfang.tex index 9f7c788..0d1b807 100644 --- a/buch/chapters/110-elliptisch/images/ellipsenumfang.tex +++ b/buch/chapters/110-elliptisch/images/ellipsenumfang.tex @@ -12,32 +12,71 @@ \usetikzlibrary{arrows,intersections,math} \begin{document} \input{ekplot.tex} -\def\skala{1} +\def\skala{1.19} \begin{tikzpicture}[>=latex,thick,scale=\skala] +\pgfkeys{/pgf/number format/.cd, fixed, fixed zerofill, precision=1} + \def\dx{10} \def\dy{4} -\draw[->] (0,-0.1) -- (0,6.8) coordinate[label={right:$E(\varepsilon)$}]; -\draw[->] (-0.1,0) -- (10.5,0) coordinate[label={$\varepsilon$}]; -\draw[line width=0.4pt] (0,\dy) -- (10,\dy); -\draw[line width=0.4pt] (\dx,0) -- (10,\dy); +%\draw[line width=0.4pt] (0,\dy) -- (10,\dy); +%\draw[line width=0.4pt] (\dx,0) -- (10,\dy); + +\draw[->] (0,{\dy-0.1}) -- (0,7.0) coordinate[label={left:$E(k=\varepsilon)$}]; +\draw[->] (-0.1,\dy) -- (10.5,\dy) coordinate[label={$\varepsilon$}]; + +\foreach \i in {0,...,10}{ + \pgfmathparse{\i/10} + \xdef\wert{\pgfmathresult} + \draw (\i,{\dy-0.1}) -- (\i,{\dy+0.1}); + \node at (\i,{\dy-0.1}) [below] {$\pgfmathprintnumber{\wert}$}; +} \draw[color=red,line width=1.4pt] \ekpath; -\fill[color=red] (\dx,\dy) circle[radius=0.05]; +\fill[color=red] (\dx,\dy) circle[radius=0.07]; -\foreach \y in {2,4,...,16}{ - \draw (-0.1,{\dy*\y/10}) -- (0.1,{\dy*\y/10}); - \pgfmathparse{\y/10} - \xdef\v{\pgfmathresult} - \node at (0,{\dy*\y/10}) [left] {$\v$}; +\foreach \y in {1.0,1.2,1.4}{ + \draw (-0.1,{\dy*\y}) -- (0.1,{\dy*\y}); + \node at (-0.1,{\dy*\y}) [left] {$\pgfmathprintnumber{\y}$}; } -\foreach \i in {1,...,9}{ - \draw (\i,-0.1) -- (\i,0.1); - \node at (\i,0) [below] {$0.\i$}; + +\draw (-0.1,{\dy*3.14159/2}) -- (0.1,{\dy*3.14159/2}); +\node at (0,{\dy*3.14159/2}) [left] {$\displaystyle\frac{\pi}2$}; + + +\punkte + +\foreach \exzentrizitaet in {0.05,0.15,...,0.95}{ + \pgfmathparse{sqrt(1-\exzentrizitaet*\exzentrizitaet)} + \xdef\halbachse{\pgfmathresult} + + \pgfmathparse{\exzentrizitaet*\dx} + \xdef\mitte{\pgfmathresult} + %\node at (\mitte,1) {$\pgfmathprintnumber{\mitte}$}; + + \pgfmathparse{(1-\exzentrizitaet)} + \xdef\breite{\halbachse} + %\node at (\mitte,0.5) {$\pgfmathprintnumber{\breite}$}; + + \begin{scope} + + \clip ({\mitte-(\breite/2)},{1.8*\dy}) + rectangle ({\mitte+(\breite/2)+0.1},{1.8*\dy+1.1}); + \fill[color=blue!20] ({\mitte-\breite/2},{1.8*\dy}) + ellipse({\breite} and 1); + \draw[color=blue,line width=1.4pt] + ({\mitte-\breite/2},{1.8*\dy}) + ellipse({\breite} and 1); + \draw[color=blue,line width=0.2pt] + ({\mitte-\breite/2},{1.8*\dy+1}) + -- + ({\mitte-\breite/2},{1.8*\dy}) + -- + ({\mitte+\breite/2},{1.8*\dy}); + \end{scope} } -\draw (10,-0.1) -- (10,0.1); -\node at (10,0) [below] {$1.0$}; + \end{tikzpicture} \end{document} -- cgit v1.2.1 From bfd6e3d56f2e91f81b42c811fbff62abc153724d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=BCller?= Date: Sat, 16 Oct 2021 10:09:16 +0200 Subject: new files --- buch/chapters/110-elliptisch/images/Makefile | 13 ++- buch/chapters/110-elliptisch/images/rechteck.cpp | 54 +++++++++++ .../110-elliptisch/images/unvollstaendig.m | 81 +++++++++++++++++ .../110-elliptisch/images/unvollstaendig.pdf | Bin 0 -> 46390 bytes .../110-elliptisch/images/unvollstaendig.tex | 100 +++++++++++++++++++++ 5 files changed, 247 insertions(+), 1 deletion(-) create mode 100644 buch/chapters/110-elliptisch/images/rechteck.cpp create mode 100644 buch/chapters/110-elliptisch/images/unvollstaendig.m create mode 100644 buch/chapters/110-elliptisch/images/unvollstaendig.pdf create mode 100644 buch/chapters/110-elliptisch/images/unvollstaendig.tex (limited to 'buch/chapters/110-elliptisch/images') diff --git a/buch/chapters/110-elliptisch/images/Makefile b/buch/chapters/110-elliptisch/images/Makefile index 327fed1..4912cca 100644 --- a/buch/chapters/110-elliptisch/images/Makefile +++ b/buch/chapters/110-elliptisch/images/Makefile @@ -3,7 +3,7 @@ # # (c) 2021 Prof Dr Andreas Müller, OST Ostschweizer Fachhochschule # -all: lemniskate.pdf ellipsenumfang.pdf +all: lemniskate.pdf ellipsenumfang.pdf unvollstaendig.pdf lemniskate.pdf: lemniskate.tex pdflatex lemniskate.tex @@ -14,3 +14,14 @@ ellipsenumfang.pdf: ellipsenumfang.tex ekplot.tex ekplot.tex: ellipsenumfang.m octave ellipsenumfang.m +rechteck: rechteck.cpp + g++ -O -Wall -g rechteck.cpp -o rechteck + +test: rechteck + ./rechteck + +unvollstaendig.pdf: unvollstaendig.tex unvollpath.tex + pdflatex unvollstaendig.tex + +unvollpath.tex: unvollstaendig.m + octave unvollstaendig.m diff --git a/buch/chapters/110-elliptisch/images/rechteck.cpp b/buch/chapters/110-elliptisch/images/rechteck.cpp new file mode 100644 index 0000000..6bd6a06 --- /dev/null +++ b/buch/chapters/110-elliptisch/images/rechteck.cpp @@ -0,0 +1,54 @@ +/* + * rechteck.cpp + * + * (c) 2021 Prof Dr Andreas Müller, OST Ostschweizer Fachhochschule + */ +#include +#include +#include +#include +#include + +double ast = 1; + +std::complex integrand(double k, const std::complex& z) { + std::complex s = z * z; + std::complex eins(1); + std::complex result = eins / sqrt((eins - s) * (eins - k * k * s)); + return ast * ((result.imag() < 0) ? -result : result); +} + +std::complex segment(double k, const std::complex& z1, + const std::complex& z2, int n = 100) { + std::complex dz = z2 - z1; + std::complex summe(0); + double h = 1. / n; + summe = integrand(k, z1); + summe += integrand(k, z2); + for (int i = 1; i < n; i++) { + double t = i * h; + std::complex z = (1 - t) * z1 + t * z2; + summe += 2. * integrand(k, z); + } + return dz * h * summe / 2.; +} + +int main(int argc, char *argv[]) { + double k = 0.5; + double y = -0.0001; + double xstep = -0.1; + ast = 1; + std::complex z(0, y); + std::complex w = segment(k, std::complex(0), z); + std::cout << z << std::endl; + int counter = 100; + while (counter-- > 0) { + std::complex znext = z + std::complex(xstep); + std::complex incr = segment(k, z, znext); + w += incr; + std::cout << znext << " -> " << w << ", "; + std::cout << integrand(k, znext) << std::endl; + z = znext; + } + return EXIT_SUCCESS; +} diff --git a/buch/chapters/110-elliptisch/images/unvollstaendig.m b/buch/chapters/110-elliptisch/images/unvollstaendig.m new file mode 100644 index 0000000..25196d0 --- /dev/null +++ b/buch/chapters/110-elliptisch/images/unvollstaendig.m @@ -0,0 +1,81 @@ +# +# unvollstaendig.m +# +# (c) 2021 Prof Dr Andreas Müller, OST Ostschweizer Fachhochschule +# +global N; +N = 200; +global n; +n = 5; + +function retval = integrand_f(t, k) + retval = 1 / sqrt((1 - t^2) * (1 - k^2 * t^2)); +endfunction + +function retval = integrand_e(t, k) + retval = sqrt((1-k^2*t^2)/(1-t^2)); +endfunction + +function retval = integrand_pi(n, t, k) + retval = 1 / ((1-n*t^2) * sqrt((1-k^2*t^2)*(1-t^2))); +endfunction + +function retval = elliptisch1(f, name, k) + global N; + global n; + s = 0; + fprintf(f, "\\def\\ell%s{ (0,0)", name); + delta = 1 / N; + for x = (0:delta:(1-delta)) + h = delta / n; + for t = (x+h/2:h:x+delta) + s = s + integrand_f(t, k) * h; + endfor + fprintf(f, "\n -- ({\\dx*%.4f},{\\dy*%.4f})", x + delta, s); + endfor + fprintf(f, "}\n"); +endfunction + +function retval = elliptisch2(f, name, k) + global N; + global n; + s = 0; + fprintf(f, "\\def\\ell%s{ (0,0)", name); + delta = 1 / N; + for x = (0:delta:(1-delta)) + h = delta / n; + for t = (x+h/2:h:x+delta) + s = s + integrand_e(t, k) * h; + endfor + fprintf(f, "\n -- ({\\dx*%.4f},{\\dy*%.4f})", x + delta, s); + endfor + fprintf(f, "\n}\n"); +endfunction + +fn = fopen("unvollpath.tex", "w"); + +elliptisch1(fn, "Fzero", 0.0); +elliptisch1(fn, "Fone", 0.1); +elliptisch1(fn, "Ftwo", 0.2); +elliptisch1(fn, "Fthree", 0.3); +elliptisch1(fn, "Ffour", 0.4); +elliptisch1(fn, "Ffive", 0.5); +elliptisch1(fn, "Fsix", 0.6); +elliptisch1(fn, "Fseven", 0.7); +elliptisch1(fn, "Feight", 0.8); +elliptisch1(fn, "Fnine", 0.9); +elliptisch1(fn, "Ften", 1.0); + +elliptisch2(fn, "Ezero", 0.0); +elliptisch2(fn, "Eone", 0.1); +elliptisch2(fn, "Etwo", 0.2); +elliptisch2(fn, "Ethree", 0.3); +elliptisch2(fn, "Efour", 0.4); +elliptisch2(fn, "Efive", 0.5); +elliptisch2(fn, "Esix", 0.6); +elliptisch2(fn, "Eseven", 0.7); +elliptisch2(fn, "Eeight", 0.8); +elliptisch2(fn, "Enine", 0.9); +elliptisch2(fn, "Eten", 1.0); + +fclose(fn); diff --git a/buch/chapters/110-elliptisch/images/unvollstaendig.pdf b/buch/chapters/110-elliptisch/images/unvollstaendig.pdf new file mode 100644 index 0000000..4da2c0c Binary files /dev/null and b/buch/chapters/110-elliptisch/images/unvollstaendig.pdf differ diff --git a/buch/chapters/110-elliptisch/images/unvollstaendig.tex b/buch/chapters/110-elliptisch/images/unvollstaendig.tex new file mode 100644 index 0000000..1a1af13 --- /dev/null +++ b/buch/chapters/110-elliptisch/images/unvollstaendig.tex @@ -0,0 +1,100 @@ +% +% unvollstaendig.tex -- Plots der unvollständigen elliptischen integrale +% +% (c) 2021 Prof Dr Andreas Müller, OST Ostschweizer Fachhochschule +% +\documentclass[tikz]{standalone} +\usepackage{amsmath} +\usepackage{times} +\usepackage{txfonts} +\usepackage{pgfplots} +\usepackage{csvsimple} +\usetikzlibrary{arrows,intersections,math} +\input{unvollpath.tex} +\begin{document} +\def\skala{1} +\begin{tikzpicture}[>=latex,thick,scale=\skala] + +\pgfkeys{/pgf/number format/.cd, fixed, fixed zerofill, precision=1} + +\def\dx{12.8} +\def\dy{6} + +\definecolor{darkgreen}{rgb}{0,0.6,0} +\definecolor{blau}{rgb}{0.3,0.3,1} + +\begin{scope} +\begin{scope} +\clip (-0.1,-0.1) rectangle ({\dx+0.0},{10.1}); + +\fill[color=darkgreen!10] \ellEzero -- (\dx,{1.571*\dy}) -- (\dx,0) -- cycle; +\fill[color=red!10] \ellEzero -- (\dx,{1.571*\dy}) -- (\dx,10.1) -- (0,10.2) -- cycle; + +\node[color=red] at ({0.6*\dx},{1.3*\dy}) [scale=2] {$F(x,k)$}; +\node[color=darkgreen] at ({0.6*\dx},{0.3*\dy}) [scale=2] {$E(x,k)$}; + + +\draw[color=red!0!blau,line width=1.0pt] \ellFzero; +\draw[color=red!10!blau,line width=1.0pt] \ellFone; +\draw[color=red!20!blau,line width=1.0pt] \ellFtwo; +\draw[color=red!30!blau,line width=1.0pt] \ellFthree; +\draw[color=red!40!blau,line width=1.0pt] \ellFfour; +\draw[color=red!50!blau,line width=1.0pt] \ellFfive; +\draw[color=red!60!blau,line width=1.0pt] \ellFsix; +\draw[color=red!70!blau,line width=1.0pt] \ellFseven; +\draw[color=red!80!blau,line width=1.0pt] \ellFeight; +\draw[color=red!90!blau,line width=1.0pt] \ellFnine; +\draw[color=red!100!blau,line width=1.0pt] \ellFten; + +\draw[color=darkgreen!100!blau,line width=1.0pt] \ellEten; +\draw[color=darkgreen!90!blau,line width=1.0pt] \ellEnine; +\draw[color=darkgreen!80!blau,line width=1.0pt] \ellEeight; +\draw[color=darkgreen!70!blau,line width=1.0pt] \ellEseven; +\draw[color=darkgreen!60!blau,line width=1.0pt] \ellEsix; +\draw[color=darkgreen!50!blau,line width=1.0pt] \ellEfive; +\draw[color=darkgreen!40!blau,line width=1.0pt] \ellEfour; +\draw[color=darkgreen!30!blau,line width=1.0pt] \ellEthree; +\draw[color=darkgreen!20!blau,line width=1.0pt] \ellEtwo; +\draw[color=darkgreen!10!blau,line width=1.0pt] \ellEone; +\draw[color=darkgreen!0!blau,line width=1.0pt] \ellEzero; + +\end{scope} + +\draw[line width=0.2pt] (\dx,0) -- (\dx,10.1); + +\begin{scope} + \clip ({0.7*\dx},0) rectangle (\dx,10.1); + \draw[color=white,line width=0.5pt] \ellEzero -- (\dx,{1.571*\dy}); +\end{scope} + +\draw[->] ({-0.1},0) -- ({\dx+0.3},0) coordinate[label={$x$}]; +\foreach \x in {0,0.2,...,1.0}{ + \draw ({\x*\dx},-0.1) -- ({\x*\dx},0.1); + \node at ({\x*\dx},0) [below] {$\pgfmathprintnumber{\x}$}; +} +\draw[->] (0,{-0.1}) -- (0,{10.3}) coordinate[label={right:$y$}]; +\foreach \y in {0.5,1,1.5}{ + %\draw[line width=0.2pt] (0,{\y*\dy}) -- (\dx,{\y*\dy}); + \draw (-0.1,{\y*\dy}) -- (0.1,{\y*\dy}); + \node at (0,{\y*\dy}) [left] {$\pgfmathprintnumber{\y}$}; +} +\foreach \c in {0,10,...,100}{ + \pgfmathparse{\c/100} + \xdef\k{\pgfmathresult} + \node[color=red!\c!blau] at ({0.02*\dx},{0.95*\dy+0.04*\c}) + [right] {$k=\pgfmathprintnumber{\k}$}; +} +\foreach \c in {0,10,...,100}{ + \pgfmathparse{\c/100} + \xdef\k{\pgfmathresult} + \node[color=darkgreen!\c!blau] at ({0.98*\dx},{0.75*\dy-0.04*\c}) + [left] {$k=\pgfmathprintnumber{\k}$}; +} + +\draw ({\dx-0.1},{1.571*\dy}) -- ({\dx+0.1},{1.571*\dy}); +\node at (\dx,{1.571*\dy}) [right] {$\frac{\pi}2$}; +\end{scope} + +\end{tikzpicture} +\end{document} + -- cgit v1.2.1 From eeb4c0186284aca82d85c0e45e7471a3be1b9cd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=BCller?= Date: Sat, 16 Oct 2021 21:44:20 +0200 Subject: wertebereich elliptischer integrale --- buch/chapters/110-elliptisch/images/Makefile | 14 +- buch/chapters/110-elliptisch/images/rechteck.cpp | 369 +++++++++++++++++++++-- buch/chapters/110-elliptisch/images/rechteck.pdf | Bin 0 -> 70950 bytes buch/chapters/110-elliptisch/images/rechteck.tex | 80 +++++ 4 files changed, 431 insertions(+), 32 deletions(-) create mode 100644 buch/chapters/110-elliptisch/images/rechteck.pdf create mode 100644 buch/chapters/110-elliptisch/images/rechteck.tex (limited to 'buch/chapters/110-elliptisch/images') diff --git a/buch/chapters/110-elliptisch/images/Makefile b/buch/chapters/110-elliptisch/images/Makefile index 4912cca..6e3a5ce 100644 --- a/buch/chapters/110-elliptisch/images/Makefile +++ b/buch/chapters/110-elliptisch/images/Makefile @@ -3,7 +3,7 @@ # # (c) 2021 Prof Dr Andreas Müller, OST Ostschweizer Fachhochschule # -all: lemniskate.pdf ellipsenumfang.pdf unvollstaendig.pdf +all: lemniskate.pdf ellipsenumfang.pdf unvollstaendig.pdf rechteck.pdf lemniskate.pdf: lemniskate.tex pdflatex lemniskate.tex @@ -15,13 +15,19 @@ ekplot.tex: ellipsenumfang.m octave ellipsenumfang.m rechteck: rechteck.cpp - g++ -O -Wall -g rechteck.cpp -o rechteck + g++ `pkg-config --cflags gsl` `pkg-config --libs gsl` -O -Wall -g -std=c++11 rechteck.cpp -o rechteck -test: rechteck - ./rechteck +rechteckpfade.tex: rechteck + ./rechteck --outfile rechteckpfade.tex + +rechteck.pdf: rechteck.tex rechteckpfade.tex + pdflatex rechteck.tex unvollstaendig.pdf: unvollstaendig.tex unvollpath.tex pdflatex unvollstaendig.tex unvollpath.tex: unvollstaendig.m octave unvollstaendig.m + + + diff --git a/buch/chapters/110-elliptisch/images/rechteck.cpp b/buch/chapters/110-elliptisch/images/rechteck.cpp index 6bd6a06..3ece11c 100644 --- a/buch/chapters/110-elliptisch/images/rechteck.cpp +++ b/buch/chapters/110-elliptisch/images/rechteck.cpp @@ -8,47 +8,360 @@ #include #include #include +#include +#include +#include +#include double ast = 1; -std::complex integrand(double k, const std::complex& z) { - std::complex s = z * z; - std::complex eins(1); - std::complex result = eins / sqrt((eins - s) * (eins - k * k * s)); - return ast * ((result.imag() < 0) ? -result : result); +/** + * \brief Base class for integrands + */ +class integrand { +protected: + double _k; +public: + double k() const { return _k; } + integrand(double k) : _k(k) { } + virtual std::complex operator()(const std::complex& z) const = 0; + static double kprime(double k); +}; + +double integrand::kprime(double k) { + return sqrt(1 - k*k); } -std::complex segment(double k, const std::complex& z1, - const std::complex& z2, int n = 100) { +/** + * \brief Elliptic integral of the first kind + */ +class integrand1 : public integrand { +public: + integrand1(double k) : integrand(k) { } + virtual std::complex operator()( + const std::complex& z) const { + std::complex square = z * z; + std::complex eins(1.0); + std::complex result = eins + / sqrt((eins - square) * (eins - k() * k() * square)); + return ast * ((result.imag() < 0) ? -result : result); + } +}; + +/** + * \brief A class to trace curves + */ +class curvetracer { + const integrand& _f; +public: + typedef std::list > curve_t; + curvetracer(const integrand& f) : _f(f) { } + + std::complex startpoint(const std::complex& z, + int n = 100) const; + + std::complex segment(const std::complex& z1, + const std::complex& z2, int n) const; + + std::pair,std::complex > segmentl( + const std::complex& start, + const std::complex& dir, + double stepsize, int n = 10) const; + + curve_t trace(const std::complex& startz, + const std::complex& dir, + const std::complex& startw, + int maxsteps) const; + + static curve_t mirrorx(const curve_t& c); + static curve_t mirrory(const curve_t& c); + static curve_t mirror(const curve_t& c); +}; + +/** + * \brief Perform integration for a + * + * \param z1 the start point of the segment in the domain + * \param z2 the end point of the segment in the domain + * \param n the number of integration steps to use + * \return the increment along that segment + */ +std::complex curvetracer::segment(const std::complex& z1, + const std::complex& z2, int n = 100) const { std::complex dz = z2 - z1; std::complex summe(0); - double h = 1. / n; - summe = integrand(k, z1); - summe += integrand(k, z2); - for (int i = 1; i < n; i++) { + double h = 1. / (2 * n); + for (int i = 1; i < 2 * n; i += 2) { double t = i * h; std::complex z = (1 - t) * z1 + t * z2; - summe += 2. * integrand(k, z); + summe += _f(z); } - return dz * h * summe / 2.; + return dz * h * summe * 2.; } -int main(int argc, char *argv[]) { - double k = 0.5; - double y = -0.0001; - double xstep = -0.1; - ast = 1; - std::complex z(0, y); - std::complex w = segment(k, std::complex(0), z); - std::cout << z << std::endl; +/** + * \brief Exception thrown when the number of iterations is exceeded + */ +class toomanyiterations : public std::runtime_error { +public: + toomanyiterations(const std::string& cause) + : std::runtime_error(cause) { + } +}; + +/** + * \brief Perform integration with a given target length + * + * \param start the start point + * \param dir the direction in which to integrate + * \param stepsize the required length of the step + * \param n the number of integration steps + * \return the increment in the range by this segment + */ +std::pair, std::complex > curvetracer::segmentl( + const std::complex& start, + const std::complex& dir, + double stepsize, + int n) const { + std::complex s(0.); + std::complex z = start; int counter = 100; - while (counter-- > 0) { - std::complex znext = z + std::complex(xstep); - std::complex incr = segment(k, z, znext); - w += incr; - std::cout << znext << " -> " << w << ", "; - std::cout << integrand(k, znext) << std::endl; - z = znext; + while (abs(s) < stepsize) { + s = s + segment(z, z + dir, n); + z = z + dir; + if (counter-- == 0) { + throw toomanyiterations("too many iterations"); + } + } + return std::make_pair(z, s); +} + +/** + * \brief Trace a curve from a starting point in the domain + * + * \param startz the start point of the curve in the domain + * \param dir the direction of the curve in the domain + * \param startw the initial function value where the curve starts in + * the range + * \param maxsteps the maximum number of dir-steps before giving up + * \return the curve as a list of points + */ +curvetracer::curve_t curvetracer::trace(const std::complex& startz, + const std::complex& dir, + const std::complex& startw, + int maxsteps) const { + curve_t result; + std::complex z = startz; + std::complex w = startw; + result.push_back(w); + while (maxsteps-- > 0) { + try { + auto seg = segmentl(z, dir, abs(dir), 40); + z = seg.first; + w = w + seg.second; + result.push_back(w); + } catch (const toomanyiterations& x) { + std::cerr << "iterations exceeded after "; + std::cerr << result.size(); + std::cerr << " points"; + maxsteps = 0; + } + } + return result; +} + +/** + * \brief Find the initial point for a coordinate curve + * + * \param k the elliptic integral parameter + * \param z the desired starting point argument + */ +std::complex curvetracer::startpoint(const std::complex& z, + int n) const { + std::cerr << "start at " << z.real() << "," << z.imag() << std::endl; + return segment(std::complex(0.), z, n); +} + + +curvetracer::curve_t curvetracer::mirrorx(const curve_t& c) { + curve_t result; + for (auto z : c) { + result.push_back(-std::conj(z)); + } + return result; +} + +curvetracer::curve_t curvetracer::mirrory(const curve_t& c) { + curve_t result; + for (auto z : c) { + result.push_back(std::conj(z)); + } + return result; +} + +curvetracer::curve_t curvetracer::mirror(const curve_t& c) { + curve_t result; + for (auto z : c) { + result.push_back(-z); + } + return result; +} + +/** + * \brief Class to draw the curves to a file + */ +class curvedrawer { + std::ostream *_out; + std::string _color; +public: + curvedrawer(std::ostream *out) : _out(out), _color("red") { } + const std::string& color() const { return _color; } + void color(const std::string& c) { _color = c; } + void operator()(const curvetracer::curve_t& curve); + std::ostream *out() { return _out; } +}; + +/** + * \brief Operator to draw a curve + * + * \param curve the curve to draw + */ +void curvedrawer::operator()(const curvetracer::curve_t& curve) { + double first = true; + for (auto z : curve) { + if (first) { + *_out << "\\draw[color=" << _color << "] "; + first = false; + } else { + *_out << std::endl << " -- "; + } + *_out << "({" << z.real() << "*\\dx},{" << z.imag() << "*\\dy})"; } + *_out << ";" << std::endl; +} + +static struct option longopts[] = { +{ "outfile", required_argument, NULL, 'o' }, +{ "k", required_argument, NULL, 'k' }, +{ NULL, 0, NULL, 0 } +}; + +/** + * \brief Main function + */ +int main(int argc, char *argv[]) { + double k = 0.6; + + int c; + int longindex; + std::string outfilename; + while (EOF != (c = getopt_long(argc, argv, "o:k:", longopts, &longindex))) + switch (c) { + case 'o': + outfilename = std::string(optarg); + break; + case 'k': + k = std::stod(optarg); + break; + } + + double kprime = integrand::kprime(k); + + double xmax = gsl_sf_ellint_Kcomp(k, GSL_PREC_DOUBLE); + double ymax = gsl_sf_ellint_Kcomp(kprime, GSL_PREC_DOUBLE); + std::cout << "xmax = " << xmax << std::endl; + std::cout << "ymax = " << ymax << std::endl; + + curvedrawer *cdp; + std::ofstream *outfile = NULL; + if (outfilename.c_str()) { + outfile = new std::ofstream(outfilename.c_str()); + } + if (outfile) { + cdp = new curvedrawer(outfile); + } else { + cdp = new curvedrawer(&std::cout); + } + + integrand1 f(k); + curvetracer ct(f); + + // fill + (*cdp->out()) << "\\fill[color=red!10] ({" << (-xmax) << "*\\dx},0) " + << "rectangle ({" << xmax << "*\\dx},{" << ymax << "*\\dy});" + << std::endl; + (*cdp->out()) << "\\fill[color=blue!10] ({" << (-xmax) << "*\\dx},{" + << (-ymax) << "*\\dy}) rectangle ({" << xmax << "*\\dx},0);" + << std::endl; + + // "circles" + std::complex dir(0.01, 0); + for (double im = 0.2; im < 3; im += 0.2) { + std::complex startz(0, im); + std::complex startw = ct.startpoint(startz); + curvetracer::curve_t curve = ct.trace(startz, dir, + startw, 1000); + cdp->color("red"); + (*cdp)(curve); + (*cdp)(curvetracer::mirrorx(curve)); + cdp->color("blue"); + (*cdp)(curvetracer::mirrory(curve)); + (*cdp)(curvetracer::mirror(curve)); + } + + // imaginary axis + (*cdp->out()) << "\\draw[color=red] (0,0) -- (0,{" << ymax + << "*\\dy});" << std::endl; + (*cdp->out()) << "\\draw[color=blue] (0,0) -- (0,{" << (-ymax) + << "*\\dy});" << std::endl; + + // arguments between 0 and 1 + dir = std::complex(0, 0.01); + for (double re = 0.2; re < 1; re += 0.2) { + std::complex startz(re, 0.001); + std::complex startw = ct.startpoint(startz); + startw = std::complex(startw.real(), 0); + curvetracer::curve_t curve = ct.trace(startz, dir, + startw, 1000); + cdp->color("red"); + (*cdp)(curve); + (*cdp)(curvetracer::mirrorx(curve)); + cdp->color("blue"); + (*cdp)(curvetracer::mirrory(curve)); + (*cdp)(curvetracer::mirror(curve)); + } + + // argument 1 (singularity) + { + std::complex startz(1.); + std::complex startw(xmax); + curvetracer::curve_t curve = ct.trace(startz, dir, + startw, 1000); + cdp->color("red"); + (*cdp)(curve); + (*cdp)(curvetracer::mirrorx(curve)); + cdp->color("blue"); + (*cdp)(curvetracer::mirror(curve)); + (*cdp)(curvetracer::mirrory(curve)); + } + + // argument 1/k + { + std::complex startz(1/k); + std::complex startw(xmax, ymax); + curvetracer::curve_t curve = ct.trace(startz, dir, + startw, 1000); + cdp->color("red"); + (*cdp)(curve); + (*cdp)(curvetracer::mirrorx(curve)); + cdp->color("blue"); + (*cdp)(curvetracer::mirror(curve)); + (*cdp)(curvetracer::mirrory(curve)); + } + + // border + (*cdp->out()) << "\\def\\xmax{" << xmax << "}" << std::endl; + (*cdp->out()) << "\\def\\ymax{" << ymax << "}" << std::endl; + return EXIT_SUCCESS; } diff --git a/buch/chapters/110-elliptisch/images/rechteck.pdf b/buch/chapters/110-elliptisch/images/rechteck.pdf new file mode 100644 index 0000000..5fa07cb Binary files /dev/null and b/buch/chapters/110-elliptisch/images/rechteck.pdf differ diff --git a/buch/chapters/110-elliptisch/images/rechteck.tex b/buch/chapters/110-elliptisch/images/rechteck.tex new file mode 100644 index 0000000..622a9e9 --- /dev/null +++ b/buch/chapters/110-elliptisch/images/rechteck.tex @@ -0,0 +1,80 @@ +% +% rechteck.tex -- rechteck für Wertebereich der ell. Integrale +% +% (c) 2021 Prof Dr Andreas Müller, OST Ostschweizer Fachhochschule +% +\documentclass[tikz]{standalone} +\usepackage{amsmath} +\usepackage{times} +\usepackage{txfonts} +\usepackage{pgfplots} +\usepackage{csvsimple} +\usetikzlibrary{arrows,intersections,math} +\begin{document} +\def\skala{1} +\begin{tikzpicture}[>=latex,thick,scale=\skala] + +\def\dx{3} +\def\dy{3} + +\input{rechteckpfade.tex} + +\begin{scope} + \clip ({-\xmax*\dx},{-\ymax*\dy}) rectangle ({\xmax*\dx},{\ymax*\dy}); + \fill[color=red!10] (0,{\ymax*\dy}) circle[radius=0.45]; + \fill[color=blue!10] (0,{-\ymax*\dy}) circle[radius=0.45]; + \draw[color=gray!80] (0,{\ymax*\dy}) -- (0,{\ymax*\dy-0.45}); + \draw[color=gray!80] (0,{-\ymax*\dy}) -- (0,{-\ymax*\dy+0.45}); +\end{scope} + +\draw ({-\xmax*\dx},{-\ymax*\dy}) rectangle ({\xmax*\dx},{\ymax*\dy}); + +\draw[->] ({-\xmax*\dx-0.3},0) -- ({\xmax*\dx+0.9},0) + coordinate[label={$\operatorname{Re}F(k,z)$}]; + +\draw[<->,line width=0.7pt] + ({-\xmax*\dx},{\ymax*\dy+0.2}) + -- + ({\xmax*\dx},{\ymax*\dy+0.2}); +\draw[line width=0.2pt] + ({-\xmax*\dx},{\ymax*\dy}) + -- + ({-\xmax*\dx},{\ymax*\dy+0.3}); +\draw[line width=0.2pt] + ({\xmax*\dx},{\ymax*\dy}) + -- + ({\xmax*\dx},{\ymax*\dy+0.3}); + +\node at ({-0.5*\xmax*\dx},{\ymax*\dy+0.2}) [above] {$2K(k)$}; +\draw[->] (0,{\ymax*\dy}) -- (0,{\ymax*\dy+0.7}) + coordinate[label={right:$\operatorname{Im}F(k,z)$}]; +\draw (0,{-\ymax*\dy}) -- (0,{-\ymax*\dy-0.2}); + +\draw[line width=0.2pt] + ({-\xmax*\dx-0.3},{-\ymax*\dy}) + -- + ({-\xmax*\dx},{-\ymax*\dy}); +\draw[line width=0.2pt] + ({-\xmax*\dx-0.3},{\ymax*\dy}) + -- + ({-\xmax*\dx},{\ymax*\dy}); +\draw[<->,line width=0.7pt] + ({-\xmax*\dx-0.2},{\ymax*\dy}) + -- + ({-\xmax*\dx-0.2},0); + +\node at ({-\xmax*\dx-0.2},{-0.5*\ymax*\dy}) [rotate=90,above] {$K(k')$}; +\node at ({-\xmax*\dx-0.2},{0.5*\ymax*\dy}) [rotate=90,above] {$K(k')$}; + +\draw[<->,line width=0.7pt] + ({-\xmax*\dx-0.2},{-\ymax*\dy}) + -- + ({-\xmax*\dx-0.2},0); + +\node at ({\xmax*\dx},{\ymax*\dy}) [right] {$K(k)+iK(k')$}; +\fill[color=white] ({\xmax*\dx},{\ymax*\dy}) circle[radius=0.05]; +\draw ({\xmax*\dx},{\ymax*\dy}) circle[radius=0.05]; + +\end{tikzpicture} +\end{document} + -- cgit v1.2.1 From 24e0ebb5475b275af76900be4cbe5d7a8df0ef06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=BCller?= Date: Mon, 18 Oct 2021 08:51:09 +0200 Subject: improve elliptic integrals --- buch/chapters/110-elliptisch/images/rechteck.cpp | 53 +++++++++++++++++++++-- buch/chapters/110-elliptisch/images/rechteck.pdf | Bin 70950 -> 91630 bytes 2 files changed, 50 insertions(+), 3 deletions(-) (limited to 'buch/chapters/110-elliptisch/images') diff --git a/buch/chapters/110-elliptisch/images/rechteck.cpp b/buch/chapters/110-elliptisch/images/rechteck.cpp index 3ece11c..c3f6f1b 100644 --- a/buch/chapters/110-elliptisch/images/rechteck.cpp +++ b/buch/chapters/110-elliptisch/images/rechteck.cpp @@ -243,6 +243,7 @@ void curvedrawer::operator()(const curvetracer::curve_t& curve) { static struct option longopts[] = { { "outfile", required_argument, NULL, 'o' }, { "k", required_argument, NULL, 'k' }, +{ "deltax", required_argument, NULL, 'd' }, { NULL, 0, NULL, 0 } }; @@ -250,13 +251,18 @@ static struct option longopts[] = { * \brief Main function */ int main(int argc, char *argv[]) { - double k = 0.6; + double k = 0.625; + double deltax = 0.2; int c; int longindex; std::string outfilename; - while (EOF != (c = getopt_long(argc, argv, "o:k:", longopts, &longindex))) + while (EOF != (c = getopt_long(argc, argv, "o:k:d:", longopts, + &longindex))) switch (c) { + case 'd': + deltax = std::stod(optarg); + break; case 'o': outfilename = std::string(optarg); break; @@ -296,7 +302,7 @@ int main(int argc, char *argv[]) { // "circles" std::complex dir(0.01, 0); - for (double im = 0.2; im < 3; im += 0.2) { + for (double im = deltax; im < 3; im += deltax) { std::complex startz(0, im); std::complex startw = ct.startpoint(startz); curvetracer::curve_t curve = ct.trace(startz, dir, @@ -345,7 +351,28 @@ int main(int argc, char *argv[]) { (*cdp)(curvetracer::mirrory(curve)); } + // arguments between 1 and 1/k + { + for (double x0 = 1 + deltax; x0 < 1/k; x0 += deltax) { + double y0 = sqrt(1-1/(x0*x0))/kprime; + //std::cout << "y0 = " << y0 << std::endl; + double y = gsl_sf_ellint_F(asin(y0), kprime, + GSL_PREC_DOUBLE); + std::complex startz(x0); + std::complex startw(xmax, y); + curvetracer::curve_t curve = ct.trace(startz, dir, + startw, 1000); + cdp->color("red"); + (*cdp)(curve); + (*cdp)(curvetracer::mirrorx(curve)); + cdp->color("blue"); + (*cdp)(curvetracer::mirror(curve)); + (*cdp)(curvetracer::mirrory(curve)); + } + } + // argument 1/k +#if 0 { std::complex startz(1/k); std::complex startw(xmax, ymax); @@ -358,6 +385,26 @@ int main(int argc, char *argv[]) { (*cdp)(curvetracer::mirror(curve)); (*cdp)(curvetracer::mirrory(curve)); } +#endif + + // arguments larger than 1/k + { + double x0 = 1; + while (x0 <= 1/k + 0.0001) { x0 += deltax; } + for (; x0 < 4; x0 += deltax) { + std::complex startz(x0); + std::complex startw(gsl_sf_ellint_F( + asin(1/(k*x0)), k, GSL_PREC_DOUBLE), ymax); + curvetracer::curve_t curve = ct.trace(startz, dir, + startw, 1000); + cdp->color("red"); + (*cdp)(curve); + (*cdp)(curvetracer::mirrorx(curve)); + cdp->color("blue"); + (*cdp)(curvetracer::mirror(curve)); + (*cdp)(curvetracer::mirrory(curve)); + } + } // border (*cdp->out()) << "\\def\\xmax{" << xmax << "}" << std::endl; diff --git a/buch/chapters/110-elliptisch/images/rechteck.pdf b/buch/chapters/110-elliptisch/images/rechteck.pdf index 5fa07cb..845a550 100644 Binary files a/buch/chapters/110-elliptisch/images/rechteck.pdf and b/buch/chapters/110-elliptisch/images/rechteck.pdf differ -- cgit v1.2.1 From de63530c4baaac2bdbb2ca414a5f452ec18dce50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=BCller?= Date: Mon, 18 Oct 2021 08:57:18 +0200 Subject: better range image for elliptic integrals --- buch/chapters/110-elliptisch/images/rechteck.cpp | 1 + buch/chapters/110-elliptisch/images/rechteck.pdf | Bin 91630 -> 91630 bytes 2 files changed, 1 insertion(+) (limited to 'buch/chapters/110-elliptisch/images') diff --git a/buch/chapters/110-elliptisch/images/rechteck.cpp b/buch/chapters/110-elliptisch/images/rechteck.cpp index c3f6f1b..c65ae0f 100644 --- a/buch/chapters/110-elliptisch/images/rechteck.cpp +++ b/buch/chapters/110-elliptisch/images/rechteck.cpp @@ -389,6 +389,7 @@ int main(int argc, char *argv[]) { // arguments larger than 1/k { + dir = std::complex(0, 0.01); double x0 = 1; while (x0 <= 1/k + 0.0001) { x0 += deltax; } for (; x0 < 4; x0 += deltax) { diff --git a/buch/chapters/110-elliptisch/images/rechteck.pdf b/buch/chapters/110-elliptisch/images/rechteck.pdf index 845a550..894091f 100644 Binary files a/buch/chapters/110-elliptisch/images/rechteck.pdf and b/buch/chapters/110-elliptisch/images/rechteck.pdf differ -- cgit v1.2.1