HP Forums
mini challenge: find the smallest cosine of an integer - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: General Forum (/forum-4.html)
+--- Thread: mini challenge: find the smallest cosine of an integer (/thread-17595.html)

Pages: 1 2


RE: mini challenge: find the smallest cosine of an integer - Albert Chan - 10-24-2021 11:42 PM

(10-24-2021 06:17 PM)Albert Chan Wrote:  10 P0=0 @ P1=1 @ P=P0 @ S=2
20 P=P+P1 @ S2=ABS(SIN(P))
30 IF S>S2 THEN S=S2 @ DISP P @ P0=P1 @ P1=P @ P=P0
40 IF P<1.E+12 THEN 20

It is not obvious (at least for me), why smaller |sin(P)| signaled a convergent.
Say, 2 neighboring convergents, p1/q1 > π > p2/q2
We write this to show p2/q2 is the better estimate for π:

p1/q1 > (p1+p2)/(q1+q2) > π > p2/q2

(p1+p2) > (q1+q2)*π
p1 - q1*π > q2*π - p2 > 0
|p1 - q1*π| > |p2 - q2*π|

Both sides are tiny. Within this range, sin is increasing function, so take sin of both side.

sin(|p1 - q1*π|) > sin(|p2 - q2*π|)
|sin(p1)| > |sin(p2)|

Thus, when |sin(P)| get smaller, we found a convergent.