Function of #cas
LegendreP
The Legendre polynomial in monomials, proved at every real , and its exact values at rational points.
#cas (LegendreP n x)#cas (LegendreP n q)#cas [N d] (LegendreP n q)LegendreP writes a Legendre polynomial in powers of its argument, or gives its exact value at a rational point. Its coefficients are rational, and they come out as exact fractions. The theorem holds at every real for SymLean’s CAS.Analysis.SpecialFunctions.legendre n, which we define as Mathlib’s shifted Legendre polynomial at , so it is the classical , with .
Examples (11)#
Basic Examples (2)
in monomials, with the theorem at every real :
#cas (LegendreP 3 x)
polynomial with exact rational coefficients
5/2*x^3 - 3/2*x- Input (polynomial in x)
LegendreP 3 x
Checked by Lean’s kernel: Monomial expansion of the Legendre polynomial
∀ (x : ℝ), Polynomial.eval x (CAS.Analysis.SpecialFunctions.legendre 3) = 5 / 2 * x ^ 3 - 3 / 2 * x
from CAS.Analysis.SpecialFunctions.legendre_eval_eq_sum_coeff
The certificate: 1 checked step
Monomial expansion of the Legendre polynomial
∀ (x : ℝ), Polynomial.eval x (CAS.Analysis.SpecialFunctions.legendre 3) = 5 / 2 * x ^ 3 - 3 / 2 * x
The computation
Checked coefficients
Coefficients of x^0, …, x^3: [0, -3/2, 0, 5/2] Guarantee: the displayed polynomial equals P_3 at every real x
The exact value at a rational point:
#cas (LegendreP 2 (1/2))
exact rational value
-1/8- Domain
Legendre polynomial at a rational point
Checked by Lean’s kernel: Exact value of the Legendre polynomial
Polynomial.eval (1 / 2) (CAS.Analysis.SpecialFunctions.legendre 2) = -(1 / 8)
from CAS.Analysis.SpecialFunctions.legendre_eval_ratCast
The certificate: 1 checked step
Exact value of the Legendre polynomial
Polynomial.eval (1 / 2) (CAS.Analysis.SpecialFunctions.legendre 2) = -(1 / 8)
Scope (3)
A higher degree, with every coefficient in lowest terms:
#cas (LegendreP 10 x)
polynomial with exact rational coefficients
46189/256*x^10 - 109395/256*x^8 + 45045/128*x^6 - 15015/128*x^4 + 3465/256*x^2 - 63/256- Input (polynomial in x)
LegendreP 10 x
Checked by Lean’s kernel: Monomial expansion of the Legendre polynomial
∀ (x : ℝ), Polynomial.eval x (CAS.Analysis.SpecialFunctions.legendre 10) = 46189 / 256 * x ^ 10 - 109395 / 256 * x ^ 8 + 45045 / 128 * x ^ 6 - 15015 / 128 * x ^ 4 + 3465 / 256 * x ^ 2 - 63 / 256
from CAS.Analysis.SpecialFunctions.legendre_eval_eq_sum_coeff
The certificate: 1 checked step
Monomial expansion of the Legendre polynomial
∀ (x : ℝ), Polynomial.eval x (CAS.Analysis.SpecialFunctions.legendre 10) = 46189 / 256 * x ^ 10 - 109395 / 256 * x ^ 8 + 45045 / 128 * x ^ 6 - 15015 / 128 * x ^ 4 + 3465 / 256 * x ^ 2 - 63 / 256
The computation
Checked coefficients
Coefficients of x^0, …, x^10: [-63/256, 0, 3465/256, 0, -15015/128, 0, 45045/128, 0, -109395/256, 0, 46189/256] Guarantee: the displayed polynomial equals P_10 at every real x
#cas [expand] prints the same polynomial as #cas alone, here :
#cas [expand] (LegendreP 5 x)
polynomial with exact rational coefficients
63/8*x^5 - 35/4*x^3 + 15/8*x- Input (polynomial in x)
LegendreP 5 x
Checked by Lean’s kernel: Monomial expansion of the Legendre polynomial
∀ (x : ℝ), Polynomial.eval x (CAS.Analysis.SpecialFunctions.legendre 5) = 63 / 8 * x ^ 5 - 35 / 4 * x ^ 3 + 15 / 8 * x
from CAS.Analysis.SpecialFunctions.legendre_eval_eq_sum_coeff
The certificate: 1 checked step
Monomial expansion of the Legendre polynomial
∀ (x : ℝ), Polynomial.eval x (CAS.Analysis.SpecialFunctions.legendre 5) = 63 / 8 * x ^ 5 - 35 / 4 * x ^ 3 + 15 / 8 * x
The computation
Checked coefficients
Coefficients of x^0, …, x^5: [0, 15/8, 0, -35/4, 0, 63/8] Guarantee: the displayed polynomial equals P_5 at every real x
[N d] adds the first digits of the exact value, here exact:
#cas [N 10] (LegendreP 2 (1/2))
exact rational value and its first 10 significant digits, truncated
-1/8 = -0.1250000000- Domain
Legendre polynomial at a rational point
Checked by Lean’s kernel: Exact value and digits of the Legendre polynomial
Polynomial.eval (1 / 2) (CAS.Analysis.SpecialFunctions.legendre 2) = -(1 / 8) ∧ -(1250000000 + 1) / 10 ^ 10 < Polynomial.eval (1 / 2) (CAS.Analysis.SpecialFunctions.legendre 2) ∧ Polynomial.eval (1 / 2) (CAS.Analysis.SpecialFunctions.legendre 2) ≤ -1250000000 / 10 ^ 10
from CAS.Analysis.SpecialFunctions.legendre_eval_ratCast
The certificate: 1 checked step
Exact value and digits of the Legendre polynomial
Polynomial.eval (1 / 2) (CAS.Analysis.SpecialFunctions.legendre 2) = -(1 / 8) ∧ -(1250000000 + 1) / 10 ^ 10 < Polynomial.eval (1 / 2) (CAS.Analysis.SpecialFunctions.legendre 2) ∧ Polynomial.eval (1 / 2) (CAS.Analysis.SpecialFunctions.legendre 2) ≤ -1250000000 / 10 ^ 10
Applications (1)
A proof can take the printed theorem as a hypothesis and specialize it, here at . Only the three standard axioms are used:
theorem legendre_three_at_half (h : ∀ x : ℝ, (CAS.Analysis.SpecialFunctions.legendre 3).eval x = 5 / 2 * x ^ 3 - 3 / 2 * x) : (CAS.Analysis.SpecialFunctions.legendre 3).eval (1 / 2) = -7 / 16 := by rw [h] norm_num #print axioms legendre_three_at_half
legendre_three_at_half depends on the axioms propext, Classical.choice, Quot.sound.
Properties and Relations (1)
The polynomial at is , the value of the theorem above, and the call at the point agrees:
#cas [N 5] (LegendreP 3 (1/2))
exact rational value and its first 5 significant digits, truncated
-7/16 = -0.43750- Domain
Legendre polynomial at a rational point
Checked by Lean’s kernel: Exact value and digits of the Legendre polynomial
Polynomial.eval (1 / 2) (CAS.Analysis.SpecialFunctions.legendre 3) = -(7 / 16) ∧ -(43750 + 1) / 10 ^ 5 < Polynomial.eval (1 / 2) (CAS.Analysis.SpecialFunctions.legendre 3) ∧ Polynomial.eval (1 / 2) (CAS.Analysis.SpecialFunctions.legendre 3) ≤ -43750 / 10 ^ 5
from CAS.Analysis.SpecialFunctions.legendre_eval_ratCast
The certificate: 1 checked step
Exact value and digits of the Legendre polynomial
Polynomial.eval (1 / 2) (CAS.Analysis.SpecialFunctions.legendre 3) = -(7 / 16) ∧ -(43750 + 1) / 10 ^ 5 < Polynomial.eval (1 / 2) (CAS.Analysis.SpecialFunctions.legendre 3) ∧ Polynomial.eval (1 / 2) (CAS.Analysis.SpecialFunctions.legendre 3) ≤ -43750 / 10 ^ 5
Possible Issues (3)
The degree is at most 30. The bound keeps the rational coefficients short, and legendre n is defined at every degree:
#cas (LegendreP 31 x)
Error
LegendreP accepts degrees up to 30
A call computes with numbers of at most 10000 digits, and is larger:
#cas (LegendreP 2 (10 ^ 5000))
Error
LegendreP: evaluating `LegendreP 2 (10 ^ 5000)` needs a number with more than 10000 digits, the most that a call computes
LegendreP is a call, not a mode, and the message lists its three forms:
#cas [LegendreP 5]
Error
`LegendreP` is no mode of `#cas`; write `#cas (LegendreP n x)`, `#cas [expand] (LegendreP n x)` or `#cas [N d] (LegendreP n x)`
Neat Examples (1)
takes the value at , a repeating decimal, so the report prints ≈:
#cas [N 20] (LegendreP 5 (1 / 3))
exact rational value and its first 20 significant digits, truncated
1/3 ≈ 0.33333333333333333333- Domain
Legendre polynomial at a rational point
Checked by Lean’s kernel: Exact value and digits of the Legendre polynomial
Polynomial.eval (1 / 3) (CAS.Analysis.SpecialFunctions.legendre 5) = 1 / 3 ∧ 33333333333333333333 / 10 ^ 20 ≤ Polynomial.eval (1 / 3) (CAS.Analysis.SpecialFunctions.legendre 5) ∧ Polynomial.eval (1 / 3) (CAS.Analysis.SpecialFunctions.legendre 5) < (33333333333333333333 + 1) / 10 ^ 20
from CAS.Analysis.SpecialFunctions.legendre_eval_ratCast
The certificate: 1 checked step
Exact value and digits of the Legendre polynomial
Polynomial.eval (1 / 3) (CAS.Analysis.SpecialFunctions.legendre 5) = 1 / 3 ∧ 33333333333333333333 / 10 ^ 20 ≤ Polynomial.eval (1 / 3) (CAS.Analysis.SpecialFunctions.legendre 5) ∧ Polynomial.eval (1 / 3) (CAS.Analysis.SpecialFunctions.legendre 5) < (33333333333333333333 + 1) / 10 ^ 20
See Also
ChebyshevT · HermiteHe · BernoulliB · expand · N
