* [PATCH] sysdeps: Update Taylor Series formula in comment
@ 2021-12-11 18:02 Akila Welihinda
2021-12-12 6:34 ` Paul Zimmermann
2021-12-12 18:35 ` [PATCH] sysdeps: Simplify sin Taylor Series calculation Akila Welihinda
0 siblings, 2 replies; 8+ messages in thread
From: Akila Welihinda @ 2021-12-11 18:02 UTC (permalink / raw)
To: libc-alpha; +Cc: Akila Welihinda
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)
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] sysdeps: Update Taylor Series formula in comment
2021-12-11 18:02 [PATCH] sysdeps: Update Taylor Series formula in comment Akila Welihinda
@ 2021-12-12 6:34 ` Paul Zimmermann
2021-12-12 16:50 ` Akila Welihinda
2021-12-12 18:35 ` [PATCH] sysdeps: Simplify sin Taylor Series calculation Akila Welihinda
1 sibling, 1 reply; 8+ messages in thread
From: Paul Zimmermann @ 2021-12-12 6:34 UTC (permalink / raw)
To: Akila Welihinda; +Cc: libc-alpha, akilawelihinda
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)
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] sysdeps: Update Taylor Series formula in comment
2021-12-12 6:34 ` Paul Zimmermann
@ 2021-12-12 16:50 ` Akila Welihinda
0 siblings, 0 replies; 8+ messages in thread
From: Akila Welihinda @ 2021-12-12 16:50 UTC (permalink / raw)
To: Paul Zimmermann; +Cc: libc-alpha
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)
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH] sysdeps: Simplify sin Taylor Series calculation
2021-12-11 18:02 [PATCH] sysdeps: Update Taylor Series formula in comment Akila Welihinda
2021-12-12 6:34 ` Paul Zimmermann
@ 2021-12-12 18:35 ` Akila Welihinda
2021-12-13 9:53 ` Paul Zimmermann
1 sibling, 1 reply; 8+ messages in thread
From: Akila Welihinda @ 2021-12-12 18:35 UTC (permalink / raw)
To: libc-alpha; +Cc: Akila Welihinda
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>
---
sysdeps/ieee754/dbl-64/s_sin.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/sysdeps/ieee754/dbl-64/s_sin.c b/sysdeps/ieee754/dbl-64/s_sin.c
index 7d89e3dfc2..a412c3642d 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; \
})
--
2.30.1 (Apple Git-130)
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] sysdeps: Simplify sin Taylor Series calculation
2021-12-12 18:35 ` [PATCH] sysdeps: Simplify sin Taylor Series calculation Akila Welihinda
@ 2021-12-13 9:53 ` Paul Zimmermann
2021-12-13 14:08 ` Siddhesh Poyarekar
0 siblings, 1 reply; 8+ messages in thread
From: Paul Zimmermann @ 2021-12-13 9:53 UTC (permalink / raw)
To: Akila Welihinda; +Cc: libc-alpha, akilawelihinda
Dear Akila,
thank you for the new version, this seems good to me.
Do you have commit access?
Best regards,
Paul Zimmermann
> From: Akila Welihinda <akilawelihinda@ucla.edu>
> Date: Sun, 12 Dec 2021 10:35:03 -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 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>
> ---
> sysdeps/ieee754/dbl-64/s_sin.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/sysdeps/ieee754/dbl-64/s_sin.c b/sysdeps/ieee754/dbl-64/s_sin.c
> index 7d89e3dfc2..a412c3642d 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; \
> })
>
> --
> 2.30.1 (Apple Git-130)
Reviewed-by: Paul Zimmermann <Paul.Zimmermann@inria.fr>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] sysdeps: Simplify sin Taylor Series calculation
2021-12-13 9:53 ` Paul Zimmermann
@ 2021-12-13 14:08 ` Siddhesh Poyarekar
2021-12-13 14:31 ` Paul Zimmermann
0 siblings, 1 reply; 8+ messages in thread
From: Siddhesh Poyarekar @ 2021-12-13 14:08 UTC (permalink / raw)
To: Paul Zimmermann, Akila Welihinda; +Cc: libc-alpha
On 12/13/21 15:23, Paul Zimmermann wrote:
> Dear Akila,
>
> thank you for the new version, this seems good to me.
>
> Do you have commit access?
>
This is Akila's first submission. Paul, could you please commit for him?
Thanks,
Siddhesh
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] sysdeps: Simplify sin Taylor Series calculation
2021-12-13 14:08 ` Siddhesh Poyarekar
@ 2021-12-13 14:31 ` Paul Zimmermann
2021-12-13 16:58 ` Akila Welihinda
0 siblings, 1 reply; 8+ messages in thread
From: Paul Zimmermann @ 2021-12-13 14:31 UTC (permalink / raw)
To: Siddhesh Poyarekar; +Cc: akilawelihinda, libc-alpha
Dear Siddhesh,
> This is Akila's first submission. Paul, could you please commit for him?
sure, done. Thank you Akila for your contribution!
Paul
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] sysdeps: Simplify sin Taylor Series calculation
2021-12-13 14:31 ` Paul Zimmermann
@ 2021-12-13 16:58 ` Akila Welihinda
0 siblings, 0 replies; 8+ messages in thread
From: Akila Welihinda @ 2021-12-13 16:58 UTC (permalink / raw)
To: Paul Zimmermann; +Cc: Siddhesh Poyarekar, libc-alpha
Thank you Paul and Siddhesh for the review!
On Mon, Dec 13, 2021 at 6:32 AM Paul Zimmermann <Paul.Zimmermann@inria.fr>
wrote:
> Dear Siddhesh,
>
> > This is Akila's first submission. Paul, could you please commit for him?
>
> sure, done. Thank you Akila for your contribution!
>
> Paul
>
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2021-12-13 16:58 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-11 18:02 [PATCH] sysdeps: Update Taylor Series formula in comment Akila Welihinda
2021-12-12 6:34 ` Paul Zimmermann
2021-12-12 16:50 ` Akila Welihinda
2021-12-12 18:35 ` [PATCH] sysdeps: Simplify sin Taylor Series calculation Akila Welihinda
2021-12-13 9:53 ` Paul Zimmermann
2021-12-13 14:08 ` Siddhesh Poyarekar
2021-12-13 14:31 ` Paul Zimmermann
2021-12-13 16:58 ` Akila Welihinda
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).