mlfp 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mlfp-0.1.0/LICENSE +21 -0
- mlfp-0.1.0/MANIFEST.in +3 -0
- mlfp-0.1.0/PKG-INFO +297 -0
- mlfp-0.1.0/README.md +239 -0
- mlfp-0.1.0/docs/conf.py +1 -0
- mlfp-0.1.0/mlfp/__init__.py +50 -0
- mlfp-0.1.0/mlfp/_version.py +10 -0
- mlfp-0.1.0/mlfp/mlfp.py +614 -0
- mlfp-0.1.0/mlfp.egg-info/PKG-INFO +297 -0
- mlfp-0.1.0/mlfp.egg-info/SOURCES.txt +16 -0
- mlfp-0.1.0/mlfp.egg-info/dependency_links.txt +1 -0
- mlfp-0.1.0/mlfp.egg-info/requires.txt +12 -0
- mlfp-0.1.0/mlfp.egg-info/top_level.txt +4 -0
- mlfp-0.1.0/pyproject.toml +71 -0
- mlfp-0.1.0/setup.cfg +24 -0
- mlfp-0.1.0/setup.py +50 -0
- mlfp-0.1.0/test/test_sample.py +2 -0
mlfp-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Mehmet Keçeci
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
mlfp-0.1.0/MANIFEST.in
ADDED
mlfp-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mlfp
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: mlfp: Mittag-Leffler and Prabhakar function, MLF
|
|
5
|
+
Home-page: https://github.com/WhiteSymmetry/mlfp
|
|
6
|
+
Author: Mehmet Keçeci
|
|
7
|
+
Author-email: Mehmet Keçeci <enfo@tuta.io>
|
|
8
|
+
Maintainer: Mehmet Keçeci
|
|
9
|
+
Maintainer-email: enfo@tuta.io
|
|
10
|
+
License: MIT License
|
|
11
|
+
|
|
12
|
+
Copyright (c) 2026 Mehmet Keçeci
|
|
13
|
+
|
|
14
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
15
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
16
|
+
in the Software without restriction, including without limitation the rights
|
|
17
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
18
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
19
|
+
furnished to do so, subject to the following conditions:
|
|
20
|
+
|
|
21
|
+
The above copyright notice and this permission notice shall be included in all
|
|
22
|
+
copies or substantial portions of the Software.
|
|
23
|
+
|
|
24
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
25
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
26
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
27
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
28
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
29
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
30
|
+
SOFTWARE.
|
|
31
|
+
|
|
32
|
+
Project-URL: Homepage, https://github.com/WhiteSymmetry/mlfp
|
|
33
|
+
Project-URL: Bug Tracker, https://github.com/WhiteSymmetry/mlfp/issues
|
|
34
|
+
Classifier: Programming Language :: Python :: 3
|
|
35
|
+
Classifier: Operating System :: OS Independent
|
|
36
|
+
Classifier: Intended Audience :: Science/Research
|
|
37
|
+
Classifier: Topic :: Scientific/Engineering :: Visualization
|
|
38
|
+
Requires-Python: >=3.11
|
|
39
|
+
Description-Content-Type: text/markdown
|
|
40
|
+
License-File: LICENSE
|
|
41
|
+
Requires-Dist: scipy
|
|
42
|
+
Requires-Dist: matplotlib
|
|
43
|
+
Requires-Dist: numpy
|
|
44
|
+
Provides-Extra: test
|
|
45
|
+
Requires-Dist: pytest; extra == "test"
|
|
46
|
+
Requires-Dist: pytest-cov; extra == "test"
|
|
47
|
+
Requires-Dist: pytest-mock; extra == "test"
|
|
48
|
+
Requires-Dist: ruff; extra == "test"
|
|
49
|
+
Requires-Dist: scipy; extra == "test"
|
|
50
|
+
Requires-Dist: matplotlib; extra == "test"
|
|
51
|
+
Requires-Dist: numpy; extra == "test"
|
|
52
|
+
Dynamic: author
|
|
53
|
+
Dynamic: home-page
|
|
54
|
+
Dynamic: license-file
|
|
55
|
+
Dynamic: maintainer
|
|
56
|
+
Dynamic: maintainer-email
|
|
57
|
+
Dynamic: requires-python
|
|
58
|
+
|
|
59
|
+
# mlfp
|
|
60
|
+
mlfp: Mittag-Leffler and Prabhakar function, MLF, Mittag-Leffler and Prabhakar function evaluation: Mittag-Leffler ve Prabhakar fonksiyonlarının hesaplanması.
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
# mlfp <img src="https://github.com/WhiteSymmetry/mlfp/blob/main/docs/logo.png" alt="mlfp" align="right" height="140"/>
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
Parameter validation tests
|
|
69
|
+
|
|
70
|
+
=======================================================
|
|
71
|
+
|
|
72
|
+
[OK] negative alpha → MittagLefflerError
|
|
73
|
+
|
|
74
|
+
[OK] zero alpha → MittagLefflerError
|
|
75
|
+
|
|
76
|
+
[OK] nan alpha → MittagLefflerError
|
|
77
|
+
|
|
78
|
+
[OK] infinite beta → MittagLefflerError
|
|
79
|
+
|
|
80
|
+
[OK] zero gamma → MittagLefflerError
|
|
81
|
+
|
|
82
|
+
[OK] tolerance = 1 → MittagLefflerError
|
|
83
|
+
|
|
84
|
+
[OK] tolerance = 0 → MittagLefflerError
|
|
85
|
+
|
|
86
|
+
[OK] negative series_threshold → MittagLefflerError
|
|
87
|
+
|
|
88
|
+
[OK] zero max_series_terms → MittagLefflerError
|
|
89
|
+
|
|
90
|
+
[OK] complex z to __call__ → MittagLefflerError
|
|
91
|
+
|
|
92
|
+
========================================================
|
|
93
|
+
|
|
94
|
+
Safe-limit overflow detection
|
|
95
|
+
|
|
96
|
+
====================================================================================================
|
|
97
|
+
|
|
98
|
+
[OK ] α=0.25, |z|=10.3 → MittagLefflerError (The Mittag-Leffler value is too large to represent in f…)
|
|
99
|
+
|
|
100
|
+
[OK ] α=0.5 , |z|=49 → MittagLefflerError (The Mittag-Leffler value is too large to represent in f…)
|
|
101
|
+
|
|
102
|
+
[OK ] α=1.0 , |z|=1.28e+03 → MittagLefflerError (The Mittag-Leffler value is too large to represent in f…)
|
|
103
|
+
|
|
104
|
+
[OK ] α=2.0 , |z|=9.07e+05 → MittagLefflerError (The Mittag-Leffler value is too large to represent in f…)
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
============================================================================
|
|
108
|
+
|
|
109
|
+
Numerical comparison: mlfp vs mpmath (ground truth) vs pymittagleffler
|
|
110
|
+
|
|
111
|
+
mlfp tolerance : 1.0e-13
|
|
112
|
+
|
|
113
|
+
mpmath digits : dynamic (>=50, up to 600)
|
|
114
|
+
|
|
115
|
+
pass criterion : relative error < 1e-09
|
|
116
|
+
|
|
117
|
+
=============================================================================
|
|
118
|
+
|
|
119
|
+
angle = 0.000000 rad (0.0°)
|
|
120
|
+
|
|
121
|
+
----------------------------------------------------------------------------------------------------
|
|
122
|
+
|
|
123
|
+
[OK ] α=0.25, β=0.5 | n= 13 | vs mpmath: max_abs=1.11e+190, max_rel=7.23e-14 | vs pymtl: max_rel=7.19e-14
|
|
124
|
+
|
|
125
|
+
angle = 0.785398 rad (45.0°)
|
|
126
|
+
|
|
127
|
+
----------------------------------------------------------------------------------------------------
|
|
128
|
+
|
|
129
|
+
[OK ] α=0.25, β=0.5 | n= 13 | vs mpmath: max_abs=3.40e-14, max_rel=3.40e-14 | vs pymtl: max_rel=3.41e-14
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
angle = 1.570796 rad (90.0°)
|
|
133
|
+
|
|
134
|
+
----------------------------------------------------------------------------------------------------
|
|
135
|
+
|
|
136
|
+
[OK ] α=0.25, β=0.5 | n= 13 | vs mpmath: max_abs=2.56e-14, max_rel=2.56e-14 | vs pymtl: max_rel=2.57e-14
|
|
137
|
+
|
|
138
|
+
angle = 2.356194 rad (135.0°)
|
|
139
|
+
|
|
140
|
+
----------------------------------------------------------------------------------------------------
|
|
141
|
+
|
|
142
|
+
[OK ] α=0.25, β=0.5 | n= 13 | vs mpmath: max_abs=2.23e-14, max_rel=2.23e-14 | vs pymtl: max_rel=2.25e-14
|
|
143
|
+
|
|
144
|
+
angle = 3.141593 rad (180.0°)
|
|
145
|
+
|
|
146
|
+
----------------------------------------------------------------------------------------------------
|
|
147
|
+
|
|
148
|
+
[OK ] α=0.25, β=0.5 | n= 13 | vs mpmath: max_abs=2.08e-14, max_rel=2.08e-14 | vs pymtl: max_rel=2.09e-14
|
|
149
|
+
|
|
150
|
+
angle = 3.926991 rad (225.0°)
|
|
151
|
+
|
|
152
|
+
----------------------------------------------------------------------------------------------------
|
|
153
|
+
|
|
154
|
+
[OK ] α=0.25, β=0.5 | n= 13 | vs mpmath: max_abs=2.11e-14, max_rel=2.11e-14 | vs pymtl: max_rel=2.13e-14
|
|
155
|
+
|
|
156
|
+
=====================================================================
|
|
157
|
+
|
|
158
|
+
Series vs OPC consistency (gamma = 1) — small |z|, both methods valid
|
|
159
|
+
|
|
160
|
+
=====================================================================
|
|
161
|
+
|
|
162
|
+
[OK ] α=0.5 , β=1.0 | max_abs=2.01e-13, max_rel=5.13e-14
|
|
163
|
+
[OK ] α=1.0 , β=1.5 | max_abs=3.65e-14, max_rel=1.18e-14
|
|
164
|
+
[OK ] α=1.5 , β=0.5 | max_abs=8.20e-14, max_rel=5.60e-14
|
|
165
|
+
[OK ] α=2.0 , β=2.0 | max_abs=3.11e-15, max_rel=2.66e-15
|
|
166
|
+
|
|
167
|
+
=====================================================================
|
|
168
|
+
|
|
169
|
+
Sample values (angle = π/2, mpmath reference uses adaptive precision)
|
|
170
|
+
|
|
171
|
+
=====================================================================
|
|
172
|
+
|
|
173
|
+
alpha beta r mlfp Re ref Re mlfp Im ref Im
|
|
174
|
+
|
|
175
|
+
---------------------------------------------------------------------------------------------
|
|
176
|
+
|
|
177
|
+
0.500 1.000 0.0000 1.00000000e+00 1.00000000e+00 0.00000000e+00 0.00000000e+00
|
|
178
|
+
|
|
179
|
+
================
|
|
180
|
+
|
|
181
|
+
Overall: PASS ✅
|
|
182
|
+
|
|
183
|
+
================
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
# Examples
|
|
187
|
+
|
|
188
|
+
```python
|
|
189
|
+
import numpy as np
|
|
190
|
+
from mlfp import mittag_leffler
|
|
191
|
+
|
|
192
|
+
alpha, beta = 1.0, 2.0
|
|
193
|
+
z = np.linspace(0.0, 2.0, 64)
|
|
194
|
+
result = mittag_leffler(z, alpha, beta)
|
|
195
|
+
print(result)
|
|
196
|
+
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
```python
|
|
200
|
+
import numpy as np
|
|
201
|
+
from mlfp import MittagLeffler, mittag_leffler
|
|
202
|
+
|
|
203
|
+
# 1. Two-parameter Mittag-Leffler function
|
|
204
|
+
ml = MittagLeffler(alpha=0.5, beta=1.0)
|
|
205
|
+
|
|
206
|
+
print(ml(0.0)) # 1.0
|
|
207
|
+
print(ml(0.5)) # 1.9523604891825568
|
|
208
|
+
print(ml(1.0)) # 5.008980080762283
|
|
209
|
+
print(ml(2.0)) # 108.94090438997797
|
|
210
|
+
|
|
211
|
+
# 2. Array evaluation
|
|
212
|
+
z = np.array([0.0, 0.25, 0.5, 1.0, 2.0, 5.0])
|
|
213
|
+
print(ml(z))
|
|
214
|
+
|
|
215
|
+
# 3. Small arguments now use the reliable Taylor-series branch
|
|
216
|
+
ml07 = MittagLeffler(alpha=0.7, beta=1.0)
|
|
217
|
+
print(ml07(0.001)) # 1.0011013529...
|
|
218
|
+
print(ml07(0.01)) # 1.0110864355...
|
|
219
|
+
print(ml07(1.0)) # 3.7041461454...
|
|
220
|
+
|
|
221
|
+
# 4. Prabhakar / three-parameter function
|
|
222
|
+
prabhakar = MittagLeffler(alpha=0.5, beta=1.0, gamma=0.7)
|
|
223
|
+
print(prabhakar(0.1)) # 1.0853656185...
|
|
224
|
+
print(prabhakar(0.5)) # 1.6154153961...
|
|
225
|
+
print(prabhakar(1.0)) # 3.3153696560...
|
|
226
|
+
print(prabhakar(2.0)) # 47.137926541...
|
|
227
|
+
|
|
228
|
+
# 5. Functional interface
|
|
229
|
+
print(mittag_leffler(1.0, alpha=0.5, beta=1.0))
|
|
230
|
+
print(mittag_leffler(0.5, alpha=0.5, beta=1.0, gamma=0.7))
|
|
231
|
+
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
```python
|
|
235
|
+
import numpy as np
|
|
236
|
+
import mpmath as mp
|
|
237
|
+
from pymittagleffler import mittag_leffler as pymittag_leffler
|
|
238
|
+
from mlfp import MittagLeffler
|
|
239
|
+
|
|
240
|
+
mp.mp.dps = 40
|
|
241
|
+
|
|
242
|
+
def mpmath_reference(z, alpha, beta, terms=2000):
|
|
243
|
+
z = mp.mpc(z)
|
|
244
|
+
total = mp.mpc(0)
|
|
245
|
+
for k in range(terms):
|
|
246
|
+
term = z**k / mp.gamma(alpha * k + beta)
|
|
247
|
+
total += term
|
|
248
|
+
if abs(term) < mp.mpf(10) ** -30:
|
|
249
|
+
break
|
|
250
|
+
return complex(total)
|
|
251
|
+
|
|
252
|
+
alpha, beta = 1.0, 1.5
|
|
253
|
+
r = np.linspace(0.0, 12.0, 256)
|
|
254
|
+
z = r * np.exp(1j * np.pi / 2)
|
|
255
|
+
|
|
256
|
+
mlfp = MittagLeffler(
|
|
257
|
+
alpha=alpha,
|
|
258
|
+
beta=beta,
|
|
259
|
+
gamma=1.0,
|
|
260
|
+
tolerance=1.0e-13,
|
|
261
|
+
series_threshold=0.1,
|
|
262
|
+
).evaluate_complex(z)
|
|
263
|
+
|
|
264
|
+
reference = pymittag_leffler(z, alpha, beta)
|
|
265
|
+
mp_reference = np.array(
|
|
266
|
+
[mpmath_reference(value, alpha, beta) for value in z],
|
|
267
|
+
dtype=np.complex128,
|
|
268
|
+
)
|
|
269
|
+
|
|
270
|
+
difference = np.abs(mlfp - reference)
|
|
271
|
+
jmax = int(np.argmax(difference))
|
|
272
|
+
|
|
273
|
+
print(f"Maximum difference at r = {r[jmax]:.6f}")
|
|
274
|
+
print(f"z = {z[jmax]}")
|
|
275
|
+
print(f"mlfp = {mlfp[jmax]}")
|
|
276
|
+
print(f"pymittagleffler = {reference[jmax]}")
|
|
277
|
+
print(f"mpmath reference = {mp_reference[jmax]}")
|
|
278
|
+
print(f"|mlfp - pymtl| = {difference[jmax]:.6e}")
|
|
279
|
+
print(f"|mlfp - mpmath| = {abs(mlfp[jmax] - mp_reference[jmax]):.6e}")
|
|
280
|
+
print(f"|pymtl - mpmath| = {abs(reference[jmax] - mp_reference[jmax]):.6e}")
|
|
281
|
+
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
```python
|
|
285
|
+
import numpy as np
|
|
286
|
+
from mlfp import mittag_leffler
|
|
287
|
+
z = np.linspace(0.4, 2.0) + 3j * np.linspace(0.5, 1.5)
|
|
288
|
+
ml = mittag_leffler(z, alpha=0.5, beta=2.5)
|
|
289
|
+
print(z)
|
|
290
|
+
print(ml)
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
---
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
|
mlfp-0.1.0/README.md
ADDED
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
# mlfp
|
|
2
|
+
mlfp: Mittag-Leffler and Prabhakar function, MLF, Mittag-Leffler and Prabhakar function evaluation: Mittag-Leffler ve Prabhakar fonksiyonlarının hesaplanması.
|
|
3
|
+
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# mlfp <img src="https://github.com/WhiteSymmetry/mlfp/blob/main/docs/logo.png" alt="mlfp" align="right" height="140"/>
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
Parameter validation tests
|
|
11
|
+
|
|
12
|
+
=======================================================
|
|
13
|
+
|
|
14
|
+
[OK] negative alpha → MittagLefflerError
|
|
15
|
+
|
|
16
|
+
[OK] zero alpha → MittagLefflerError
|
|
17
|
+
|
|
18
|
+
[OK] nan alpha → MittagLefflerError
|
|
19
|
+
|
|
20
|
+
[OK] infinite beta → MittagLefflerError
|
|
21
|
+
|
|
22
|
+
[OK] zero gamma → MittagLefflerError
|
|
23
|
+
|
|
24
|
+
[OK] tolerance = 1 → MittagLefflerError
|
|
25
|
+
|
|
26
|
+
[OK] tolerance = 0 → MittagLefflerError
|
|
27
|
+
|
|
28
|
+
[OK] negative series_threshold → MittagLefflerError
|
|
29
|
+
|
|
30
|
+
[OK] zero max_series_terms → MittagLefflerError
|
|
31
|
+
|
|
32
|
+
[OK] complex z to __call__ → MittagLefflerError
|
|
33
|
+
|
|
34
|
+
========================================================
|
|
35
|
+
|
|
36
|
+
Safe-limit overflow detection
|
|
37
|
+
|
|
38
|
+
====================================================================================================
|
|
39
|
+
|
|
40
|
+
[OK ] α=0.25, |z|=10.3 → MittagLefflerError (The Mittag-Leffler value is too large to represent in f…)
|
|
41
|
+
|
|
42
|
+
[OK ] α=0.5 , |z|=49 → MittagLefflerError (The Mittag-Leffler value is too large to represent in f…)
|
|
43
|
+
|
|
44
|
+
[OK ] α=1.0 , |z|=1.28e+03 → MittagLefflerError (The Mittag-Leffler value is too large to represent in f…)
|
|
45
|
+
|
|
46
|
+
[OK ] α=2.0 , |z|=9.07e+05 → MittagLefflerError (The Mittag-Leffler value is too large to represent in f…)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
============================================================================
|
|
50
|
+
|
|
51
|
+
Numerical comparison: mlfp vs mpmath (ground truth) vs pymittagleffler
|
|
52
|
+
|
|
53
|
+
mlfp tolerance : 1.0e-13
|
|
54
|
+
|
|
55
|
+
mpmath digits : dynamic (>=50, up to 600)
|
|
56
|
+
|
|
57
|
+
pass criterion : relative error < 1e-09
|
|
58
|
+
|
|
59
|
+
=============================================================================
|
|
60
|
+
|
|
61
|
+
angle = 0.000000 rad (0.0°)
|
|
62
|
+
|
|
63
|
+
----------------------------------------------------------------------------------------------------
|
|
64
|
+
|
|
65
|
+
[OK ] α=0.25, β=0.5 | n= 13 | vs mpmath: max_abs=1.11e+190, max_rel=7.23e-14 | vs pymtl: max_rel=7.19e-14
|
|
66
|
+
|
|
67
|
+
angle = 0.785398 rad (45.0°)
|
|
68
|
+
|
|
69
|
+
----------------------------------------------------------------------------------------------------
|
|
70
|
+
|
|
71
|
+
[OK ] α=0.25, β=0.5 | n= 13 | vs mpmath: max_abs=3.40e-14, max_rel=3.40e-14 | vs pymtl: max_rel=3.41e-14
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
angle = 1.570796 rad (90.0°)
|
|
75
|
+
|
|
76
|
+
----------------------------------------------------------------------------------------------------
|
|
77
|
+
|
|
78
|
+
[OK ] α=0.25, β=0.5 | n= 13 | vs mpmath: max_abs=2.56e-14, max_rel=2.56e-14 | vs pymtl: max_rel=2.57e-14
|
|
79
|
+
|
|
80
|
+
angle = 2.356194 rad (135.0°)
|
|
81
|
+
|
|
82
|
+
----------------------------------------------------------------------------------------------------
|
|
83
|
+
|
|
84
|
+
[OK ] α=0.25, β=0.5 | n= 13 | vs mpmath: max_abs=2.23e-14, max_rel=2.23e-14 | vs pymtl: max_rel=2.25e-14
|
|
85
|
+
|
|
86
|
+
angle = 3.141593 rad (180.0°)
|
|
87
|
+
|
|
88
|
+
----------------------------------------------------------------------------------------------------
|
|
89
|
+
|
|
90
|
+
[OK ] α=0.25, β=0.5 | n= 13 | vs mpmath: max_abs=2.08e-14, max_rel=2.08e-14 | vs pymtl: max_rel=2.09e-14
|
|
91
|
+
|
|
92
|
+
angle = 3.926991 rad (225.0°)
|
|
93
|
+
|
|
94
|
+
----------------------------------------------------------------------------------------------------
|
|
95
|
+
|
|
96
|
+
[OK ] α=0.25, β=0.5 | n= 13 | vs mpmath: max_abs=2.11e-14, max_rel=2.11e-14 | vs pymtl: max_rel=2.13e-14
|
|
97
|
+
|
|
98
|
+
=====================================================================
|
|
99
|
+
|
|
100
|
+
Series vs OPC consistency (gamma = 1) — small |z|, both methods valid
|
|
101
|
+
|
|
102
|
+
=====================================================================
|
|
103
|
+
|
|
104
|
+
[OK ] α=0.5 , β=1.0 | max_abs=2.01e-13, max_rel=5.13e-14
|
|
105
|
+
[OK ] α=1.0 , β=1.5 | max_abs=3.65e-14, max_rel=1.18e-14
|
|
106
|
+
[OK ] α=1.5 , β=0.5 | max_abs=8.20e-14, max_rel=5.60e-14
|
|
107
|
+
[OK ] α=2.0 , β=2.0 | max_abs=3.11e-15, max_rel=2.66e-15
|
|
108
|
+
|
|
109
|
+
=====================================================================
|
|
110
|
+
|
|
111
|
+
Sample values (angle = π/2, mpmath reference uses adaptive precision)
|
|
112
|
+
|
|
113
|
+
=====================================================================
|
|
114
|
+
|
|
115
|
+
alpha beta r mlfp Re ref Re mlfp Im ref Im
|
|
116
|
+
|
|
117
|
+
---------------------------------------------------------------------------------------------
|
|
118
|
+
|
|
119
|
+
0.500 1.000 0.0000 1.00000000e+00 1.00000000e+00 0.00000000e+00 0.00000000e+00
|
|
120
|
+
|
|
121
|
+
================
|
|
122
|
+
|
|
123
|
+
Overall: PASS ✅
|
|
124
|
+
|
|
125
|
+
================
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
# Examples
|
|
129
|
+
|
|
130
|
+
```python
|
|
131
|
+
import numpy as np
|
|
132
|
+
from mlfp import mittag_leffler
|
|
133
|
+
|
|
134
|
+
alpha, beta = 1.0, 2.0
|
|
135
|
+
z = np.linspace(0.0, 2.0, 64)
|
|
136
|
+
result = mittag_leffler(z, alpha, beta)
|
|
137
|
+
print(result)
|
|
138
|
+
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
```python
|
|
142
|
+
import numpy as np
|
|
143
|
+
from mlfp import MittagLeffler, mittag_leffler
|
|
144
|
+
|
|
145
|
+
# 1. Two-parameter Mittag-Leffler function
|
|
146
|
+
ml = MittagLeffler(alpha=0.5, beta=1.0)
|
|
147
|
+
|
|
148
|
+
print(ml(0.0)) # 1.0
|
|
149
|
+
print(ml(0.5)) # 1.9523604891825568
|
|
150
|
+
print(ml(1.0)) # 5.008980080762283
|
|
151
|
+
print(ml(2.0)) # 108.94090438997797
|
|
152
|
+
|
|
153
|
+
# 2. Array evaluation
|
|
154
|
+
z = np.array([0.0, 0.25, 0.5, 1.0, 2.0, 5.0])
|
|
155
|
+
print(ml(z))
|
|
156
|
+
|
|
157
|
+
# 3. Small arguments now use the reliable Taylor-series branch
|
|
158
|
+
ml07 = MittagLeffler(alpha=0.7, beta=1.0)
|
|
159
|
+
print(ml07(0.001)) # 1.0011013529...
|
|
160
|
+
print(ml07(0.01)) # 1.0110864355...
|
|
161
|
+
print(ml07(1.0)) # 3.7041461454...
|
|
162
|
+
|
|
163
|
+
# 4. Prabhakar / three-parameter function
|
|
164
|
+
prabhakar = MittagLeffler(alpha=0.5, beta=1.0, gamma=0.7)
|
|
165
|
+
print(prabhakar(0.1)) # 1.0853656185...
|
|
166
|
+
print(prabhakar(0.5)) # 1.6154153961...
|
|
167
|
+
print(prabhakar(1.0)) # 3.3153696560...
|
|
168
|
+
print(prabhakar(2.0)) # 47.137926541...
|
|
169
|
+
|
|
170
|
+
# 5. Functional interface
|
|
171
|
+
print(mittag_leffler(1.0, alpha=0.5, beta=1.0))
|
|
172
|
+
print(mittag_leffler(0.5, alpha=0.5, beta=1.0, gamma=0.7))
|
|
173
|
+
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
```python
|
|
177
|
+
import numpy as np
|
|
178
|
+
import mpmath as mp
|
|
179
|
+
from pymittagleffler import mittag_leffler as pymittag_leffler
|
|
180
|
+
from mlfp import MittagLeffler
|
|
181
|
+
|
|
182
|
+
mp.mp.dps = 40
|
|
183
|
+
|
|
184
|
+
def mpmath_reference(z, alpha, beta, terms=2000):
|
|
185
|
+
z = mp.mpc(z)
|
|
186
|
+
total = mp.mpc(0)
|
|
187
|
+
for k in range(terms):
|
|
188
|
+
term = z**k / mp.gamma(alpha * k + beta)
|
|
189
|
+
total += term
|
|
190
|
+
if abs(term) < mp.mpf(10) ** -30:
|
|
191
|
+
break
|
|
192
|
+
return complex(total)
|
|
193
|
+
|
|
194
|
+
alpha, beta = 1.0, 1.5
|
|
195
|
+
r = np.linspace(0.0, 12.0, 256)
|
|
196
|
+
z = r * np.exp(1j * np.pi / 2)
|
|
197
|
+
|
|
198
|
+
mlfp = MittagLeffler(
|
|
199
|
+
alpha=alpha,
|
|
200
|
+
beta=beta,
|
|
201
|
+
gamma=1.0,
|
|
202
|
+
tolerance=1.0e-13,
|
|
203
|
+
series_threshold=0.1,
|
|
204
|
+
).evaluate_complex(z)
|
|
205
|
+
|
|
206
|
+
reference = pymittag_leffler(z, alpha, beta)
|
|
207
|
+
mp_reference = np.array(
|
|
208
|
+
[mpmath_reference(value, alpha, beta) for value in z],
|
|
209
|
+
dtype=np.complex128,
|
|
210
|
+
)
|
|
211
|
+
|
|
212
|
+
difference = np.abs(mlfp - reference)
|
|
213
|
+
jmax = int(np.argmax(difference))
|
|
214
|
+
|
|
215
|
+
print(f"Maximum difference at r = {r[jmax]:.6f}")
|
|
216
|
+
print(f"z = {z[jmax]}")
|
|
217
|
+
print(f"mlfp = {mlfp[jmax]}")
|
|
218
|
+
print(f"pymittagleffler = {reference[jmax]}")
|
|
219
|
+
print(f"mpmath reference = {mp_reference[jmax]}")
|
|
220
|
+
print(f"|mlfp - pymtl| = {difference[jmax]:.6e}")
|
|
221
|
+
print(f"|mlfp - mpmath| = {abs(mlfp[jmax] - mp_reference[jmax]):.6e}")
|
|
222
|
+
print(f"|pymtl - mpmath| = {abs(reference[jmax] - mp_reference[jmax]):.6e}")
|
|
223
|
+
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
```python
|
|
227
|
+
import numpy as np
|
|
228
|
+
from mlfp import mittag_leffler
|
|
229
|
+
z = np.linspace(0.4, 2.0) + 3j * np.linspace(0.5, 1.5)
|
|
230
|
+
ml = mittag_leffler(z, alpha=0.5, beta=2.5)
|
|
231
|
+
print(z)
|
|
232
|
+
print(ml)
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
---
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
|
mlfp-0.1.0/docs/conf.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"""
|
|
2
|
+
mlfp: Mittag-Leffler and Prabhakar function, MLF,
|
|
3
|
+
Mittag-Leffler and Prabhakar function evaluation:
|
|
4
|
+
Mittag-Leffler ve Prabhakar fonksiyonlarının hesaplanması.
|
|
5
|
+
|
|
6
|
+
- Two-parameter Mittag-Leffler function, gamma = 1:
|
|
7
|
+
|
|
8
|
+
E_{alpha,beta}(z)
|
|
9
|
+
|
|
10
|
+
is evaluated with Garrappa's optimal parabolic contour (OPC)
|
|
11
|
+
Laplace-transform inversion, with a Taylor series branch for
|
|
12
|
+
small |z|.
|
|
13
|
+
|
|
14
|
+
- Three-parameter Mittag-Leffler / Prabhakar function, gamma != 1:
|
|
15
|
+
|
|
16
|
+
E_{alpha,beta}^gamma(z)
|
|
17
|
+
|
|
18
|
+
is evaluated from its defining power series. The OPC residue
|
|
19
|
+
treatment is not mathematically valid for gamma != 1 because the
|
|
20
|
+
singularities are generally branch points rather than simple poles.
|
|
21
|
+
|
|
22
|
+
Compatible with Python 3.15+.
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
__version__ = "0.1.0"
|
|
26
|
+
__author__ = "Mehmet Keçeci"
|
|
27
|
+
__main__ = "0.1.0"
|
|
28
|
+
|
|
29
|
+
from .mlfp import (
|
|
30
|
+
# Temel eğri sınıfları
|
|
31
|
+
MittagLefflerError,
|
|
32
|
+
_safe_z_limit,
|
|
33
|
+
_find_optimal_bounded_param,
|
|
34
|
+
_find_optimal_unbounded_param,
|
|
35
|
+
_invert_laplace_transform_two_parameter,
|
|
36
|
+
MittagLeffler,
|
|
37
|
+
mittag_leffler,
|
|
38
|
+
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
__all__ = [
|
|
42
|
+
"MittagLefflerError",
|
|
43
|
+
"_safe_z_limit",
|
|
44
|
+
"_find_optimal_bounded_param",
|
|
45
|
+
"_find_optimal_unbounded_param",
|
|
46
|
+
"_invert_laplace_transform_two_parameter",
|
|
47
|
+
"MittagLeffler",
|
|
48
|
+
"mittag_leffler",
|
|
49
|
+
|
|
50
|
+
]
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# _version.py
|
|
3
|
+
|
|
4
|
+
__version__ = "0.1.0"
|
|
5
|
+
__license__ = "MIT"
|
|
6
|
+
__description__ = "mlfp: Mittag-Leffler and Prabhakar function, MLF"
|
|
7
|
+
__author__ = "Mehmet Keçeci"
|
|
8
|
+
__url__ = "https://github.com/WhiteSymmetry/mlfp"
|
|
9
|
+
__docs__ = "https://github.com/WhiteSymmetry/mlfp" # Opsiyonel: Dokümantasyon linki
|
|
10
|
+
__dependencies__ = ["python>=3.11"] # Diğer bağımlılıkları da ekleyebilirsiniz
|