BernoulliB[n]
gives the Bernoulli number
.
BernoulliB[n,x]
gives the Bernoulli polynomial
.
BernoulliB
BernoulliB[n]
gives the Bernoulli number
.
BernoulliB[n,x]
gives the Bernoulli polynomial
.
Details
- Mathematical function, suitable for both symbolic and numerical manipulation.
- The Bernoulli polynomials satisfy the generating function relation
. - The Bernoulli numbers are given by
. - For odd
, the Bernoulli numbers are equal to 0, except
. - BernoulliB can be evaluated to arbitrary numerical precision.
- BernoulliB automatically threads over lists.
Examples
open all close allBasic Examples (2)
Scope (3)
BernoulliB threads element-wise over lists:
BernoulliB[{2, 4, 6}]Plot[Evaluate[Table[BernoulliB[k, z], {k, 5}]], {z, 0, 1}]TraditionalForm formatting:
BernoulliB[n]//TraditionalFormBernoulliB[n, x]//TraditionalFormApplications (6)
Find sums of powers
using BernoulliB (Faulhaber's formula):
Table[(1/j + 1)Underoverscript[∑, i = 0, j]Binomial[j + 1, i] BernoulliB[i] (n + 1)^j - i + 1, {j, 1, 4}]//FactorCompare with direct summation:
Table[Underoverscript[∑, k = 1, n]k^j, {j, 4}]Set up an Euler–Maclaurin integration formula:
Sum[D[Integrate[f[x], x], {x, k}]BernoulliB[k] / k!, {k, 0, 10}]With[{r = % /. f -> (# ^ (5 / 3)&)}, (r /. x -> 10) - (r /. x -> 1)]Compare with the exact summation result:
% - NSum[x ^ (5 / 3), {x, 1, 9}]Plot roots of Bernoulli polynomials in the complex plane:
Graphics[Table[{Hue[n / 40], Point[ReIm[z /. NSolve[BernoulliB[n, z] == 0, z]]]}, {n, 36}]]Show the approach of Bernoulli numbers to a limiting form:
ListPlot[Table[Abs[BernoulliB[2n]] (Pi E / n)^2 n + 1 / 2 - 4 Pi Sqrt[E], {n, 1, 100}]]The denominator of Bernoulli numbers is given by the von Staudt–Clausen formula:
Table[Apply[Times, Select[Divisors[n] + 1, PrimeQ]], {n, 2, 30, 2}]Table[Denominator[BernoulliB[2n]], {n, 1, 15}]Compute Bernoulli numbers in modular arithmetic modulo a prime:
mod[e_, p_] := PolynomialMod[e, p]h[x_, c_, p_] := (mod[x, p] - c mod[x / c, p]/p) + (c - 1/2)BernoulliModPrime[n_Integer ? EvenQ, p_ ? PrimeQ, c_ : 2] := Quiet[mod[(n/1 - c^n)Underoverscript[∑, x = 1, p - 1]x^n - 1 h[x, c, p], p]]Table[BernoulliModPrime[10 ^ 2, p], {p, {7, 13, 17, 23, 29, 31}}]Table[mod[BernoulliB[10 ^ 2], p], {p, {7, 13, 17, 23, 29, 31}}]Properties & Relations (3)
Find BernoulliB numbers from their generating function:
SeriesCoefficient[t / (Exp[t] - 1), {t, 0, n}, Assumptions -> n ≥ 0]CoefficientList[(t/Exp[t] - 1) + O[t] ^ 13, t]Table[n!, {n, 0, 12}]Find BernoulliB polynomials from their generating function:
CoefficientList[Series[t Exp[z t] / (Exp[t] - 1), {t, 0, 6}], t]Table[n!, {n, 0, 6}]//ExpandTable[BernoulliB[n, z], {n, 0, 6}]BernoulliB can be represented as a DifferenceRoot:
DifferenceRootReduce[BernoulliB[2, k], k]Possible Issues (2)
Algorithmically produced results are frequently expressed using Zeta instead of BernoulliB:
-(2 n!/(2 π)^n)Underoverscript[∑, k = 1, ∞](1/k^n)Cos[(π n/2)]Table[%, {n, 2, 10}]Table[BernoulliB[n], {n, 2, 10}]When entered in the traditional form,
is not automatically interpreted as a Bernoulli number:
Subscript[B, n]Neat Examples (3)
Going from Bernoulli numbers to Bernoulli polynomials with umbral calculus:
Expand[(b + x) ^ 12]% /. b ^ k_. :> BernoulliB[k]BernoulliB[12, x]The 20000
Bernoulli number can be computed in under a second:
Timing[b20K = BernoulliB[20000];]Denominator[b20K]Numerator[b20K]//IntegerLengthDefine a Hankel matrix whose entries are the Bernoulli numbers:
bernoulliHankel[n_] := HankelMatrix[BernoulliB[Range[0, n - 1]], BernoulliB[Range[n - 1, 2n - 2]]]bernoulliHankel[5]//MatrixFormIts determinant can be expressed in terms of the Barnes G-function:
Table[Det[bernoulliHankel[n]] == ((-1) ^ Binomial[n, 2]BarnesG[n + 1] ^ 6) / BarnesG[2n + 1], {n, 9}]Tech Notes
Related Guides
Related Links
History
Introduced in 1988 (1.0) | Updated in 2008 (7.0)
Text
Wolfram Research (1988), BernoulliB, Wolfram Language function, https://reference.wolfram.com/language/ref/BernoulliB.html (updated 2008).
CMS
Wolfram Language. 1988. "BernoulliB." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2008. https://reference.wolfram.com/language/ref/BernoulliB.html.
APA
Wolfram Language. (1988). BernoulliB. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/BernoulliB.html
BibTeX
@misc{reference.wolfram_2026_bernoullib, author="Wolfram Research", title="{BernoulliB}", year="2008", howpublished="\url{https://reference.wolfram.com/language/ref/BernoulliB.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_bernoullib, organization={Wolfram Research}, title={BernoulliB}, year={2008}, url={https://reference.wolfram.com/language/ref/BernoulliB.html}, note=[Accessed: 13-June-2026]}