Question: How to handle ordering problems

My learning exercise today is the Calkin-Wilf Tree, and the first worksheet I have the issue, due to needing to use a set operator and at that point of computation losing the ordering if it were to be a list (I have tried with a list, and was unsuccessful) none the less my question is, can I alter the ordering condition for Sets in a worksheet produced therein? 

I also encountered a strange result that I would appreciate an explaination for as seen below in the uploaded worksheet

 


 

restart

``

https://en.wikipedia.org/wiki/Calkin–Wilf_tree

 

 

Q := proc (n) options operator, arrow; (`minus`(map(rhs, solve(`union`(seq({q[0] = 1/2, q[1] = 1, q[i+1] = 1/(2*floor(q[i])-q[i]+1)}, i = 1 .. n)))), map(rhs, solve(`union`(seq({q[0] = 1/2, q[1] = 1, q[i+1] = 1/(2*floor(q[i])-q[i]+1)}, i = 1 .. n-1))))))[] end proc

proc (n) options operator, arrow; (`minus`(map(rhs, solve(`union`(seq({q[0] = 1/2, q[1] = 1, q[i+1] = 1/(2*floor(q[i])-q[i]+1)}, i = 1 .. n)))), map(rhs, solve(`union`(seq({q[0] = 1/2, q[1] = 1, q[i+1] = 1/(2*floor(q[i])-q[i]+1)}, i = 1 .. n-1))))))[] end proc

(1)

NULL

delta := proc (x, y) options operator, arrow; piecewise(x = y, 1, x <> y, 0) end proc

proc (x, y) options operator, arrow; piecewise(x = y, 1, x <> y, 0) end proc

(2)

 

 

q[1] := 1

1

(3)

q[2] := 1/2

1/2

(4)

q0 := proc (n) options operator, arrow; 1/(2*floor(Q(n)*(1-delta(n, 2))+delta(n, 2)*q[2]+delta(n, 1)*q[1])-Q(n)*(1-delta(n, 2))-delta(n, 2)*q[2]-delta(n, 1)*q[1]+1) end proc

proc (n) options operator, arrow; 1/(2*floor(Q(n)*(1-delta(n, 2))+delta(n, 2)*q[2]+delta(n, 1)*q[1])-Q(n)*(1-delta(n, 2))-delta(n, 2)*q[2]-delta(n, 1)*q[1]+1) end proc

(5)

[seq(q0(k), k = 1 .. 20)][1]

1/(2*floor(()+1)+())

(6)

NULL


 

Download Q1_MP_08112019.mw

Please Wait...