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

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

Modified the pearl_necklace model for better double precision accuracy
and added unit tests.

  • Property mode set to 100644
File size: 718 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        double pi = 4.0*atan(1.0);
8
9        if (x >= pi*6.2/4.0){
10                double out_sin = 0.0;
11                double out_cos = 0.0;
12                out = pi/2.0;
13
14                // Explicitly writing factorial values triples the speed of the calculation
15                out_cos = 1./x - 2./pow(x,3) + 24./pow(x,5) - 720./pow(x,7);
16                out_sin = 1./pow(x,2) - 6./pow(x,4) + 120./pow(x,6) - 5040./pow(x,8);
17
18                out -= cos(x) * out_cos;
19                out -= sin(x) * out_sin;
20                return out;
21        }
22
23        // Explicitly writing factorial values triples the speed of the calculation
24        out = x - pow(x, 3)/18. + pow(x,5)/600. - pow(x,7)/35280. + pow(x,9)/3265920. - pow(x,11)/439084800.;
25
26        return out;
27}
Note: See TracBrowser for help on using the repository browser.