Language Reference

XMULT Function

performs accurate matrix multiplication

XMULT( matrix1, matrix2)

where matrix1 and matrix2 are numeric matrices.

The XMULT function computes the matrix product like the matrix multiplication operator (*) except XMULT uses extended precision to accumulate sums of products. You should use the XMULT function only when you need great accuracy.

The following program uses the XMULT function:

  
   a=1e13; 
   b=1e13; 
   c=100*a; 
   a=a+1; 
   x=c || a || b || c; 
   y=c || a || (-b) || (-c); 
  
   z=xmult(x,y`);  /* correct answer */ 
   print z [format=16.0]; 
  
   wrong = x * y`;  /* loss of precision */ 
   print wrong [format=16.0];
 

  
                        Z 
  
                  20000000000001 
  
  
                      WRONG 
  
                  19997367730176
 

Previous Page | Next Page | Top of Page