source: sasmodels/sasmodels/models/lib/Si.c @ e7678b2

core_shell_microgelscostrafo411magnetic_modelrelease_v0.94release_v0.95ticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since e7678b2 was e7678b2, checked in by piotr, 8 years ago

Code review from PAK

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