mini challenge: find the smallest cosine of an integer
|
10-24-2021, 06:17 PM
Post: #18
|
|||
|
|||
RE: mini challenge: find the smallest cosine of an integer
(10-24-2021 06:56 AM)PeterP Wrote: Alas, things get really slow when you add the test for 0.5. And just doing Pi-3 actually only gives you about 1-2 extra digits and the error still accumulates quickly. A novel way is use SIN(X) >PI, SIN(PI) @ REM sum = 3.141592653589793238462643 (25 digits of pi) 3.14159265359 -2.06761537357E-13 This program get numerator of convergents of pi With internal 25 digits of stored pi, all convergents correct Building of convergents is fast, using formula, P = P0 + k*P1 (P's are all integers, no error is introduced building P's) 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 >RUN 1 3 22 333 355 103993 104348 208341 312689 833719 1146408 4272943 5419351 80143857 165707065 245850922 411557987 1068966896 2549491779 6167950454 14885392687 21053343141 sin(2x) = 2*sin(x)*cos(x). If |cos(x)| is small, so does |sin(2x)| We pick convergents/semi-convergents with even numerator. 2x = 1+3, 1+3*3, 1+3*5, 22, 333+355, 333+355*3, 333+355*5 ... 333+355*291, 104348, ... x = 2, 5, 8, 11, 344, 699, 1054 ... 51819, 52174, ... |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)