1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
use crate::special::Probability;
use crate::Functions;
/// Provides methods for calculating hypergeometric functions.
pub struct Hypergeometric;
impl Hypergeometric {
/// Calculates the Gaussian hypergeometric function.
///
/// The Gaussian hypergeometric function is a special function defined by a series involving
/// the Pochhammer notation and factorials.
///
/// # Parameters
///
/// - `a`: The first parameter of the Gaussian hypergeometric function.
/// - `b`: The second parameter of the Gaussian hypergeometric function.
/// - `c`: The third parameter of the Gaussian hypergeometric function.
/// - `z`: The value at which to calculate the function. Note: for accuracy, 0 < `z` < 0.5.
///
/// # Returns
///
/// The value of the Gaussian hypergeometric function at the given parameters `a`, `b`, `c`, and `z`.
///
/// # Example
///
/// ```rust
/// use numerilib::special::Hypergeometric;
///
/// let a = 1.0;
/// let b = 2.0;
/// let c = 3.0;
/// let z = 0.5;
///
/// let result = Hypergeometric::gaussian(a, b, c, z);
///
/// println!("Gaussian Hypergeometric({}, {}, {}, {}) = {}", a, b, c, z, result);
/// ```
/// <hr/>
pub fn gaussian(a: f64, b: f64, c: f64, z: f64) -> f64 {
let func = |x: f64| {
((Probability::pochhammer(a, x) * Probability::pochhammer(b, x))
/ (Probability::pochhammer(c, x) * Probability::factorial(x)))
* z.powf(x)
};
Functions::summation(0_f64, 78_f64, func)
}
/// Calculates the Kummer hypergeometric function.
///
/// The Kummer hypergeometric function is a special function defined by a series involving
/// the Pochhammer notation and factorials.
///
/// # Parameters
///
/// - `a`: The first parameter of the Kummer hypergeometric function.
/// - `b`: The second parameter of the Kummer hypergeometric function.
/// - `z`: The value at which to calculate the function.
///
/// # Returns
///
/// The value of the Kummer hypergeometric function at the given parameters `a`, `b`, and `z`.
///
/// # Example
///
/// ```rust
/// use numerilib::special::Hypergeometric;
///
/// let a = 1.0;
/// let b = 2.0;
/// let z = 0.5;
///
/// let result = Hypergeometric::kummer(a, b, z);
///
/// println!("Kummer Hypergeometric({}, {}, {}) = {}", a, b, z, result);
/// ```
/// <hr/>
pub fn kummer(a: f64, b: f64, z: f64) -> f64 {
let func = |x: f64| {
(Probability::pochhammer(a, x) / Probability::pochhammer(b, x))
* (z.powf(x) / Probability::factorial(x))
};
Functions::summation(0_f64, 99_f64, func)
}
/// Calculates the Whittaker hypergeometric function.
///
/// The Whittaker hypergeometric function is a special function defined in terms of the Kummer hypergeometric function.
///
/// # Parameters
///
/// - `k`: The first parameter of the Whittaker hypergeometric function.
/// - `m`: The second parameter of the Whittaker hypergeometric function.
/// - `z`: The value at which to calculate the function.
///
/// # Returns
///
/// The value of the Whittaker hypergeometric function at the given parameters `k`, `m`, and `z`.
///
/// # Example
///
/// ```rust
/// use numerilib::special::Hypergeometric;
///
/// let k = 1.0;
/// let m = 2.0;
/// let z = 0.5;
///
/// let result = Hypergeometric::whittaker(k, m, z);
///
/// println!("Whittaker Hypergeometric({}, {}, {}) = {}", k, m, z, result);
/// ```
/// <hr/>
pub fn whittaker(k: f64, m: f64, z: f64) -> f64 {
std::f64::consts::E.powf(-z / 2_f64)
* z.powf(m + (1_f64 / 2_f64))
* Self::kummer(m - k + (1_f64 / 2_f64), (2_f64 * m) + 1_f64, z)
}
}