Back to Home Page

UBASIC code and results


y = K * x7 through the range -70 <= x <= 70
(non-parallel operation)

The following constants could be used to verify a high percent of a type of 30 digit 7th degree difference engine that does not have parallel operation. (Special provisions have to be made for the parallel operation of the Babbage Difference Engine #2).

The constant K was chosen to almost overflow a 30 digit machine, the range (x = -70 to +70) was chosen to exercize the engine about 150 cycles.

The first part of the listing is UBASIC code to setup and simulate the engine (showing negative numbers in 2's complement form).

   10    word 30
   20   point 15

   70   K=121234567890123456 ' constant to fill 30 digits
   
  130   dim Stepval(10)
  140   dim W(10)
  150   kill "x-7th.txt"
  160   print=print+"x-7th.txt"
  170   print "Starting find y= K * x^7"
  180   Starting=-70
  190   for X=Starting to Starting+8
  200   I=X-Starting
  210     Stepval(I)=K*X*X*X*X*X*X*X
  220     print "x=";X;"y=";Stepval(I)
  230   next X
  240   print "end phase"
  250  
  260   print "now lets do the differences"
  270   for N%=0 to 7
  280    W(N%)=Stepval(0)
  290   '   print #2, " ** n="n%; " w="w(n%)
  300    for I%=0 to (7-N%)
  310    '    print #2, "      n=";n%; " i=";i%, stepval(i%+1);" - "stepval(i%);
  320        Stepval(I%)=Stepval(I%+1)-Stepval(I%)
  330     '   print #2, "=";stepval(i%)
  340   next I%
  350   next N%
  360  
  370   print "these are the differences"
  380   for N=0 to 7
  390   print N,W(N)
  400   next N
  410   print "end of differences"
  420   print:print "differences in machine format - 2's complement"
  430   for N=0 to 7
  440   print N,
  450   gosub *Babprint(W(N))
  460   print
  470   next N
  480   print "end on differences in 2's complement"
  490   print "output phase"
  500   for N=-70 to 70
  510   S=K*N*N*N*N*N*N*N
  520   E=W(0)-S
  530   print " x=";N," y=";
  540   gosub *Babprint(W(0))
  550   print E;
  560   print
  570   for I%=0 to 7
  580      W(I%)=W(I%)+W(I%+1)
  590   next I%
  600   next N
  610   print "cheers"
  620   print=print
  630   stop
  632 '
  634 ' the following print subroutine just makes nice formatting
  636 '
  640   *Babprint(A)
  650   local I%,W,Delta,Mymod%,Norm
  660   Mymod%=0
  670   Norm=10000000000000000000000000000000 ' 31 zeros
  680   W=A
  690   if W<0 then W=Norm+W
  700   W=W/(Norm/10)+(1/Norm)
  710   ' if ((int(W)<>0) and (int(W)<>9)) then
  720   ' print W
  730   ' print int(W)
  740   ' print:print:
  750   ' stop
  760   ' endif
  770   for I%=Mymod% to Mymod%+30
  780   print chr(48+int(W));
  790   W=(W-int(W))*10
  800   if ((I%/5)=int(I%/5)) then print " ";
  810   next I%
  820   print ", ";
  830   return
  840   stop

---------------------------------------
results of the above in file x-7th.txt
---------------------------------------

Starting find y= K * x^7
x=-70 y=-998418797439359413246080000000 
x=-69 y=-902755418934842735754361627584 
x=-68 y=-815058644332735180656048340992 
x=-67 y=-734767752577990360090416756288 
x=-66 y=-661354050363707099011349569536 
x=-65 y=-594319480018833266477715000000 
x=-64 y=-533195268334358492080634855424 
x=-63 y=-477540615716973545341419001152 
x=-62 y=-426941425059174155913944014848 
end phase
now lets do the differences
these are the differences
 0 	-998418797439359413246080000000 
 1 	 95663378504516677491718372416 
 2 	-7966603902409122393405085824 
 3 	 560721055046387860723383936 
 4 	-32027748145212814606080000 
 5 	 1392112296168709620556800 
 6 	-40938488885136888622080 
 7 	 611022222166222218240 
end of differences

differences in machine format - 2's complement
 0 	9 00158 12025 60640 58675 39200 00000 , 
 1 	0 09566 33785 04516 67749 17183 72416 , 
 2 	9 99203 33960 97590 87760 65949 14176 , 
 3 	0 00056 07210 55046 38786 07233 83936 , 
 4 	9 99996 79722 51854 78718 53939 20000 , 
 5 	0 00000 13921 12296 16870 96205 56800 , 
 6 	9 99999 99590 61511 11486 31113 77920 , 
 7 	0 00000 00006 11022 22216 62222 18240 , 
end on differences in 2's complement
output phase
 x=-70 	 y=9 00158 12025 60640 58675 39200 00000 ,  0 
 x=-69 	 y=9 09724 45810 65157 26424 56383 72416 ,  0 
 x=-68 	 y=9 18494 13556 67264 81934 39516 59008 ,  0 
 x=-67 	 y=9 26523 22474 22009 63990 95832 43712 ,  0 
 x=-66 	 y=9 33864 59496 36292 90098 86504 30464 ,  0 
 x=-65 	 y=9 40568 05199 81166 73352 22850 00000 ,  0 
 x=-64 	 y=9 46680 47316 65641 50791 93651 44576 ,  0 
 x=-63 	 y=9 52245 93842 83026 45465 85809 98848 ,  0 
 x=-62 	 y=9 57305 85749 40825 84408 60559 85152 ,  0 
 x=-61 	 y=9 61899 09302 85212 94757 47461 91424 ,  0 
 x=-60 	 y=9 66062 08000 31104 00221 18400 00000 ,  0 
 x=-59 	 y=9 69828 94126 08854 40118 03801 85536 ,  0 
 x=-58 	 y=9 73231 59935 38599 33200 13307 00288 ,  0 
 x=-57 	 y=9 76299 88471 43261 08480 23103 64992 ,  0 
 x=-56 	 y=9 79061 64022 11245 25277 92156 83584 ,  0 
 x=-55 	 y=9 81542 82222 19848 04701 69550 00000 ,  0 
 x=-54 	 y=9 83767 59807 30396 94783 55162 15296 ,  0 
 x=-53 	 y=9 85758 44025 66146 91482 75902 83328 ,  0 
 x=-52 	 y=9 87536 21713 83954 37775 39727 03232 ,  0 
 x=-51 	 y=9 89120 28042 50751 23046 29652 26944 ,  0 
 x=-50 	 y=9 90528 54938 35841 05000 00000 00000 ,  0 
 x=-49 	 y=9 91777 59188 30039 76307 37083 53856 ,  0 
 x=-48 	 y=9 92882 70232 02682 98204 46564 67968 ,  0 
 x=-47 	 y=9 93857 97649 07522 23260 29701 19872 ,  0 
 x=-46 	 y=9 94716 38346 48532 29530 10707 41504 ,  0 
 x=-45 	 y=9 95469 83453 16651 88310 77450 00000 ,  0 
 x=-44 	 y=9 96129 24927 08479 87714 97701 21216 ,  0 
 x=-43 	 y=9 96704 61881 37949 34280 73171 74208 ,  0 
 x=-42 	 y=9 97205 06635 52001 54832 93545 34912 ,  0 
 x=-41 	 y=9 97638 90497 61282 20813 52737 47264 ,  0 
 x=-40 	 y=9 98013 69283 96882 17296 89600 00000 ,  0 
 x=-39 	 y=9 98336 28582 04144 78907 15294 37376 ,  0 
 x=-38 	 y=9 98612 88762 84562 14853 89555 22048 ,  0 
 x=-37 	 y=9 98849 09748 96782 45303 08066 68352 ,  0 
 x=-36 	 y=9 99049 95544 27750 71299 63173 64224 ,  0 
 x=-35 	 y=9 99219 98531 45005 00458 40150 00000 ,  0 
 x=-34 	 y=9 99363 23543 41150 50640 11246 22336 ,  0 
 x=-33 	 y=9 99483 31714 81533 53828 89738 31488 ,  0 
 x=-32 	 y=9 99583 44119 66137 82428 06200 40192 ,  0 
 x=-31 	 y=9 99666 45201 16725 20190 69223 12384 ,  0 
 x=-30 	 y=9 99734 86000 00243 00001 72800 00000 ,  0 
 x=-29 	 y=9 99790 87186 99520 30728 12603 96096 ,  0 
 x=-28 	 y=9 99836 41906 42275 35353 73376 22528 ,  0 
 x=-27 	 y=9 99873 18435 99456 22615 49649 70432 ,  0 
 x=-26 	 y=9 99902 62669 63937 14357 62029 11744 ,  0 
 x=-25 	 y=9 99926 00429 20592 50820 31250 00000 ,  0 
 x=-24 	 y=9 99944 39611 18770 96079 72238 78656 ,  0 
 x=-23 	 y=9 99958 72174 58191 65855 70396 15168 ,  0 
 x=-22 	 y=9 99969 75975 99284 99904 02325 79072 ,  0 
 x=-21 	 y=9 99978 16458 09000 01209 63230 82304 ,  0 
 x=-20 	 y=9 99984 48197 53100 64197 63200 00000 ,  0 
 x=-19 	 y=9 99989 16318 45973 14178 54605 90016 ,  0 
 x=-18 	 y=9 99992 57777 68966 80244 52837 29408 ,  0 
 x=-17 	 y=9 99995 02527 68290 23833 12587 86112 ,  0 
 x=-16 	 y=9 99996 74563 43485 45175 21923 44064 ,  0 
 x=-15 	 y=9 99997 92859 37501 89843 76350 00000 ,  0 
 x=-14 	 y=9 99998 72202 39392 77619 95104 50176 ,  0 
 x=-13 	 y=9 99999 23927 10655 75893 41890 85248 ,  0 
 x=-12 	 y=9 99999 56559 46240 39813 12283 11552 ,  0 
 x=-11 	 y=9 99999 76374 81244 41405 50018 17024 ,  0 
 x=-10 	 y=9 99999 87876 54321 09876 54400 00000 ,  0 
 x=-9 	 y=9 99999 94201 38820 05314 41037 79136 ,  0 
 x=-8 	 y=9 99999 97457 52683 48009 18140 02688 ,  0 
 x=-7 	 y=9 99999 99001 58120 25606 40586 75392 ,  0 
 x=-6 	 y=9 99999 99660 62080 00311 04002 21184 ,  0 
 x=-5 	 y=9 99999 99905 28549 38358 41050 00000 ,  0 
 x=-4 	 y=9 99999 99980 13692 83968 82172 96896 ,  0 
 x=-3 	 y=9 99999 99997 34860 00002 43000 01728 ,  0 
 x=-2 	 y=9 99999 99999 84481 97531 00641 97632 ,  0 
 x=-1 	 y=9 99999 99999 99878 76543 21098 76544 ,  0 
 x= 0 	 y=0 00000 00000 00000 00000 00000 00000 ,  0 
 x= 1 	 y=0 00000 00000 00121 23456 78901 23456 ,  0 
 x= 2 	 y=0 00000 00000 15518 02468 99358 02368 ,  0 
 x= 3 	 y=0 00000 00002 65139 99997 56999 98272 ,  0 
 x= 4 	 y=0 00000 00019 86307 16031 17827 03104 ,  0 
 x= 5 	 y=0 00000 00094 71450 61641 58950 00000 ,  0 
 x= 6 	 y=0 00000 00339 37919 99688 95997 78816 ,  0 
 x= 7 	 y=0 00000 00998 41879 74393 59413 24608 ,  0 
 x= 8 	 y=0 00000 02542 47316 51990 81859 97312 ,  0 
 x= 9 	 y=0 00000 05798 61179 94685 58962 20864 ,  0 
 x= 10 	 y=0 00000 12123 45678 90123 45600 00000 ,  0 
 x= 11 	 y=0 00000 23625 18755 58594 49981 82976 ,  0 
 x= 12 	 y=0 00000 43440 53759 60186 87716 88448 ,  0 
 x= 13 	 y=0 00000 76072 89344 24106 58109 14752 ,  0 
 x= 14 	 y=0 00001 27797 60607 22380 04895 49824 ,  0 
 x= 15 	 y=0 00002 07140 62498 10156 23650 00000 ,  0 
 x= 16 	 y=0 00003 25436 56514 54824 78076 55936 ,  0 
 x= 17 	 y=0 00004 97472 31709 76166 87412 13888 ,  0 
 x= 18 	 y=0 00007 42222 31033 19755 47162 70592 ,  0 
 x= 19 	 y=0 00010 83681 54026 85821 45394 09984 ,  0 
 x= 20 	 y=0 00015 51802 46899 35802 36800 00000 ,  0 
 x= 21 	 y=0 00021 83541 90999 98790 36769 17696 ,  0 
 x= 22 	 y=0 00030 24024 00715 00095 97674 20928 ,  0 
 x= 23 	 y=0 00041 27825 41808 34144 29603 84832 ,  0 
 x= 24 	 y=0 00055 60388 81229 03920 27761 21344 ,  0 
 x= 25 	 y=0 00073 99570 79407 49179 68750 00000 ,  0 
 x= 26 	 y=0 00097 37330 36062 85642 37970 88256 ,  0 
 x= 27 	 y=0 00126 81564 00543 77384 50350 29568 ,  0 
 x= 28 	 y=0 00163 58093 57724 64646 26623 77472 ,  0 
 x= 29 	 y=0 00209 12813 00479 69271 87396 03904 ,  0 
 x= 30 	 y=0 00265 13999 99756 99998 27200 00000 ,  0 
 x= 31 	 y=0 00333 54798 83274 79809 30776 87616 ,  0 
 x= 32 	 y=0 00416 55880 33862 17571 93799 59808 ,  0 
 x= 33 	 y=0 00516 68285 18466 46171 10261 68512 ,  0 
 x= 34 	 y=0 00636 76456 58849 49359 88753 77664 ,  0 
 x= 35 	 y=0 00780 01468 54994 99541 59850 00000 ,  0 
 x= 36 	 y=0 00950 04455 72249 28700 36826 35776 ,  0 
 x= 37 	 y=0 01150 90251 03217 54696 91933 31648 ,  0 
 x= 38 	 y=0 01387 11237 15437 85146 10444 77952 ,  0 
 x= 39 	 y=0 01663 71417 95855 21092 84705 62624 ,  0 
 x= 40 	 y=0 01986 30716 03117 82703 10400 00000 ,  0 
 x= 41 	 y=0 02361 09502 38717 79186 47262 52736 ,  0 
 x= 42 	 y=0 02794 93364 47998 45167 06454 65088 ,  0 
 x= 43 	 y=0 03295 38118 62050 65719 26828 25792 ,  0 
 x= 44 	 y=0 03870 75072 91520 12285 02298 78784 ,  0 
 x= 45 	 y=0 04530 16546 83348 11689 22550 00000 ,  0 
 x= 46 	 y=0 05283 61653 51467 70469 89292 58496 ,  0 
 x= 47 	 y=0 06142 02350 92477 76739 70298 80128 ,  0 
 x= 48 	 y=0 07117 29767 97317 01795 53435 32032 ,  0 
 x= 49 	 y=0 08222 40811 69960 23692 62916 46144 ,  0 
 x= 50 	 y=0 09471 45061 64158 95000 00000 00000 ,  0 
 x= 51 	 y=0 10879 71957 49248 76953 70347 73056 ,  0 
 x= 52 	 y=0 12463 78286 16045 62224 60272 96768 ,  0 
 x= 53 	 y=0 14241 55974 33853 08517 24097 16672 ,  0 
 x= 54 	 y=0 16232 40192 69603 05216 44837 84704 ,  0 
 x= 55 	 y=0 18457 17777 80151 95298 30450 00000 ,  0 
 x= 56 	 y=0 20938 35977 88754 74722 07843 16416 ,  0 
 x= 57 	 y=0 23700 11528 56738 91519 76896 35008 ,  0 
 x= 58 	 y=0 26768 40064 61400 66799 86692 99712 ,  0 
 x= 59 	 y=0 30171 05873 91145 59881 96198 14464 ,  0 
 x= 60 	 y=0 33937 91999 68895 99778 81600 00000 ,  0 
 x= 61 	 y=0 38100 90697 14787 05242 52538 08576 ,  0 
 x= 62 	 y=0 42694 14250 59174 15591 39440 14848 ,  0 
 x= 63 	 y=0 47754 06157 16973 54534 14190 01152 ,  0 
 x= 64 	 y=0 53319 52683 34358 49208 06348 55424 ,  0 
 x= 65 	 y=0 59431 94800 18833 26647 77150 00000 ,  0 
 x= 66 	 y=0 66135 40503 63707 09901 13495 69536 ,  0 
 x= 67 	 y=0 73476 77525 77990 36009 04167 56288 ,  0 
 x= 68 	 y=0 81505 86443 32735 18065 60483 40992 ,  0 
 x= 69 	 y=0 90275 54189 34842 73575 43616 27584 ,  0 
 x= 70 	 y=0 99841 87974 39359 41324 60800 00000 ,  0 
cheers
Back to Home Page