Overview of the NumberTheory Package - Maple Programming Help

Home : Support : Online Help : Mathematics : Packages : NumberTheory

Overview of the NumberTheory Package

 Calling Sequence NumberTheory[command](arguments) command(arguments)

Description

 • The NumberTheory package contains commands used to investigate the properties of the natural numbers and integers (see number theory).
 • Each command in the NumberTheory package can be accessed by using either the long form or the short form of the command name in the calling sequence.
 As the underlying implementation of the NumberTheory package is a module, it is also possible to use the form NumberTheory:-command to access a command from the package. For more information, see Module Members.

List of NumberTheory Package Commands

 • The following is a list of commands in the NumberTheory package.

 test whether a sequence of numbers is relatively prime compute the nth term in the Calkin-Wilf sequence Carmichael's lambda function generalized Chinese remainder algorithm continued fraction expansion simple continued fraction expansions for real roots of a rational polynomial minimal polynomials of primitive roots of unity with rational coefficients the set of positive divisors of an integer factorization of integers in quadratic norm-Euclidean fields solution to Minkowski's linear forms modular square root of -1 inhomogeneous Diophantine approximation integral base of an algebraic number field inverse of Euler's totient function test whether a polynomial is cyclotomic test whether a number is a Mersenne number test whether an integer is square free Fermat numbers Mersenne exponents generalized Legendre symbol generalized Jacobi symbol compute the Landau g function largest integer power divisor of a number quadratic residuosity solutions to the modulo n extended GCD problem discrete logarithm under modular arithmetics modular root modular square root Möbius function order of a number under modular multiplication solution to the nearby lattice point problem least safe prime greater than a number number of monic irreducible polynomials number of prime factors counted with multiplicity number of prime numbers less than a number prime factors of an integer primitive root modulo n pseudo primitive root modulo n quadratic residuosity of a number radical of an integer rational number in repeating decimal form modular roots of unity compute the simplest rational number in a real interval sum of powers of the divisors solutions to the sum of two squares problem solutions to a Thue equation or inequality Euler's totient function

Related Commands

 • The following commands are not in the NumberTheory package, but are closely related to number theory.

 Bernoulli polynomials Chinese Remainder Algorithm compute double factorial Euler polynomials compute factorial greatest common divisor of Gaussian integers integer factorization integer factorization greatest common divisor of integers least common multiple of integers compute integer roots solve Diophantine equations for integer solutions primality test compute integer square roots test for a perfect square determine the ith prime number determine the next largest prime determine the next smallest prime non-principal root function

Examples

 > $\mathrm{with}\left(\mathrm{NumberTheory}\right):$

Show $\frac{3}{7}$ as a repeated decimal:

 > $\mathrm{RepeatingDecimal}\left(\frac{3}{7}\right)$
 ${\mathrm{NumberTheory}}{:-}{\mathrm{RepeatingDecimal}}{}\left(\frac{{3}}{{7}}\right)$ (1)

Show $\frac{3}{7}$ as a continued fraction:

 > $\mathrm{ContinuedFraction}\left(\frac{3}{7}\right)$
 ${\mathrm{NumberTheory}}{:-}{\mathrm{ContinuedFraction}}{}\left(\frac{{3}}{{7}}\right)$ (2)

Euler's totient (phi) function is an arithmetic function that counts the positive integers less than or equal to a given value, $n$, that are coprime to $n$. The PrimeCounting (or pi) command returns the number of primes less than an integer, $n$.

Comparing pi(n) with phi(n) for the first forty values for n:

 > $\mathrm{plots}:-\mathrm{display}\left(\mathrm{DynamicSystems}:-\mathrm{DiscretePlot}\left(\left[\mathrm{seq}\left(i-0.1,i=2..40\right)\right],\left[\mathrm{seq}\left(\mathrm{PrimeCounting}\left(n\right),n=2..40\right)\right],\mathrm{style}=\mathrm{stem},\mathrm{symbol}=\mathrm{soliddiamond},\mathrm{color}="Crimson",\mathrm{legend}="pi"\right),\mathrm{DynamicSystems}:-\mathrm{DiscretePlot}\left(\left[\mathrm{seq}\left(i+0.1,i=2..40\right)\right],\left[\mathrm{seq}\left(\mathrm{Totient}\left(n\right),n=2..40\right)\right],\mathrm{style}=\mathrm{stem},\mathrm{symbol}=\mathrm{solidcircle},\mathrm{color}="MidnightBlue",\mathrm{legend}="Totient"\right),\mathrm{linestyle}=\mathrm{dot},\mathrm{transparency}=0.1,\mathrm{size}=\left[800,400\right],{\mathrm{axis}}_{2}=\left[\mathrm{gridlines}=\left[\mathrm{thickness}=0,\mathrm{color}="LightGrey"\right]\right]\right)$ Two integers are relatively prime (coprime) if the greatest common divisor of the values is 1. The following plot shows the coprimes for the integers 1 to 25:

 > $\mathrm{Statistics}:-\mathrm{HeatMap}\left(\mathrm{Matrix}\left(25,\left(i,j\right)→\mathrm{if}\left(\mathrm{AreCoprime}\left(i,j\right),1,0\right)\right),\mathrm{color}=\left["White","Pink"\right]\right)$ > 

Compatibility

 • The NumberTheory package was introduced in Maple 2016.