- sage: k = ZZ.random_element(20)
- sage: P = legendre_p(k, x, a, b)
- sage: bool(abs(P(x=a)) == 1)
+ sage: j = ZZ.random_element(20)
+ sage: k = j + 1
+ sage: Pj = legendre_p(j, x, a, b)
+ sage: Pk = legendre_p(k, x, a, b)
+ sage: integrate(Pj*Pk, x, a, b) # abs tol 1e-12
+ 0
+
+ The first few polynomials shifted to [0,1] are known to be::
+
+ sage: p0 = 1
+ sage: p1 = 2*x - 1
+ sage: p2 = 6*x^2 - 6*x + 1
+ sage: p3 = 20*x^3 - 30*x^2 + 12*x - 1
+ sage: bool(legendre_p(0, x, 0, 1) == p0)
+ True
+ sage: bool(legendre_p(1, x, 0, 1) == p1)