Home » Archimedes archive » Archimedes World » AW-1996-06-Disc 1.adf » !AcornAns_AcornAns » MathFns/Coef
MathFns/Coef
This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.
Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.
Tape/disk: | Home » Archimedes archive » Archimedes World » AW-1996-06-Disc 1.adf » !AcornAns_AcornAns |
Filename: | MathFns/Coef |
Read OK: | ✔ |
File size: | 0ACD bytes |
Load address: | 0000 |
Exec address: | 0000 |
File contents
10REM >Coef 20REM Calculate polynomial approximations to arbitrary functions 30REM in an arbitrary range, using Chebyshev Forced Oscillation of 40REM Error method to derive a near minimax solution 50REM 60MODE MODE 70INPUT "Please enter function to be approximated {eg SIN(x*PI/2)} ";f$ 80INPUT "Approximation range [a,b] {eg [0,1]}"'"Please enter a ";a$;"Please enter b ";b$ 90INPUT "Please enter degree of approximation (1 to 100) ";n%' 100a = EVAL a$ 110b = EVAL b$ 120u = 2/(b-a) 130v = (a+b)/(a-b) 140DIM f(101), c(101), t(100, 100), p(100), s(100), t2(100) 150FOR i%=0 TO n%+1 160 x = 0.5*((b-a)*COS(i%*PI/(n%+1))+(a+b)) 170 f(i%) = EVAL f$ 180NEXT 190FOR j%=0 TO n%+1 200 IF (j%AND1) sum = (f(0)-f(n%+1))/2 ELSE sum = (f(0)+f(n%+1))/2 210 FOR i%=1 TO n% 220 sum += f(i%)*COS(i%*j%*PI/(n%+1)) 230 NEXT 240 c(j%) = sum/(n%+1) 250 IF j%<>0 c(j%) = 2*c(j%) 260NEXT 270E = ABS(c(n%+1)/2) 280PRINT '"Writing z = ";u;"*x + ";v;", polynomial approximation then is:"' 290FOR i%=0 TO n% 300 PRINT "T[";i%;"](z) *",c(i%);TAB(27); 310 IF i%<n% PRINT "+" ELSE PRINT 320NEXT 330PRINT '"where T[0](z) = 1;" 340PRINT " T[1](z) = z;" 350PRINT "and T[n+1](z) = 2zT[n](z)-T[n-1](z), for n>=1"' 360REM Now we need to gen the T polys 370REM note we use array t(i,j) to hold the coef of z^j in poly T[i] 380t(0,0)=1 390t(1,1)=1 400i%=1 410WHILE i%<n% 420 t(i%+1,0) = -t(i%-1,0) 430 FOR j% = 1 TO i%+1 440 t(i%+1,j%) = 2*t(i%,j%-1)-t(i%-1,j%) 450 NEXT 460 i%+=1 470ENDWHILE 480REM Then we expand them to give an approximating poly array p(j) 490REM where each element is the coef of z^j in that poly 500FOR i%=0 TO n% 510 sum = 0 520 FOR j%=i% TO n% 530 sum += t(j%, i%)*c(j%) 540 NEXT 550 p(i%) = sum 560NEXT 570REM And now we make the substitution z = ux+v 580REM to get our final poly in argument x (poly stored in array t2) 590t2(0)=p(0)+p(1)*v 600t2(1)=p(1)*u 610s(0)=v 620s(1)=u 630i%=2 640WHILE i%<=n% 650 FOR j%=i% TO 1 STEP -1 660 s(j%)=v*s(j%)+u*s(j%-1) 670 NEXT 680 s(0)=v*s(0) 690 FOR j%=0 TO i% 700 t2(j%)+=p(i%)*s(j%) 710 NEXT 720 i%+=1 730ENDWHILE 740PRINT '"Which may also be written:"' 750FOR i%=0 TO n% 760 PRINT "x^";i%;" *",t2(i%);TAB(27); 770 IF i%<n% PRINT "+" ELSE PRINT 780NEXT 790maxerror = 0 800FOR x=a TO b STEP (b-a)/1000 810 y = t2(n%) 820 FOR i%=n%-1 TO 0 STEP -1 830 y = y*x+t2(i%) 840 NEXT 850 e = ABS(y - EVAL f$) 860 IF e>maxerror maxerror=e 870NEXT 880PRINT ''"For this approximation an upper bound on error is ";maxerror 890PRINT "Also we now know minimax error p (the error made by the best possible order ";n% 900PRINT "polynomial) lies between:"' 910PRINT E;" and ";maxerror;"."' 920PRINT "This indicates how close our approximation is to it." 930PRINT ''"Finally, if only need say 16 bit accuracy, note that our poly's coefficients" 940PRINT "multiplied by 2^20 & written in hex are as follows:"' 950FOR i%=n% TO 0 STEP -1 960 y = t2(i%) 970 IF y<0 s$="-":y=-y ELSE s$="+" 980 y2 = y*1048576+0.5 990 PRINT "x^";i%;" *",s$;RIGHT$("00000000"+STR$~y2,8);TAB(27); 1000 IF i%>0 PRINT "+" ELSE PRINT 1010NEXT
� >Coef @� Calculate polynomial approximations to arbitrary functions B� in an arbitrary range, using Chebyshev Forced Oscillation of (4� Error method to derive a near minimax solution 2� <� � FE� "Please enter function to be approximated {eg SIN(x*PI/2)} ";f$ PV� "Approximation range [a,b] {eg [0,1]}"'"Please enter a ";a$;"Please enter b ";b$ Z<� "Please enter degree of approximation (1 to 100) ";n%' da = � a$ nb = � b$ xu = 2/(b-a) �v = (a+b)/(a-b) �:� f(101), c(101), t(100, 100), p(100), s(100), t2(100) �� i%=0 � n%+1 �) x = 0.5*((b-a)*�(i%*�/(n%+1))+(a+b)) � f(i%) = � f$ �� �� j%=0 � n%+1 �= � (j%�1) sum = (f(0)-f(n%+1))/2 � sum = (f(0)+f(n%+1))/2 � � i%=1 � n% �$ sum += f(i%)*�(i%*j%*�/(n%+1)) � � � c(j%) = sum/(n%+1) � � j%<>0 c(j%) = 2*c(j%) � E = �(c(n%+1)/2) H� '"Writing z = ";u;"*x + ";v;", polynomial approximation then is:"' "� i%=0 � n% ,# � "T[";i%;"](z) *",c(i%);�27); 6 � i%<n% � "+" � � @� J� '"where T[0](z) = 1;" T� " T[1](z) = z;" ^9� "and T[n+1](z) = 2zT[n](z)-T[n-1](z), for n>=1"' h$� Now we need to gen the T polys rC� note we use array t(i,j) to hold the coef of z^j in poly T[i] |t(0,0)=1 �t(1,1)=1 �i%=1 �ȕ i%<n% � t(i%+1,0) = -t(i%-1,0) � � j% = 1 � i%+1 �* t(i%+1,j%) = 2*t(i%,j%-1)-t(i%-1,j%) � � � i%+=1 �� �B� Then we expand them to give an approximating poly array p(j) �8� where each element is the coef of z^j in that poly �� i%=0 � n% � sum = 0 � j%=i% � n% sum += t(j%, i%)*c(j%) � & p(i%) = sum 0� :/� And now we make the substitution z = ux+v DC� to get our final poly in argument x (poly stored in array t2) Nt2(0)=p(0)+p(1)*v Xt2(1)=p(1)*u b s(0)=v l s(1)=u vi%=2 � ȕ i%<=n% � � j%=i% � 1 � -1 � s(j%)=v*s(j%)+u*s(j%-1) � � � s(0)=v*s(0) � � j%=0 � i% � t2(j%)+=p(i%)*s(j%) � � � i%+=1 �� �$� '"Which may also be written:"' �� i%=0 � n% �! � "x^";i%;" *",t2(i%);�27); � i%<n% � "+" � � � maxerror = 0 � x=a � b � (b-a)/1000 * y = t2(n%) 4 � i%=n%-1 � 0 � -1 > y = y*x+t2(i%) H � R e = �(y - � f$) \ � e>maxerror maxerror=e f� pE� ''"For this approximation an upper bound on error is ";maxerror zY� "Also we now know minimax error p (the error made by the best possible order ";n% �$� "polynomial) lies between:"' �� E;" and ";maxerror;"."' �<� "This indicates how close our approximation is to it." �V� ''"Finally, if only need say 16 bit accuracy, note that our poly's coefficients" �>� "multiplied by 2^20 & written in hex are as follows:"' �� i%=n% � 0 � -1 � y = t2(i%) � � y<0 s$="-":y=-y � s$="+" � y2 = y*1048576+0.5 �1 � "x^";i%;" *",s$;�"00000000"+�~y2,8);�27); � � i%>0 � "+" � � �� �
00000000 0d 00 0a 0b f4 20 3e 43 6f 65 66 0d 00 14 40 f4 |..... >Coef...@.| 00000010 20 43 61 6c 63 75 6c 61 74 65 20 70 6f 6c 79 6e | Calculate polyn| 00000020 6f 6d 69 61 6c 20 61 70 70 72 6f 78 69 6d 61 74 |omial approximat| 00000030 69 6f 6e 73 20 74 6f 20 61 72 62 69 74 72 61 72 |ions to arbitrar| 00000040 79 20 66 75 6e 63 74 69 6f 6e 73 0d 00 1e 42 f4 |y functions...B.| 00000050 20 69 6e 20 61 6e 20 61 72 62 69 74 72 61 72 79 | in an arbitrary| 00000060 20 72 61 6e 67 65 2c 20 75 73 69 6e 67 20 43 68 | range, using Ch| 00000070 65 62 79 73 68 65 76 20 46 6f 72 63 65 64 20 4f |ebyshev Forced O| 00000080 73 63 69 6c 6c 61 74 69 6f 6e 20 6f 66 0d 00 28 |scillation of..(| 00000090 34 f4 20 45 72 72 6f 72 20 6d 65 74 68 6f 64 20 |4. Error method | 000000a0 74 6f 20 64 65 72 69 76 65 20 61 20 6e 65 61 72 |to derive a near| 000000b0 20 6d 69 6e 69 6d 61 78 20 73 6f 6c 75 74 69 6f | minimax solutio| 000000c0 6e 0d 00 32 05 f4 0d 00 3c 07 eb 20 eb 0d 00 46 |n..2....<.. ...F| 000000d0 45 e8 20 22 50 6c 65 61 73 65 20 65 6e 74 65 72 |E. "Please enter| 000000e0 20 66 75 6e 63 74 69 6f 6e 20 74 6f 20 62 65 20 | function to be | 000000f0 61 70 70 72 6f 78 69 6d 61 74 65 64 20 7b 65 67 |approximated {eg| 00000100 20 53 49 4e 28 78 2a 50 49 2f 32 29 7d 20 22 3b | SIN(x*PI/2)} ";| 00000110 66 24 0d 00 50 56 e8 20 22 41 70 70 72 6f 78 69 |f$..PV. "Approxi| 00000120 6d 61 74 69 6f 6e 20 72 61 6e 67 65 20 5b 61 2c |mation range [a,| 00000130 62 5d 20 7b 65 67 20 5b 30 2c 31 5d 7d 22 27 22 |b] {eg [0,1]}"'"| 00000140 50 6c 65 61 73 65 20 65 6e 74 65 72 20 61 20 22 |Please enter a "| 00000150 3b 61 24 3b 22 50 6c 65 61 73 65 20 65 6e 74 65 |;a$;"Please ente| 00000160 72 20 62 20 22 3b 62 24 0d 00 5a 3c e8 20 22 50 |r b ";b$..Z<. "P| 00000170 6c 65 61 73 65 20 65 6e 74 65 72 20 64 65 67 72 |lease enter degr| 00000180 65 65 20 6f 66 20 61 70 70 72 6f 78 69 6d 61 74 |ee of approximat| 00000190 69 6f 6e 20 28 31 20 74 6f 20 31 30 30 29 20 22 |ion (1 to 100) "| 000001a0 3b 6e 25 27 0d 00 64 0c 61 20 3d 20 a0 20 61 24 |;n%'..d.a = . a$| 000001b0 0d 00 6e 0c 62 20 3d 20 a0 20 62 24 0d 00 78 0f |..n.b = . b$..x.| 000001c0 75 20 3d 20 32 2f 28 62 2d 61 29 0d 00 82 13 76 |u = 2/(b-a)....v| 000001d0 20 3d 20 28 61 2b 62 29 2f 28 61 2d 62 29 0d 00 | = (a+b)/(a-b)..| 000001e0 8c 3a de 20 66 28 31 30 31 29 2c 20 63 28 31 30 |.:. f(101), c(10| 000001f0 31 29 2c 20 74 28 31 30 30 2c 20 31 30 30 29 2c |1), t(100, 100),| 00000200 20 70 28 31 30 30 29 2c 20 73 28 31 30 30 29 2c | p(100), s(100),| 00000210 20 74 32 28 31 30 30 29 0d 00 96 11 e3 20 69 25 | t2(100)..... i%| 00000220 3d 30 20 b8 20 6e 25 2b 31 0d 00 a0 29 20 78 20 |=0 . n%+1...) x | 00000230 3d 20 30 2e 35 2a 28 28 62 2d 61 29 2a 9b 28 69 |= 0.5*((b-a)*.(i| 00000240 25 2a af 2f 28 6e 25 2b 31 29 29 2b 28 61 2b 62 |%*./(n%+1))+(a+b| 00000250 29 29 0d 00 aa 11 20 66 28 69 25 29 20 3d 20 a0 |)).... f(i%) = .| 00000260 20 66 24 0d 00 b4 05 ed 0d 00 be 11 e3 20 6a 25 | f$.......... j%| 00000270 3d 30 20 b8 20 6e 25 2b 31 0d 00 c8 3d 20 e7 20 |=0 . n%+1...= . | 00000280 28 6a 25 80 31 29 20 73 75 6d 20 3d 20 28 66 28 |(j%.1) sum = (f(| 00000290 30 29 2d 66 28 6e 25 2b 31 29 29 2f 32 20 8b 20 |0)-f(n%+1))/2 . | 000002a0 73 75 6d 20 3d 20 28 66 28 30 29 2b 66 28 6e 25 |sum = (f(0)+f(n%| 000002b0 2b 31 29 29 2f 32 0d 00 d2 10 20 e3 20 69 25 3d |+1))/2.... . i%=| 000002c0 31 20 b8 20 6e 25 0d 00 dc 24 20 20 73 75 6d 20 |1 . n%...$ sum | 000002d0 2b 3d 20 66 28 69 25 29 2a 9b 28 69 25 2a 6a 25 |+= f(i%)*.(i%*j%| 000002e0 2a af 2f 28 6e 25 2b 31 29 29 0d 00 e6 06 20 ed |*./(n%+1)).... .| 000002f0 0d 00 f0 17 20 63 28 6a 25 29 20 3d 20 73 75 6d |.... c(j%) = sum| 00000300 2f 28 6e 25 2b 31 29 0d 00 fa 1c 20 e7 20 6a 25 |/(n%+1).... . j%| 00000310 3c 3e 30 20 63 28 6a 25 29 20 3d 20 32 2a 63 28 |<>0 c(j%) = 2*c(| 00000320 6a 25 29 0d 01 04 05 ed 0d 01 0e 14 45 20 3d 20 |j%).........E = | 00000330 94 28 63 28 6e 25 2b 31 29 2f 32 29 0d 01 18 48 |.(c(n%+1)/2)...H| 00000340 f1 20 27 22 57 72 69 74 69 6e 67 20 7a 20 3d 20 |. '"Writing z = | 00000350 22 3b 75 3b 22 2a 78 20 2b 20 22 3b 76 3b 22 2c |";u;"*x + ";v;",| 00000360 20 70 6f 6c 79 6e 6f 6d 69 61 6c 20 61 70 70 72 | polynomial appr| 00000370 6f 78 69 6d 61 74 69 6f 6e 20 74 68 65 6e 20 69 |oximation then i| 00000380 73 3a 22 27 0d 01 22 0f e3 20 69 25 3d 30 20 b8 |s:"'..".. i%=0 .| 00000390 20 6e 25 0d 01 2c 23 20 f1 20 22 54 5b 22 3b 69 | n%..,# . "T[";i| 000003a0 25 3b 22 5d 28 7a 29 20 2a 22 2c 63 28 69 25 29 |%;"](z) *",c(i%)| 000003b0 3b 8a 32 37 29 3b 0d 01 36 16 20 e7 20 69 25 3c |;.27);..6. . i%<| 000003c0 6e 25 20 f1 20 22 2b 22 20 8b 20 f1 0d 01 40 05 |n% . "+" . ...@.| 000003d0 ed 0d 01 4a 1d f1 20 27 22 77 68 65 72 65 20 54 |...J.. '"where T| 000003e0 5b 30 5d 28 7a 29 20 20 20 3d 20 31 3b 22 0d 01 |[0](z) = 1;"..| 000003f0 54 1d f1 20 20 22 20 20 20 20 20 20 54 5b 31 5d |T.. " T[1]| 00000400 28 7a 29 20 20 20 3d 20 7a 3b 22 0d 01 5e 39 f1 |(z) = z;"..^9.| 00000410 20 20 22 61 6e 64 20 20 20 54 5b 6e 2b 31 5d 28 | "and T[n+1](| 00000420 7a 29 20 3d 20 32 7a 54 5b 6e 5d 28 7a 29 2d 54 |z) = 2zT[n](z)-T| 00000430 5b 6e 2d 31 5d 28 7a 29 2c 20 66 6f 72 20 6e 3e |[n-1](z), for n>| 00000440 3d 31 22 27 0d 01 68 24 f4 20 4e 6f 77 20 77 65 |=1"'..h$. Now we| 00000450 20 6e 65 65 64 20 74 6f 20 67 65 6e 20 74 68 65 | need to gen the| 00000460 20 54 20 70 6f 6c 79 73 0d 01 72 43 f4 20 6e 6f | T polys..rC. no| 00000470 74 65 20 77 65 20 75 73 65 20 61 72 72 61 79 20 |te we use array | 00000480 74 28 69 2c 6a 29 20 74 6f 20 68 6f 6c 64 20 74 |t(i,j) to hold t| 00000490 68 65 20 63 6f 65 66 20 6f 66 20 7a 5e 6a 20 69 |he coef of z^j i| 000004a0 6e 20 70 6f 6c 79 20 54 5b 69 5d 0d 01 7c 0c 74 |n poly T[i]..|.t| 000004b0 28 30 2c 30 29 3d 31 0d 01 86 0c 74 28 31 2c 31 |(0,0)=1....t(1,1| 000004c0 29 3d 31 0d 01 90 08 69 25 3d 31 0d 01 9a 0c c8 |)=1....i%=1.....| 000004d0 95 20 69 25 3c 6e 25 0d 01 a4 1b 20 74 28 69 25 |. i%<n%.... t(i%| 000004e0 2b 31 2c 30 29 20 3d 20 2d 74 28 69 25 2d 31 2c |+1,0) = -t(i%-1,| 000004f0 30 29 0d 01 ae 14 20 e3 20 6a 25 20 3d 20 31 20 |0).... . j% = 1 | 00000500 b8 20 69 25 2b 31 0d 01 b8 2a 20 20 74 28 69 25 |. i%+1...* t(i%| 00000510 2b 31 2c 6a 25 29 20 3d 20 32 2a 74 28 69 25 2c |+1,j%) = 2*t(i%,| 00000520 6a 25 2d 31 29 2d 74 28 69 25 2d 31 2c 6a 25 29 |j%-1)-t(i%-1,j%)| 00000530 0d 01 c2 06 20 ed 0d 01 cc 0a 20 69 25 2b 3d 31 |.... ..... i%+=1| 00000540 0d 01 d6 05 ce 0d 01 e0 42 f4 20 54 68 65 6e 20 |........B. Then | 00000550 77 65 20 65 78 70 61 6e 64 20 74 68 65 6d 20 74 |we expand them t| 00000560 6f 20 67 69 76 65 20 61 6e 20 61 70 70 72 6f 78 |o give an approx| 00000570 69 6d 61 74 69 6e 67 20 70 6f 6c 79 20 61 72 72 |imating poly arr| 00000580 61 79 20 70 28 6a 29 0d 01 ea 38 f4 20 77 68 65 |ay p(j)...8. whe| 00000590 72 65 20 65 61 63 68 20 65 6c 65 6d 65 6e 74 20 |re each element | 000005a0 69 73 20 74 68 65 20 63 6f 65 66 20 6f 66 20 7a |is the coef of z| 000005b0 5e 6a 20 69 6e 20 74 68 61 74 20 70 6f 6c 79 0d |^j in that poly.| 000005c0 01 f4 0f e3 20 69 25 3d 30 20 b8 20 6e 25 0d 01 |.... i%=0 . n%..| 000005d0 fe 0c 20 73 75 6d 20 3d 20 30 0d 02 08 11 20 e3 |.. sum = 0.... .| 000005e0 20 6a 25 3d 69 25 20 b8 20 6e 25 0d 02 12 1c 20 | j%=i% . n%.... | 000005f0 20 73 75 6d 20 2b 3d 20 74 28 6a 25 2c 20 69 25 | sum += t(j%, i%| 00000600 29 2a 63 28 6a 25 29 0d 02 1c 06 20 ed 0d 02 26 |)*c(j%).... ...&| 00000610 10 20 70 28 69 25 29 20 3d 20 73 75 6d 0d 02 30 |. p(i%) = sum..0| 00000620 05 ed 0d 02 3a 2f f4 20 41 6e 64 20 6e 6f 77 20 |....:/. And now | 00000630 77 65 20 6d 61 6b 65 20 74 68 65 20 73 75 62 73 |we make the subs| 00000640 74 69 74 75 74 69 6f 6e 20 7a 20 3d 20 75 78 2b |titution z = ux+| 00000650 76 0d 02 44 43 f4 20 74 6f 20 67 65 74 20 6f 75 |v..DC. to get ou| 00000660 72 20 66 69 6e 61 6c 20 70 6f 6c 79 20 69 6e 20 |r final poly in | 00000670 61 72 67 75 6d 65 6e 74 20 78 20 28 70 6f 6c 79 |argument x (poly| 00000680 20 73 74 6f 72 65 64 20 69 6e 20 61 72 72 61 79 | stored in array| 00000690 20 74 32 29 0d 02 4e 15 74 32 28 30 29 3d 70 28 | t2)..N.t2(0)=p(| 000006a0 30 29 2b 70 28 31 29 2a 76 0d 02 58 10 74 32 28 |0)+p(1)*v..X.t2(| 000006b0 31 29 3d 70 28 31 29 2a 75 0d 02 62 0a 73 28 30 |1)=p(1)*u..b.s(0| 000006c0 29 3d 76 0d 02 6c 0a 73 28 31 29 3d 75 0d 02 76 |)=v..l.s(1)=u..v| 000006d0 08 69 25 3d 32 0d 02 80 0d c8 95 20 69 25 3c 3d |.i%=2...... i%<=| 000006e0 6e 25 0d 02 8a 15 20 e3 20 6a 25 3d 69 25 20 b8 |n%.... . j%=i% .| 000006f0 20 31 20 88 20 2d 31 0d 02 94 1d 20 20 73 28 6a | 1 . -1.... s(j| 00000700 25 29 3d 76 2a 73 28 6a 25 29 2b 75 2a 73 28 6a |%)=v*s(j%)+u*s(j| 00000710 25 2d 31 29 0d 02 9e 06 20 ed 0d 02 a8 10 20 73 |%-1).... ..... s| 00000720 28 30 29 3d 76 2a 73 28 30 29 0d 02 b2 10 20 e3 |(0)=v*s(0).... .| 00000730 20 6a 25 3d 30 20 b8 20 69 25 0d 02 bc 19 20 20 | j%=0 . i%.... | 00000740 74 32 28 6a 25 29 2b 3d 70 28 69 25 29 2a 73 28 |t2(j%)+=p(i%)*s(| 00000750 6a 25 29 0d 02 c6 06 20 ed 0d 02 d0 0a 20 69 25 |j%).... ..... i%| 00000760 2b 3d 31 0d 02 da 05 ce 0d 02 e4 24 f1 20 27 22 |+=1........$. '"| 00000770 57 68 69 63 68 20 6d 61 79 20 61 6c 73 6f 20 62 |Which may also b| 00000780 65 20 77 72 69 74 74 65 6e 3a 22 27 0d 02 ee 0f |e written:"'....| 00000790 e3 20 69 25 3d 30 20 b8 20 6e 25 0d 02 f8 21 20 |. i%=0 . n%...! | 000007a0 f1 20 22 78 5e 22 3b 69 25 3b 22 20 20 2a 22 2c |. "x^";i%;" *",| 000007b0 74 32 28 69 25 29 3b 8a 32 37 29 3b 0d 03 02 16 |t2(i%);.27);....| 000007c0 20 e7 20 69 25 3c 6e 25 20 f1 20 22 2b 22 20 8b | . i%<n% . "+" .| 000007d0 20 f1 0d 03 0c 05 ed 0d 03 16 10 6d 61 78 65 72 | ..........maxer| 000007e0 72 6f 72 20 3d 20 30 0d 03 20 1a e3 20 78 3d 61 |ror = 0.. .. x=a| 000007f0 20 b8 20 62 20 88 20 28 62 2d 61 29 2f 31 30 30 | . b . (b-a)/100| 00000800 30 0d 03 2a 0f 20 79 20 3d 20 74 32 28 6e 25 29 |0..*. y = t2(n%)| 00000810 0d 03 34 17 20 e3 20 69 25 3d 6e 25 2d 31 20 b8 |..4. . i%=n%-1 .| 00000820 20 30 20 88 20 2d 31 0d 03 3e 14 20 20 79 20 3d | 0 . -1..>. y =| 00000830 20 79 2a 78 2b 74 32 28 69 25 29 0d 03 48 06 20 | y*x+t2(i%)..H. | 00000840 ed 0d 03 52 14 20 65 20 3d 20 94 28 79 20 2d 20 |...R. e = .(y - | 00000850 a0 20 66 24 29 0d 03 5c 1c 20 e7 20 65 3e 6d 61 |. f$)..\. . e>ma| 00000860 78 65 72 72 6f 72 20 6d 61 78 65 72 72 6f 72 3d |xerror maxerror=| 00000870 65 0d 03 66 05 ed 0d 03 70 45 f1 20 27 27 22 46 |e..f....pE. ''"F| 00000880 6f 72 20 74 68 69 73 20 61 70 70 72 6f 78 69 6d |or this approxim| 00000890 61 74 69 6f 6e 20 61 6e 20 75 70 70 65 72 20 62 |ation an upper b| 000008a0 6f 75 6e 64 20 6f 6e 20 65 72 72 6f 72 20 69 73 |ound on error is| 000008b0 20 22 3b 6d 61 78 65 72 72 6f 72 0d 03 7a 59 f1 | ";maxerror..zY.| 000008c0 20 20 20 22 41 6c 73 6f 20 77 65 20 6e 6f 77 20 | "Also we now | 000008d0 6b 6e 6f 77 20 6d 69 6e 69 6d 61 78 20 65 72 72 |know minimax err| 000008e0 6f 72 20 70 20 28 74 68 65 20 65 72 72 6f 72 20 |or p (the error | 000008f0 6d 61 64 65 20 62 79 20 74 68 65 20 62 65 73 74 |made by the best| 00000900 20 70 6f 73 73 69 62 6c 65 20 6f 72 64 65 72 20 | possible order | 00000910 22 3b 6e 25 0d 03 84 24 f1 20 20 20 22 70 6f 6c |";n%...$. "pol| 00000920 79 6e 6f 6d 69 61 6c 29 20 6c 69 65 73 20 62 65 |ynomial) lies be| 00000930 74 77 65 65 6e 3a 22 27 0d 03 8e 1f f1 20 45 3b |tween:"'..... E;| 00000940 22 20 20 61 6e 64 20 20 22 3b 6d 61 78 65 72 72 |" and ";maxerr| 00000950 6f 72 3b 22 2e 22 27 0d 03 98 3c f1 20 22 54 68 |or;"."'...<. "Th| 00000960 69 73 20 69 6e 64 69 63 61 74 65 73 20 68 6f 77 |is indicates how| 00000970 20 63 6c 6f 73 65 20 6f 75 72 20 61 70 70 72 6f | close our appro| 00000980 78 69 6d 61 74 69 6f 6e 20 69 73 20 74 6f 20 69 |ximation is to i| 00000990 74 2e 22 0d 03 a2 56 f1 20 27 27 22 46 69 6e 61 |t."...V. ''"Fina| 000009a0 6c 6c 79 2c 20 69 66 20 6f 6e 6c 79 20 6e 65 65 |lly, if only nee| 000009b0 64 20 73 61 79 20 31 36 20 62 69 74 20 61 63 63 |d say 16 bit acc| 000009c0 75 72 61 63 79 2c 20 6e 6f 74 65 20 74 68 61 74 |uracy, note that| 000009d0 20 6f 75 72 20 70 6f 6c 79 27 73 20 63 6f 65 66 | our poly's coef| 000009e0 66 69 63 69 65 6e 74 73 22 0d 03 ac 3e f1 20 20 |ficients"...>. | 000009f0 20 22 6d 75 6c 74 69 70 6c 69 65 64 20 62 79 20 | "multiplied by | 00000a00 32 5e 32 30 20 26 20 77 72 69 74 74 65 6e 20 69 |2^20 & written i| 00000a10 6e 20 68 65 78 20 61 72 65 20 61 73 20 66 6f 6c |n hex are as fol| 00000a20 6c 6f 77 73 3a 22 27 0d 03 b6 14 e3 20 69 25 3d |lows:"'..... i%=| 00000a30 6e 25 20 b8 20 30 20 88 20 2d 31 0d 03 c0 0f 20 |n% . 0 . -1.... | 00000a40 79 20 3d 20 74 32 28 69 25 29 0d 03 ca 1f 20 e7 |y = t2(i%).... .| 00000a50 20 79 3c 30 20 73 24 3d 22 2d 22 3a 79 3d 2d 79 | y<0 s$="-":y=-y| 00000a60 20 8b 20 73 24 3d 22 2b 22 0d 03 d4 17 20 79 32 | . s$="+".... y2| 00000a70 20 3d 20 79 2a 31 30 34 38 35 37 36 2b 30 2e 35 | = y*1048576+0.5| 00000a80 0d 03 de 31 20 f1 20 22 78 5e 22 3b 69 25 3b 22 |...1 . "x^";i%;"| 00000a90 20 20 2a 22 2c 73 24 3b c2 22 30 30 30 30 30 30 | *",s$;."000000| 00000aa0 30 30 22 2b c3 7e 79 32 2c 38 29 3b 8a 32 37 29 |00"+.~y2,8);.27)| 00000ab0 3b 0d 03 e8 15 20 e7 20 69 25 3e 30 20 f1 20 22 |;.... . i%>0 . "| 00000ac0 2b 22 20 8b 20 f1 0d 03 f2 05 ed 0d ff |+" . ........| 00000acd