Number Theory
Number Theory
Number theory is one of the oldest and most intuitive fields of mathematics. It studies integers and their properties.
Packing a large number of sophisticated algorithms, many recent and original, into a powerful collection of functions, Wolfram Language draws on almost every major result in number theory.
A key tool for two decades in the advance of the field, Wolfram Language’s symbolic architecture and web of highly efficient algorithms make it a unique platform for number theoretic experiments, discoveries and proofs.
Factoring & primes
Divisibility & divisors
Congruences & modular arithmetic
Number representations
Diophantine & other equations
Analytic number theory
Algebraic number theory
Factoring & Primes
Factoring & Primes
The primes have been a focal point for investigations of numbers for more than two millennia.
Wolfram Language implements state-of-the-art algorithms for handling both primes and the advanced mathematics that has grown up around their study.
Generating Primes
Generating Primes
◼
Use it to quickly find the millionth prime:
In[]:=
Prime[10^6]
Out[]=
15485863
◼
Find the next prime after 1000:
In[]:=
NextPrime[1000]
Out[]=
1009
Visualize the gaps between primes below :
4
10
In[]:=
Histogram[Table[NextPrime[s]-NextPrime[s,-1],{s,10^4}]]
Out[]=
In[]:=
NextPrime[1000,-1]
Out[]=
997
◼
A random 10-digit prime:
In[]:=
RandomPrime[{10^9,10^10}]
Out[]=
8270303057
◼
A Mersenne prime exponent is a prime number for which the Mersenne number -1 is prime.
p
p
2
Here are the first 10 Mersenne prime exponents:
In[]:=
Table[MersennePrimeExponent[n],{n,10}]
Out[]=
{2,3,5,7,13,17,19,31,61,89}
Sequence of Primes
Sequence of Primes
◼
Compute the number of primes up to :
10
10
Generate a path based on the PrimePi function:
Plot over a subset of the reals:
Plot over a subset of the complexes:
Primality Testing
Primality Testing
◼
PrimeQ is used to test whether an integer is a prime number.
Test whether 119 is prime or not:
Test whether 149 is composite or not:
◼
CoprimeQ is used to test whether two numbers are relatively prime.
Two integers are called relatively prime (mutually prime, coprime) when the only positive integer that can be used to divide both of them is 1.
Test whether two numbers are relatively prime:
Integers are relatively prime if their greatest common divisor is 1.
◼
MersennePrimeExponentQ is used to test whether an integer is a Mersenne prime exponent.
Test whether 5 is a Mersenne prime exponent:
Check:
Highlight Mersenne prime exponents:
◼
PrimePowerQ is used to test whether a number is a power of a prime number.
Test whether 9 is a power of a prime number:
Recognize Mersenne numbers:
Theorems & Equations
Theorems & Equations
◼
Primes represents the domain of prime numbers.
◼
You can use Reduce to reduce expressions over the primes, or FullSimplify to simplify assuming numbers are prime.
◼
Factoring & Primes
Factoring & Primes
The prime factorization of integers is one of the most important results in number theory. It says that every natural number can be written uniquely as a product of primes.
The unique factorization is needed to establish much of what comes later. It gives an alternative, conceptually simpler way to find a lot of numerical characteristics of a number.
Factoring
Factoring
◼
FactorInteger gives a list of the prime factors of an integer, together with their exponents.
Compute for large integers:
Every integer is a prime or a product of primes.
The number of trailing zeros:
◼
SquareFreeQ is used to test whether a number or a polynomial is square free.
Test whether 10 is square free:
Check:
Factoring-Related Functions
Factoring-Related Functions
Compute PrimeNu for 24:
Compute PrimeOmega for 24:
Check:
Compute the Liouville function at 8:
Compute the Mangoldt function at 25:
Plot the MangoldtLambda sequence for the first 100 numbers:
Another function: MoebiusMu
Divisibility & Divisors
Divisibility & Divisors
Divisibility is one of the key notions in number theory.
Divisibility
Divisibility
Test whether a number is divisible by 19:
Highlight numbers divisible by 3:
Find the GCD and LCM of two numbers:
Divisibility & Divisors
Divisibility & Divisors
Divisors
Divisors
The divisors of 1729:
Compare the following plots:
Congruences & Modular Arithmetic
Congruences & Modular Arithmetic
Congruences are of great practical importance in both number theory and everyday life.
The theory of congruences was introduced by Gauss. He created a new branch of number theory by introducing a remarkable notation.
Congruences satisfy a number of important properties and are extremely useful in many areas of number theory.
Functions Related to Congruences & Modular Arithmetic
Functions Related to Congruences & Modular Arithmetic
Plot the sequence with fixed modulus:
◼
PowerMod is known as modular exponentiation.
Plot the sequence with a fixed modulus:
Other functions: MultiplicativeOrder, PrimitiveRoot, ChineseRemainder, PowerModList, CarmichaelLambda, PrimitivePolynomialQ
Diophantine & Other Equations
Diophantine & Other Equations
Functions Related to Diophantine & Other Equations
Functions Related to Diophantine & Other Equations
◼
Integers represents the domain of integers.
◼
You can use Reduce to reduce expressions.
Find a Pythagorean triple:
◼
A linear Diophantine equation in two variables is an equation of the form
Geometrically, a linear Diophantine equation gives a line.
The solutions to this equation are the integer points that are on the line:
Number Representations
Number Representations
DigitRepresentations
DigitRepresentations
Wolfram Language can handle numbers of essentially unlimited length, in any base, using state-of-the-art platform-optimized algorithms, including several developed at Wolfram Research.
For rational numbers, it uses number theoretic methods to efficiently find the exact forms of repeating digit sequences.
◼
FromDigits constructs an integer from a list of decimal digits.
You can also use symbolic digits and base:
A binary integer:
Expansions in different bases can be terminating or non-terminating for the same number:
Decompose an amount of money in different denominations:
Decompose an amount of seconds in days, hours, minutes and seconds:
Continued Fractions & Rational Approximations
Continued Fractions & Rational Approximations
A continued fraction is an expression obtained through an iterative process of representing a number as the sum of its integer part and the reciprocal of another number, then writing this other number as the sum of its integer part and another reciprocal and so on.
Wolfram Language has highly efficient original algorithms for finding large numbers of terms in continued fractions, as well as for handling exact continued fractions for quadratic irrationals.
Rational number:
◼
Convergents gives a list of the convergents corresponding to the continued fraction terms list.
Give all convergents for a rational number:
You can see that they tend to the number.
◼
Khinchin is Khinchin’s constant.
Number Representations
Number Representations
Representations as Sums of Powers
Representations as Sums of Powers
Another function: EllipticTheta
Partitions
Partitions
All partitions of 5:
Analytic Number Theory
Analytic Number Theory
Analytic number theory is a branch of number theory that uses methods from mathematical analysis to solve problems about the integers.
Analytic number theory can be split up into two major parts, divided more by the types of problems they attempt to solve than fundamental differences in technique:
◼
Multiplicative number theory
◼
Additive number theory
Building on its broad strengths in mathematics in general and in special functions in particular, Wolfram Language provides a unique level of support for analytic number theory, including not only highly general function evaluation but also symbolic simplification.
Multiplicative Number Theory
Multiplicative Number Theory
Multiplicative number theory is a subfield of analytic number theory that deals with prime numbers and with factorization and divisors. The focus is usually on developing approximate formulas for counting these objects in various contexts.
Zeta Functions
Zeta Functions
Wolfram Language supports zeta and polylogarithm functions of a complex variable in full generality, performing efficient arbitrary-precision evaluation and implementing extensive symbolic transformations.
Other functions: Zeta, RiemannSiegelZ, RiemannSiegelTheta, StieltjesGamma, RiemannXi, PolyLog, LerchPhi, HurwitzZeta, HurwitzLerchPhi, DirichletBeta, DirichletEta, DirichletLambda, PrimeZetaP
Dirichlet Series
Dirichlet Series
For example,
Another function: DirichetL
Arithmetic Functions
Arithmetic Functions
◼
MoebiusMu gives the Moebius function μ(n), which is defined as follows:
Other functions: Divisors, DivisorSigma, EulerPhi
Prime Numbers
Prime Numbers
Plot PrimePi compared with estimates:
Other functions: PrimeNu, PrimeOmega, Prime, LiouvilleLambda, MangoldtLambda
Perfect Numbers
Perfect Numbers
A perfect number is a positive integer that is equal to the sum of its positive divisors, excluding the number itself.
28 is a perfect number:
Here is the plot of the length of the first 47 even perfect numbers, with log-scaled values:
There is a peculiar connection between perfect numbers and Mersenne primes.
The following is the table of the first 8 Mersenne primes and corresponding perfect numbers:
Other functions: MersennePrimeExponent, MersennePrimeExponentQ
Operations
Operations
Additive Number Theory
Additive Number Theory
Additive number theory is the subfield of number theory concerning the study of subsets of integers and their behavior under addition.
Integer Partitions
Integer Partitions
IntegerPartitions, PartitionsP, PartitionsQ
Base-like Representations
Base-like Representations
Representation in Terms of Powers
Representation in Terms of Powers
Summation-Related Operations
Summation-Related Operations
Sum, Product, DirichletConvolve, DivisorSum, DiscreteConvolve
Arithmetic Functions
Arithmetic Functions
PrimeOmega, PrimeNu, Mod, EulerPhi, MoebiusMu, DivisorSigma
Algebraic Number Theory
Algebraic Number Theory
Algebraic number theory is a branch of number theory that uses the techniques of abstract algebra to study the integers, rational numbers and their generalizations.
With its convenient symbolic representation of algebraic numbers, Wolfram Language’s state-of-the-art algebraic number theory capabilities provide a concrete implementation of one of the historically richest areas of pure mathematics—all tightly integrated with Wolfram Language’s powerful unified environment.
Algebraic Numbers and Representation
Algebraic Numbers and Representation
◼
Represent an algebraic number:
Do arithmetic:
Get a numerical approximation:
Other functions: Root, RootApproximant, IsolatingInterval, MinimalPolynomial, AlgebraicNumberPolynomial
Algebraic Number Fields
Algebraic Number Fields
◼
ToNumberField finds a common field or expresses numbers in a given field.
Factorization
Factorization
◼
Compare:
Other
Other
◼
Extension is a field extension for number theoretic and polynomial operations.
◼
RootReduce reduces an algebraic number to minimal root form.
Useful Reference Pages
Useful Reference Pages
What Is Next?
What Is Next?
CITE THIS NOTEBOOK
CITE THIS NOTEBOOK
An Overview of Number Theory
by Lusine Sukiasyan
Wolfram Community, STAFF PICKS, November 13, 2023
https://community.wolfram.com/groups/-/m/t/3064700
by Lusine Sukiasyan
Wolfram Community, STAFF PICKS, November 13, 2023
https://community.wolfram.com/groups/-/m/t/3064700