From 6893688fccb63844102d8f1d728302d4eb823d68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=BCller?= Date: Sat, 18 Jun 2022 11:01:07 +0200 Subject: add new graphs --- buch/chapters/030-geometrie/trigonometrisch.tex | 12 +- buch/chapters/040-rekursion/gamma.tex | 130 +++++++++++++++++---- buch/chapters/040-rekursion/gammalimit/Makefile | 11 ++ buch/chapters/040-rekursion/gammalimit/l.cpp | 26 +++++ buch/chapters/040-rekursion/gammalimit/l.m | 19 +++ buch/chapters/040-rekursion/images/Makefile | 6 +- buch/chapters/040-rekursion/images/loggammaplot.m | 43 +++++++ .../chapters/040-rekursion/images/loggammaplot.pdf | Bin 0 -> 30948 bytes .../chapters/040-rekursion/images/loggammaplot.tex | 89 ++++++++++++++ 9 files changed, 309 insertions(+), 27 deletions(-) create mode 100644 buch/chapters/040-rekursion/gammalimit/Makefile create mode 100644 buch/chapters/040-rekursion/gammalimit/l.cpp create mode 100644 buch/chapters/040-rekursion/gammalimit/l.m create mode 100644 buch/chapters/040-rekursion/images/loggammaplot.m create mode 100644 buch/chapters/040-rekursion/images/loggammaplot.pdf create mode 100644 buch/chapters/040-rekursion/images/loggammaplot.tex (limited to 'buch/chapters') diff --git a/buch/chapters/030-geometrie/trigonometrisch.tex b/buch/chapters/030-geometrie/trigonometrisch.tex index dc1f46a..047e6cb 100644 --- a/buch/chapters/030-geometrie/trigonometrisch.tex +++ b/buch/chapters/030-geometrie/trigonometrisch.tex @@ -167,11 +167,11 @@ und umgekehrt: \[ \sin\alpha = -\sqrt{1-\cos^2\alpha\mathstrut} +\sqrt{1-{\cos\mathstrut\!}^2\,\alpha\mathstrut} \qquad\text{und}\qquad \cos\alpha = -\sqrt{1-\sin^2\alpha\mathstrut} +\sqrt{1-{\sin\mathstrut\!}^2\,\alpha\mathstrut} \] Da sich alle Funktionen durch $\cos\alpha$ und $\sin\alpha$ ausdrücken lassen, können alle auch nur durch eine ausgedrückt werden. @@ -197,7 +197,7 @@ Tabelle~\ref{buch:geometrie:tab:trigo} zusammengestellt ist. &\displaystyle\frac{\sqrt{\csc^2\alpha-1}}{\csc\alpha} \\ \cos\alpha - &\sqrt{1-\sin^2\alpha\mathstrut} + &\sqrt{1-\sin{\!}^2\,\alpha\mathstrut} &\cos\alpha &\displaystyle\frac{1}{\sqrt{1+\tan^2\alpha}} &\displaystyle\frac{\cot\alpha}{\sqrt{1+\cot^2\alpha}} @@ -205,7 +205,7 @@ Tabelle~\ref{buch:geometrie:tab:trigo} zusammengestellt ist. &\displaystyle\frac{1}{\csc\alpha} \\ \tan\alpha - &\displaystyle\frac{\sin\alpha}{\sqrt{1-\sin^2\alpha\mathstrut}} + &\displaystyle\frac{\sin\alpha}{\sqrt{1-\sin{\!}^2\,\alpha\mathstrut}} &\displaystyle\frac{\sqrt{1-\cos^2\alpha\mathstrut}}{\cos\alpha} &\tan\alpha &\displaystyle\frac{1}{\cot\alpha} @@ -213,7 +213,7 @@ Tabelle~\ref{buch:geometrie:tab:trigo} zusammengestellt ist. &\displaystyle\sqrt{\csc^2\alpha-1} \\ \cot\alpha - &\displaystyle\frac{\sqrt{1-\sin^2\alpha\mathstrut}}{\sin\alpha} + &\displaystyle\frac{\sqrt{1-\sin{\!}^2\,\alpha\mathstrut}}{\sin\alpha} &\displaystyle\frac{\cos\alpha}{\sqrt{1-\cos^2\alpha\mathstrut}} &\displaystyle\frac{1}{\tan\alpha} &\cot\alpha @@ -229,7 +229,7 @@ Tabelle~\ref{buch:geometrie:tab:trigo} zusammengestellt ist. &\displaystyle\frac{\csc\alpha}{\sqrt{\csc^2\alpha-1}} \\ \csc\alpha - &\displaystyle\frac{1}{\sqrt{1-\sin^2\alpha\mathstrut}} + &\displaystyle\frac{1}{\sqrt{1-\sin{\!}^2\,\alpha\mathstrut}} &\displaystyle\frac{1}{\cos\alpha} &\displaystyle\sqrt{1+\tan^2\alpha} &\displaystyle\frac{\sqrt{1+\cot^2\alpha}}{\cot\alpha} diff --git a/buch/chapters/040-rekursion/gamma.tex b/buch/chapters/040-rekursion/gamma.tex index 8c02752..e4dfa9a 100644 --- a/buch/chapters/040-rekursion/gamma.tex +++ b/buch/chapters/040-rekursion/gamma.tex @@ -203,7 +203,41 @@ x\lim_{n\to\infty} Weil $n/(n+1)\to 1$ ist und die Funktion $z\mapsto z^{x-1}$ für alle nach der Definition zulässigen Werte von $x$ eine stetige Funktion ist. +% +% +% \subsubsection{Numerische Unzulänglichkeiten der Grenzwertdefinition} +\begin{table} +\centering +%\renewcommand{\arraystretch}{1.1} +\begin{tabular}{|>{$}c<{$}|>{$}r<{$}|>{$}l<{$}|>{$}l<{$}|} +\hline +\log_{10} n& n&n!n^{x-1}/(x)_n\mathstrut & \text{Fehler% +\vrule height12pt depth6pt width0pt} \\ +\hline +\text{\vrule height12pt depth0pt width0pt} + 1& 10&1.\underline{7}947392559855804&0.0222854050800643\\ + 2& 100&1.\underline{77}46707942830697&0.0022169433775536\\ + 3& 1000&1.\underline{772}6754214755178&0.0002215705700017\\ + 4& 10000&1.\underline{7724}760067171375&0.0000221558116213\\ + 5& 100000&1.\underline{77245}60664742375&0.0000022155687214\\ + 6& 1000000&1.\underline{77245}40724623101&0.0000002215567940\\ + 7& 10000000&1.\underline{7724538}730613721&0.0000000221558560\\ + 8& 100000000&1.\underline{77245385}31233258&0.0000000022178097\\ + 9& 1000000000&1.\underline{77245385}11320680&0.0000000002265519\\ + 10& 10000000000&1.\underline{772453850}9261316&0.0000000000206155\\ + 11&100000000000&1.\underline{77245385}14549788&0.0000000005494627\\ + & \infty&1.\underline{7724538509055161}& +\text{\vrule height12pt depth6pt width0pt} \\ +\hline +\end{tabular} +\caption{Numerische Berechnung mit der Grenzwertdefinition +und rekursiver Berechnung von $n!/(x)_n$ mit Hilfe der Folge +\eqref{buch:rekursion:gamma:pnfolge}. +Die Konvergenz ist sehr langsam, die Anzahl korrekter Stellen +wächst logarithmisch mit $n$. +\label{buch:rekursion:gamma:produktberechnung}} +\end{table} Die Grenzwertdefinition~\ref{buch:rekursion:gamma:def:definition} ist zwar zweifellos richtig, kann aber nicht für die numerische Berechnung der Gamma-Funktion verwendet werden. @@ -237,6 +271,24 @@ ist. Die Approximation mit Hilfe der Grenzwertdefinition kann also grundsätzlich nicht mehr als zwei korrekte Nachkommastellen liefern. +Den Quotienten $n!/(x)_n$ kann man mit Hilfe der Rekursionsformel +\begin{equation} +p_n = p_{n-1}\cdot \frac{n}{x+n-1},\qquad +p_0 = 0 +\label{buch:rekursion:gamma:pnfolge} +\end{equation} +etwas effizienter berechnen. +Insbesondere umgeht man damit das Problem, dass $n!$ den Wertebereich +des \texttt{double} Datentyps sprengt. +Der Wert der Gamma-Funktion kann dann durch $p_nn^{x-1}$ approximiert +werden. +Die Tabelle~\ref{buch:rekursion:gamma:produktberechnung} fasst die +Resultate zusammen und zeigt, dass die Konvergenz logarithmisch ist: +die Anzahl korrekter Nachkommastellen ist $\log_{10}n$. + +% +% Produktformel +% \subsection{Produktformel} Ein möglicher Ausweg aus den numerischen Schwierigkeiten mit der Grenzwertdefinition ist, den schnell wachsenden Faktor $n!$ @@ -253,8 +305,10 @@ xe^{\gamma x} \prod_{k=1}^\infty \biggl(1+\frac{x}k\biggr)\,e^{-\frac{x}{k}}, \label{buch:rekursion:gamma:eqn:produktformel} +\index{Gamma-Funktion!Produktformel}% \end{equation} wobei $\gamma$ die Euler-Mascheronische Konstante +\index{Euler-Mascheronische Konstante}% \[ \gamma = @@ -368,16 +422,20 @@ vollständig bewiesen. \begin{table} \centering -\begin{tabular}{|>{$}c<{$}|>{$}c<{$}|>{$}c<{$}|} +\begin{tabular}{|>{$}c<{$}|>{$}r<{$}|>{$}c<{$}|>{$}c<{$}|} \hline -k & \Gamma(\frac12,n) & \Gamma(\frac12) - \Gamma(\frac12,n) \\ +k & n & \Gamma(\frac12,n) & \Gamma(\frac12) - \Gamma(\frac12,n)% +\text{\vrule height12pt depth6pt width0pt} \\ \hline -1 & 1.\underline{7}518166478 & -0.0206372031 \\ -2 & 1.\underline{77}02543372 & -0.0021995137 \\ -3 & 1.\underline{772}2324556 & -0.0002213953 \\ -4 & 1.\underline{7724}316968 & -0.0000221541 \\ -5 & 1.\underline{77245}16354 & -0.0000022156 \\ -6 & 1.\underline{772453}6293 & -0.0000002216 \\ +\text{\vrule height12pt depth0pt width0pt} + 1& 10& 1.\underline{7}518166478& -0.0206372031 \\ + 2& 100& 1.\underline{77}02543372& -0.0021995137 \\ + 3& 1000& 1.\underline{772}2324556& -0.0002213953 \\ + 4& 10000& 1.\underline{7724}316968& -0.0000221541 \\ + 5& 100000& 1.\underline{77245}16354& -0.0000022156 \\ + 6&1000000& 1.\underline{772453}6293& -0.0000002216 \\ +\infty& & 1.\underline{7724538509}& +\text{\vrule height12pt depth6pt width0pt} \\ \hline \end{tabular} \caption{Werte $\Gamma(\frac12,n)$ von $\Gamma(\frac12)$ berechnet mit @@ -385,6 +443,9 @@ $n=10^k$ Faktoren der Produktformel~\eqref{buch:rekursion:gamma:eqn:produktformel} und der zugehörige Fehler. Die korrekten Nachkommastellen sind unterstrichen. +Die Konvergenz ist genau gleich langsam wie in der Berechnung mit +Hilfe der Grenzwert-Definition in +Tabelle~\ref{buch:rekursion:gamma:produktberechnung}. \label{buch:rekursion:gamma:gammatabelle}} \end{table} @@ -436,6 +497,9 @@ die richtigen Werte für natürliche Argumente hat, es wird aber auch gezeigt, dass dies nicht ausreicht um zu schliessen, dass die Integralformel mit der früher definierten Gamma-Funktion übereinstimmt. +% +% Funktionalgleichung für die Integraldefinition +% \subsubsection{Funktionalgleichung für die Integraldefinition} Tatsächlich ist es einfach nachzuprüfen, dass die Funktionalgleichung der Gamma-Funktion auch für die Definition~\ref{buch:rekursion:def:gamma} @@ -494,6 +558,9 @@ die Werte der Fakultät annimmt. \label{buch:rekursion:fig:gamma}} \end{figure} +% +% Der Wert Gamma(1/2) +% \subsubsection{Der Wert $\Gamma(\frac12)$} Die Integraldarstellung kann dazu verwendet werden, $\Gamma(\frac12)$ zu berechnen. @@ -516,7 +583,11 @@ der Gamma-Funktion und berechnen Der Integrand im letzten Integral ist die Wahrscheinlichkeitsdichte einer Normalverteilung, deren Integral wohlbekannt ist. -\subsubsection{Alternative Lösungen} +% +% Alternative Lösungen +% +\subsubsection{Alternative Lösungen der +Funktionalgleichung~\ref{buch:rekursion:eqn:gammadef}} Die Funktion $\Gamma(z)$ ist nicht die einzige Funktion, die natürlichen Zahlen die Werte $\Gamma(n+1) = n!$ der Fakultät annimmt. Indem man eine beliebige Funktion $f(z)$ addiert, die auf alle @@ -560,6 +631,9 @@ Dann ist $ f(z) = \Gamma(z) $. % XXX Gamma in the interval (1,2) %Man beachte, dass +% +% Laplace-Transformierte der Potenzfunktion +% \subsubsection{Laplace-Transformierte der Potenzfunktion} Die Integraldarstellung der Gamma-Funktion erlaubt jetzt auch, die Laplace-Transformation der Potenzfunktion zu berechnen. @@ -594,6 +668,9 @@ Durch die Substitution $st = u$ oder $t=\frac{u}{s}$ wird daraus \] \end{proof} +% +% Pol erster Ordnung bei z=0 +% \subsubsection{Pol erster Ordnung bei $z=0$} Wir haben zu prüfen, dass sowohl der Wert $\Gamma(1)$ korrekt ist als auch die Rekursionsformel~\eqref{buch:rekursion:eqn:gammadef} gilt. @@ -644,6 +721,9 @@ Daraus ergibt sich für $\Gamma(z)$ der Ausdruck \] Die Gamma-Funktion hat daher an der Stelle $z=0$ einen Pol erster Ordnung. +% +% Ausdehnung auf Re(z) < 0 +% \subsubsection{Ausdehnung auf $\operatorname{Re}z<0$} Die Integralformel konvergiert nicht für $\operatorname{Re}z\le 0$. Durch analytische Fortsetzung, wie sie im @@ -683,22 +763,29 @@ Somit hat $\Gamma(z)$ Pole erster Ordnung bei den negativen ganzen Zahlen und bei $0$, wie sie in Abbildung~\ref{buch:rekursion:fig:gamma} gezeigt werden. +% +% Numerische Berechnung +% \subsubsection{Numerische Berechnung} \begin{table} \centering -\begin{tabular}{|>{$}c<{$}|>{$}c<{$}>{$}c<{$}|} +\begin{tabular}{|>{$}c<{$}|>{$}r<{$}|>{$}c<{$}>{$}c<{$}|} \hline -k & y(10^k) & y(10^k) - \Gamma(\frac{5}{2}) \\ +k & n=10^k & y(n) & y(n) - \Gamma(\frac{5}{3})  +\text{\vrule height12pt depth6pt width0pt} \\ \hline -1 & 0.0000000000 & -0.9027452930 \\ -2 & 0.3319129461 & -0.5708323468 \\ -3 & 0.\underline{902}5209490 & -0.0002243440 \\ -4 & 0.\underline{902745}1207 & -0.0000001723 \\ -5 & 0.\underline{902745}0962 & -0.0000001968 \\ -6 & 0.\underline{902745}0962 & -0.0000001968 \\ +\text{\vrule height12pt depth0pt width0pt} +1 & 10 & 0.0000000000 & -0.9027452930 \\ +2 & 100 & 0.3319129461 & -0.5708323468 \\ +3 & 1000 & 0.\underline{902}5209490 & -0.0002243440 \\ +4 & 10000 & 0.\underline{902745}1207 & -0.0000001723 \\ +5 & 100000 & 0.\underline{902745}0962 & -0.0000001968 \\ +6 & 1000000 & 0.\underline{902745}0962 & -0.0000001968 \\ + & \infty & 0.\underline{9027452929} & +\text{\vrule height12pt depth6pt width0pt} \\ \hline \end{tabular} -\caption{Resultate der Berechnung von $\Gamma(\frac{5}{2})$ mit Hilfe +\caption{Resultate der Berechnung von $\Gamma(\frac{5}{3})$ mit Hilfe der Differentialgleichung \eqref{buch:rekursion:gamma:eqn:gammadgl}. Die korrekten Stellen sind unterstrichen. Es sind immerhin sechs korrekte Stellen gefunden, wobei nur 337 @@ -708,7 +795,7 @@ Auswertungen des Integranden notwendig waren. Im Prinzip könnte die Integraldefinition der numerischen Berechnung entgegenkommen. Um diese Hypothese zu prüfen, berechnen wir das Integral für -$z=\frac52$ mit Hilfe der äquivalenten Differentialgleichungen +$z=\frac53$ mit Hilfe der äquivalenten Differentialgleichungen \begin{equation} \dot{y}(t) = t^{z-1}e^{-t} \qquad\text{mit Anfangsbedingung $y(0)=0$}. @@ -717,10 +804,13 @@ $z=\frac52$ mit Hilfe der äquivalenten Differentialgleichungen Der gesuchte Wert ist der Grenzwert $\lim_{t\to\infty} y(t)$. In der Tabelle~\ref{buch:rekursion:gamma:table:gammaintegral} sind die Werte von $y(10^k)$ sowie die Differenzen -$y(10^k) - \Gamma(\frac{5}{2})$ zusammengefasst. +$y(10^k) - \Gamma(\frac{5}{3})$ zusammengefasst. Die Genauigkeit erreicht sechs korrekte Nachkommastellen mit nur 337 Auswertungen des Integranden. +Eine noch wesentlich effizientere Auswertung des $\Gamma$-Integrals +mit Hilfe der Gauss-Laguerre-Quadratur wird in Kapitel~\ref{chapter:laguerre} +von Patrick Müller dargestellt. % % diff --git a/buch/chapters/040-rekursion/gammalimit/Makefile b/buch/chapters/040-rekursion/gammalimit/Makefile new file mode 100644 index 0000000..0804e74 --- /dev/null +++ b/buch/chapters/040-rekursion/gammalimit/Makefile @@ -0,0 +1,11 @@ +# +# Makefile -- build gamma limit test programm +# +# (c) 2022 Prof Dr Andreas Müller, OST Ostschweizer Fachhochschule +# +l: l.cpp + g++ -O2 -g -Wall `pkg-config --cflags gsl` `pkg-config --libs gsl` \ + -o l l.cpp + +test: l + ./l diff --git a/buch/chapters/040-rekursion/gammalimit/l.cpp b/buch/chapters/040-rekursion/gammalimit/l.cpp new file mode 100644 index 0000000..7a86800 --- /dev/null +++ b/buch/chapters/040-rekursion/gammalimit/l.cpp @@ -0,0 +1,26 @@ +/* + * l.cpp + * + * (c) 2022 Prof Dr Andreas Müller, OST Ostschweizer Fachhochschule + */ +#include +#include +#include + +int main(int argc, char *argv[]) { + double x = 0.5; + double g = tgamma(x); + printf("limit: %20.16f\n", g); + double p = 1; + long long N = 100000000000; + long long n = 10; + for (long long k = 1; k <= N; k++) { + p = p * k / (x + k - 1); + if (0 == k % n) { + double gval = p * pow(k, x-1); + printf("%12ld %20.16f %20.16f\n", k, gval, gval - g); + n = n * 10; + } + } + return EXIT_SUCCESS; +} diff --git a/buch/chapters/040-rekursion/gammalimit/l.m b/buch/chapters/040-rekursion/gammalimit/l.m new file mode 100644 index 0000000..32b6442 --- /dev/null +++ b/buch/chapters/040-rekursion/gammalimit/l.m @@ -0,0 +1,19 @@ +# +# l.m -- Berechnung der Gamma-Funktion +# +# (c) 2022 Prof Dr Andreas Müller, OST Ostschweizer Fachhochschule +# +global N; +N = 10000; + +function retval = gamma(x, n) + p = 1; + for k = (1:n) + p = p * k / (x + k - 1); + end + retval = p * n^(x-1); +endfunction + +for n = (100:100:N) + printf("Gamma(%4d) = %10f\n", n, gamma(0.5, n)); +end diff --git a/buch/chapters/040-rekursion/images/Makefile b/buch/chapters/040-rekursion/images/Makefile index 86dfa1e..a1884f4 100644 --- a/buch/chapters/040-rekursion/images/Makefile +++ b/buch/chapters/040-rekursion/images/Makefile @@ -3,7 +3,7 @@ # # (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 gammaplot.pdf: gammaplot.tex gammapaths.tex pdflatex gammaplot.tex @@ -29,4 +29,8 @@ 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 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 new file mode 100644 index 0000000..8ac9eb4 Binary files /dev/null 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 new file mode 100644 index 0000000..c3c17ea --- /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{7.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} + -- cgit v1.2.1