source: sasmodels/sasmodels/models/lib/Si.c @ 7d256c8

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

Removing unused variables from Si(x) function.

  • Property mode set to 100644
File size: 746 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) + 40320/pow(x,9);
16                out_sin = 1/x - 6/pow(x,4) + 120/pow(x,6) - 5040/pow(x,8) + 362880/pow(x,10);
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;
25
26        //printf ("Si=%g %g\n", x, out);
27        return out;
28}
Note: See TracBrowser for help on using the repository browser.