core_shell_microgelscostrafo411magnetic_modelrelease_v0.94release_v0.95ticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change
on this file since fad5dc1 was
e7678b2,
checked in by piotr, 9 years ago
|
Code review from PAK
|
-
Property mode set to
100644
|
File size:
766 bytes
|
Rev | Line | |
---|
[cf404cb] | 1 | double Si(double x); |
---|
[dcef2ee] | 2 | |
---|
[0420af7] | 3 | // integral of sin(x)/x Taylor series approximated to w/i 0.1% |
---|
[cf404cb] | 4 | double Si(double x) |
---|
| 5 | { |
---|
[e7678b2] | 6 | double out; |
---|
[cf404cb] | 7 | |
---|
[e7678b2] | 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; |
---|
[cf404cb] | 12 | |
---|
[e7678b2] | 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); |
---|
[cf404cb] | 16 | |
---|
[e7678b2] | 17 | out -= cos(x) * out_cos; |
---|
| 18 | out -= sin(x) * out_sin; |
---|
| 19 | return out; |
---|
| 20 | } |
---|
[cf404cb] | 21 | |
---|
[e7678b2] | 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.; |
---|
[cf404cb] | 24 | |
---|
[e7678b2] | 25 | return out; |
---|
[cf404cb] | 26 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.