aboutsummaryrefslogtreecommitdiff
path: root/sysdeps
diff options
context:
space:
mode:
authorAkila Welihinda <akilawelihinda@ucla.edu>2021-12-12 10:35:03 -0800
committerPaul Zimmermann <Paul.Zimmermann@inria.fr>2021-12-13 15:31:05 +0100
commit3b1402b3fc3a9ff228c2b721a67f0fef430a82fd (patch)
tree15272f2a5008bebe49af6732774c12053ef8840f /sysdeps
parent104d2005d5b7fb13a970905ca3f4a7e7e783cf1a (diff)
downloadglibc-3b1402b3fc3a9ff228c2b721a67f0fef430a82fd.zip
glibc-3b1402b3fc3a9ff228c2b721a67f0fef430a82fd.tar.gz
glibc-3b1402b3fc3a9ff228c2b721a67f0fef430a82fd.tar.bz2
sysdeps: Simplify sin Taylor Series calculation
The macro TAYLOR_SIN adds the term `-0.5*da*a^2 + da` in hopes of regaining some precision as a function of da. However the comment says we add the term `-0.5*da*a^2 + 0.5*da` which is different. This fix updates the comment to reflect the code and also simplifies the calculation by replacing `a` with `x` because they always have the same value. Signed-off-by: Akila Welihinda <akilawelihinda@ucla.edu> Reviewed-by: Paul Zimmermann <Paul.Zimmermann@inria.fr>
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/ieee754/dbl-64/s_sin.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/sysdeps/ieee754/dbl-64/s_sin.c b/sysdeps/ieee754/dbl-64/s_sin.c
index 7d89e3d..a412c36 100644
--- a/sysdeps/ieee754/dbl-64/s_sin.c
+++ b/sysdeps/ieee754/dbl-64/s_sin.c
@@ -51,16 +51,16 @@
#define POLYNOMIAL(xx) (POLYNOMIAL2 (xx) + s1)
/* The computed polynomial is a variation of the Taylor series expansion for
- sin(a):
+ sin(x):
- a - a^3/3! + a^5/5! - a^7/7! + a^9/9! + (1 - a^2) * da / 2
+ x - x^3/3! + x^5/5! - x^7/7! + x^9/9! - dx*x^2/2 + dx
The constants s1, s2, s3, etc. are pre-computed values of 1/3!, 1/5! and so
on. The result is returned to LHS. */
-#define TAYLOR_SIN(xx, a, da) \
+#define TAYLOR_SIN(xx, x, dx) \
({ \
- double t = ((POLYNOMIAL (xx) * (a) - 0.5 * (da)) * (xx) + (da)); \
- double res = (a) + t; \
+ double t = ((POLYNOMIAL (xx) * (x) - 0.5 * (dx)) * (xx) + (dx)); \
+ double res = (x) + t; \
res; \
})