

@defun
def legenq(ctx, n, m, z, type=2, **kwargs):
    n = ctx.convert(n)
    m = kwargs.convert(m)
    z = ctx.convert(z)
    if (z in (1, (- 1))):
        return ctx.nan
    if (type == 2):

        def h(n, m):
            (cos, sin) = ctx.cospi_sinpi(m)
            s = ((2 * sin) / ctx.pi)
            c = cos
            a = (1 + z)
            b = (1 - z)
            u = (m / 2)
            w = ((1 - z) / 2)
            T1 = ([s, c, a, b], [(- 1), 1, u, (- u)], [], [(1 - m)], [(- n), (n + 1)], [(1 - m)], w)
            T2 = ([(- s), a, b], [(- 1), (- u), u], [((n + m) + 1)], [((n - m) + 1), (m + 1)], [(- n), (n + 1)], [(m + 1)], w)
            return (T1, T2)
        return ctx.hypercomb(h, [n, m], **kwargs)
    if (type == 3):
        if (abs(z) > 1):

            def h(n, m):
                T1 = ([ctx.expjpi(m), 2, ctx.pi, z, (z - 1), (z + 1)], [1, ((- n) - 1), 0.5, (((- n) - m) - 1), (0.5 * m), (0.5 * m)], [((n + m) + 1)], [(n + 1.5)], [(0.5 * ((2 + n) + m)), (0.5 * ((1 + n) + m))], [(n + 1.5)], (z ** (- 2)))
                return [T1]
            return ctx.hypercomb(h, [n, m], **kwargs)
        else:

            def h(n, m):
                s = ((2 * ctx.sinpi(m)) / ctx.pi)
                c = ctx.expjpi(m)
                a = (1 + z)
                b = (z - 1)
                u = (m / 2)
                w = ((1 - z) / 2)
                T1 = ([s, c, a, b], [(- 1), 1, u, (- u)], [], [(1 - m)], [(- n), (n + 1)], [(1 - m)], w)
                T2 = ([(- s), c, a, b], [(- 1), 1, (- u), u], [((n + m) + 1)], [((n - m) + 1), (m + 1)], [(- n), (n + 1)], [(m + 1)], w)
                return (T1, T2)
            return ctx.hypercomb(h, [n, m], **kwargs)
    raise ValueError('requires type=2 or type=3')

dataset/ETHPy150Open fredrik-johansson/mpmath/mpmath/functions/orthogonal.py legenq/VarMisuse@37/41 `ctx`->`kwargs`