def I_func(x): return \ x**4 * float(mpmath.hyp2f2(1., 1., 5. / 2., 3., x * x / 2.)) / 6. \ + math.pi * (1 - x * x) * scipy.special.erfi(x / math.sqrt(2.)) \ - 3. * x * x \ + math.sqrt(2. * math.pi) * math.exp(x * x / 2.) * x \ + 2.
def hyper2F2_array(a, b, c, d, x): """ :param a: :param b: :param c: :param d: :param x: :return: """ if isinstance(x, int) or isinstance(x, float): out = mpmath.hyp2f2(a, b, c, d, x) else: n = len(x) out = np.zeros(n) for i in range(n): out[i] = mpmath.hyp2f2(a, b, c, d, x[i]) return out
def W(z): return \ ( z**4 * float(mpmath.hyp2f2(1., 1., 5. / 2., 3., z * z / 2.)) / 6. + math.pi * (1. - z * z) * scipy.special.erfi(z / math.sqrt(2.)) + math.sqrt(2. * math.pi) * math.exp(z * z / 2.) * z + (z * z - 2.) * (math.log(2. * z * z) + np.euler_gamma) - 3. * z * z )
def int_exact(self, x): '''Integral of dawson function: analytical solution''' # Evaluated with arbitrary precision arithmetic # 50 times faster than direct integration; can still suffer from numeric overflow y = np.zeros(x.size) i = 0 for t in x: # run a loop since mpm doesn't support vectorization y[i] = 0.5 * t * t * float(mpm.hyp2f2( 1, 1, 3 / 2, 2, t * t)) + 0.25 * np.pi * erfi(t) i += 1 return y
def _voigt_helper(x, amp, x0, std_G, hwhm_L): z = (x - x0 + 1j*hwhm_L) / np.sqrt(2*np.pi*std_G**2) hyperg = np.array([complex(hyp2f2(1, 1, 3/2., 2, arg)) for arg in -z**2]) val = erf(z)/2. + 1j*z**2/np.pi * hyperg return amp * val