From 531c564ecc1d73e1ddf25890720212d89f18edc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=BCller?= Date: Wed, 8 Dec 2021 20:15:41 +0100 Subject: add new stuff about airy and hypergeometric functions --- .../050-differential/uebungsaufgaben/501.tex | 63 +++++++++++ .../050-differential/uebungsaufgaben/502.tex | 60 +++++++++++ .../050-differential/uebungsaufgaben/503.tex | 19 ++++ .../050-differential/uebungsaufgaben/Makefile | 15 +++ .../050-differential/uebungsaufgaben/airy.cpp | 118 +++++++++++++++++++++ .../050-differential/uebungsaufgaben/airy.pdf | Bin 0 -> 18892 bytes .../050-differential/uebungsaufgaben/airy.tex | 59 +++++++++++ 7 files changed, 334 insertions(+) create mode 100644 buch/chapters/050-differential/uebungsaufgaben/501.tex create mode 100644 buch/chapters/050-differential/uebungsaufgaben/502.tex create mode 100644 buch/chapters/050-differential/uebungsaufgaben/503.tex create mode 100644 buch/chapters/050-differential/uebungsaufgaben/Makefile create mode 100644 buch/chapters/050-differential/uebungsaufgaben/airy.cpp create mode 100644 buch/chapters/050-differential/uebungsaufgaben/airy.pdf create mode 100644 buch/chapters/050-differential/uebungsaufgaben/airy.tex (limited to 'buch/chapters/050-differential/uebungsaufgaben') diff --git a/buch/chapters/050-differential/uebungsaufgaben/501.tex b/buch/chapters/050-differential/uebungsaufgaben/501.tex new file mode 100644 index 0000000..d27e21c --- /dev/null +++ b/buch/chapters/050-differential/uebungsaufgaben/501.tex @@ -0,0 +1,63 @@ +Finden Sie eine Lösung der Airy Differentialgleichung +\[ +y''-xy=0 +\] +mit Anfangsbedingungen $y(0)=a$ und $y'(0)=b$. + +\begin{loesung} +An der Stelle $x=0$ folgt aus der Differentialgleichung, dass $y''(0)=0$ +gelten muss. +In einem Potenzreihenansatz der Form +\begin{align*} +y(x) +&= +\sum_{k=0}^\infty a_kx^k +&&\Rightarrow& +y'(x) +&= +\sum_{k=1}^\infty a_kx^{k-1} +\\ +&&&& +y''(x) +&= +\sum_{k=2}^\infty k(k-1)a_kx^{k-2} +\end{align*} +kann man daher $a_2=0$ setzen und damit die Summation in der +Reihenentwicklung für $y''(x)$ erst bei $k=3$ beginnen. + +Setzt man den Ansatz in die Differentialgleichung ein, erhält man +\begin{align*} +0 +&= +y''(x)-xy(x) +\\ +&= +\sum_{k=3}^\infty k(k-1)a_kx^{k-2} +- +\sum_{k=0}^\infty a_kx^{k+1} +\\ +&= +\sum_{k=0}^\infty (k+3)(k+2)a_{k+3}x^{k+1} +- +\sum_{k=0}^\infty a_{k}x^{k+1} +\\ +&= +\sum_{k=0}^\infty \bigl((k+3)(k+2)a_{k+3}-a_{k}\bigr)x^{k+1}. +\end{align*} +Koeffizientenvergleich liefert jetzt die Rekursionsbeziehungen +\[ +a_{k+3} = \frac1{(k+3)(k+2)} {a_k}. +\] +Da $a_2=0$ ist folgt daraus auch, dass $a_5=a_8=a_{11}=\dots=0$ ist. + +Aus den Anfangsbedingungen liest man ab dass $a_0=a$ und $a_1=b$, daraus +kann man jetzt die Lösung konstruieren, es ist +\[ +y(x) += +a\biggl(1+\frac{1}{2\cdot 3}x^3 + \frac{1}{2\cdot3\cdot5\cdot 6}x^6 + \dots\biggr) ++ +b\biggl(x+\frac{1}{3\cdot 4}x^4 + \frac{1}{3\cdot 4\cdot 6\cdot 7}x^7+\dots\biggr). +\qedhere +\] +\end{loesung} diff --git a/buch/chapters/050-differential/uebungsaufgaben/502.tex b/buch/chapters/050-differential/uebungsaufgaben/502.tex new file mode 100644 index 0000000..cb0256d --- /dev/null +++ b/buch/chapters/050-differential/uebungsaufgaben/502.tex @@ -0,0 +1,60 @@ +Schreiben Sie die in Aufgabe~\ref{501} gefundenen Lösungen der +Airy-Differentialgleichung als hypergeometrische Funktionen. + +\begin{loesung} +Die Lösung für $a=1$ und $b=0$ hat die Reihenentwicklung +\begin{align*} +y_1(x) +&= +\sum_{k=0}^\infty +\frac{1}{2\cdot 3\cdot 5\cdot 6\cdot\ldots\cdot (3k-1)\cdot 3k} +x^{3k} +\\ +&= +\sum_{k=0}^\infty +\frac{1}{2\cdot 5\cdot \ldots\cdot (3k-1)} +\frac{1}{3\cdot 6\cdot \ldots\cdot 3k} +x^{3k} +\\ +&= +\sum_{k=0}^\infty +\frac{1}{3^k\cdot \frac23\cdot(\frac23+1)\cdot\ldots\cdot(\frac23+k-1)} +\frac{1}{3^k\cdot k!} +(x^3)^k +\\ +&= +\sum_{k=0}^\infty +\frac{1}{(\frac23)_k} \frac{1}{k!}\biggl(\frac{x^3}{9}\biggr)^k += +\mathstrut_0F_1\biggl( +\begin{matrix}\text{---}\\\frac23\end{matrix};\frac{x^3}{9} +\biggr). +\end{align*} +Aus der zweiten Lösung für $a=0$ und $b=1$ muss erst der gemeinsame +Faktor $x$ ausgeklammert werden: +\begin{align*} +y_2(x) +&= +x\sum_{k=0}^\infty +\frac{1}{3\cdot4\cdot 6\cdot 7\cdot\ldots\cdot 3k\cdot(3k+1)}x^{3k} +\\ +&= +x\sum_{k=0}^\infty +\frac{1}{4\cdot 7\cdot\ldots\cdot (3k+1)} +\frac{1}{3^k} +\frac{(x^3)^k}{k!} +\\ +&= +x\sum_{k=0}^\infty +\frac{1}{\frac43\cdot (\frac43+1)\cdot (\frac43+2)\cdot\ldots\cdot \frac43+k-1} +\frac{1}{(3^2)^k} +\frac{(x^3)^k}{k!} +\\ +&= +x\cdot\mathstrut_0F_1\biggl( +\begin{matrix}\text{---}\\\frac43\end{matrix}; +\frac{x^3}{9} +\biggr). +\qedhere +\end{align*} +\end{loesung} diff --git a/buch/chapters/050-differential/uebungsaufgaben/503.tex b/buch/chapters/050-differential/uebungsaufgaben/503.tex new file mode 100644 index 0000000..7cb47de --- /dev/null +++ b/buch/chapters/050-differential/uebungsaufgaben/503.tex @@ -0,0 +1,19 @@ +Verwenden Sie die Funktion \texttt{gsl_sf_hyperg_0F1} oder ein Programm, +welches die Reihenentwicklung der hypergeometrischen Funktion +$\mathstrut_0F_1$ direkt berechnet, um die +in Aufgabe \ref{501} gefundenen Lösungen der Airy-Differentialgleichung +zu plotten. + +\begin{loesung} +\begin{figure} +\centering +\includegraphics{chapters/050-differential/uebungsaufgaben/airy.pdf} +\caption{Plot der Lösungen der Airy-Differentialgleichung $y''-xy=0$ +zu den Anfangsbedingungen $y(0)=1$ und $y'(0)=0$ in {\color{red}rot} +und $y(0)=0$ und $y'(0)=1$ in {\color{blue}blau}. +\end{figure} +Die Implementation der hypergeometrische Funktion $\mathstrut_0F_1$ in der +GNU Scientific Library führt $\mathstrut_0F_1$ auf Bessel-Funktionen +zurück, was für $c=\frac23$ nicht möglich ist. +In diesem Fall ist also eine eigene Implementation nötig. +\end{loesung} diff --git a/buch/chapters/050-differential/uebungsaufgaben/Makefile b/buch/chapters/050-differential/uebungsaufgaben/Makefile new file mode 100644 index 0000000..b62f60c --- /dev/null +++ b/buch/chapters/050-differential/uebungsaufgaben/Makefile @@ -0,0 +1,15 @@ +# +# Makefile +# +# (c) 2021 Prof Dr Andreas Müller, OST Ostschweizer Fachhochschule +# +all: airy.pdf + +airy: airy.cpp + g++ -o airy -Wall -g -O2 `pkg-config --cflags gsl` airy.cpp `pkg-config --libs gsl` + +airypaths.tex: airy + ./airy --debug + +airy.pdf: airy.tex airypaths.tex + pdflatex airy.tex diff --git a/buch/chapters/050-differential/uebungsaufgaben/airy.cpp b/buch/chapters/050-differential/uebungsaufgaben/airy.cpp new file mode 100644 index 0000000..20cad38 --- /dev/null +++ b/buch/chapters/050-differential/uebungsaufgaben/airy.cpp @@ -0,0 +1,118 @@ +/* + * airy.cpp + * + * (c) 2021 Prof Dr Andreas Müller, OST Ostschweizer Fachhochschule + */ +#include +#include +#include +#include +#include +#include + +bool debug = false; + +struct option options[] = { +{ "debug", no_argument, 0, 'd' }, +{ "outfile", required_argument, 0, 'o' }, +{ "a", required_argument, 0, 'a' }, +{ "b", required_argument, 0, 'b' }, +{ "s", required_argument, 0, 's' }, +{ NULL, 0, 0, 0 } +}; + +double h0f1(double c, double x) { + if (debug) + fprintf(stderr, "%s:%d: c = %.5f, x = %.5f\n", + __FILE__, __LINE__, c, x); + double s = 0; + int k = 0; + double term = 1.; + s += term; + int counter = 0; + while (fabs(term) > 0.000000000001) { + k++; + term *= x / ((c+k-1) * k); + s += term; + // if (debug) + // fprintf(stderr, "term = %.14f\n", term); + counter++; + } + if (debug) + fprintf(stderr, "x = %f, terms = %d\n", x, counter); + return s; +} + +double f0(double x) { + //return gsl_sf_hyperg_0F1(2/3, x*x*x/9.); + return h0f1(2./3., x*x*x/9.); +} +double f1(double x) { + //return gsl_sf_hyperg_0F1(2/3, x*x*x/9.); + return h0f1(2./3., x*x*x/9.); +} + +double f2(double x) { + return x * gsl_sf_hyperg_0F1(4./3., x*x*x/9.); +} + +double f3(double x) { + return x * h0f1(4./3., x*x*x/9.); +} + +void plot(FILE *outfile, const char *name, double (*f)(double x), + double a, double b, int steps) { + fprintf(outfile, "\\def\\%s{\n", name); + fprintf(outfile, "({%.5f*\\dx},{%.5f*\\dy})", a, f(a)); + double h = (b-a)/steps; + for (int i = 0; i <= steps; i++) { + double x = a + h*i; + if (debug) + fprintf(stderr, "x = %.5f\n", x); + fprintf(outfile, "\n\t--({%.5f*\\dx},{%.5f*\\dy})", + x, f(x)); + } + fprintf(outfile, "}\n"); +} + +int main(int argc, char *argv[]) { + std::string outfilename("airypaths.tex"); + int c; + int longindex; + double a = -8; + double b = 2.5; + int steps = 200; + while (EOF != (c = getopt_long(argc, argv, "a:b:do:s:", + options, &longindex))) + switch (c) { + case 'a': + a = std::stod(optarg); + break; + case 'b': + b = std::stod(optarg); + break; + case 'd': + debug = true; + break; + case 'o': + outfilename = std::string(optarg); + break; + case 's': + steps = std::stoi(optarg); + break; + } + + if (debug) + fprintf(stderr, "%s:%d: outfile: '%s'\n", + __FILE__, __LINE__, outfilename.c_str()); + + FILE *outfile = fopen(outfilename.c_str(), "w"); + + plot(outfile, "yonepath", f1, a, b, 100); + plot(outfile, "ytwopath", f2, a, b, 100); + plot(outfile, "ythreepath", f3, a, b, 100); + + fclose(outfile); + + return EXIT_SUCCESS; +} diff --git a/buch/chapters/050-differential/uebungsaufgaben/airy.pdf b/buch/chapters/050-differential/uebungsaufgaben/airy.pdf new file mode 100644 index 0000000..f52e601 Binary files /dev/null and b/buch/chapters/050-differential/uebungsaufgaben/airy.pdf differ diff --git a/buch/chapters/050-differential/uebungsaufgaben/airy.tex b/buch/chapters/050-differential/uebungsaufgaben/airy.tex new file mode 100644 index 0000000..27ee546 --- /dev/null +++ b/buch/chapters/050-differential/uebungsaufgaben/airy.tex @@ -0,0 +1,59 @@ +% +% 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{airypaths.tex} +\definecolor{darkgreen}{rgb}{0,0.6,0} +\begin{tikzpicture}[>=latex,thick,scale=\skala] + +% add image content here +\def\dx{1} +\def\dy{1} + +\begin{scope} +\clip ({-8*\dx},{-1.3*\dy}) rectangle ({2.5*\dx},{4*\dy}); +\draw[color=red,line width=1.4pt] \yonepath; +%\draw[color=darkgreen,line width=1.4pt] \ytwopath; +\draw[color=blue,line width=1.4pt] \ythreepath; +\end{scope} + +\draw[->] (-8.1,0) -- (2.9,0) coordinate[label={$x$}]; +\draw[->] (0,-1.4) -- (0,4.4) coordinate[label={$y$}]; + +\foreach \x in {-8,...,-1}{ + \draw ({\x*\dx},-0.1) -- ({\x*\dx},0.1); +} +\foreach \y in {-1,1,2,3,4}{ + \draw (-0.1,{\y*\dy}) -- (0.1,{\y*\dy}); +} +\draw ({\dx},-0.1) -- ({\dx},0.1); +\draw ({2*\dx},-0.1) -- ({2*\dx},0.1); + +\node at (\dx,0) [below] {$1$}; +\node at ({2*\dx},0) [below] {$2$}; + +\foreach \x in {-7,...,-1}{ + \node at ({\x*\dx},0) [below] {$\x$}; +} +\foreach \y in {2,3,4}{ + \node at (-0.1,{\y*\dy}) [left] {$\y$}; +} +\node at (-0.1,\dy) [above left] {$-1$}; +\node at (0.1,-\dy) [right] {$-1$}; + +\node[color=red] at ({-1.2*\dx},{0.6*\dy}) [above left] {$y_1(x)$}; +\node[color=blue] at ({-1.4*\dx},{-1.1*\dy}) [below] {$y_2(x)$}; + +\end{tikzpicture} +\end{document} + -- cgit v1.2.1