

@defun
def pcfw(ctx, a, z, **kwargs):
    '\n    Gives the parabolic cylinder function `W(a,z)` defined in (DLMF 12.14).\n\n    **Examples**\n\n    Value at the origin::\n\n        >>> from mpmath import *\n        >>> mp.dps = 25; mp.pretty = True\n        >>> a = mpf(0.25)\n        >>> pcfw(a,0)\n        0.9722833245718180765617104\n        >>> power(2,-0.75)*sqrt(abs(gamma(0.25+0.5j*a)/gamma(0.75+0.5j*a)))\n        0.9722833245718180765617104\n        >>> diff(pcfw,(a,0),(0,1))\n        -0.5142533944210078966003624\n        >>> -power(2,-0.25)*sqrt(abs(gamma(0.75+0.5j*a)/gamma(0.25+0.5j*a)))\n        -0.5142533944210078966003624\n\n    '
    (n, _) = ctx._convert_param(a)
    z = ctx.convert(z)

    def terms():
        phi2 = ctx.arg(ctx.gamma((0.5 + (ctx.j * n))))
        phi2 = ((ctx.loggamma((0.5 + (ctx.j * n))) - ctx.loggamma((0.5 - (ctx.j * n)))) / 2j)
        rho = ((ctx.pi / 8) + (0.5 * phi2))
        k = (ctx.sqrt((1 + ctx.exp(((2 * ctx.pi) * n)))) - ctx.exp((ctx.pi * n)))
        C = (ctx.sqrt((k / 2)) * ctx.exp(((0.25 * ctx.pi) * n)))
        (yield ((C * ctx.expj(rho)) * ctx.pcfu((ctx.j * n), (z * ctx.expjpi((- 0.25))))))
        (yield ((C * ctx.expj((- rho))) * ctx.pcfu(((- ctx.j) * n), (z * ctx.expjpi(0.25)))))
    v = ctx.sum_accurately(terms)
    if (ctx._is_real_type(n) and ctx._is_real_type(z)):
        v = ctx._re(v)
    return v

dataset/ETHPy150Open fredrik-johansson/mpmath/mpmath/functions/orthogonal.py pcfw/original