sysdeps: Update Taylor Series formula in comment

Message ID 20211211180214.5692-1-akilawelihinda@ucla.edu
State Superseded
Headers
Series sysdeps: Update Taylor Series formula in comment |

Checks

Context Check Description
dj/TryBot-apply_patch success Patch applied to master at the time it was sent
dj/TryBot-32bit success Build for i686

Commit Message

Akila Welihinda Dec. 11, 2021, 6:02 p.m. UTC
  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 just updates the comment to reflect the
code.

Signed-off-by: Akila Welihinda <akilawelihinda@ucla.edu>
---
 sysdeps/ieee754/dbl-64/s_sin.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Paul Zimmermann Dec. 12, 2021, 6:34 a.m. UTC | #1
Dear Akila,

this change looks good to me.

To make the code clearer, what do you think of changing 'a' into 'x' in
the macro TAYLOR_SIN (and 'da' to 'dx')?

Paul Zimmermann

> From: Akila Welihinda <akilawelihinda@ucla.edu>
> Date: Sat, 11 Dec 2021 10:02:14 -0800
> Cc: Akila Welihinda <akilawelihinda@ucla.edu>
> 
> 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 just updates the comment to reflect the
> code.
> 
> Signed-off-by: Akila Welihinda <akilawelihinda@ucla.edu>
> ---
>  sysdeps/ieee754/dbl-64/s_sin.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/sysdeps/ieee754/dbl-64/s_sin.c b/sysdeps/ieee754/dbl-64/s_sin.c
> index 7d89e3dfc2..31e08e3a70 100644
> --- a/sysdeps/ieee754/dbl-64/s_sin.c
> +++ b/sysdeps/ieee754/dbl-64/s_sin.c
> @@ -53,7 +53,7 @@
>  /* The computed polynomial is a variation of the Taylor series expansion for
>     sin(a):
>  
> -   a - a^3/3! + a^5/5! - a^7/7! + a^9/9! + (1 - a^2) * da / 2
> +   a - a^3/3! + a^5/5! - a^7/7! + a^9/9! - da*a^2/2 + da
>  
>     The constants s1, s2, s3, etc. are pre-computed values of 1/3!, 1/5! and so
>     on.  The result is returned to LHS.  */
> -- 
> 2.30.1 (Apple Git-130)
  
Akila Welihinda Dec. 12, 2021, 4:50 p.m. UTC | #2
Thanks for taking a look! I think changing a -> x and da -> dx is a good
idea since it looks like we always center the Taylor Series around 0. So I
think the TAYLOR_SIN macro only needs x, dx, and xx as its input. I'll make
this change soon.

On Sat, Dec 11, 2021 at 10:35 PM Paul Zimmermann <Paul.Zimmermann@inria.fr>
wrote:

>        Dear Akila,
>
> this change looks good to me.
>
> To make the code clearer, what do you think of changing 'a' into 'x' in
> the macro TAYLOR_SIN (and 'da' to 'dx')?
>
> Paul Zimmermann
>
> > From: Akila Welihinda <akilawelihinda@ucla.edu>
> > Date: Sat, 11 Dec 2021 10:02:14 -0800
> > Cc: Akila Welihinda <akilawelihinda@ucla.edu>
> >
> > 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 just updates the comment to reflect the
> > code.
> >
> > Signed-off-by: Akila Welihinda <akilawelihinda@ucla.edu>
> > ---
> >  sysdeps/ieee754/dbl-64/s_sin.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/sysdeps/ieee754/dbl-64/s_sin.c
> b/sysdeps/ieee754/dbl-64/s_sin.c
> > index 7d89e3dfc2..31e08e3a70 100644
> > --- a/sysdeps/ieee754/dbl-64/s_sin.c
> > +++ b/sysdeps/ieee754/dbl-64/s_sin.c
> > @@ -53,7 +53,7 @@
> >  /* The computed polynomial is a variation of the Taylor series
> expansion for
> >     sin(a):
> >
> > -   a - a^3/3! + a^5/5! - a^7/7! + a^9/9! + (1 - a^2) * da / 2
> > +   a - a^3/3! + a^5/5! - a^7/7! + a^9/9! - da*a^2/2 + da
> >
> >     The constants s1, s2, s3, etc. are pre-computed values of 1/3!, 1/5!
> and so
> >     on.  The result is returned to LHS.  */
> > --
> > 2.30.1 (Apple Git-130)
>
  

Patch

diff --git a/sysdeps/ieee754/dbl-64/s_sin.c b/sysdeps/ieee754/dbl-64/s_sin.c
index 7d89e3dfc2..31e08e3a70 100644
--- a/sysdeps/ieee754/dbl-64/s_sin.c
+++ b/sysdeps/ieee754/dbl-64/s_sin.c
@@ -53,7 +53,7 @@ 
 /* The computed polynomial is a variation of the Taylor series expansion for
    sin(a):
 
-   a - a^3/3! + a^5/5! - a^7/7! + a^9/9! + (1 - a^2) * da / 2
+   a - a^3/3! + a^5/5! - a^7/7! + a^9/9! - da*a^2/2 + da
 
    The constants s1, s2, s3, etc. are pre-computed values of 1/3!, 1/5! and so
    on.  The result is returned to LHS.  */