Back to ABC Home Page

ABC - Computer
Examples

The purpose of this page is to show that solving simple integer simultaneous equations,
  • with out scaling,
  • using the Atanosoff algorithm,
can give both exact and erroneous answers.
Also that scaling the example with erroneous answers
  • can give almost correct answers
  • within 0.001 percent - depending on scaling.

I attribute the errors to using integer arithmetic.
(High precision floating point arithmetic can yield more precise answers,

- but can still yield some "fuzz" due to some non-exact representations,

such as one divided by three.
Sophisticated software packages such as
"MATHEMATICA"
fight this problem using other techniques
- such as retaining the fraction (1/3) rather than decimal approximation 0.3333333...)

Executive Summary:
  1. Be careful of integer examples, you may get a rude surprise.

  2. In general, scale (multiply) the numbers so that the high order digits are about 10^10 for maximum resistance to underflow and overflow errors.

The following pair illustrates the problem of underflow - depending on which way the problem is solved -

- the left, organized one way, gives the correct integer answer
- the right, organized the other (or place the pivot in the other variable) does not give the correct integer answer.
The following example is from the ABC movie
The ABC in Operation
showing a non-scaled example that works
under the ABC rules of operation.
simultaneous equations
         2x + 4y - 8 = 0
          x - 3y + 11 = 0
   with solutions
         x = -2, y = 3

 
 
 
scaled by multiplying by 1 
  and running a simulation 
  yields the following trace

-------------------------------------------
Event #  0  Pivot =  Last Op = Load Drm 
     KA           2          4         -8
     CA           1         -3         11
Event #  1  Pivot =  Last Op = Sub      
     KA           2          4         -8
     CA          -1         -7         19
Event #  2  Pivot =  Last Op = SHR 1     
     KA           1          2         -4
     CA          -1         -7         19
Event #  3  Pivot =  Last Op = Add      
     KA           1          2         -4
     CA           0         -5         15
  EXIT , CA(pivot) = zero 






--------------------------------------------

the above has eliminated the "x" variable
   yielding        y = 3
 


back solve into the above    
    x - 3y + 11 = 0
  yields
    x - 3(3) + 11 = 0
  or
   x = -2
  the correct answer
 
The following example is from the ABC movie
The ABC in Operation
showing a non-scaled example that works
under the ABC rules of operation.
simultaneous equations
         4y  + 2x -  8 = 0
        -3y  +  x + 11 = 0
   with solutions
         x = -2, y = 3
 
Note: the x and y columns are reversed,
should make no difference in the result !!!
 
scaled by multiplying by 1 
  and running a simulation 
  yields the following trace

------------------------------------------
Event #  0  Pivot =  Last Op = Load Drm 
     KA           4          2         -8
     CA          -3          1         11     
Event #  1  Pivot =  Last Op = Add      
     KA           4          2         -8
     CA           1          3          3    
Event #  2  Pivot =  Last Op = SHR 1     
     KA           2          1         -4 
     CA           1          3          3    
Event #  3  Pivot =  Last Op = Sub      
     KA           2          1         -4
     CA          -1          2          7     
Event #  4  Pivot =  Last Op = SHR 1     
     KA           1          0         -2
     CA          -1          2          7     
Event #  5  Pivot =  Last Op = Add      
     KA           1          0         -2
     CA           0          2          5     
 EXIT , CA(pivot) = zero 
------------------------------------------

the above has eliminated the "y" variable
   yielding        
       2x = -5
or  x = -2.5

back solve into the above    
      x - 3y + 11 = 0
   yields
  -2.5x - 3y + 11 = 0
   or
 y = 3.1666...
  NOT the correct answer

Now - lets take the re-ordered equations, 
   yielding the incorrect answers
and scale by multiplying by 10,000
The following example is from the ABC movie The ABC in Operation
showing a non-scaled example that works under the ABC rules of operation.
simultaneous equations
         4y  + 2x -  8 = 0
        -3y  +  x + 11 = 0
   with solutions
         x = -2, y = 3
 
Note: the x and y columns are reversed,
      should make no difference in the result !!!
 
scaled by multiplying by 10,000 and running a simulation 
  yields the following trace
---------------------------------------------- 
     KA            40000           20000          -80000
     CA           -30000           10000          110000   
