Calkin Wilf Sequence - 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 : Calkin Wilf Sequence

NumberTheory

  

CalkinWilfSequence

  

compute the nth term in the Calkin-Wilf sequence

 

Calling Sequence

Parameters

Description

Examples

Compatibility

Calling Sequence

CalkinWilfSequence(n)

Parameters

n

-

positive integer

Description

• 

The CalkinWilfSequence function computes the nth term in the Calkin-Wilf sequence.

• 

The vertices of the Calkin-Wilf tree are labeled with rational numbers . The root vertex is defined to be . For any vertex , its children are  and .

• 

The Calkin-Wilf sequence is obtained by breadth-first traversal of the Calkin-Wilf tree, where the lesser child is traversed first.

• 

Every positive rational number occurs exactly once in the Calkin-Wilf tree.

Examples

(1)

(2)

The Calkin-Wilf tree and sequence for the first seven vertices.

(3)

Graphs for larger trees can be generated using the following procedure:

DrawCWTree := proc( n, { graphstyle := tree } )
    local cwseq, cwgraph;
    cwseq := (x -> convert( x, 'string' ))~( [ seq( NumberTheory:-CalkinWilfSequence(i), i = 1 .. n ) ] ):
    cwgraph := GraphTheory:-Graph( { seq( { cwseq[i], cwseq[ floor( (1/2) * i ) ] }, i = 2 .. n ) } ):
    return GraphTheory:-DrawGraph( cwgraph, style = graphstyle );
end proc:

Compatibility

• 

The NumberTheory[CalkinWilfSequence] command was introduced in Maple 2016.

• 

For more information on Maple 2016 changes, see Updates in Maple 2016.

See Also

GraphTheory[DrawGraph]

GraphTheory[Graph]

NumberTheory

 


Download Help Document