Number Theory: Arithmetic Functions
Getting Started
Many commands in this example worksheet are available at Maple's top level, meaning that no packages are required to be loaded. While any command in the Number Theory package can be referred to using the long form, for example, NumberTheory:-Totient, it is often easier to load the package and then use the short form command names as well.
restart;
with(NumberTheory):
Examples
Euler's totient function is an arithmetic function that counts the positive integers less than or equal to a given value, n, that are coprime to n. For a positive integer, n, another number k is said to be coprime, or relatively prime, if the greatest common divisor gcd⁡n,k = 1. For example, 14 and 15 are coprime because the gcd of 14 and 15 is 1, but 14 and 21 are not coprime since the gcd is 7.
Euler's totient function is also known as Euler's phi function, and is denoted as φ⁡n or ϕ⁡n. As such, φ⁡n and ϕ⁡n are aliases for the Totient command.
Totient⁡21,φ⁡21,ϕ⁡21
12,12,12
To visualize the first hundred values for phi(n):
plots:-pointplot⁡seq⁡n,Totient⁡n,n=2..100,labels=n,φ⁡n,symbol=solidcircle,color=MidnightBlue,size=600,golden
The PrimeCounting (or pi) command returns the number of primes less than an integer, n.
PrimeCounting⁡21,pi⁡21
8,8
To visualize the first hundred values for pi(n):
plots:-pointplot⁡seq⁡n,PrimeCounting⁡n,n=2..100,labels=n,π⁡n,symbol=soliddiamond,color=Crimson,size=600,golden
Comparing pi(n) with phi(n) for the first forty values for n:
plots:-display⁡DynamicSystems:-DiscretePlot⁡seq⁡i−0.1,i=2..40,seq⁡PrimeCounting⁡n,n=2..40,style=stem,symbol=soliddiamond,color=Crimson,legend=pi,DynamicSystems:-DiscretePlot⁡seq⁡i+0.1,i=2..40,seq⁡Totient⁡n,n=2..40,style=stem,symbol=solidcircle,color=MidnightBlue,legend=Totient,linestyle=dot,transparency=0.1,size=800,400,axis2=gridlines=thickness=0,color=LightGrey
The Moebius function is defined as a multiplicative arithmetic function mu(r), where:
r = 1 if r is a square-free positive integer with an even number of prime factors
r = -1 if r is a square-free positive integer with an odd number of prime factors
r = 0 if r has a squared prime factor
For example, mu(2) = −1 because 2 is a square-free positive integer which has one prime factor. mu(4) = 0 since 4 is not a square-free positive integer. The first 75 values for the Moebius function are plotted below:
plots:-pointplot⁡seq⁡n,Moebius⁡n,n=1..75,labels=n,μ⁡n,symbolsize=15,symbol=box,color=OrangeRed,size=600,400,tickmarks=default,−1,0,1
See Also
NumberTheory
Download Help Document