diff options
author | haddoucher <reda.haddouche@ost.ch> | 2022-08-16 14:36:07 +0200 |
---|---|---|
committer | haddoucher <reda.haddouche@ost.ch> | 2022-08-16 14:36:07 +0200 |
commit | f031b148a79d1dafb0e3405643be05e7a7eb1222 (patch) | |
tree | 3f0c7d27ba90e10874a885cae9026fdbaa0b01e6 /buch/papers/0f1/listings/potenzreihe.c | |
parent | Update tschebyscheff_beispiel.tex (diff) | |
parent | Merge pull request #5 from haddoucher/sturmliouville/erik-branch (diff) | |
download | SeminarSpezielleFunktionen-f031b148a79d1dafb0e3405643be05e7a7eb1222.tar.gz SeminarSpezielleFunktionen-f031b148a79d1dafb0e3405643be05e7a7eb1222.zip |
Merge remote-tracking branch 'origin/master' into sturmliouville/redabranch
Diffstat (limited to 'buch/papers/0f1/listings/potenzreihe.c')
-rw-r--r-- | buch/papers/0f1/listings/potenzreihe.c | 60 |
1 files changed, 58 insertions, 2 deletions
diff --git a/buch/papers/0f1/listings/potenzreihe.c b/buch/papers/0f1/listings/potenzreihe.c index bfaa0e3..23fdfea 100644 --- a/buch/papers/0f1/listings/potenzreihe.c +++ b/buch/papers/0f1/listings/potenzreihe.c @@ -1,12 +1,68 @@ #include <math.h>
-static double powerseries(const double b, const double z, unsigned int n)
+/**
+ * @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 c in 0F1(;c;z)
+ * @param z in 0F1(;c;z)
+ * @param n number of itertions (precision)
+ * @return Result
+ */
+static double powerseries(const double c, const double z, unsigned int n)
{
double temp = 0.0;
for (unsigned int k = 0; k < n; ++k)
{
- temp += pow(z, k) / (factorial(k) * pochhammer(b, k));
+ temp += pow(z, k) / (factorial(k) * pochhammer(c, k));
}
return temp;
|