2222from mathics .core .evaluation import Evaluation
2323from mathics .core .systemsymbols import SymbolComplexInfinity , SymbolMachinePrecision
2424from mathics .eval .specialfns .hypergeom import (
25+ eval_Hypergeometric1F1 ,
2526 eval_Hypergeometric2F1 ,
2627 eval_HypergeometricPQF ,
2728 eval_N_HypergeometricPQF ,
@@ -44,30 +45,42 @@ class HypergeometricPFQ(MPMathFunction):
4445
4546 Result is symbollicaly simplified by default:
4647 >> HypergeometricPFQ[{3}, {2}, 1]
47- = HypergeometricPFQ[{3}, {2}, 1]
48+ = 3 E / 2
49+
4850 unless a numerical evaluation is explicitly requested:
4951 >> HypergeometricPFQ[{3}, {2}, 1] // N
5052 = 4.07742
53+
5154 >> HypergeometricPFQ[{3}, {2}, 1.]
5255 = 4.07742
5356
57+ >> Plot[HypergeometricPFQ[{1, 1}, {3, 3, 3}, x], {x, -30, 30}]
58+ = -Graphics-
59+
60+ >> HypergeometricPFQ[{1, 1, 2}, {3, 3}, z]
61+ = -4 PolyLog[2, z] / z ^ 2 + 4 Log[1 - z] / z ^ 2 - 4 Log[1 - z] / z + 8 / z
62+
5463 The following special cases are handled:
5564 >> HypergeometricPFQ[{}, {}, z]
56- = 1
65+ = E ^ z
5766 >> HypergeometricPFQ[{0}, {b}, z]
5867 = 1
59- >> Hypergeometric1F1[b, b, z]
60- = E ^ z
68+
69+ >> HypergeometricPFQ[{1, 1, 3}, {2, 2}, x]
70+ = -Log[1 - x] / (2 x) - 1 / (-2 + 2 x)
71+
72+ 'HypergeometricPFQ' evaluates to a polynomial if any of the parameters $a_k$ is a non-positive integer:
73+ >> HypergeometricPFQ[{-2, a}, {b}, x]
74+ = (-2 a x (1 + b) + a x ^ 2 (1 + a) + b (1 + b)) / (b (1 + b))
75+
76+ Value at origin:
77+ >> HypergeometricPFQ[{a1, b2, a3}, {b1, b2, b3}, 0]
78+ = 1
6179 """
6280
6381 attributes = A_NUMERIC_FUNCTION | A_PROTECTED | A_READ_PROTECTED
6482 mpmath_name = "hyper"
6583 nargs = {3 }
66- rules = {
67- "HypergeometricPFQ[{}, {}, z_]" : "1" ,
68- "HypergeometricPFQ[{0}, b_, z_]" : "1" ,
69- "HypergeometricPFQ[b_, b_, z_]" : "Exp[z]" ,
70- }
7184 summary_text = "compute the generalized hypergeometric function"
7285 sympy_name = "hyper"
7386
@@ -96,30 +109,55 @@ class Hypergeometric1F1(MPMathFunction):
96109 <dd>returns ${}_1 F_1(a; b; z)$.
97110 </dl>
98111
99- Result is symbollicaly simplified by default:
100- >> Hypergeometric1F1[3, 2, 1]
101- = HypergeometricPFQ[{3}, {2}, 1]
102- unless a numerical evaluation is explicitly requested:
103- >> Hypergeometric1F1[3, 2, 1] // N
104- = 4.07742
105- >> Hypergeometric1F1[3, 2, 1.]
106- = 4.07742
112+ Numeric evaluation:
113+ >> Hypergeometric1F1[1, 2, 3.0]
114+ = 6.36185
107115
108- Plot 'M'[3, 2, x] from 0 to 2 in steps of 0.5 :
109- >> Plot[Hypergeometric1F1[3 , 2, x], {x, 0. 5, 2 }]
116+ Plot over a subset of reals :
117+ >> Plot[Hypergeometric1F1[1 , 2, x], {x, - 5, 5 }]
110118 = -Graphics-
111- Here, plot explicitly requests a numerical evaluation.
119+
120+ >> Plot[{Hypergeometric1F1[1/2, Sqrt[2], x], Hypergeometric1F1[1/2, Sqrt[3], x], Hypergeometric1F1[1/2, Sqrt[5], x]}, {x, -4, 4}]
121+ = -Graphics-
122+
123+ >> Plot[{Hypergeometric1F1[Sqrt[3], Sqrt[2], z], -0.01}, {z, -10, -2}]
124+ = -Graphics-
125+
126+ >> Plot[{Hypergeometric1F1[Sqrt[2], b, 1], Hypergeometric1F1[Sqrt[5], b, 1], Hypergeometric1F1[Sqrt[7], b, 1]}, {b, -3, 3}]
127+ = -Graphics-
128+
129+ Compute the elementwise values of an array:
130+ >> Hypergeometric1F1[1, 1, {{1, 0}, {0, 1}}]
131+ = {{E, 1}, {1, E}}
132+
133+ >> Hypergeometric1F1[1/2, 1, x]
134+ = BesselI[0, x / 2] E ^ (x / 2)
135+
136+ Evaluate using complex arguments:
137+ >> Hypergeometric1F1[2 + I, 2, 0.5]
138+ = 1.61833 + 0.379258 I
139+
140+ 'Hypergeometric1F1' evaluates to simpler functions for certain parameters:
141+ >> Hypergeometric1F1[1/2, 1, x]
142+ = BesselI[0, x / 2] E ^ (x / 2)
143+
144+ >> Hypergeometric1F1[2, 1, x]
145+ = (1 + x) E ^ x
146+
147+ >> Hypergeometric1F1[1, 1/2, x]
148+ = -Sqrt[x] (-E ^ (-x) / Sqrt[x] - Sqrt[Pi] Erf[Sqrt[x]]) E ^ x
112149 """
113150
114151 attributes = A_LISTABLE | A_NUMERIC_FUNCTION | A_PROTECTED
115152 mpmath_name = "hymp1f1"
116153 nargs = {3 }
117- rules = {
118- "Hypergeometric1F1[a_, b_, z_]" : "HypergeometricPFQ[{a},{b},z]" ,
119- }
120154 summary_text = "compute Kummer confluent hypergeometric function"
121155 sympy_name = ""
122156
157+ def eval (self , a , b , z , evaluation : Evaluation ):
158+ "Hypergeometric1F1[a_, b_, z_]"
159+ return eval_Hypergeometric1F1 (a , b , z )
160+
123161
124162class Hypergeometric2F1 (MPMathFunction ):
125163 """
0 commit comments