// integrate screen 
// v0.1  Keith Lofstrom  2012 Jul 22  

#define  H2  0.25      // Height / 2
#define  W2  0.50      // Width / 2
#define  Z   1.00      // Distance 
#define  d   1e-3

#include <stdio.h>
#include <math.h>

int main() {
   double pi = 2.0*atan(1.0) ;
   double sum = 0.0 ;
   double x, y ;

   for( x = -(W2-d/2) ; x < W2 ; x+=d ) {
      for( y = -(H2-d/2) ; y < H2 ; y+=d ) {
         double den = x*x + y*y + Z*Z ;
	 sum += sqrt( (x*x + y*y) / (den*den*den) ) ;
      }  }
   sum *= d * d ;

   printf( "screen integral=%8.5f for H=%7.4f +/-W=%7.4f d step =%10.4e\n",
                            sum,      2*H2,    2*W2,      d );
   return( 0 );
}
