From 4d8a6e3b8f982c947439958b1d22154012376b76 Mon Sep 17 00:00:00 2001 From: tlatorre Date: Fri, 19 Oct 2018 10:58:52 -0500 Subject: speed up sin_theta calculation by replacing sin(acos(cos_theta)) with sqrt(1-pow(cos_theta,2)) --- src/scattering.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/scattering.c') diff --git a/src/scattering.c b/src/scattering.c index 0247c62..c4bdd57 100644 --- a/src/scattering.c +++ b/src/scattering.c @@ -158,7 +158,7 @@ double get_probability(double beta, double cos_theta, double theta0) /* Technically this isn't defined up to a sign, but it doesn't matter since * we are going to square it everywhere. */ - sin_theta = fabs(sin(acos(cos_theta))); + sin_theta = sqrt(1-pow(cos_theta,2)); return gsl_spline2d_eval(spline, beta*cos_theta, beta*sin_theta*theta0, xacc, yacc)/(theta0*sin_theta); } -- cgit