mailing list of musl libc
 help / color / mirror / code / Atom feed
* x87 asin and acos
@ 2019-02-23 14:21 Shane Seelig
  2019-02-23 15:08 ` Rich Felker
  2019-02-23 20:30 ` Szabolcs Nagy
  0 siblings, 2 replies; 6+ messages in thread
From: Shane Seelig @ 2019-02-23 14:21 UTC (permalink / raw)
  To: musl

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


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

end of thread, other threads:[~2019-02-24  2:53 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-23 14:21 x87 asin and acos Shane Seelig
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

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).