FLINT Arithmetic Functions#

sage.libs.flint.arith_sage.bell_number(n)[source]#

Return the \(n\)-th Bell number.

See Wikipedia article Bell_number.

ALGORITHM:

Uses arith_bell_number().

EXAMPLES:

sage: from sage.libs.flint.arith_sage import bell_number
sage: [bell_number(i) for i in range(10)]
[1, 1, 2, 5, 15, 52, 203, 877, 4140, 21147]
sage: bell_number(10)
115975
sage: bell_number(40)
157450588391204931289324344702531067
sage: bell_number(100)
47585391276764833658790768841387207826363669686825611466616334637559114497892442622672724044217756306953557882560751
>>> from sage.all import *
>>> from sage.libs.flint.arith_sage import bell_number
>>> [bell_number(i) for i in range(Integer(10))]
[1, 1, 2, 5, 15, 52, 203, 877, 4140, 21147]
>>> bell_number(Integer(10))
115975
>>> bell_number(Integer(40))
157450588391204931289324344702531067
>>> bell_number(Integer(100))
47585391276764833658790768841387207826363669686825611466616334637559114497892442622672724044217756306953557882560751
sage.libs.flint.arith_sage.bernoulli_number(n)[source]#

Return the \(n\)-th Bernoulli number.

See Wikipedia article Bernoulli_number.

EXAMPLES:

sage: from sage.libs.flint.arith_sage import bernoulli_number
sage: [bernoulli_number(i) for i in range(10)]
[1, -1/2, 1/6, 0, -1/30, 0, 1/42, 0, -1/30, 0]
sage: bernoulli_number(10)
5/66
sage: bernoulli_number(40)
-261082718496449122051/13530
sage: bernoulli_number(100)
-94598037819122125295227433069493721872702841533066936133385696204311395415197247711/33330
>>> from sage.all import *
>>> from sage.libs.flint.arith_sage import bernoulli_number
>>> [bernoulli_number(i) for i in range(Integer(10))]
[1, -1/2, 1/6, 0, -1/30, 0, 1/42, 0, -1/30, 0]
>>> bernoulli_number(Integer(10))
5/66
>>> bernoulli_number(Integer(40))
-261082718496449122051/13530
>>> bernoulli_number(Integer(100))
-94598037819122125295227433069493721872702841533066936133385696204311395415197247711/33330
sage.libs.flint.arith_sage.dedekind_sum(p, q)[source]#

Return the Dedekind sum \(s(p, q)\) where \(p\) and \(q\) are arbitrary integers.

See Wikipedia article Dedekind_sum.

EXAMPLES:

sage: from sage.libs.flint.arith_sage import dedekind_sum
sage: dedekind_sum(4, 5)
-1/5
>>> from sage.all import *
>>> from sage.libs.flint.arith_sage import dedekind_sum
>>> dedekind_sum(Integer(4), Integer(5))
-1/5
sage.libs.flint.arith_sage.euler_number(n)[source]#

Return the Euler number of index \(n\).

See Wikipedia article Euler_number.

EXAMPLES:

sage: from sage.libs.flint.arith_sage import euler_number
sage: [euler_number(i) for i in range(8)]
[1, 0, -1, 0, 5, 0, -61, 0]
>>> from sage.all import *
>>> from sage.libs.flint.arith_sage import euler_number
>>> [euler_number(i) for i in range(Integer(8))]
[1, 0, -1, 0, 5, 0, -61, 0]
sage.libs.flint.arith_sage.harmonic_number(n)[source]#

Return the harmonic number \(H_n\).

See Wikipedia article Harmonic_number.

EXAMPLES:

sage: from sage.libs.flint.arith_sage import harmonic_number
sage: n = 500 + randint(0,500)
sage: bool( sum(1/k for k in range(1,n+1)) == harmonic_number(n) )
True
>>> from sage.all import *
>>> from sage.libs.flint.arith_sage import harmonic_number
>>> n = Integer(500) + randint(Integer(0),Integer(500))
>>> bool( sum(Integer(1)/k for k in range(Integer(1),n+Integer(1))) == harmonic_number(n) )
True
sage.libs.flint.arith_sage.number_of_partitions(n)[source]#

Return the number of partitions of the integer \(n\).

See Wikipedia article Partition_(number_theory).

EXAMPLES:

sage: from sage.libs.flint.arith_sage import number_of_partitions
sage: number_of_partitions(3)
3
sage: number_of_partitions(10)
42
sage: number_of_partitions(40)
37338
sage: number_of_partitions(100)
190569292
sage: number_of_partitions(100000)
27493510569775696512677516320986352688173429315980054758203125984302147328114964173055050741660736621590157844774296248940493063070200461792764493033510116079342457190155718943509725312466108452006369558934464248716828789832182345009262853831404597021307130674510624419227311238999702284408609370935531629697851569569892196108480158600569421098519
>>> from sage.all import *
>>> from sage.libs.flint.arith_sage import number_of_partitions
>>> number_of_partitions(Integer(3))
3
>>> number_of_partitions(Integer(10))
42
>>> number_of_partitions(Integer(40))
37338
>>> number_of_partitions(Integer(100))
190569292
>>> number_of_partitions(Integer(100000))
27493510569775696512677516320986352688173429315980054758203125984302147328114964173055050741660736621590157844774296248940493063070200461792764493033510116079342457190155718943509725312466108452006369558934464248716828789832182345009262853831404597021307130674510624419227311238999702284408609370935531629697851569569892196108480158600569421098519
sage.libs.flint.arith_sage.stirling_number_1(n, k)[source]#

Return the unsigned Stirling number of the first kind.

EXAMPLES:

sage: from sage.libs.flint.arith_sage import stirling_number_1
sage: [stirling_number_1(8,i) for i in range(9)]
[0, 5040, 13068, 13132, 6769, 1960, 322, 28, 1]
>>> from sage.all import *
>>> from sage.libs.flint.arith_sage import stirling_number_1
>>> [stirling_number_1(Integer(8),i) for i in range(Integer(9))]
[0, 5040, 13068, 13132, 6769, 1960, 322, 28, 1]
sage.libs.flint.arith_sage.stirling_number_2(n, k)[source]#

Return the Stirling number of the second kind.

EXAMPLES:

sage: from sage.libs.flint.arith_sage import stirling_number_2
sage: [stirling_number_2(8,i) for i in range(9)]
[0, 1, 127, 966, 1701, 1050, 266, 28, 1]
>>> from sage.all import *
>>> from sage.libs.flint.arith_sage import stirling_number_2
>>> [stirling_number_2(Integer(8),i) for i in range(Integer(9))]
[0, 1, 127, 966, 1701, 1050, 266, 28, 1]