aboutsummaryrefslogtreecommitdiffstats
path: root/buch/papers/0f1
diff options
context:
space:
mode:
authorFabian <@>2022-07-26 21:27:23 +0200
committerFabian <@>2022-07-26 21:27:23 +0200
commitc53e9fe25866376d1b3086579c01725444a04702 (patch)
treeb907a6f6269b481a697cda63dea995a54886c458 /buch/papers/0f1
parent0f1, Mathe done (diff)
downloadSeminarSpezielleFunktionen-c53e9fe25866376d1b3086579c01725444a04702.tar.gz
SeminarSpezielleFunktionen-c53e9fe25866376d1b3086579c01725444a04702.zip
0f1, Code ueberarbeitet
Diffstat (limited to 'buch/papers/0f1')
-rw-r--r--buch/papers/0f1/listings/kettenbruchIterativ.c16
-rw-r--r--buch/papers/0f1/listings/kettenbruchRekursion.c22
-rw-r--r--buch/papers/0f1/listings/potenzreihe.c56
-rw-r--r--buch/papers/0f1/teil2.tex6
4 files changed, 86 insertions, 14 deletions
diff --git a/buch/papers/0f1/listings/kettenbruchIterativ.c b/buch/papers/0f1/listings/kettenbruchIterativ.c
index befea8e..d897b8f 100644
--- a/buch/papers/0f1/listings/kettenbruchIterativ.c
+++ b/buch/papers/0f1/listings/kettenbruchIterativ.c
@@ -1,5 +1,13 @@
-static double fractionRekursion0f1(const double c, const double x, unsigned int n)
+/**
+ * @brief Calculates the Hypergeometric Function 0F1(;b;z)
+ * @param b0 in 0F1(;b0;z)
+ * @param z in 0F1(;b0;z)
+ * @param n number of itertions (precision)
+ * @return Result
+ */
+static double fractionRekursion0f1(const double c, const double z, unsigned int n)
{
+ //declaration
double a = 0.0;
double b = 0.0;
double Ak = 0.0;
@@ -21,15 +29,15 @@ static double fractionRekursion0f1(const double c, const double x, unsigned int
else if (k == 1)
{
a = 1.0; //a1
- b = x/c; //b1
+ b = z/c; //b1
//recursion fomula for A1, B1
Ak = a * Ak_1 + b * 1.0;
Bk = a * Bk_1;
}
else
{
- a = 1 + (x / (k * ((k - 1) + c)));//ak
- b = -(x / (k * ((k - 1) + c))); //bk
+ a = 1 + (z / (k * ((k - 1) + c)));//ak
+ b = -(z / (k * ((k - 1) + c))); //bk
//recursion fomula for Ak, Bk
Ak = a * Ak_1 + b * Ak_2;
Bk = a * Bk_1 + b * Bk_2;
diff --git a/buch/papers/0f1/listings/kettenbruchRekursion.c b/buch/papers/0f1/listings/kettenbruchRekursion.c
index 958d4e1..143683f 100644
--- a/buch/papers/0f1/listings/kettenbruchRekursion.c
+++ b/buch/papers/0f1/listings/kettenbruchRekursion.c
@@ -1,18 +1,26 @@
-static double fractionIter0f1(const double b0, const double z, unsigned int n)
+/**
+ * @brief Calculates the Hypergeometric Function 0F1(;c;z)
+ * @param c in 0F1(;c;z)
+ * @param z in 0F1(;c;z)
+ * @param k number of itertions (precision)
+ * @return Result
+ */
+static double fractionIter0f1(const double c, const double z, unsigned int k)
{
+ //declaration
double a = 0.0;
double b = 0.0;
- double abn = 0.0;
+ double abk = 0.0;
double temp = 0.0;
- for (; n > 0; --n)
+ for (; k > 0; --k)
{
- abn = z / (n * ((n - 1) + b0)); //abn = ak, bk
+ abk = z / (k * ((k - 1) + c)); //abk = ak, bk
- a = n > 1 ? (1 + abn) : 1; //a0, a1
- b = n > 1 ? -abn : abn; //b1
+ a = k > 1 ? (1 + abk) : 1; //a0, a1
+ b = k > 1 ? -abk : abk; //b1
- temp = b / (a + temp);
+ temp = b / (a + temp); ////bk / (ak + last result)
}
return a + temp; //a0 + temp
diff --git a/buch/papers/0f1/listings/potenzreihe.c b/buch/papers/0f1/listings/potenzreihe.c
index bfaa0e3..3eb9b86 100644
--- a/buch/papers/0f1/listings/potenzreihe.c
+++ b/buch/papers/0f1/listings/potenzreihe.c
@@ -1,5 +1,61 @@
#include <math.h>
+/**
+ * @brief Calculates pochhammer
+ * @param (a+n-1)!
+ * @return Result
+ */
+static double pochhammer(const double x, double n)
+{
+ double temp = x;
+
+ if (n > 0)
+ {
+ while (n > 1)
+ {
+ temp *= (x + n - 1);
+ --n;
+ }
+
+ return temp;
+ }
+ else
+ {
+ return 1;
+ }
+}
+
+/**
+ * @brief Calculates the Factorial
+ * @param n!
+ * @return Result
+ */
+static double fac(int n)
+{
+ double temp = n;
+
+ if (n > 0)
+ {
+ while (n > 1)
+ {
+ --n;
+ temp *= n;
+ }
+ return temp;
+ }
+ else
+ {
+ return 1;
+ }
+}
+
+/**
+ * @brief Calculates the Hypergeometric Function 0F1(;b;z)
+ * @param b0 in 0F1(;b0;z)
+ * @param z in 0F1(;b0;z)
+ * @param n number of itertions (precision)
+ * @return Result
+ */
static double powerseries(const double b, const double z, unsigned int n)
{
double temp = 0.0;
diff --git a/buch/papers/0f1/teil2.tex b/buch/papers/0f1/teil2.tex
index 446bc93..ca48e6e 100644
--- a/buch/papers/0f1/teil2.tex
+++ b/buch/papers/0f1/teil2.tex
@@ -26,7 +26,7 @@ Die naheliegendste Lösung ist die Programmierung der Potenzreihe. Allerdings is
+ \frac{z^{20}}{(20+b) \cdot 2.4 \cdot 10^{18}}
\end{align}
-\lstinputlisting[style=C,float,caption={Potenzreihe.},label={0f1:listing:potenzreihe}]{papers/0f1/listings/potenzreihe.c}
+\lstinputlisting[style=C,float,caption={Potenzreihe.},label={0f1:listing:potenzreihe}, firstline=59]{papers/0f1/listings/potenzreihe.c}
\subsection{Kettenbruch
\label{0f1:subsection:kettenbruch}}
@@ -57,7 +57,7 @@ Nach allen Umformungen ergibt sich folgender, irregulärer Kettenbruch \eqref{0f
der als Code \ref{0f1:listing:kettenbruchIterativ} umgesetzt wurde.
\cite{0f1:wolfram-0f1}
-\lstinputlisting[style=C,float,caption={Rekursionsformel für Kettenbruch.},label={0f1:listing:kettenbruchIterativ}]{papers/0f1/listings/kettenbruchIterativ.c}
+\lstinputlisting[style=C,float,caption={Rekursionsformel für Kettenbruch.},label={0f1:listing:kettenbruchIterativ}, firstline=8]{papers/0f1/listings/kettenbruchIterativ.c}
\subsection{Rekursionsformel
\label{0f1:subsection:rekursionsformel}}
@@ -175,4 +175,4 @@ Näherungsbruch: \qquad$\displaystyle\frac{A_k}{B_k}$
Ein grosser Vorteil dieser Umsetzung \ref{0f1:listing:kettenbruchRekursion} ist, dass im Vergleich zum Code \ref{0f1:listing:kettenbruchIterativ} eine Division gespart werden kann und somit weniger Folgefehler entstehen können.
%Code
-\lstinputlisting[style=C,float,caption={Iterativ umgesetzter Kettenbruch.},label={0f1:listing:kettenbruchRekursion}]{papers/0f1/listings/kettenbruchRekursion.c} \ No newline at end of file
+\lstinputlisting[style=C,float,caption={Iterativ umgesetzter Kettenbruch.},label={0f1:listing:kettenbruchRekursion}, firstline=8]{papers/0f1/listings/kettenbruchRekursion.c} \ No newline at end of file