mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Shane Seelig <stseelig@mail.com>
To: musl@lists.openwall.com
Subject: x87 asin and acos
Date: Sat, 23 Feb 2019 09:21:08 -0500	[thread overview]
Message-ID: <e5a4695c-2333-f496-88ab-51b2241696e6@mail.com> (raw)

Currently 'asin' uses the algorithm:
	arcsin(x) == arctan(x/(sqrt((1-x)(1+x))))
If the following algorithm were to be used instead, an 'fadd' could be
removed.
	arcsin(x) == arctan(x/(sqrt(1-x**2)))


current:
	fldx	X(%esp)		# %st(0) = x

	fld 	%st(0)		# %st(1) = x
				# %st(0) = x

	fld1			# %st(2) = x
				# %st(1) = x
				# %st(0) = 1
	# unixware bug
	fsub	%st(0),%st(1)	# %st(2) = x
				# %st(1) = 1-x
				# %st(0) = 1

	fadd	%st(2), %st(0)	# %st(2) = x
				# %st(1) = 1-x
				# %st(0) = 1+x

	fmulp	%st(0), %st(1)	# %st(1) = x
				# %st(0) = 1-x**2

	fsqrt			# %st(1) = x
				# %st(0) = sqrt(1-x**2)

	fpatan			# %st(0) = arcsin(x)

	ret


new:
	fldx	X(%esp)		# %st(0) = x

	fld	%st(0)		# %st(1) = x
				# %st(0) = x

	fmul	%st(0), %st(0)	# %st(1) = x
				# %st(0) = x**2

	fld1			# %st(2) = x
				# %st(1) = x**2
				# %st(0) = 1
	# unixware bug
	fsubp	%st(0), %st(1)	# %st(1) = x
				# %st(0) = 1-x**2

	fsqrt			# %st(1) = x
				# %st(0) = sqrt(1-x**2)

	fpatan			# %st(0) = arcsin(x)

	ret


affected files:
	math/i386/acos.s
	math/i386/asin.s
	math/x32/acosl.s
	math/x32/asinl.s
	math/x86_64/acosl.s
	math/x86_64/asinl.s

Please CC me.

--

Shane


             reply	other threads:[~2019-02-23 14:21 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-23 14:21 Shane Seelig [this message]
2019-02-23 15:08 ` Rich Felker
2019-02-23 19:57   ` Rich Felker
2019-02-24  2:53     ` Damian McGuckin
2019-02-23 20:30 ` Szabolcs Nagy
2019-02-23 20:36   ` Szabolcs Nagy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e5a4695c-2333-f496-88ab-51b2241696e6@mail.com \
    --to=stseelig@mail.com \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).