From 3a95957a38a1cc8bcd865459a75cda87a2a8b56c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=BCller?= Date: Sat, 18 Jun 2022 21:41:57 +0200 Subject: add new image, stuff about hypergeometrich series --- buch/chapters/040-rekursion/images/0f1.cpp | 94 +++++++++++++++++++++ buch/chapters/040-rekursion/images/0f1.pdf | Bin 0 -> 49497 bytes buch/chapters/040-rekursion/images/0f1.tex | 86 +++++++++++++++++++ buch/chapters/040-rekursion/images/Makefile | 12 ++- .../chapters/040-rekursion/images/loggammaplot.pdf | Bin 30948 -> 30943 bytes .../chapters/040-rekursion/images/loggammaplot.tex | 2 +- 6 files changed, 192 insertions(+), 2 deletions(-) create mode 100644 buch/chapters/040-rekursion/images/0f1.cpp create mode 100644 buch/chapters/040-rekursion/images/0f1.pdf create mode 100644 buch/chapters/040-rekursion/images/0f1.tex (limited to 'buch/chapters/040-rekursion/images') 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 +#include +#include +#include +#include +#include +#include + +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 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 new file mode 100644 index 0000000..2c35813 Binary files /dev/null and b/buch/chapters/040-rekursion/images/0f1.pdf differ 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 a1884f4..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 loggammaplot.pdf +all: gammaplot.pdf fibonacci.pdf order.pdf beta.pdf loggammaplot.pdf \ + 0f1.pdf gammaplot.pdf: gammaplot.tex gammapaths.tex pdflatex gammaplot.tex @@ -34,3 +35,12 @@ loggammaplot.pdf: loggammaplot.tex loggammadata.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.pdf b/buch/chapters/040-rekursion/images/loggammaplot.pdf index 8ac9eb4..a2963f2 100644 Binary files a/buch/chapters/040-rekursion/images/loggammaplot.pdf and b/buch/chapters/040-rekursion/images/loggammaplot.pdf differ diff --git a/buch/chapters/040-rekursion/images/loggammaplot.tex b/buch/chapters/040-rekursion/images/loggammaplot.tex index c3c17ea..8ca4e1c 100644 --- a/buch/chapters/040-rekursion/images/loggammaplot.tex +++ b/buch/chapters/040-rekursion/images/loggammaplot.tex @@ -19,7 +19,7 @@ \def\dx{1} \def\dy{0.6} -\def\xmax{7.8} +\def\xmax{8} \def\xmin{-4.9} \def\ymax{8} \def\ymin{-3.1} -- cgit v1.2.1