Event #  1  Pivot =  Last Op = Add      
     KA            40000           20000          -80000
     CA            10000           30000           30000    
Event #  2  Pivot =  Last Op = SHR 1     
     KA            20000           10000          -40000
     CA            10000           30000           30000     
Event #  3  Pivot =  Last Op = Sub      
     KA            20000           10000          -40000
     CA           -10000           20000           70000     
Event #  4  Pivot =  Last Op = SHR 1     
     KA            10000            5000          -20000 
     CA           -10000           20000           70000     
Event #  5  Pivot =  Last Op = Add      
     KA            10000            5000          -20000
     CA                0           25000           50000    
 EXIT , CA(pivot) = zero 
-------------------------------------------------------- 
       the above has eliminated the "y" variable
          yielding        
              25000x = -50000
       or  x = -2

       back solve into the above    
          x - 3y + 11 = 0
          yields
              -2 - 3y + 11 = 0
          or
              y = 3
          THE correct answer
 
 
	


Are you confused yet?? - - - Ah good - me too - misery loves company !!!

Now here is another integer equation, that gives incorrect results,
that when scaled, gives "good enough" results
- "good enough for government work" ;-))


The following example gives incorrect answers,
 under the ABC rules of operation, 
 unless scaled as in the example to the right.
 
   simultaneous equations
         6x + 2y - 16 = 0
         5x + 2y - 11 = 0
   with solutions
         x = 3, y = -2
 
scaled by multiplying by 1 
  and running a simulation 
  yields the following trace
------------------------------------------ 
Event #  0  Pivot =  Last Op = Load Drm 
     KA           6          1        -16 
     CA           5          2        -11 
Event #  1  Pivot =  Last Op = Sub      
     KA           6          1        -16 
     CA          -1          1          5 
Event #  2  Pivot =  Last Op = SHR 1     
     KA           3          0         -8 
     CA          -1          1          5 
Event #  3  Pivot =  Last Op = Add      
     KA           3          0         -8
     CA           2          1         -3
Event #  4  Pivot =  Last Op = SHR 1     
     KA           1          0         -4 
     CA           2          1         -3 
Event #  5  Pivot =  Last Op = Sub      
     KA           1          0         -4 
     CA           1          1          1
Event #  6  Pivot =  Last Op = Sub      
     KA           1          0         -4
     CA           0          1          5 
 EXIT , CA(pivot) = zero 
--------------------------------------------- 
 the above has eliminated the "x" variable

   yielding        y = - 5


 back solve into the above    
      5x + 2y - 11 = 0
  yields
      5x + 2(-5) - 11 = 0
   or
      5x = 21
   or
       x = 4.2

rather than the correct (above)
       x = 3, y = -2
 
 

 

simultaneous equations
         6x + 2y - 16 = 0
         5x + 2y - 11 = 0
   with solutions
         x = 3, y = -2
 
scaled by multiplying by 10,000
  and running a simulation 
  yields the following trace
------------------------------------------
Event #  0  Pivot =  Last Op = Load Drm 
     KA       60000      10000    -160000
     CA       50000      20000    -110000 
Event #  1  Pivot =  Last Op = Sub      
     KA       60000      10000    -160000
     CA      -10000      10000      50000
Event #  2  Pivot =  Last Op = SHR 1     
     KA       30000       5000     -80000
     CA      -10000      10000      50000
Event #  3  Pivot =  Last Op = Add      
     KA       30000       5000     -80000
     CA       20000      15000     -30000
Event #  4  Pivot =  Last Op = SHR 1     
     KA       15000       2500     -40000 
     CA       20000      15000     -30000 
...
     ...
     ...
Event #  42  Pivot =  Last Op = Sub      
     KA           3          0        -10
     CA           0      11666      23340
 EXIT , CA(pivot) = zero 
------------------------------------------  
the above has eliminated the "x" variable
  leaving   11666y = - 23340
       or        y = - 2.000685753.... 


back solve into the above    
        5x + 2y - 11 = 0
yields
        5x + 2(- 2.000685753) - 11 = 0
     or
        5x = 15.001371506
     or
         x = 3.0002743012
 
  rather than the exactly correct (above)
         x = 3, y = -2 


If you have comments or suggestions, Send e-mail to Ed Thelen

Back to ABC Home Page