Arithmetic Functions - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Mathematics : Number Theory : Examples : Arithmetic Functions

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 gcdn,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.

Totient21,φ21,ϕ21

12,12,12

(1)

To visualize the first hundred values for phi(n):

plots:-pointplotseqn,Totientn,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.

PrimeCounting21,pi21

8,8

(2)

To visualize the first hundred values for pi(n):

plots:-pointplotseqn,PrimeCountingn,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:-displayDynamicSystems:-DiscretePlotseqi0.1,i=2..40,seqPrimeCountingn,n=2..40,style=stem,symbol=soliddiamond,color=Crimson,legend=pi,DynamicSystems:-DiscretePlotseqi+0.1,i=2..40,seqTotientn,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:-pointplotseqn,Moebiusn,n=1..75,labels=n,μn,symbolsize=15,symbol=box,color=OrangeRed,size=600,400,tickmarks=default,1,0,1

See Also

NumberTheory