def eval(cls, n, a, b, x): # Simplify to other polynomials # P^{a, a}_n(x) if a == b: if a == -S.Half: return RisingFactorial(S.Half, n) / factorial(n) * chebyshevt(n, x) elif a == S.Zero: return legendre(n, x) elif a == S.Half: return RisingFactorial(3*S.Half, n) / factorial(n + 1) * chebyshevu(n, x) else: return RisingFactorial(a + 1, n) / RisingFactorial(2*a + 1, n) * gegenbauer(n, a + S.Half, x) elif b == -a: # P^{a, -a}_n(x) return gamma(n + a + 1) / gamma(n + 1) * (1 + x)**(a/2) / (1 - x)**(a/2) * assoc_legendre(n, -a, x) if not n.is_Number: # Symbolic result P^{a,b}_n(x) # P^{a,b}_n(-x) ---> (-1)**n * P^{b,a}_n(-x) if x.could_extract_minus_sign(): return S.NegativeOne**n * jacobi(n, b, a, -x) # We can evaluate for some special values of x if x == S.Zero: return (2**(-n) * gamma(a + n + 1) / (gamma(a + 1) * factorial(n)) * hyper([-b - n, -n], [a + 1], -1)) if x == S.One: return RisingFactorial(a + 1, n) / factorial(n) elif x == S.Infinity: if n.is_positive: # Make sure a+b+2*n \notin Z if (a + b + 2*n).is_integer: raise ValueError("a + b + 2*n should not be an integer.") return RisingFactorial(a + b + n + 1, n) * S.Infinity else: # n is a given fixed integer, evaluate into polynomial return jacobi_poly(n, a, b, x)
def _eval_rewrite_as_hyper(self, z): return (pi / 2) * hyper((S.Half, S.Half), (S.One, ), z)
def _eval_rewrite_as_hyper(self, *args): if len(args) == 1: z = args[0] return (pi / 2) * hyper((-S.Half, S.Half), (S.One, ), z)
def _eval_rewrite_as_hyper(self, z): pf1 = S.One / (3**Rational(2, 3) * gamma(Rational(2, 3))) pf2 = z / (root(3, 3) * gamma(Rational(1, 3))) return pf1 * hyper([], [Rational(2, 3)], z**3 / 9) - pf2 * hyper( [], [Rational(4, 3)], z**3 / 9)
def _eval_rewrite_as_hyper(self, z): pf1 = z**2 / (2 * root(3, 6) * gamma(Rational(2, 3))) pf2 = root(3, 6) / gamma(Rational(1, 3)) return pf1 * hyper([], [Rational(5, 3)], z**3 / 9) + pf2 * hyper( [], [Rational(1, 3)], z**3 / 9)
def _eval_rewrite_as_hyper(self, z): pf1 = z**2 / (2 * 3**Rational(2, 3) * gamma(Rational(2, 3))) pf2 = 1 / (root(3, 3) * gamma(Rational(1, 3))) return pf1 * hyper([], [Rational(5, 3)], z**3 / 9) - pf2 * hyper( [], [Rational(1, 3)], z**3 / 9)