aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Müller <afm@ws-mn-120019.hsr.ch>2021-10-26 12:56:06 +0200
committerAndreas Müller <afm@ws-mn-120019.hsr.ch>2021-10-26 12:56:06 +0200
commit26283a4a3d53f7871506ab320cbf356b2eaf4cf4 (patch)
tree50611106e111bc1f2760e5c607afbec283c90872
parentDifferentialgleichung für das mathematische Pendel (diff)
downloadSeminarSpezielleFunktionen-26283a4a3d53f7871506ab320cbf356b2eaf4cf4.tar.gz
SeminarSpezielleFunktionen-26283a4a3d53f7871506ab320cbf356b2eaf4cf4.zip
jacobiplots hinzugefügt
-rw-r--r--buch/chapters/110-elliptisch/images/Makefile28
-rw-r--r--buch/chapters/110-elliptisch/images/jacobi.cpp154
-rw-r--r--buch/chapters/110-elliptisch/images/jacobiplots.pdfbin0 -> 57199 bytes
-rw-r--r--buch/chapters/110-elliptisch/images/jacobiplots.tex93
-rw-r--r--buch/chapters/110-elliptisch/images/rechteck.pdfbin91630 -> 91639 bytes
-rw-r--r--buch/chapters/110-elliptisch/images/unvollstaendig.pdfbin46390 -> 46396 bytes
6 files changed, 273 insertions, 2 deletions
diff --git a/buch/chapters/110-elliptisch/images/Makefile b/buch/chapters/110-elliptisch/images/Makefile
index 5749ae0..f3f783f 100644
--- a/buch/chapters/110-elliptisch/images/Makefile
+++ b/buch/chapters/110-elliptisch/images/Makefile
@@ -4,7 +4,7 @@
# (c) 2021 Prof Dr Andreas Müller, OST Ostschweizer Fachhochschule
#
all: lemniskate.pdf ellipsenumfang.pdf unvollstaendig.pdf rechteck.pdf \
- ellipse.pdf pendel.pdf
+ ellipse.pdf pendel.pdf jacobiplots.pdf
lemniskate.pdf: lemniskate.tex
pdflatex lemniskate.tex
@@ -16,7 +16,7 @@ ekplot.tex: ellipsenumfang.m
octave ellipsenumfang.m
rechteck: rechteck.cpp
- g++ `pkg-config --cflags gsl` `pkg-config --libs gsl` -O -Wall -g -std=c++11 rechteck.cpp -o rechteck
+ g++ -O -Wall -g -std=c++11 rechteck.cpp -o rechteck `pkg-config --cflags gsl` `pkg-config --libs gsl`
rechteckpfade.tex: rechteck
./rechteck --outfile rechteckpfade.tex
@@ -36,3 +36,27 @@ ellipse.pdf: ellipse.tex
pendel.pdf: pendel.tex
pdflatex pendel.tex
+jacobi: jacobi.cpp
+ g++ -O -Wall -g -std=c++11 jacobi.cpp -o jacobi `pkg-config --cflags gsl` `pkg-config --libs gsl`
+
+test: blubb.tex
+
+blubb.tex: jacobi
+ ./jacobi --umax=14 --outfile=blubb.tex blubb 0.7
+
+jacobipaths.tex: jacobi Makefile
+ ./jacobi --umax=13 --steps=200 --outfile=jacobipaths.tex \
+ zero 0.00 \
+ one 0.2 \
+ two 0.4 \
+ three 0.6 \
+ four 0.8 \
+ five 0.9 \
+ six 0.99 \
+ seven 0.999 \
+ eight 0.9999 \
+ nine 0.99999 \
+ ten 1.0
+
+jacobiplots.pdf: jacobiplots.tex jacobipaths.tex
+ pdflatex jacobiplots.tex
diff --git a/buch/chapters/110-elliptisch/images/jacobi.cpp b/buch/chapters/110-elliptisch/images/jacobi.cpp
new file mode 100644
index 0000000..438fe48
--- /dev/null
+++ b/buch/chapters/110-elliptisch/images/jacobi.cpp
@@ -0,0 +1,154 @@
+/*
+ * jacobi.cpp
+ *
+ * (c) 2021 Prof Dr Andreas Müller, OST Ostschweizer Fachhochschule
+ */
+#include <cstdlib>
+#include <cstdio>
+#include <cmath>
+#include <gsl/gsl_sf_elljac.h>
+#include <vector>
+#include <iostream>
+#include <sstream>
+#include <fstream>
+#include <getopt.h>
+
+namespace jacobi {
+
+static struct option longopts[] {
+{ "k", required_argument, NULL, 'k' },
+{ "m", required_argument, NULL, 'm' },
+{ "outfile", required_argument, NULL, 'o' },
+{ "infile", required_argument, NULL, 'i' },
+{ "umin", required_argument, NULL, 'f' },
+{ "umax", required_argument, NULL, 't' },
+{ "steps", required_argument, NULL, 's' },
+{ NULL, 0, NULL, 0 }
+};
+
+/**
+ * \brief A class to contain a single plot
+ */
+class jacobiplot : public std::vector<std::pair<double,double> > {
+ std::string punkt(std::pair<double,double> x) const {
+ char buffer[128];
+ snprintf(buffer, sizeof(buffer), "({%.4f*\\dx},{%.4f*\\dy})",
+ x.first, x.second);
+ return std::string(buffer);
+ }
+public:
+ jacobiplot() { }
+ void write(std::ostream& out, const std::string& name) const {
+ out << "\\def\\" << name << "{" << std::endl;
+ auto i = begin();
+ out << punkt(*i);
+ for (i++; i != end(); i++) {
+ out << std::endl << " -- " << punkt(*i);
+ }
+ out << std::endl << "}" << std::endl;
+ }
+};
+
+/**
+ * \brief A class containing all three basic functions
+ */
+class jacobiplots {
+ jacobiplot _sn;
+ jacobiplot _cn;
+ jacobiplot _dn;
+ double _m;
+public:
+ const jacobiplot& sn() const { return _sn; }
+ const jacobiplot& cn() const { return _cn; }
+ const jacobiplot& dn() const { return _dn; }
+ jacobiplots(double m) : _m(m) { }
+ double m() const { return _m; }
+ void add(double umin, double umax, int steps) {
+ _sn.clear();
+ _cn.clear();
+ _dn.clear();
+ double h = (umax - umin) / steps;
+ for (int i = 0; i <= steps; i++) {
+ double u = umin + i * h;
+ double snvalue, cnvalue, dnvalue;
+ gsl_sf_elljac_e(u, m(), &snvalue, &cnvalue, &dnvalue);
+ _sn.push_back(std::make_pair(u, snvalue));
+ _cn.push_back(std::make_pair(u, cnvalue));
+ _dn.push_back(std::make_pair(u, dnvalue));
+ }
+ }
+ void write(std::ostream& out, const std::string& name) const {
+ out << "% name=" << name << ", m=" << m() << std::endl;
+ out << "\\def\\m" << name << "{" << m() << "}" << std::endl;
+ _sn.write(out, std::string("sn") + name);
+ _cn.write(out, std::string("cn") + name);
+ _dn.write(out, std::string("dn") + name);
+ }
+};
+
+int main(int argc, char *argv[]) {
+ int c;
+ int longindex;
+ std::ostream *out = &std::cout;
+ std::string infilename;
+ int steps = 100;
+ double umin = 0;
+ double umax = 10;
+ while (EOF != (c = getopt_long(argc, argv, "o:i:f:t:s:", longopts,
+ &longindex)))
+ switch (c) {
+ case 'o':
+ out = new std::ofstream(optarg);
+ (*out) << "%" << std::endl;
+ (*out) << "% " << optarg << std::endl;
+ (*out) << "%" << std::endl;
+ break;
+ case 'i':
+ infilename = std::string(optarg);
+ break;
+ case 'f':
+ umin = std::stod(optarg);
+ break;
+ case 't':
+ umax = std::stod(optarg);
+ break;
+ case 's':
+ steps = std::stoi(optarg);
+ break;
+ }
+
+ if (infilename.size() == 0) {
+ while ((optind + 1) < argc) {
+ std::string name(argv[optind++]);
+ double m = std::stod(argv[optind++]);
+ jacobiplots j(m);
+ j.add(umin, umax, steps);
+ j.write(*out, name);
+ }
+ } else {
+ std::ifstream infile(infilename);
+ while (!infile.eof()) {
+ std::string name;
+ double m;
+ infile >> name;
+ infile >> m;
+ jacobiplots j(m);
+ j.add(umin, umax, steps);
+ j.write(*out, name);
+ }
+ }
+
+ return EXIT_SUCCESS;
+}
+
+} // namespace jacobi
+
+int main(int argc, char *argv[]) {
+ try {
+ return jacobi::main(argc, argv);
+ } catch (const std::exception& x) {
+ std::cerr << "cannot build sn/cn/dn file: " << x.what();
+ std::cerr << std::endl;
+ }
+ return EXIT_FAILURE;
+}
diff --git a/buch/chapters/110-elliptisch/images/jacobiplots.pdf b/buch/chapters/110-elliptisch/images/jacobiplots.pdf
new file mode 100644
index 0000000..c1885c9
--- /dev/null
+++ b/buch/chapters/110-elliptisch/images/jacobiplots.pdf
Binary files differ
diff --git a/buch/chapters/110-elliptisch/images/jacobiplots.tex b/buch/chapters/110-elliptisch/images/jacobiplots.tex
new file mode 100644
index 0000000..4fc572e
--- /dev/null
+++ b/buch/chapters/110-elliptisch/images/jacobiplots.tex
@@ -0,0 +1,93 @@
+%
+% jacobiplots.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}
+\def\dx{1}
+\def\dy{2}
+\definecolor{darkgreen}{rgb}{0,0.6,0}
+\input{jacobipaths.tex}
+\def\piticks{
+ \draw (3.1415,-0.1) -- (3.1415,0.1);
+ \node at (3.1415,0) [below] {$\pi$};
+ \draw (6.2831,-0.1) -- (6.2831,0.1);
+ \node at (6.2831,0) [below] {$2\pi$};
+ \draw (9.4248,-0.1) -- (9.4248,0.1);
+ \node at (9.4248,0) [below] {$3\pi$};
+ \draw (12.5664,-0.1) -- (12.5664,0.1);
+ \node at (12.5664,0) [below] {$4\pi$};
+}
+\def\mlabel#1{
+%\fill[color=gray!50] (-0.2,-6) rectangle (7.0,2.3);
+\fill[color=gray!50] (-0.2,1.65) rectangle (7.0,2.3);
+\draw[line width=0.5pt] (-0.2,-6) rectangle (7.0,2.3);
+\begin{scope}[scale=0.5]
+\node at (6.5,{\dy+2}) {$m = #1$};
+\end{scope}
+}
+\def\jacobiplot#1#2#3#4{
+
+
+\begin{scope}[scale=0.5]
+\draw[->] (-0.1,0) -- (13.5,0) coordinate[label={$u$}];
+\piticks
+\draw[->] (0,-2.1) -- (0,2.5) coordinate[label={right:$\operatorname{sn}(u,k)$}];
+\draw[color=red#4] #1;
+\end{scope}
+
+\begin{scope}[yshift=-2.5cm,scale=0.5]
+\draw[->] (-0.1,0) -- (13.5,0) coordinate[label={$u$}];
+\piticks
+\draw[->] (0,-2.1) -- (0,2.5) coordinate[label={right:$\operatorname{cn}(u,k)$}];
+\draw[color=blue#4] #2;
+\end{scope}
+
+\begin{scope}[yshift=-5.5cm,scale=0.5]
+\draw[->] (-0.1,0) -- (13.5,0) coordinate[label={$u$}];
+\piticks
+\draw[->] (0,-0.1) -- (0,3.5) coordinate[label={right:$\operatorname{dn}(u,k)$}];
+\draw[color=darkgreen#4] #3;
+\end{scope}
+
+}
+%\input{blubb.tex}
+\begin{tikzpicture}[>=latex,thick,scale=\skala]
+
+\begin{scope}
+\mlabel{\mone}
+\jacobiplot{\snzero}{\cnzero}{\dnzero}{!50}
+\jacobiplot{\snone}{\cnone}{\dnone}{}
+\end{scope}
+
+\begin{scope}[xshift=7.3cm]
+\mlabel{\mfive}
+\jacobiplot{\snzero}{\cnzero}{\dnzero}{!50}
+\jacobiplot{\snfive}{\cnfive}{\dnfive}{}
+\end{scope}
+
+\begin{scope}[xshift=0cm,yshift=-8.4cm]
+\mlabel{\mseven}
+\jacobiplot{\snzero}{\cnzero}{\dnzero}{!50}
+%\jacobiplot{\sneight}{\cneight}{\dneight}{}
+\jacobiplot{\snseven}{\cnseven}{\dnseven}{}
+\end{scope}
+
+\begin{scope}[xshift=7.3cm,yshift=-8.4cm]
+\mlabel{\mnine}
+\jacobiplot{\snzero}{\cnzero}{\dnzero}{!50}
+\jacobiplot{\snnine}{\cnnine}{\dnnine}{}
+\end{scope}
+
+
+\end{tikzpicture}
+\end{document}
+
diff --git a/buch/chapters/110-elliptisch/images/rechteck.pdf b/buch/chapters/110-elliptisch/images/rechteck.pdf
index ea5869d..6209897 100644
--- a/buch/chapters/110-elliptisch/images/rechteck.pdf
+++ b/buch/chapters/110-elliptisch/images/rechteck.pdf
Binary files differ
diff --git a/buch/chapters/110-elliptisch/images/unvollstaendig.pdf b/buch/chapters/110-elliptisch/images/unvollstaendig.pdf
index f28495c..491f328 100644
--- a/buch/chapters/110-elliptisch/images/unvollstaendig.pdf
+++ b/buch/chapters/110-elliptisch/images/unvollstaendig.pdf
Binary files differ