Post Reply 
smallest |cos(x)| ?
10-10-2021, 01:36 PM
Post: #12
RE: smallest |cos(x)| ?
Trivia: 2 convergents cannot have both even denominator (or both even numerator)

Code:
def genConvergents(coefs):
    'Return generator for convergents of n/d'
    n0, d0, n1, d1 = 0, 1, 1, 0
    for coef in coefs:
        n0, n1 = n1, n0 + coef * n1
        d0, d1 = d1, d0 + coef * d1
        yield (n1, d1)

From the loops, assume d0 is odd, d1 is even (same reasoning for numerator)

d1 ← d0 + coef*d1 = odd + even = odd

With this trivia, our search for "best" denominator = 2k+1 guaranteed exist.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
smallest |cos(x)| ? - Albert Chan - 10-07-2021, 12:14 PM
RE: smallest |cos(x)| ? - Werner - 10-07-2021, 03:40 PM
RE: smallest |cos(x)| ? - Albert Chan - 10-07-2021, 06:40 PM
RE: smallest |cos(x)| ? - Werner - 10-08-2021, 07:02 AM
RE: smallest |cos(x)| ? - Albert Chan - 10-08-2021, 08:17 PM
RE: smallest |cos(x)| ? - ijabbott - 10-09-2021, 01:15 PM
RE: smallest |cos(x)| ? - Albert Chan - 10-09-2021, 02:09 PM
RE: smallest |cos(x)| ? - Albert Chan - 10-09-2021, 05:01 PM
RE: smallest |cos(x)| ? - EdS2 - 10-08-2021, 08:24 AM
RE: smallest |cos(x)| ? - Werner - 10-08-2021, 02:16 PM
RE: smallest |cos(x)| ? - Albert Chan - 10-08-2021, 07:54 PM
RE: smallest |cos(x)| ? - Werner - 10-11-2021, 01:16 PM
RE: smallest |cos(x)| ? - Albert Chan - 10-11-2021, 04:22 PM
RE: smallest |cos(x)| ? - Albert Chan - 10-10-2021 01:36 PM
RE: smallest |cos(x)| ? - Albert Chan - 10-11-2021, 10:05 PM



User(s) browsing this thread: 2 Guest(s)