• 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 





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

.

( )
, -301
, & .
(c) '94 by

.. , & ,
.
26 1994 .
/*****************************************************************************
*
.FILE : func.c
*
.TITLE : ,
* :

*
.DESCR :
* : numeric.obj
* :
* :
*
.NOTE : NOT FOR RENTAL OR SALE.
* : FEDERAL LAW PROVIDES SEVERE CIVIL
& CRIMINAL PENALTIES FOR
* : UNAUTHORIZED DUPLICATION OR
DISTRIBUTION.
* :
* : (C) '94 by P$P
*****************************************************************************/
#include
<math.h>
/*
No.1 */
double
f1 (double x, double y)
{ return 0.5 * cos (y); }
/*
No.2 */
double
f2 (double x, double y)
{ return 0.5 - sin (y); }
/*
No.3 */
double
f3 (double x, double y)
{ return sqrt (x * x + y * y); }
/*****************************************************************************
*
.FILE : numeric.c
*
.TITLE : ()
*
.DESCR : (1994 )
* :
* : : ..
(. -301)
* :
: ..
* :
*
.NOTE : NOT FOR RENTAL OR SALE.
* : FEDERAL LAW PROVIDES SEVERE CIVIL
& CRIMINAL PENALTIES FOR
* : UNAUTHORIZED DUPLICATION OR
DISTRIBUTION.
* :
* : (C) '94 by P$P
*****************************************************************************/
#include
<math.h>
#include
<stdio.h>
/*****************************************************************************
*
.NAME : m_Simpson
*
.TITLE :
()
*
.DESCR :
* :
*
.PARAMS : double m_Simpson (double (*func) (double, double),
* : double t_fix, double t_limit, int N);
* : double (*func) (double, double) - -
* : double t_fix -

* : double t_limit - ,
* : -t_limit
* : int N -
*
.RETURN :
*****************************************************************************/
double
m_Simpson (double (*func) (double, double),
double t_fix, double
t_limit, int N)
{
double sum1 = 0; /* Ŀ */
double sum2 = 0; /* 堠 */
double sum3 = 0; /* ٠ */
double sum; /* 򠠠
*/
double h
= (2 * t_limit) / N; /* */
int i; /* */
sum1 = (*func) (t_fix, -t_limit) + (*func)
(t_fix, +t_limit);
for (i = 1; i <= N - 1; i++) sum2 +=
(*func) (t_fix, -t_limit + (i * h));
sum2 *= 2;
for (i = 1; i <= N; i++) sum3 +=
(*func) (t_fix, -t_limit + ((i-0.5) * h));
sum3 *= 4;
sum = sum1 + sum2 + sum3;
sum = (h / 6) * sum;
return sum;
}
/* */
/*
*/
/* ~~~~~~~~~~~~~~~~~~~~~
*/
#define
PI 3.1415926536 /* Ϡ */
double
k; /*
- */
int
N_MAX; /*
*/
double
(*currFunc) (double, double); /* */
double
f1 (double x, double y);
double
f2 (double x, double y);
double
f3 (double x, double y);
/*****************************************************************************
*
.NAME : double F (double dummy, double
t)
*
.TITLE :
(G (t)).
* : . .
*
.DESCR : /2
* :
* : G (t + /2) * sin (t + /2) dt
* : t

* : ڠ
-/2
* : G (t) = currFunc (t, tau)
dtau
* :
* : -t
*
.PARAMS : double F (double dummy, double t);
* : double dummy - ,
* : , ..
* :
* : double -

*
.RETURN : : G (t) * sin (k * t);
*****************************************************************************/
double
F (double dummy, double t)
{
double G;
t = t + PI / 2; /*
, */
/* (
- /2) */
G = m_Simpson (currFunc, t, t, N_MAX);
return G * sin (k * t);
}
/*****************************************************************************
*
.NAME : main
*
.TITLE : .
*
.DESCR :
,
* : k
N_MAX.
* :

* : - /2.
* :
*
.PARAMS : void main (void);
*
.RETURN :
*****************************************************************************/
void
main (void)
{
double integral; /* */
int
selection; /* 蠠 */
/* */
double (*functions []) (double, double) = {
f1, f2, f3 };
printf ("\n () ");
printf ("\n ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ");
printf ("\n ڠ ");
printf ("\n I = sin k(x + y) f (x, y) dx dy ");
printf ("\n ٠ ");
printf ("\n D ");
printf ("\n D = { (x, y): x, y
>= 0; x + y <= }, f C (D)");
printf ("\n");
printf ("\n
: ");
printf
("\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ");
printf ("\n 1) f (x, y) = 0.5 * cos (y) ");
printf ("\n ڠ
0; k != 1 ");
printf ("\n sin x * sin (kx) dx => ");
printf ("\n ٠
/2; k = 1 ");
printf ("\n ");
printf ("\n 2) f (x, y) = 0.5 - sin (y) ");
printf ("\n ڠ ");
printf ("\n x * sin (kx) dx =====> ; k = 1 ");
printf ("\n ٠ ");
printf ("\n ");
printf ("\n 3) f (x, y) = sqrt (x * x + y * y)");
printf ("\n");
do
{
printf (" : ");
scanf ("%d", &selection);
} while (!(1 <= selection &&
selection <= 3));
printf (" k: ");
scanf ("%lg", &k);
do
{
printf (" N:
");
scanf ("%d", &N_MAX);
} while (!(N_MAX > 0));
printf ("\n");
printf ("\n
...");
currFunc = functions [selection - 1]; /* */
integral = m_Simpson (F, 0, PI / 2,
N_MAX); /* */
printf ("\n :
%.12lg", integral); /* 䠠 */
printf ("\n : = %.12lg; /2
= %.12lg", PI, PI / 2);
}
numeric.c
func.c
*** *** EGEEEEEEE(EE
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I = sin k(x + y) f (x, y) dx dy
D
ED = {
(x, y): x, y >= 0; x + y <= }, f
C (D)
āE EEEIE:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1) f (x, y) = 0.5 * cos
(y)
0; k != 1 sin x * sin (kx) dx =>
/2; k = 1 2) f (x, y) = 0.5 - sin
(y) x * sin (kx) dx =====> ; k = 1 3) f (x, y) = sqrt (x * x + y
* y)
E 1
Ek:
1
E EEEN: 64
EE...
GEEE
1.57079633258
E =
3.1415926536; /2 = 1.5707963268
. .

      ©2010