[go: up one dir, main page]

Menu

[r303]: / libpetey / erfc_table.cc  Maximize  Restore  History

Download this file

42 lines (29 with data), 790 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <math.h>
#include <stdio.h>
#include <gsl/gsl_sf_erf.h>
#include "gsl/gsl_fit.h"
#include "erfinv.h"
int main() {
int n=40;
double x[n];
double x1;
double y[n];
//double xmin=0.001;
double xmin=0.;
double xmax=25;
for (int i=0; i<n; i++) {
//x[i]=xmin*pow(xmax/xmin, 1.*i/(n-1.));
x[i]=xmin+(xmax-xmin)*i/(n-1);
y[i]=gsl_sf_erfc(x[i]);
x1=erfcinv(y[i]);
printf("%14.10g %14.10g %14.10g %10.3g\n", x[i], y[i], x1, x[i]-x1);
}
printf("#define ERFCINV_NTABLE %d\n", n);
printf("double erfcinv_ytable[ERFCINV_NTABLE]={");
for (int i=0; i<n; i++) printf(", %30.25g", x[i]);
printf("};\n");
printf("double erfcinv_xtable[ERFCINV_NTABLE]={");
for (int i=0; i<n; i++) printf(", %30.25g", y[i]);
printf("};\n");
return 0;
}