Attachment 'int1.c'

Download

   1 // integrate screen 
   2 // v0.1  Keith Lofstrom  2012 Jul 22  
   3 
   4 #define  H2  0.25      // Height / 2
   5 #define  W2  0.50      // Width / 2
   6 #define  Z   1.00      // Distance 
   7 #define  d   1e-3
   8 
   9 #include <stdio.h>
  10 #include <math.h>
  11 
  12 int main() {
  13    double pi = 2.0*atan(1.0) ;
  14    double sum = 0.0 ;
  15    double x, y ;
  16 
  17    for( x = -(W2-d/2) ; x < W2 ; x+=d ) {
  18       for( y = -(H2-d/2) ; y < H2 ; y+=d ) {
  19          double den = x*x + y*y + Z*Z ;
  20 	 sum += sqrt( (x*x + y*y) / (den*den*den) ) ;
  21       }  }
  22    sum *= d * d ;
  23 
  24    printf( "screen integral=%8.5f for H=%7.4f +/-W=%7.4f d step =%10.4e\n",
  25                             sum,      2*H2,    2*W2,      d );
  26    return( 0 );
  27 }

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2012-07-22 22:33:53, 0.7 KB) [[attachment:int1.c]]
  • [get | view] (2012-07-22 23:30:23, 0.7 KB) [[attachment:int2.c]]
 All files | Selected Files: delete move to page

You are not allowed to attach a file to this page.