Post Made Community Wiki by Dennis
18 added 203 characters in body
source | link

PARI/GPPARI/GP

This yields 7625597484987, demonstrating not only that ^ represents exponentiation rather than a bitwise operator but that exponentiation is right-associative. This is the mathematical convention, but many other languages are left-associative instead, giving the much smaller 19683. See PARI/GP Operator Precedence or section 2.4 in the User's Guide to PARI/GP.

This demonstrates two principles of PARI/GPGP. First is the ability to convert between different forms with conversion commands like Pol (polynomial), Vec (vector), Vecsmall (vector of small integers), Set (set), Mat (matrix), etc. Second is the fact that the parser completely ignores spaces, so V ec is the same as Vec. Space is added only for readability. This can, however, have interesting effects on constrained coding!

Note that the ' is optional (but good form): it ensures that, see the program treats x as a variable even if a value has been assigned to itlength 1 snippet.

PARI/GP

This yields 7625597484987, demonstrating not only that ^ represents exponentiation rather than a bitwise operator but that exponentiation is right-associative. This is the mathematical convention, but many other languages are left-associative instead, giving the much smaller 19683.

This demonstrates two principles of PARI/GP. First is the ability to convert between different forms with conversion commands like Pol (polynomial), Vec (vector), Vecsmall (vector of small integers), Set (set), Mat (matrix), etc. Second is the fact that the parser completely ignores spaces, so V ec is the same as Vec. Space is added only for readability. This can, however, have interesting effects on constrained coding!

Note that the ' is optional (but good form): it ensures that the program treats x as a variable even if a value has been assigned to it.

PARI/GP

This yields 7625597484987, demonstrating not only that ^ represents exponentiation rather than a bitwise operator but that exponentiation is right-associative. This is the mathematical convention, but many other languages are left-associative instead, giving the much smaller 19683. See PARI/GP Operator Precedence or section 2.4 in the User's Guide to PARI/GP.

This demonstrates two principles of GP. First is the ability to convert between different forms with conversion commands like Pol (polynomial), Vec (vector), Vecsmall (vector of small integers), Set (set), Mat (matrix), etc. Second is the fact that the parser completely ignores spaces, so V ec is the same as Vec. Space is added only for readability. This can, however, have interesting effects on constrained coding!

Note that the ' is optional (but good form), see the length 1 snippet.

17 15
source | link

Length 14: Vec(eta('x)^2)

This computes the Taylor series of the Dedekind eta function, squares it, and returns the coefficients. This is a slick way to compute sequence A002107 in the OEIS, the number of partitions of a number into an even number of distinct parts minus number of partitions of the same number into an odd number of distinct parts, with 2 types of each part. (Replacing the 2 in the program with a different number changes the number of parts accordingly; using 1, for instance, yields A010815 instead.)

Note that the ' is optional (but good form): it ensures that the program treats x as a variable even if a value has been assigned to it.

Length 15: hyperu(-838,9,1)

This computes 1676! * (binomial(838,0)/838! - binomial(838,1)/939! + binomial(838,2)/1040! - ... + binomial(838,838)/1676!) using the U-confluent hypergeometric function. See A006902 in the OEIS.

Length 25: (Mod([1,1;1,0],m)^n)[1,2]

Length 14: hyperu(-8,9,1)

This computes 16! * (binomial(8,0)/8! - binomial(8,1)/9! + binomial(8,2)/10! - ... + binomial(8,8)/16!) using the U-confluent hypergeometric function. See A006902 in the OEIS.

Length 14: Vec(eta('x)^2)

This computes the Taylor series of the Dedekind eta function, squares it, and returns the coefficients. This is a slick way to compute sequence A002107 in the OEIS, the number of partitions of a number into an even number of distinct parts minus number of partitions of the same number into an odd number of distinct parts, with 2 types of each part. (Replacing the 2 in the program with a different number changes the number of parts accordingly; using 1, for instance, yields A010815 instead.)

Note that the ' is optional (but good form): it ensures that the program treats x as a variable even if a value has been assigned to it.

Length 15: hyperu(-38,9,1)

This computes 76! * (binomial(38,0)/38! - binomial(38,1)/39! + binomial(38,2)/40! - ... + binomial(38,38)/76!) using the U-confluent hypergeometric function. See A006902 in the OEIS.

Length 25: (Mod([1,1;1,0],m)^n)[1,2]

16 length 14
source | link

teichmuller(x) gives the Teichmüller character of x, that is, the unique (p-1)-th root of unity congruent to x / p^k modulo p with k maximal. PARI/GP has strong support for class field theory and has many nontrivial functions built in.

Length 12: sum(n=1,9,n) Length 13: sumdiv(9,d,d) Length 13: suminf(n=1,n)

Length 14: hyperu(-8,9,1)

This computes 16! * (binomial(8,0)/8! - binomial(8,1)/9! + binomial(8,2)/10! - ... + binomial(8,8)/16!) using the U-confluent hypergeometric function. See A006902 in the OEIS.

teichmuller gives the Teichmüller character of x, that is, the unique (p-1)-th root of unity congruent to x / p^k modulo p with k maximal. PARI/GP has strong support for class field theory and has many nontrivial functions built in.

Length 12: sum(n=1,9,n) Length 13: sumdiv(9,d,d) Length 13: suminf(n=1,n)

teichmuller(x) gives the Teichmüller character of x, that is, the unique (p-1)-th root of unity congruent to x / p^k modulo p with k maximal. PARI/GP has strong support for class field theory and has many nontrivial functions built in.

Length 14: hyperu(-8,9,1)

This computes 16! * (binomial(8,0)/8! - binomial(8,1)/9! + binomial(8,2)/10! - ... + binomial(8,8)/16!) using the U-confluent hypergeometric function. See A006902 in the OEIS.

15 cleanup, add links
source | link
14 add length 13
source | link
13 expand on length 1
source | link
12 add links to explain terms
source | link
11 Hilbert symbol
source | link
10 Teichmüller character
source | link
9 length 10
source | link
8 length 9
source | link
7 length 8
source | link
6 lengths 4 and 7
source | link
5 fordiv
source | link
4 3^3^3
source | link
3 Another snippet
source | link
2 Add two snippets
source | link
1
source | link