diff options
Diffstat (limited to 'buch/chapters/040-rekursion/images')
-rw-r--r-- | buch/chapters/040-rekursion/images/0f1.cpp | 94 | ||||
-rw-r--r-- | buch/chapters/040-rekursion/images/0f1.pdf | bin | 0 -> 49497 bytes | |||
-rw-r--r-- | buch/chapters/040-rekursion/images/0f1.tex | 86 | ||||
-rw-r--r-- | buch/chapters/040-rekursion/images/Makefile | 16 | ||||
-rw-r--r-- | buch/chapters/040-rekursion/images/loggammaplot.m | 43 | ||||
-rw-r--r-- | buch/chapters/040-rekursion/images/loggammaplot.pdf | bin | 0 -> 30943 bytes | |||
-rw-r--r-- | buch/chapters/040-rekursion/images/loggammaplot.tex | 89 | ||||
-rw-r--r-- | buch/chapters/040-rekursion/images/order.pdf | bin | 32692 -> 32688 bytes | |||
-rw-r--r-- | buch/chapters/040-rekursion/images/order.tex | 2 |
9 files changed, 328 insertions, 2 deletions
diff --git a/buch/chapters/040-rekursion/images/0f1.cpp b/buch/chapters/040-rekursion/images/0f1.cpp new file mode 100644 index 0000000..24ca3f1 --- /dev/null +++ b/buch/chapters/040-rekursion/images/0f1.cpp @@ -0,0 +1,94 @@ +/* + * 0f1.cpp + * + * (c) 2022 Prof Dr Andreas Müller, OST Ostschweizer Fachhochschule + */ +#include <cstring> +#include <cstdio> +#include <cstdlib> +#include <cmath> +#include <string> +#include <iostream> +#include <fstream> + +static int N = 100; +static double xmin = -50; +static double xmax = 30; +static int points = 200; + +double f(double b, double x) { + double s = 1; + double p = 1; + for (int k = 1; k < N; k++) { + p = p * x / (k * (b + k - 1.)); + s += p; + } + return s; +} + +typedef std::pair<double, double> point_t; + +point_t F(double b, double x) { + return std::make_pair(x, f(b, x)); +} + +std::string ff(double f) { + if (f > 1000) { f = 1000; } + if (f < -1000) { f = -1000; } + char b[128]; + snprintf(b, sizeof(b), "%.4f", f); + return std::string(b); +} + +std::ostream& operator<<(std::ostream& out, const point_t& p) { + char b[128]; + out << "({" << ff(p.first) << "*\\dx},{" << ff(p.second) << "*\\dy})"; + return out; +} + +void curve(std::ostream& out, double b, const std::string& name) { + double h = (xmax - xmin) / points; + out << "\\def\\kurve" << name << "{"; + out << std::endl << "\t" << F(b, xmin); + for (int i = 1; i <= points; i++) { + double x = xmin + h * i; + out << std::endl << "\t-- " << F(b, x); + } + out << std::endl; + out << "}" << std::endl; +} + +int main(int argc, char *argv[]) { + std::ofstream out("0f1data.tex"); + + double s = 13/(xmax-xmin); + out << "\\def\\dx{" << ff(s) << "}" << std::endl; + out << "\\def\\dy{" << ff(s) << "}" << std::endl; + out << "\\def\\xmin{" << ff(s * xmin) << "}" << std::endl; + out << "\\def\\xmax{" << ff(s * xmax) << "}" << std::endl; + + curve(out, 0.5, "one"); + curve(out, 1.5, "two"); + curve(out, 2.5, "three"); + curve(out, 3.5, "four"); + curve(out, 4.5, "five"); + curve(out, 5.5, "six"); + curve(out, 6.5, "seven"); + curve(out, 7.5, "eight"); + curve(out, 8.5, "nine"); + curve(out, 9.5, "ten"); + + curve(out,-0.5, "none"); + curve(out,-1.5, "ntwo"); + curve(out,-2.5, "nthree"); + curve(out,-3.5, "nfour"); + curve(out,-4.5, "nfive"); + curve(out,-5.5, "nsix"); + curve(out,-6.5, "nseven"); + curve(out,-7.5, "neight"); + curve(out,-8.5, "nnine"); + curve(out,-9.5, "nten"); + + out.close(); + return EXIT_SUCCESS; +} diff --git a/buch/chapters/040-rekursion/images/0f1.pdf b/buch/chapters/040-rekursion/images/0f1.pdf Binary files differnew file mode 100644 index 0000000..2c35813 --- /dev/null +++ b/buch/chapters/040-rekursion/images/0f1.pdf diff --git a/buch/chapters/040-rekursion/images/0f1.tex b/buch/chapters/040-rekursion/images/0f1.tex new file mode 100644 index 0000000..1bc8b87 --- /dev/null +++ b/buch/chapters/040-rekursion/images/0f1.tex @@ -0,0 +1,86 @@ +% +% 0f1.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} +\def\skala{1} +\input{0f1data.tex} +\definecolor{darkgreen}{rgb}{0,0.6,0} +\begin{tikzpicture}[>=latex,thick,scale=\skala] + +\begin{scope} +\clip (\xmin,-1) rectangle (\xmax,5); +\draw[color=blue!5!red,line width=1.4pt] \kurveone; +\draw[color=blue!16!red,line width=1.4pt] \kurvetwo; +\draw[color=blue!26!red,line width=1.4pt] \kurvethree; +\draw[color=blue!37!red,line width=1.4pt] \kurvefour; +\draw[color=blue!47!red,line width=1.4pt] \kurvefive; +\draw[color=blue!57!red,line width=1.4pt] \kurvesix; +\draw[color=blue!68!red,line width=1.4pt] \kurveseven; +\draw[color=blue!78!red,line width=1.4pt] \kurveeight; +\draw[color=blue!89!red,line width=1.4pt] \kurvenine; +\draw[color=blue!100!red,line width=1.4pt] \kurveten; +\def\ds{0.4} +\begin{scope}[yshift=0.5cm] +\node[color=blue!5!red] at (\xmin,{1*\ds}) [right] {$\alpha=0.5$}; +\node[color=blue!16!red] at (\xmin,{2*\ds}) [right] {$\alpha=1.5$}; +\node[color=blue!26!red] at (\xmin,{3*\ds}) [right] {$\alpha=2.5$}; +\node[color=blue!37!red] at (\xmin,{4*\ds}) [right] {$\alpha=2.5$}; +\node[color=blue!47!red] at (\xmin,{5*\ds}) [right] {$\alpha=3.5$}; +\node[color=blue!57!red] at (\xmin,{6*\ds}) [right] {$\alpha=5.5$}; +\node[color=blue!68!red] at (\xmin,{7*\ds}) [right] {$\alpha=6.5$}; +\node[color=blue!78!red] at (\xmin,{8*\ds}) [right] {$\alpha=7.5$}; +\node[color=blue!89!red] at (\xmin,{9*\ds}) [right] {$\alpha=8.5$}; +\node[color=blue!100!red]at (\xmin,{10*\ds}) [right] {$\alpha=9.5$}; +\end{scope} +\node at (-1.7,4.5) {$\displaystyle +y=\mathstrut_0F_1\biggl(\begin{matrix}\text{---}\\\alpha\end{matrix};x\biggr)$}; +\end{scope} + +\draw[->] (\xmin-0.2,0) -- (\xmax+0.3,0) coordinate[label=$x$]; +\draw[->] (0,-0.5) -- (0,5.3) coordinate[label={right:$y$}]; + +\begin{scope}[yshift=-6.5cm] +\begin{scope} +\clip (\xmin,-5) rectangle (\xmax,5); + +\draw[color=darkgreen!5!red,line width=1.4pt] \kurvenone; +\draw[color=darkgreen!16!red,line width=1.4pt] \kurventwo; +\draw[color=darkgreen!26!red,line width=1.4pt] \kurventhree; +\draw[color=darkgreen!37!red,line width=1.4pt] \kurvenfour; +\draw[color=darkgreen!47!red,line width=1.4pt] \kurvenfive; +\draw[color=darkgreen!57!red,line width=1.4pt] \kurvensix; +\draw[color=darkgreen!68!red,line width=1.4pt] \kurvenseven; +\draw[color=darkgreen!78!red,line width=1.4pt] \kurveneight; +\draw[color=darkgreen!89!red,line width=1.4pt] \kurvennine; +\draw[color=darkgreen!100!red,line width=1.4pt] \kurventen; +\end{scope} + +\draw[->] (\xmin-0.2,0) -- (\xmax+0.3,0) coordinate[label=$x$]; +\draw[->] (0,-5.2) -- (0,5.3) coordinate[label={right:$y$}]; +\def\ds{-0.4} +\begin{scope}[yshift=-0.5cm] +\node[color=darkgreen!5!red] at (\xmax,{1*\ds}) [left] {$\alpha=-0.5$}; +\node[color=darkgreen!16!red] at (\xmax,{2*\ds}) [left] {$\alpha=-1.5$}; +\node[color=darkgreen!26!red] at (\xmax,{3*\ds}) [left] {$\alpha=-2.5$}; +\node[color=darkgreen!37!red] at (\xmax,{4*\ds}) [left] {$\alpha=-2.5$}; +\node[color=darkgreen!47!red] at (\xmax,{5*\ds}) [left] {$\alpha=-3.5$}; +\node[color=darkgreen!57!red] at (\xmax,{6*\ds}) [left] {$\alpha=-5.5$}; +\node[color=darkgreen!68!red] at (\xmax,{7*\ds}) [left] {$\alpha=-6.5$}; +\node[color=darkgreen!78!red] at (\xmax,{8*\ds}) [left] {$\alpha=-7.5$}; +\node[color=darkgreen!89!red] at (\xmax,{9*\ds}) [left] {$\alpha=-8.5$}; +\node[color=darkgreen!100!red]at (\xmax,{10*\ds}) [left] {$\alpha=-9.5$}; +\end{scope} +\end{scope} + +\end{tikzpicture} +\end{document} + diff --git a/buch/chapters/040-rekursion/images/Makefile b/buch/chapters/040-rekursion/images/Makefile index 86dfa1e..54ed23b 100644 --- a/buch/chapters/040-rekursion/images/Makefile +++ b/buch/chapters/040-rekursion/images/Makefile @@ -3,7 +3,8 @@ # # (c) 2021 Prof Dr Andreas Müller, OST Ostschweizer Fachhochschule # -all: gammaplot.pdf fibonacci.pdf order.pdf beta.pdf +all: gammaplot.pdf fibonacci.pdf order.pdf beta.pdf loggammaplot.pdf \ + 0f1.pdf gammaplot.pdf: gammaplot.tex gammapaths.tex pdflatex gammaplot.tex @@ -29,4 +30,17 @@ beta.pdf: beta.tex betapaths.tex betapaths.tex: betadist.m octave betadist.m +loggammaplot.pdf: loggammaplot.tex loggammadata.tex + pdflatex loggammaplot.tex +loggammadata.tex: loggammaplot.m + octave loggammaplot.m + +0f1: 0f1.cpp + g++ -O -Wall -g -o 0f1 0f1.cpp + +0f1data.tex: 0f1 + ./0f1 + +0f1.pdf: 0f1.tex 0f1data.tex + pdflatex 0f1.tex diff --git a/buch/chapters/040-rekursion/images/loggammaplot.m b/buch/chapters/040-rekursion/images/loggammaplot.m new file mode 100644 index 0000000..5456e4f --- /dev/null +++ b/buch/chapters/040-rekursion/images/loggammaplot.m @@ -0,0 +1,43 @@ +# +# loggammaplot.m +# +# (c) 2022 Prof Dr Andreas Müller, OST Ostschweizer Fachhochschule +# +xmax = 10; +xmin = 0.1; +N = 500; + +fn = fopen("loggammadata.tex", "w"); + +fprintf(fn, "\\def\\loggammapath{\n ({%.4f*\\dx},{%.4f*\\dy})", + xmax, log(gamma(xmax))); +xstep = (xmax - 1) / N; +for x = (xmax:-xstep:1) + fprintf(fn, "\n\t-- ({%.4f*\\dx},{%.4f*\\dy})", x, log(gamma(x))); +endfor +for k = (0:0.2:10) + x = exp(-k); + fprintf(fn, "\n\t-- ({%.4f*\\dx},{%.4f*\\dy})", x, log(gamma(x))); +endfor +fprintf(fn, "\n}\n"); + +function retval = lgp(fn, x0, name) + fprintf(fn, "\\def\\loggammaplot%s{\n", name); + fprintf(fn, "\\draw[color=red,line width=1pt] "); + for k = (-7:0.1:7) + x = x0 + 0.5 * tanh(k); + if (k > -5) + fprintf(fn, "\n\t-- "); + end + fprintf(fn, "({%.4f*\\dx},{%.4f*\\dy})", x, log(gamma(x))); + endfor + fprintf(fn, ";\n}\n"); +endfunction + +lgp(fn, -0.5, "zero"); +lgp(fn, -1.5, "one"); +lgp(fn, -2.5, "two"); +lgp(fn, -3.5, "three"); +lgp(fn, -4.5, "four"); + +fclose(fn); diff --git a/buch/chapters/040-rekursion/images/loggammaplot.pdf b/buch/chapters/040-rekursion/images/loggammaplot.pdf Binary files differnew file mode 100644 index 0000000..a2963f2 --- /dev/null +++ b/buch/chapters/040-rekursion/images/loggammaplot.pdf diff --git a/buch/chapters/040-rekursion/images/loggammaplot.tex b/buch/chapters/040-rekursion/images/loggammaplot.tex new file mode 100644 index 0000000..8ca4e1c --- /dev/null +++ b/buch/chapters/040-rekursion/images/loggammaplot.tex @@ -0,0 +1,89 @@ +% +% tikztemplate.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} +\def\skala{1} +\input{loggammadata.tex} +\begin{tikzpicture}[>=latex,thick,scale=\skala] + +% add image content here + +\def\dx{1} +\def\dy{0.6} +\def\xmax{8} +\def\xmin{-4.9} +\def\ymax{8} +\def\ymin{-3.1} + +\fill[color=blue!20] ({\xmin*\dx},{\ymin*\dy}) rectangle ({-4*\dx},{\ymax*\dy}); +\fill[color=blue!20] ({-3*\dx},{\ymin*\dy}) rectangle ({-2*\dx},{\ymax*\dy}); +\fill[color=blue!20] ({-1*\dx},{\ymin*\dy}) rectangle ({-0*\dx},{\ymax*\dy}); + +\draw[->] ({\xmin*\dx-0.1},0) -- ({\xmax*\dx+0.3},0) + coordinate[label={$x$}]; +\draw[->] (0,{\ymin*\dy-0.1}) -- (0,{\ymax*\dy+0.3}) + coordinate[label={right:$y$}]; + +\begin{scope} +\clip ({\xmin*\dx},{\ymin*\dy}) rectangle ({\xmax*\dx},{\ymax*\dy}); + +\foreach \x in {-1,-2,-3,-4}{ + \draw[color=blue,line width=0.3pt] + ({\x*\dx},{\ymin*\dy}) -- ({\x*\dx},{\ymax*\dy}); +} + +\draw[color=red,line width=1pt] \loggammapath; + +\loggammaplotzero +\loggammaplotone +\loggammaplottwo +\loggammaplotthree +\loggammaplotfour + +\end{scope} + +\foreach \y in {0.1,10,100,1000,1000}{ + \draw[line width=0.3pt] + ({\xmin*\dx},{ln(\y)*\dy}) + -- + ({\xmax*\dx},{ln(\y)*\dy}) ; +} + +\foreach \x in {1,...,8}{ + \draw ({\x*\dx},{-0.05}) -- ({\x*\dx},{0.05}); + \node at ({\x*\dx},0) [below] {$\x$}; +} + +\foreach \x in {-1,...,-4}{ + \draw ({\x*\dx},{-0.05}) -- ({\x*\dx},{0.05}); +} +\foreach \x in {-1,...,-3}{ + \node at ({\x*\dx},0) [below right] {$\x$}; +} +\node at ({-4*\dx},0) [below left] {$-4$}; + +\def\htick#1#2{ + \draw (-0.05,{ln(#1)*\dy}) -- (0.05,{ln(#1)*\dy}); + \node at (0,{ln(#1)*\dy}) [above right] {#2}; +} + +\htick{10}{$10^1$} +\htick{100}{$10^2$} +\htick{1000}{$10^3$} +\htick{0.1}{$10^{-1}$} + +\node[color=red] at ({3*\dx},{ln(30)*\dy}) {$y=\log|\Gamma(x)|$}; + + +\end{tikzpicture} +\end{document} + diff --git a/buch/chapters/040-rekursion/images/order.pdf b/buch/chapters/040-rekursion/images/order.pdf Binary files differindex cc175a9..88b2b08 100644 --- a/buch/chapters/040-rekursion/images/order.pdf +++ b/buch/chapters/040-rekursion/images/order.pdf diff --git a/buch/chapters/040-rekursion/images/order.tex b/buch/chapters/040-rekursion/images/order.tex index 9a2511c..0284735 100644 --- a/buch/chapters/040-rekursion/images/order.tex +++ b/buch/chapters/040-rekursion/images/order.tex @@ -65,7 +65,7 @@ \node at ({-0.1/\skala},{\y*\dy}) [left] {$\y$}; } -\node[color=darkgreen] at (0.65,{0.5*\dy}) [above,rotate=55] {$k=7$}; +\node[color=darkgreen] at ({0.64*\dx},{0.56*\dy}) [rotate=42] {$k=7$}; \begin{scope}[yshift=-0.7cm] \def\dy{0.125} |