scipy 1.8.0 Pypi GitHub Homepage
Other Docs
ParametersReturnsBackRef
bernoulli(n)

Parameters

n : int

Indicated the number of terms in the Bernoulli series to generate.

Returns

ndarray

The Bernoulli numbers [B(0), B(1), ..., B(n)] .

Bernoulli numbers B0..Bn (inclusive).

Examples

>>> from scipy.special import bernoulli, zeta
... bernoulli(4) array([ 1. , -0.5 , 0.16666667, 0. , -0.03333333])

The Wikipedia article () points out the relationship between the Bernoulli numbers and the zeta function, B_n^+ = -n * zeta(1 - n) for n > 0 :

>>> n = np.arange(1, 5)
... -n * zeta(1 - n) array([ 0.5 , 0.16666667, -0. , -0.03333333])

Note that, in the notation used in the wikipedia article, bernoulli computes B_n^- (i.e. it used the convention that B_1 is -1/2). The relation given above is for B_n^+ , so the sign of 0.5 does not match the output of bernoulli(4) .

See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

scipy.special._basic.bernoulli

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


GitHub : /scipy/special/_basic.py#1452
type: <class 'function'>
Commit: