EulerE¶
Status: Stable
documented, exercised by the test suite and/or worked examples, with no known limitations recorded.
Description¶
EulerE[n]
gives the Euler number E_n.
EulerE[n, x]
gives the Euler polynomial E_n(x).
Notes
Non-negative integer n gives the exact integer E\_n (odd n give 0, E\_0 = 1, E\_2 = -1, E\_4 = 5); an inexact integer-valued n evaluates it at machine or arbitrary (MPFR) precision. EulerE\[n, x\] expands the degree-n polynomial with exact rational coefficients, staying symbolic in x or evaluating numerically when x is inexact; EulerE\[n, 1/2\] folds to 2^-n EulerE\[n\]. Listable.Examples (7)¶
Every input below was run against the current Mathilda build and its output recorded.
Basic examples (2)¶
In[1]:= Table[EulerE[k], {k, 0, 10}]
Out[1]= {1, 0, -1, 0, 5, 0, -61, 0, 1385, 0, -50521}
In[2]:= EulerE[3, z]
Out[2]= 1/4 - 3/2 z^2 + z^3
Applications (5)¶
In[3]:= EulerE[4]
Out[3]= 5
In[4]:= Table[EulerE[2 n], {n, 0, 6}]
Out[4]= {1, -1, 5, -61, 1385, -50521, 2702765}
In[5]:= EulerE[6, x]
Out[5]= -3 x + 5 x^3 - 3 x^5 + x^6
In[6]:= Sum[EulerE[2 k] / (2 k)! Pi^(2 k), {k, 0, 5}]
Out[6]= 1 - 1/2 Pi^2 + 5/24 Pi^4 - 61/720 Pi^6 + 277/8064 Pi^8 - 50521/3628800 Pi^10
In[7]:= N[EulerE[5, 1/3], 40]
Out[7]= -0.24897119341563786008230452674897119341565
Algorithm¶
Mathilda -- Euler numbers and polynomials.
The Euler polynomials are the coefficients of the generating function
and the Euler numbers are E_n = 2^n E_n(1/2). For odd n the numbers vanish; E_0 = 1, E_2 = -1, E_4 = 5, E_6 = -61, ...
Evaluation is layered so each argument shape takes the cheapest exact or numeric route:
exact non-negative integer n -> exact integer E_n (cached recurrence)
inexact integer-valued n -> the integer, numericalised (Real/MPFR)
EulerE[n, x] -> the degree-n polynomial in monomial
form with exact rational coefficients,
then evaluated (exact x stays exact,
inexact x evaluates numerically)
EulerE[n, 1/2], symbolic n -> 2^-n EulerE[n]
everything else -> stays symbolic (return NULL)
Euler numbers E_n are computed by the recurrence
with odd-index numbers identically zero, using exact GMP integers in a lazily-grown, process-lifetime cache.
The Euler polynomial coefficients are obtained from the Taylor expansion
powers of two in C(n,j) E_{n-j}/2^{n-j} (x-1/2)^j combine to a single 2^{n-i}) to the all-integer inner sum
Attributes: Listable, Protected.
Implementation notes¶
Algorithm. builtin_eulere serves EulerE[n] (the Euler number E_n) and EulerE[n, x] (the Euler polynomial E_n(x)). The numbers come from the recurrence E_0 = 1, E_{2m} = -Sum_{k=0}^{m-1} C(2m,2k) E_{2k}, with odd indices identically zero, kept as exact GMP integers in a lazily-grown, process-lifetime cache. Layered dispatch: an exact non-negative integer n returns the exact integer E_n; an inexact integer-valued n returns it numericalised (Real/MPFR); EulerE[n, x] builds the degree-n polynomial in monomial form, E_n(x) = Sum_i c_i x^i with c_i = S_i / 2^{n-i} and the all-integer inner sum S_i = Sum_{j=i}^{n} (-1)^{j-i} C(n,j) C(j,i) E_{n-j} (exact rational coefficients, evaluated once); and a symbolic-n special case EulerE[n, 1/2] -> 2^-n EulerE[n]. Everything else stays symbolic. Degenerate numeric results (e.g. EulerE[200.], overflowing a double) are promoted to an extended-exponent MPFR real.
Data structures. Expr; GMP mpz_t cache for the numbers and mpq_t for polynomial coefficients, assembled into canonical Integer/BigInt/Rational leaves. Caps: EULER_NUMBER_CAP = 5000, EULER_POLY_CAP = 1000. No ND kernel and no Compile[] lowering (CompileDiagnostics reports Compiled -> False): EulerE is an integer-indexed exact table, not an element-wise machine-real function. Diagnostics route through mth_message (argt).
Complexity / limits. The number recurrence is O(n^2) in growing big-integers; the polynomial is a double sum of exact integer binomials. Beyond the caps the call stays symbolic. Attributes: Listable, Protected.
Attributes: Listable, Protected.
References¶
See also: N
- DLMF §24.2, §24.4 — Euler numbers and polynomials: generating function 2 e^{xt}/(e^t+1), E_n = 2^n E_n(1/2), and the recurrence for E_{2m}.
- Source:
src/special_functions/eulere.c - Specification:
docs/spec/builtins/special-functions.md - Tests:
tests/test_eulere.c - Tests:
tests/test_numeric_stress.c
Notes & additional examples¶
Notes¶
EulerE[n] is the integer Euler number E_n (odd n vanish, E_0 = 1),
and EulerE[n, x] is the degree-n Euler polynomial with exact rational
coefficients. The truncated secant-style series above is the partial sum
of sec(Pi/2)'s generating expansion; the polynomial form stays symbolic in
x or, given an inexact argument, evaluates to arbitrary precision.