(* 9. Dec. 1989 HK *) CLOUT("Test Benchmark for MAS."). BEGIN PRAGMA(TIME); CLOUT("Pi is computed to 100 digits, then the result"); BLINES(0); CLOUT(" is compared to the expected value."); END. (*global variables*) VAR x, pi1, pi, AbsErr, dig, tdig: LIST. (*requested precision, may be changed.*) dig:=100. (*Atari: 50 -> 10 sec, 100 -> 30 sec, 500 -> 800 sec, 1000 -> 3000 sec, 2000 -> 13000 sec. *) (*enter comparison value for pi*) (* 100 digits: (2 (259827921 59572535 43258099 288993829 98521885 523358216 163647820 483469570 341575392 221327768 71487876 210828714)) 500 digits: (2 (93568092 520549573 131785390 196091530 325382260 403604995 485734752 229871352 12356700 35111721 369386764 1295825 164190099 224857141 461681843 129321537 17474935 103757154 299289358 359960434 434892908 531168548 483608753 226956660 187806864 169229296 16793180 328297719 84724285 186639945 421563362 132737959 402044179 517923718 460981083 204471666 348585389 340542185 317978167 23944600 59018185 324458197 169584624 163039612 57017697 332216899 259827917 59572535 43258099 288993829 98521885 523358216 163647820 483469570 341575392 221327768 71487876 210828714)) 1000 digits: (2 (396607056 394638857 80645563 350557546 258512399 110543521 471503976 56076049 108054982 460633677 119120139 66284484 149965470 16786254 287353121 74603542 523779908 42448567 122575539 74524624 191175560 19994647 22899831 146455507 134426360 372256502 105193970 429876277 325179401 456212748 288356870 379024223 418679174 180566941 156107938 434868038 439577636 418741941 94822884 228374652 390169375 366273198 230617256 499286572 317297587 70613987 439593045 409477763 191581381 353719688 22489317 209519240 390633570 313351330 357137642 12108236 318612822 93568087 520549573 131785390 196091530 325382260 403604995 485734752 229871352 12356700 35111721 369386764 1295825 164190099 224857141 461681843 129321537 17474935 103757154 299289358 359960434 434892908 531168548 483608753 226956660 187806864 169229296 16793180 328297719 84724285 186639945 421563362 132737959 402044179 517923718 460981083 204471666 348585389 340542185 317978167 23944600 59018185 324458197 169584624 163039612 57017697 332216899 259827917 59572535 43258099 288993829 98521885 523358216 163647820 483469570 341575392 221327768 71487876 210828714)) 2000 digits: (2 (291185737 415169668 158277613 318302041 273096237 46079127 437377594 194237856 359429003 69494330 397712221 301680989 259986936 268911098 457625321 149889226 242689591 415155408 160889958 501165482 499894384 421982511 145537617 75085560 450679455 453735540 278264170 265427003 142417612 62932608 536112055 173590753 423462366 358406742 93132958 473613939 454311807 257231523 467856699 445077038 326919424 387313394 29295932 397706208 61876632 401339534 359024566 145556818 159023350 525884101 418000319 321007491 318045293 512700986 79683427 309946271 103940451 45459520 439664740 358063115 485096941 137198822 420381178 195581765 308125190 167888459 368757790 5104436 81752552 314407668 428877992 456168748 266504444 347806683 325441142 87773491 400006966 294495213 407055684 73292958 302316294 275403757 159386997 382602192 480648651 423652057 467598463 433649384 467218083 308291142 370058981 345971721 227013993 2640163 437970074 453131575 385585684 499222271 348417150 174386490 262889653 218130706 280503310 7304664 475723255 19493070 524249339 140612694 121914999 83495180 248305995 490319617 84904744 532597414 343400608 396607051 394638857 80645563 350557546 258512399 110543521 471503976 56076049 108054982 460633677 119120139 66284484 149965470 16786254 287353121 74603542 523779908 42448567 122575539 74524624 191175560 19994647 22899831 146455507 134426360 372256502 105193970 429876277 325179401 456212748 288356870 379024223 418679174 180566941 156107938 434868038 439577636 418741941 94822884 228374652 390169375 366273198 230617256 499286572 317297587 70613987 439593045 409477763 191581381 353719688 22489317 209519240 390633570 313351330 357137642 12108236 318612822 93568087 520549573 131785390 196091530 325382260 403604995 485734752 229871352 12356700 35111721 369386764 1295825 164190099 224857141 461681843 129321537 17474935 103757154 299289358 359960434 434892908 531168548 483608753 226956660 187806864 169229296 16793180 328297719 84724285 186639945 421563362 132737959 402044179 517923718 460981083 204471666 348585389 340542185 317978167 23944600 59018185 324458197 169584624 163039612 57017697 332216899 259827917 59572535 43258099 288993829 98521885 523358216 163647820 483469570 341575392 221327768 71487876 210828714)) *) tdig:=100. (*must correspond to the number of digits below.*) PRAGMA(LISP). (SETQ x (2 (259827921 59572535 43258099 288993829 98521885 523358216 163647820 483469570 341575392 221327768 71487876 210828714)) ) (PRAGMA MODULA) (*convert to rational number.*) BEGIN APSPRE(tdig); pi1:=RNFAP(x); (*find maximal meaningful precision*) IF dig < tdig THEN xx:=dig ELSE xx:=tdig END; AbsErr:=RNRED(1,IEXP(10,xx)); CLOUT("AbsErr = "); RNDWR(AbsErr,xx); END. (*compute new value of pi.*) APSPRE(dig). CLOUT("Computing pi ..."). pi:=APPI(). CLOUT("... done."). BEGIN CLOUT("pi="); APWRIT(pi) END. BEGIN CLOUT("Checking Result ... "); x:=APFRN(pi1); e:=APFRN(AbsErr); z:=APABS(APDIFF(pi,x)); t:=APCMPR(z,e); IF t <= 0 THEN CLOUT("Pi correctly computed.") ELSE CLOUT("Pi not correct.") END; END. BEGIN CLOUT("Test finished."); PRAGMA(TIME) END. (*EXIT.*)