mailing list of musl libc
 help / color / mirror / code / Atom feed
* [musl] cacosh.c - Comment needs correction
@ 2024-03-08  4:20 Damian McGuckin
  2024-03-08  4:44 ` [musl] " Damian McGuckin
  0 siblings, 1 reply; 4+ messages in thread
From: Damian McGuckin @ 2024-03-08  4:20 UTC (permalink / raw)
  To: MUSL


The routine produces the correct answer.

However, currently, the comment at the top says

 	/* acosh(z) = i acos(z) */

I believe this is technically wrong;

To reflect the code, it should be changed to something like:

 	/* cacosh(z) = acosh(x +/- i y) = +/- i acos(x + i y) */

Somebody may want to rephrase that, i.e. if the sign of 'y' is positive
then the result is

 	i * cacos(z)

If the sign is negative, then the result is

 	-i * cacos(z)

I could always be wrong - Damian

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [musl] Re: cacosh.c - Comment needs correction
  2024-03-08  4:20 [musl] cacosh.c - Comment needs correction Damian McGuckin
@ 2024-03-08  4:44 ` Damian McGuckin
  2024-03-09 20:23   ` Szabolcs Nagy
  0 siblings, 1 reply; 4+ messages in thread
From: Damian McGuckin @ 2024-03-08  4:44 UTC (permalink / raw)
  To: MUSL

On Fri, 8 Mar 2024, Damian McGuckin wrote:

>
> The routine produces the correct answer.
>
> However, currently, the comment at the top says
>
> 	/* acosh(z) = i acos(z) */
>
> I believe this is technically wrong;
>
> To reflect the code, it should be changed to something like:
>
> 	/* cacosh(z) = acosh(x +/- i y) = +/- i acos(x + i y) */

Sorry (fat fingers or worse):

  	/* cacosh(z) = acosh(x +/- i y) = +/- i acos(x +/- i y) */

Thanks - Damian

Pacific Engineering Systems International ..... 20D Grose St, Glebe NSW 2037
Ph:+61-2-8571-0847 .. Fx:+61-2-9692-9623 | unsolicited email not wanted here
Views & opinions here are mine and not those of any past or present employer

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [musl] Re: cacosh.c - Comment needs correction
  2024-03-08  4:44 ` [musl] " Damian McGuckin
@ 2024-03-09 20:23   ` Szabolcs Nagy
  2024-03-09 21:56     ` Damian McGuckin
  0 siblings, 1 reply; 4+ messages in thread
From: Szabolcs Nagy @ 2024-03-09 20:23 UTC (permalink / raw)
  To: Damian McGuckin; +Cc: MUSL

* Damian McGuckin <damianm@esi.com.au> [2024-03-08 15:44:32 +1100]:

> On Fri, 8 Mar 2024, Damian McGuckin wrote:
> 
> > 
> > The routine produces the correct answer.
> > 
> > However, currently, the comment at the top says
> > 
> > 	/* acosh(z) = i acos(z) */
> > 
> > I believe this is technically wrong;
> > 
> > To reflect the code, it should be changed to something like:
> > 
> > 	/* cacosh(z) = acosh(x +/- i y) = +/- i acos(x + i y) */
> 
> Sorry (fat fingers or worse):
> 
>  	/* cacosh(z) = acosh(x +/- i y) = +/- i acos(x +/- i y) */
> 

according to section 6.2 of

https://cs.uwaterloo.ca/~smwatt/pub/reprints/2000-sigsam-according.pdf

  acosh(z) = +-i acos(z)

with + when Im(z)>0 or Im(z)==0 && Re(z)<=1

i guess the Im(z)==+0 && Re(z)>1 case is tricky with ieee -0.0 as it
depends on if sqrt(-z) is i or -i for z=1, which depends on if pure
reals are treated specially sqrt(-1)==i or as sqrt(-1-0i)==-i, in the
latter case the current code looks right to me, just the comment wrong.


> Thanks - Damian
> 
> Pacific Engineering Systems International ..... 20D Grose St, Glebe NSW 2037
> Ph:+61-2-8571-0847 .. Fx:+61-2-9692-9623 | unsolicited email not wanted here
> Views & opinions here are mine and not those of any past or present employer

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [musl] Re: cacosh.c - Comment needs correction
  2024-03-09 20:23   ` Szabolcs Nagy
@ 2024-03-09 21:56     ` Damian McGuckin
  0 siblings, 0 replies; 4+ messages in thread
From: Damian McGuckin @ 2024-03-09 21:56 UTC (permalink / raw)
  To: Szabolcs Nagy; +Cc: MUSL

On Sat, 9 Mar 2024, Szabolcs Nagy wrote:

> i guess the Im(z)==+0 && Re(z)>1 case is tricky with ieee -0.0 as it
> depends on if sqrt(-z) is i or -i for z=1, which depends on if pure
> reals are treated specially sqrt(-1)==i or as sqrt(-1-0i)==-i, in the
> latter case the current code looks right to me, just the comment wrong.

I agree. The code is correct. I thought I had said that.

It is simply that the comment is slightly wrong.

Thanks - Damian

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-03-09 21:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-08  4:20 [musl] cacosh.c - Comment needs correction Damian McGuckin
2024-03-08  4:44 ` [musl] " Damian McGuckin
2024-03-09 20:23   ` Szabolcs Nagy
2024-03-09 21:56     ` Damian McGuckin

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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 NNTP newsgroup(s).