diff options
author | Andreas Müller <andreas.mueller@ost.ch> | 2022-08-16 06:51:49 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-16 06:51:49 +0200 |
commit | 24fffe5705978f136f6df3601255fbf961d1acf0 (patch) | |
tree | 0ffe04ce47e2acb582ba8f1b4111b4467adee652 /buch/papers/0f1/listings | |
parent | Merge pull request #52 from daHugen/master (diff) | |
parent | Merge branch 'master' into master (diff) | |
download | SeminarSpezielleFunktionen-24fffe5705978f136f6df3601255fbf961d1acf0.tar.gz SeminarSpezielleFunktionen-24fffe5705978f136f6df3601255fbf961d1acf0.zip |
Merge pull request #53 from f1bi1n/master
2 Ueberarbeitung
Diffstat (limited to '')
-rw-r--r-- | buch/papers/0f1/listings/kettenbruchIterativ.c | 60 | ||||
-rw-r--r-- | buch/papers/0f1/listings/kettenbruchRekursion.c | 60 |
2 files changed, 60 insertions, 60 deletions
diff --git a/buch/papers/0f1/listings/kettenbruchIterativ.c b/buch/papers/0f1/listings/kettenbruchIterativ.c index d897b8f..3caaf43 100644 --- a/buch/papers/0f1/listings/kettenbruchIterativ.c +++ b/buch/papers/0f1/listings/kettenbruchIterativ.c @@ -1,53 +1,27 @@ /**
- * @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)
+ * @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 fractionRekursion0f1(const double c, const double z, unsigned int n)
+static double fractionIter0f1(const double c, const double z, unsigned int k)
{
//declaration
double a = 0.0;
double b = 0.0;
- double Ak = 0.0;
- double Bk = 0.0;
- double Ak_1 = 0.0;
- double Bk_1 = 0.0;
- double Ak_2 = 0.0;
- double Bk_2 = 0.0;
+ double abk = 0.0;
+ double temp = 0.0;
- for (unsigned int k = 0; k <= n; ++k)
+ for (; k > 0; --k)
{
- if (k == 0)
- {
- a = 1.0; //a0
- //recursion fomula for A0, B0
- Ak = a;
- Bk = 1.0;
- }
- else if (k == 1)
- {
- a = 1.0; //a1
- b = z/c; //b1
- //recursion fomula for A1, B1
- Ak = a * Ak_1 + b * 1.0;
- Bk = a * Bk_1;
- }
- else
- {
- 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;
- }
- //save old values
- Ak_2 = Ak_1;
- Bk_2 = Bk_1;
- Ak_1 = Ak;
- Bk_1 = Bk;
+ abk = z / (k * ((k - 1) + c)); //abk = ak, bk
+
+ a = k > 1 ? (1 + abk) : 1; //a0, a1
+ b = k > 1 ? -abk : abk; //b1
+
+ temp = b / (a + temp); //bk / (ak + last result)
}
- //approximation fraction
- return Ak/Bk;
-}
+
+ return a + temp; //a0 + temp
+}
\ No newline at end of file diff --git a/buch/papers/0f1/listings/kettenbruchRekursion.c b/buch/papers/0f1/listings/kettenbruchRekursion.c index 3caaf43..d897b8f 100644 --- a/buch/papers/0f1/listings/kettenbruchRekursion.c +++ b/buch/papers/0f1/listings/kettenbruchRekursion.c @@ -1,27 +1,53 @@ /**
- * @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)
+ * @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 fractionIter0f1(const double c, const double z, unsigned int k)
+static double fractionRekursion0f1(const double c, const double z, unsigned int n)
{
//declaration
double a = 0.0;
double b = 0.0;
- double abk = 0.0;
- double temp = 0.0;
+ double Ak = 0.0;
+ double Bk = 0.0;
+ double Ak_1 = 0.0;
+ double Bk_1 = 0.0;
+ double Ak_2 = 0.0;
+ double Bk_2 = 0.0;
- for (; k > 0; --k)
+ for (unsigned int k = 0; k <= n; ++k)
{
- abk = z / (k * ((k - 1) + c)); //abk = ak, bk
-
- a = k > 1 ? (1 + abk) : 1; //a0, a1
- b = k > 1 ? -abk : abk; //b1
-
- temp = b / (a + temp); //bk / (ak + last result)
+ if (k == 0)
+ {
+ a = 1.0; //a0
+ //recursion fomula for A0, B0
+ Ak = a;
+ Bk = 1.0;
+ }
+ else if (k == 1)
+ {
+ a = 1.0; //a1
+ b = z/c; //b1
+ //recursion fomula for A1, B1
+ Ak = a * Ak_1 + b * 1.0;
+ Bk = a * Bk_1;
+ }
+ else
+ {
+ 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;
+ }
+ //save old values
+ Ak_2 = Ak_1;
+ Bk_2 = Bk_1;
+ Ak_1 = Ak;
+ Bk_1 = Bk;
}
-
- return a + temp; //a0 + temp
-}
\ No newline at end of file + //approximation fraction
+ return Ak/Bk;
+}
|