/******************************************************************************/
/* */
/* COMPARE (K+L, K) MINUS CONTINUED-FRACTIONS CONVERGENTS TO EXPECTED VALUE */
/* 02/23/11 (dkc) */
/* */
/* This C program subtracts generalized continued-fraction convergents of */
/* log(3)/log(2) from the (K+L, K) value of a generalized dead limb and */
/* determines if the difference is the (K+L, K) value of a shorter */
/* generalized dead limb. */
/* */
/******************************************************************************/
#include <stdio.h>
#include <math.h>
unsigned int conv[21*2]={
2, 1,
4, 2,
3, 2,
6, 4,
9, 6,
5, 3,
8, 5,
16, 10,
24, 15,
11, 7,
19, 12,
38, 24,
57, 36,
76, 48,
27, 17,
46, 29,
65, 41,
130, 82,
84, 53,
149, 94,
233, 147};
unsigned int table[159*2]={
0, 0, // 0
4, 3, // 1
5, 4, // 2 (6, 2) => (3, 2)
5, 4, // 3 (7, 3) => (5, 3)
6, 5, // 4
6, 5, // 5 (10, 5) => (8, 5)
7, 6, // 6
8, 7, // 7 (14, 7) => (11, 7)
8, 7, // 8
9, 8, // 9
9, 8, // 10
10, 9, // 11
11, 10, // 12 (22, 12) => (19, 12)
11, 10, // 13
12, 11, // 14
12, 11, // 15
13, 12, // 16
13, 12, // 17 (29, 17) => (27, 17)
14, 13, // 18
15, 14, // 19
15, 14, // 20
16, 15, // 21
16, 15, // 22
17, 16, // 23
18, 17, // 24
18, 17, // 25
19, 18, // 26
19, 18, // 27
20, 19, // 28
20, 19, // 29 (48, 29) => (46, 29)
21, 20, // 30
22, 21, // 31
22, 21, // 32
23, 22, // 33
23, 22, // 34
24, 23, // 35
25, 24, // 36
25, 24, // 37
26, 25, // 38
26, 25, // 39
27, 26, // 40
27, 26, // 41 (67, 41) => (65, 41)
28, 27, // 42
29, 28, // 43
29, 28, // 44
30, 29, // 45
30, 29, // 46
31, 30, // 47
32, 31, // 48
32, 31, // 49
33, 32, // 50
33, 32, // 51
34, 33, // 52
34, 34, // 53 (87, 53) => (84, 53) Note: Even count the same.
35, 34, // 54
36, 35, // 55
36, 35, // 56
37, 36, // 57
37, 36, // 58
38, 37, // 59
39, 38, // 60
39, 38, // 61
40, 39, // 62
40, 39, // 63
41, 40, // 64
42, 41, // 65
42, 41, // 66
43, 42, // 67
43, 42, // 68
44, 43, // 69
44, 43, // 70
45, 44, // 71
46, 45, // 72
46, 45, // 73
47, 46, // 74
47, 46, // 75
48, 47, // 76
49, 48, // 77
49, 48, // 78
50, 49, // 79
50, 49, // 80
51, 50, // 81
51, 50, // 82
52, 51, // 83
53, 52, // 84
53, 52, // 85
54, 53, // 86
54, 53, // 87
55, 54, // 88
56, 55, // 89
56, 55, // 90
57, 56, // 91
57, 56, // 92
58, 57, // 93
58, 57, // 94 // (152, 94) => (149, 94)
59, 58, // 95
60, 59, // 96
60, 59, // 97
61, 60, // 98
61, 60, // 99
62, 61, // 100
63, 62, // 101
63, 62, // 102
64, 63, // 103
64, 63, // 104
65, 64, // 105
65, 65, // 106 // Note: Even count the same.
66, 65, // 107
67, 66, // 108
67, 66, // 109
68, 67, // 110
68, 67, // 111
69, 68, // 112
70, 69, // 113
70, 69, // 114
71, 70, // 115
71, 70, // 116
72, 71, // 117
73, 72, // 118
73, 72, // 119
74, 73, // 120
74, 73, // 121
75, 74, // 122
75, 74, // 123
76, 75, // 124
77, 76, // 125
77, 76, // 126
78, 77, // 127
78, 77, // 128
79, 78, // 129
80, 79, // 130
80, 79, // 131
81, 80, // 132
81, 80, // 133
82, 81, // 134
82, 82, // 135 // Note: Even count same.
83, 82, // 136
84, 83, // 137
84, 83, // 138
85, 84, // 139
85, 84, // 140
86, 85, // 141
87, 86, // 142
87, 86, // 143
88, 87, // 144
88, 87, // 145
89, 88, // 146
89, 88, // 147
90, 89, // 148
91, 90, // 149
91, 90, // 150
92, 91, // 151
92, 91, // 152
93, 92, // 153
94, 93, // 154
94, 93, // 155
95, 94, // 156
95, 94, // 157
96, 95}; // 158
int main () {
unsigned int i,j,k,l,a,b,c,d,z,delo,dela,delb;
FILE *Outfp;
Outfp = fopen("out2e.dat","w");
for (i=1; i<159; i++) {
z=table[2*i]; // evens
a=table[2*i+1]; // evens
b=i; // odds
printf(" i=%d, z=%d, a=%d \n",b,z,a);
for (j=0; j<21; j++) {
c=conv[2*j]; // K+L
d=conv[2*j+1]; // K
if (d>=b)
continue;
if ((z+b)<c) {
printf("error: i=%d, j=%d, z+b=%d, c=%d \n",i,j,z+b,c);
goto zskip;
}
delo=b-d; // delta odds
dela=z+b-c; // delta (evens+odds)
delb=a+b-c; // delta (evens+odds)
k=table[2*delo]+delo; // expected delta (evens+odds)
l=table[2*delo+1]+delo; // expected delta (evens+odds)
if ((k!=dela)&&(l!=dela)&&(k!=delb)&&(l!=delb)) {
printf("error: i=%d, j=%d, k=%d, l=%d, dela=%d, delb=%d \n",i,j,k,l,dela,delb);
goto zskip;
}
}
}
zskip:
fclose(Outfp);
return(0);
}