source: sasmodels/sasmodels/models/lib/sas_Si.c @ 1e7b0db0

core_shell_microgelscostrafo411magnetic_modelticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since 1e7b0db0 was 473a9f1, checked in by wojciech, 7 years ago

Changed function and files names in lib to comply with new standards

  • Property mode set to 100644
File size: 853 bytes
Line 
1// integral of sin(x)/x Taylor series approximated to w/i 0.1%
2double sas_Si(double x);
3double sas_Si(double x)
4{
5    if (x >= M_PI*6.2/4.0) {
6        const double xxinv = 1./(x*x);
7        // Explicitly writing factorial values triples the speed of the calculation
8        const double out_cos = (((-720.*xxinv + 24.)*xxinv - 2.)*xxinv + 1.)/x;
9        const double out_sin = (((-5040.*xxinv + 120.)*xxinv - 6.)*xxinv + 1)*xxinv;
10
11        double sin_x, cos_x;
12        SINCOS(x, sin_x, cos_x);
13        return M_PI_2 - cos_x*out_cos - sin_x*out_sin;
14    } else {
15        const double xx = x*x;
16        // Explicitly writing factorial values triples the speed of the calculation
17        return (((((-1./439084800.*xx
18            + 1./3265920.)*xx
19            - 1./35280.)*xx
20            + 1./600.)*xx
21            - 1./18.)*xx
22            + 1.)*x;
23    }
24}
Note: See TracBrowser for help on using the repository browser.