Attachment 'int2.c'

Download

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

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.