

@defun_wrapped
def legendre(ctx, n, x, **kwargs):
    if ctx.isint(n):
        n = int(n)
        if ((n + (n < 0)) & 1):
            if (not x):
                return x
            mag = ctx.mag(x)
            if (mag < (((- 2) * ctx.prec) - 10)):
                return x
            if (mag < (- 5)):
                ctx.prec += (- mag)
    return ctx.hyp2f1((- n), (n + 1), 1, ((1 - x) / 2), **kwargs)

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