[comp.sys.transputer] Improper results on T800 using PASCAL-XSC with better arithmetic

kirchner@informatik.uni-kl.de (Reinhard Kirchner) (04/29/91)

From article <1991Apr25.060030.27603@eng.umd.edu>, by choudhry@eng.umd.edu (Zafar Ullah Choudhry):

I tried to compile the given program with slightly modifications using the 
new programming language PASCAL-XSC, available as ShareWare in the newsgroup
comp.binaries.ibm.pc.
The result is as I expected very interesting for all arithmetic testers.
Look at the following source-code for PASCAL-XSC and the results:

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

program txxx ( input,output ) ;
use i_ari ;
(* the datatype interval is predefined in the module i_ari together with *)
(* all used interval operations *)

  var we, weneg : interval ;
  var freea8,freea7, xdin : interval ;
  var free_l1, free_l2 : interval ;
  var yin : interval ;
  var exact_reals : boolean ;


function point ( i : interval ) : boolean ;
(* this function decides, if an interval has equal boundaries and is *)
(* therefore a so called point interval                              *)

begin
    point := inf(i) = sup(i) ;
end ;

begin
        (* read in the values for we, weneg, freea8, freea7, yin and xdin *)
        writeln ( 'please enter :' ) ;
        write ( 'we :' ) ;      read ( we ) ;
        write ( 'weneg :' ) ;   read ( weneg ) ;
        write ( 'freea8 : ' ) ; read ( freea8 ) ;
        write ( 'freea7 : ' ) ; read ( freea7 ) ;
        write ( 'yin : ' ) ;    read ( yin ) ;
        write ( 'xdin : ' ) ;   read ( xdin ) ;

        exact_reals := point (we) and point (freea8) and point (freea7)
                       and point (yin) and point (xdin) ;

        if not exact_reals then
        begin
           writeln ( 'Caution!!!!!!!!!' ) ;
           writeln ( 'input data not exactly representable using decimal to ' ) ;
           writeln ( 'IEEE binary double conversion' ) ;
           writeln ( 'The values read in are in the following ranges :' ) ;
           writeln ( 'we     :      ',we ) ;
           writeln ( 'weneg  :      ',weneg ) ;
           writeln ( 'freea8 :      ',freea8 ) ;
           writeln ( 'freea7 :      ',freea7 ) ;
           writeln ( 'yin    :      ',yin ) ;
           writeln ( 'xdin   :      ',xdin ) ;
        end ;


	(* caculate the result using naive interval arithmetic*)
	free_l1 := freea8 * (we * yin + xdin);
	free_l2 := freea7 * (we * yin + xdin);

	writeln('The Expected Results: ') ;
        writeln('free_l[1]=',-0.000002,' and free_l[2]=',0.000007) ;
        writeln('Note: These results are expected, but I don''t know why !!!' );
        writeln('      These results are completely wrong!!!' ) ;
        writeln ;
	writeln('The exact and enclosed calculated results corresponding to the') ;
        writeln('input data displayed above are :' ) ;
        writeln('free_l[1]=',free_l1) ;
        writeln('free_l[2]=',free_l2) ;
        writeln ;
        writeln('Note: The used data here are intervals, which do contain' ) ;
        writeln('      the specified constants of the original program' ) ;
        writeln('      Thus, the resulting intervals do contain the' ) ;
        writeln('      exact result of the original input constants!' ) ;

	writeln('Done...');
end.

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

These are the input data:
 
3
7.29211508e-5
-7.29211508e-5
0.250648
-0.968078
-16018765.0
1168.106812

----------------------------------------------------------------------
 
This is the output of the program:

please enter :
we :weneg :freea8 : freea7 : yin : xdin : Caution!!!!!!!!!
input data not exactly representable using decimal to 
IEEE binary double conversion
The values read in are in the following ranges :
we     :      [  7.292115079999999E-005,  7.292115080000002E-005]
weneg  :      [ -7.292115080000002E-005, -7.292115079999999E-005]
freea8 :      [  2.506479999999999E-001,  2.506480000000001E-001]
freea7 :      [ -9.680780000000002E-001, -9.680779999999999E-001]
yin    :      [ -1.601876500000000E+007, -1.601876500000000E+007]
xdin   :      [  1.168106811999999E+003,  1.168106812000001E+003]
The Expected Results:
free_l[1]=-2.000000000000000E-006 and free_l[2]= 7.000000000000000E-006
Note: These results are expected, but I don't know why !!!
      These results are completely wrong!!!

The exact and enclosed calculated results corresponding to the
input data displayed above are :
free_l[1]=[  8.473215234786038E-006,  8.473215405758313E-006]
free_l[2]=[ -3.272610762334308E-005, -3.272610696299670E-005]

Note: The used data here are intervals, which do contain
      the specified constants of the original program
      Thus, the resulting intervals do contain the
      exact result of the original input constants!
Done...

---------------------------------------------------------------------
 
The underlying PASCAL-XSC is available for the most of tested machines,
such as T800 machines, SUN workstations and IBM/PC's etc. 
Please contact us : 
 
Numerik Software GmbH
Dr. Michael Neaga
Rettigstr. 6
W-7570 Baden-Baden
e-mail: ae18@dkauni2.bitnet