Пример #1
0
static double  probabilities(int n)
{
  double tp, cinf, f0, Lamb, abserr;
  
  cinf=sqrt(1.0-rho*rho)/sigma*(v+k*teta*T);
 
  if(n==1)
    {
      f0=charact_funct1(0.0); 

      Lamb=(log(fabs(f0))+12.0*log(10.0))/cinf;

      intg(0.0, Lamb, charact_funct1, 1e-14, 1e-10, &tp, &abserr);

      tp=0.5+tp/M_PI;
      return tp;

    } 
  else
    {
      f0=charact_funct2(0.0); 

      Lamb=(log(fabs(f0))+12.0*log(10.0))/cinf;

      intg(0.0, Lamb, charact_funct2, 1e-14, 1e-10, &tp, &abserr);

      tp=0.5+tp/M_PI;
      return tp;
    }
}
Пример #2
0
int main(int arg, const int *argv[])
{
  int i;
  float li=0,lf=2;
  float x[N+1];
  printf("Integration of the parabola 4x-2xx between xi=0 and xf=2:\n");
  for(i=0; i<=N; i++) x[i] = i/100.;
  //for(i=0; i<=N; i++) printf("x[%d]: %f\n",i,x[i]);
  printf("Integral: %.2f\n\n",intg(x,N,li,lf));
  return 0;
}
Пример #3
0
void intg_multi(double a, double b, double (*f)(double []), double ea, double er, double *val, double *abserr, double x[], int n)
/* integral the function double f(double x[n]) with respect to x[0] in domain [a, b], while x[1]...x[n] is taken as given constants, modified by Xiao Wei, INRIA  */
{
 	nconst=n;
	xconst=(double *)calloc(nconst+1, sizeof (double));
	
	for (int i=1; i<=nconst; i++)
	{
		xconst[i]=x[i];
	}
	fmulti_origin=f;
	intg(a, b, f_new, ea, er, val, abserr);
	free(xconst);
}