shithub: mc

ref: 4a6a372ad70eb3bde6f0fa6bac7760383b6f6ea8
dir: /lib/math/test/tan-impl.myr/

View raw version
use std
use math
use testr

const main = {
	math.fptrap(false)
	testr.run([
		[.name="tan-cot-01", .fn = tancot01], /* flt32 */
		[.name="tan-cot-02", .fn = tancot02], /* flt64 */
		[.name="tan-cot-03", .fn = tancot03], /* off-by-1-ulp quarantine */
		[.name="tan-cot-04", .fn = tancot04], /* exhaustively test C */
		[.name="tan-cot-05", .fn = tancot05], /* NaN handling */
	][:])
}

const same32 = {a, b
	if a == b
		-> true
	;;

	if std.isnan(std.flt32frombits(a)) && std.isnan(std.flt32frombits(b))
		-> true
	;;

	-> false
}

const same64 = {a, b
	if a == b
		-> true
	;;

	if std.isnan(std.flt64frombits(a)) && std.isnan(std.flt64frombits(b))
		-> true
	;;

	-> false
}

const tancot01 = {c
	var inputs : (uint32, uint32, uint32)[:] = [
		(0x00000000, 0x00000000, 0x7f800000),
		(0x80000000, 0x80000000, 0xff800000),
		(0x01000000, 0x01000000, 0x7e000000),
		(0x3c000000, 0x3c0000ab, 0x42fffeab),
		(0x9e95c3a1, 0x9e95c3a1, 0xe05acc1d),
		(0xb77e2471, 0xb77e2471, 0xc780ef84),
		(0xd6fb3787, 0x3fc3e4b0, 0x3f274655),
		(0x73beb86b, 0xc03fdfc0, 0xbeaac75a),
		(0x78e127aa, 0xbd743d4f, 0xc18629d5),
		(0x495cd1f0, 0xc036296b, 0xbeb3e251),
		(0x3f5bddd1, 0x3f9455b7, 0x3f5ce7d8),
		(0xf1a5d464, 0x3faec70a, 0x3f3b7bed),
		(0x4b877ee5, 0xbea1d1b9, 0xc04a7f60),
		(0x91716066, 0x91716066, 0xed87c133),
		(0x78b5b2be, 0xbf33a6ca, 0xbfb665c7),
		(0xd697d28b, 0x3f2a1d37, 0x3fc09fa6),
		(0x2faeb840, 0x2faeb840, 0x4f3b8bcc),
		(0x652c1dfc, 0x3e06264d, 0x40f443bd),
		(0xcc2cba6f, 0x41b5c9c3, 0x3d3440f9),
		(0x7e10c1ed, 0x3f3ae4bf, 0x3faf546b),
		(0xe65e6ac1, 0xbeff4f29, 0xc00058a9),
		(0xa249358f, 0xa249358f, 0xdca2daf9),
		(0xedfabd59, 0x41135f72, 0x3dde58fe),
		(0xe5041607, 0x40162a53, 0x3eda367b),
		(0xe7f766dc, 0x421af490, 0x3cd377a8),
		(0x44ad2e60, 0x3be0be50, 0x4311cd45),
		(0x02c42753, 0x02c42753, 0x7c270d81),
		(0xa6383652, 0xa6383652, 0xd8b1e1bf),
		(0x96b84e4b, 0x96b84e4b, 0xe831ca9c),
		(0x010937a9, 0x010937a9, 0x7deecdb2),
		(0x0a350f6e, 0x0a350f6e, 0x74b4fa79),
		(0xc7aed7a1, 0x3ee7a189, 0x400d7765),
		(0xf59d39e3, 0xbd1aa1aa, 0xc1d3e906),
		(0xf4532cda, 0x3e247e88, 0x40c7345b),
		(0xeec7c1c9, 0xbe7caa4b, 0xc081b07d),
		(0x2c8b7263, 0x2c8b7263, 0x526afc52),
		(0xa7f2d525, 0xa7f2d525, 0xd706f0d2),
		(0x927fced4, 0x927fced4, 0xec80189b),
		(0xe4db95ed, 0x3e092efb, 0x40eedcce),
		(0xfcc97783, 0x3ffc8e75, 0x3f01bec8),
		(0xa5e3ccd3, 0xa5e3ccd3, 0xd90fd86d),
		(0xf4264176, 0x4077503e, 0x3e847eee),
		(0x77c8a8a7, 0x3f261644, 0x3fc54b51),
		(0xf6f29a5e, 0xbef8da53, 0xc003ad1d),
	][:]

	for (x, yt, yc) : inputs
		var xf : flt32 = std.flt32frombits(x)
		var rtf, rcf
		rtf = math.tan(xf)
		rcf = math.cot(xf)

		var rtu = std.flt32bits(rtf)
		var rcu = std.flt32bits(rcf)

		testr.check(c, same32(rtu, yt),
			"tan(0x{b=16,w=8,p=0}) should be 0x{b=16,w=8,p=0}, was 0x{b=16,w=8,p=0}",
			x, yt, rtu)

		testr.check(c, same32(rcu, yc),
			"cot(0x{b=16,w=8,p=0}) should be 0x{b=16,w=8,p=0}, was 0x{b=16,w=8,p=0}",
			x, yc, rcu)
	;;
}

const tancot02 = {c
	var inputs : (uint64, uint64, uint64)[:] = [
		(0x0000000000000000, 0x0000000000000000, 0x7ff0000000000000),
		(0x8000000000000000, 0x8000000000000000, 0xfff0000000000000),
		(0x41bb951f1572eba5, 0xbc8f54f5227a4e84, 0xc35057584c429b3a), /* [GB91]'s "Xhard" */
		(0x5101000000000000, 0xbff4f77bbc53c8f9, 0xbfe86b6d64c43ec0),
		(0x4b01000000000000, 0xbfe96f60bbc6c837, 0xbff421332f057cb5),
		(0xc3a19e952471b77e, 0xbfecc29cbf8278ef, 0xbff1cd6894a73f54),
		(0x3787d6fbb86b73be, 0x3787d6fbb86b73be, 0x48557a09a4de8cf1),
		(0x27aa78e1d1f0495c, 0x27aa78e1d1f0495c, 0x5833574ee69506a6),
		(0x7ee54b8760669171, 0xbfe9c97ba8512160, 0xbff3dadcdaf63a4f),
		(0xb2be78b5d28bd697, 0xb2be78b5d28bd697, 0xcd20cd75656cae19),
		(0xb8402fae1dfc652c, 0xb8402fae1dfc652c, 0xc79fa1bcab9bfa3a),
		(0xba6fcc2cc1ed7e10, 0xba6fcc2cc1ed7e10, 0xc5701a13dad38280),
		(0x6ac1e65e358fa249, 0x3fc7cd0dbfe6d3df, 0x401582ff610d2706),
		(0xbd59edfa1607e504, 0xbd59edfa1607e504, 0xc283beeb209192c9),
		(0x66dce7f72e6044ad, 0x3ff4fbabd2ab23f9, 0x3fe8668db91e9b7e),
		(0x275302c43652a638, 0x275302c43652a638, 0x588aee9adce0c415),
		(0x4e4b96b837a90109, 0xc01f79ba64664aea, 0xbfc04441334c23a7),
		(0x0f6e0a35d7a1c7ae, 0x0f6e0a35d7a1c7ae, 0x70710b440e1aaef5),
		(0x39e3f59d2cdaf453, 0x39e3f59d2cdaf453, 0x45f9a6ebd03c22d5),
		(0xc1c9eec772632c8b, 0x3ff0f7dd116e0647, 0x3fee2c8f34e6790d),
		(0xd525a7f2ced4927f, 0x3ff9b655c6a6b5fe, 0x3fe3e9a613743163),
		(0x95ede4db7783fcc9, 0x95ede4db7783fcc9, 0xe9f1209007b04e55),
		(0xccd3a5e34176f426, 0x3fde5ad1ab611c65, 0x4000de012b1b5082),
		(0xa8a777c89a5ef6f2, 0xa8a777c89a5ef6f2, 0xd735d128ee518a7a),
		(0x0e80d207f7fc1dee, 0x0e80d207f7fc1dee, 0x715e706d3d44d3cb),
		(0xdc3ccf9de59c1620, 0xc025240a96dce158, 0xbfb837f561f3466c),
		(0xc53a12760a738704, 0xbfd33aa6f3b5cde8, 0xc00aa05505b58fed),
		(0x013d7cd6b38fd663, 0x013d7cd6b38fd663, 0x7ea15cfab65b2026),
		(0x24c9826368e2bab6, 0x24c9826368e2bab6, 0x5b141232d64139ff),
		(0x673ee065b77f3411, 0xc002680c95540481, 0xbfdbd0fc321d37ee),
		(0x8648f8f528372eef, 0x8648f8f528372eef, 0xf99480a7cbbaf84f),
		(0x70bdc29525e17f3d, 0xbfcab0378314cf75, 0xc0132f3505ba9e89),
		(0x949d1ddd9d2c70d9, 0x949d1ddd9d2c70d9, 0xeb41959d6300f232),
		(0xed7a82c886f9b2b5, 0xbffc586c9dee2029, 0xbfe210199dcba8ea),
		(0x953f916c39b9967c, 0x953f916c39b9967c, 0xeaa0380b8daa847f),
		(0x0e43ed486cdf330c, 0x0e43ed486cdf330c, 0x7199b1a551a932e8),
		(0xb626a5410afb3c6e, 0xb626a5410afb3c6e, 0xc9b69bfcb4e83197),
		(0x9e3633326b5d0ef3, 0x9e3633326b5d0ef3, 0xe1a71025b63c78d7),
		(0xf5c8913f8e308a65, 0xbfcb0c899ca207ec, 0xc012edba9bf64e3d),
		(0xaf1c2b5cfb3e9c97, 0xaf1c2b5cfb3e9c97, 0xd0c22cfe8b4e4af6),
		(0xae2582384f4c4364, 0xae2582384f4c4364, 0xd1b7cdea08fb3afc),
		(0x13a48905d9e021e7, 0x13a48905d9e021e7, 0x6c38eec83f657958),
		(0x764d46c054f3e5f8, 0xc00236c5e85323a3, 0xbfdc1c3d52cfee80),
		(0x1c8142b5bce1d2a8, 0x1c8142b5bce1d2a8, 0x635da9b7849a7998),
	][:]

var n = 0
	for (x, yt, yc) : inputs
n++
		var xf : flt64 = std.flt64frombits(x)
		var rtf, rcf
		rtf = math.tan(xf)
		rcf = math.cot(xf)

		var rtu = std.flt64bits(rtf)
		var rcu = std.flt64bits(rcf)

		testr.check(c, same64(rtu, yt),
			"tan(0x{b=16,w=16,p=0}) should be 0x{b=16,w=16,p=0}, was 0x{b=16,w=16,p=0}",
			x, yt, rtu)

		testr.check(c, same64(rcu, yc),
			"cot(0x{b=16,w=16,p=0}) should be 0x{b=16,w=16,p=0}, was 0x{b=16,w=16,p=0}",
			x, yc, rcu)
	;;
}

const tancot03 = {c
	var inputs : (uint64, uint64, uint64, uint64, uint64)[:] = [
		(0xf83b13a6a142b6d5, 0xbf5a86f73542c78a, 0xc0834d0a344cbe85, 0xbf5a86f73542c789, 0xc0834d0a344cbe85),
		(0x3f80000000000000, 0x3f800015557777af, 0x405fffd55549f49b, 0x3f800015557777af, 0x405fffd55549f49a),
		(0x77709d0579b8480f, 0x40657b00018b5542, 0x3f77d5ea4c97113d, 0x40657b00018b5543, 0x3f77d5ea4c97113d),
		(0xd5de89ca329a1145, 0x4068d90e2dd81e00, 0x3f749afa8f6b9cf9, 0x4068d90e2dd81e00, 0x3f749afa8f6b9cf8),
	][:]

	for (x, yt_perfect, yc_perfect, yt_acceptable, yc_acceptable) : inputs
		var xf : flt64 = std.flt64frombits(x)
		var rtf, rcf
		rtf = math.tan(xf)
		rcf = math.cot(xf)

		var rtu = std.flt64bits(rtf)
		var rcu = std.flt64bits(rcf)

		testr.check(c, (same64(rtu, yt_perfect) || same64(rtu, yt_acceptable)),
			"tan(0x{b=16,w=16,p=0}) should be 0x{b=16,w=16,p=0}, will also accept 0x{b=16,w=16,p=0}, was 0x{b=16,w=16,p=0}",
			x, yt_perfect, yt_acceptable, rtu)

		testr.check(c, (same64(rcu, yc_perfect) || same64(rcu, yc_acceptable)),
			"cot(0x{b=16,w=16,p=0}) should be 0x{b=16,w=16,p=0}, will also accept 0x{b=16,w=16,p=0}, was 0x{b=16,w=16,p=0}",
			x, yc_perfect, yc_acceptable, rcu)
	;;
}

const tancot04 = {c
	/*
	   There should be one of these for each j, each corresponding
	   to the appropriate xi. This should ensure that, when
	   upgrading the C tables, things don't get too terribly
	   broken.
	 */
	var inputs : (uint64, uint64, uint64)[:] = [
		(0x3c79565a4a53b896, 0x3c79565a4a53b896, 0x43643514e5e6151d), /* j = 0 */
		(0x521071413389fce0, 0xc069c888b4021d3b, 0xbf73db97f25fd281),
		(0xbf7c2388653f944a, 0xbf7c23a56814d6a2, 0xc06231fa9c94d936),
		(0x503ece41b1165990, 0x40564720618519f6, 0x3f86fb83eb45eb36),
		(0xf549b46989519196, 0x405362a6d937767d, 0x3f8a6964419f2412),
		(0xcd512459433a0231, 0x3f91b4eac5967922, 0x404cea6483e23c58),
		(0xcaf4adbc5ee7cd89, 0xc0483c7c5380436e, 0xbf952017aadab226),
		(0x475f423e817765ea, 0xbf96b5919e08c282, 0xc0468bbe82b62f6c),
		(0xfcf1de6e51eb3a2a, 0xbf9a4811a09dd560, 0xc0437b3b137bbcbf),
		(0x6d2a3c2098179905, 0x3f9f1551031330ae, 0x404078cd715b3aff),
		(0x62e01a08ac6db91f, 0x403e0e0bcee51c2c, 0x3fa109172f8fb6e5),
		(0x5516368407fe18ac, 0xbfa2a9ddeb41fdb2, 0xc03b6ee3c2e19447),
		(0x5c7c4e1923c950ec, 0x403a340e131a9b8c, 0x3fa38a1c47557d66),
		(0x52924d2cbb5901d1, 0x3fa490894ccf2c23, 0x4038e5ac3c9ea8a7),
		(0x77352e83554977a2, 0x3fa741604124d6ca, 0x40360433cfc3b416),
		(0xeab236c01f08c19f, 0x4034ed5f1b1f4d57, 0x3fa8773a05bad8e8),
		(0x54b55622172ba5a0, 0x3faa765b3f6b8f73, 0x40335927794e9bd3),
		(0xda739024569252ce, 0x40326751a22b67ca, 0x3fabd216c378b36d),
		(0xdb96494b55f3f081, 0xc0314440acaa21e0, 0xbfada7110aa502e2),
		(0x5a446ae100d4ad56, 0x40308389b1b086a8, 0x3faf011c18275726),
		(0x447aa716086a8c88, 0xbfb0675ddd971236, 0xc02f365afa1f8a00),
		(0xf968280b3a414e54, 0x3fb138c1ea322780, 0x402dbadbee341cac),
		(0x79a51c7ac9f069e8, 0x402d72743ce098d6, 0x3fb1631a402c8bcd),
		(0x60ffe411eafbc6da, 0x3fb251a2b23e2026, 0x402bf304e674f736),
		(0x4f318e7d4aea96dc, 0xc02a0caf0e7cbf34, 0xbfb3a7a47204e201),
		(0xc404978c116309d8, 0x3fb433de58d623c0, 0x402957dfc56925ab),
		(0xe66830cbfd75b885, 0x4028733a310ce62e, 0x3fb4f0cb6b3bb391),
		(0x5aa8e5159f4c635a, 0xc027399eacbe42ec, 0xbfb60b8e0f2a47b3),
		(0xc0197a1d458871ce, 0xbfb616745039ebcf, 0xc0272e28bde38084),
		(0xfec0c7c70c5fef38, 0x3fb74390e9cea2bf, 0x4026022137bd7bbb),
		(0x536118c6d0da429d, 0xbfb82e815bcb8454, 0xc0252c4e4ad03fb7),
		(0xc0c5332662ea8467, 0xbfb8fb3bbbe9507a, 0xc0247ec9aabe16a4),
		(0x640531fd736dc271, 0x3fb9ed0fe38c96f4, 0x4023bf9d7f18200a),
		(0x4223b2a56016896f, 0x3fbaa24c8e7074dc, 0x4023393b6983f060),
		(0xe47b0287f9f402c4, 0xbfbb77a83aebd88c, 0xc022a3e8d92ebb66),
		(0x720e26846afc74a5, 0xbfbbdb0ae1cd9bfc, 0xc02261674852b84a),
		(0x6e03d54eae350b2b, 0x3fbc6d5994a2db4d, 0x402202cdbfabb7c2),
		(0xe223c42c81a9e6a1, 0x3fbde6dc34d255c1, 0x40211f6a57a2ab8b),
		(0xf5b0b388d525a652, 0xbfbe3c30082a93b9, 0xc020ef17c4c56fb5),
		(0xc872046ad7b74e5d, 0x40207f837f2bb080, 0x3fbf08ac1c355dae),
		(0x69df9989dca89d7f, 0x401fbfeee53b8ab8, 0x3fc0204931062ab3),
		(0xcc324b95dbc8fd01, 0xbfc09375925b4df4, 0xc01ee3546f5cc75d),
		(0xf721d915cf272a16, 0x401ea89e0f1b1f2b, 0x3fc0b333f1b3aa2d),
		(0x727b9da90c1b363d, 0xc01dffd43f5fbb8a, 0xbfc11129f51ec3b0),
		(0x76833092f555af28, 0x3fc199c2dfe24290, 0x401d17019925c551),
		(0x4aee1902b654832c, 0x401c77a2efc4a270, 0x3fc1fc4ba79a254b),
		(0xfc53224870aff4ac, 0xc01bf5d5327767d8, 0xbfc24fcac6864d6e),
		(0x5657a3059c18f2d9, 0x3fc2ca3784efa8a1, 0x401b3fa8abd32c27),
		(0x7bff45dd88b13800, 0x3fc3097e149ad48c, 0x401ae516e8c1b891),
		(0x5dee435102358eaf, 0xc01a220c17076f81, 0xbfc39793235ac8be),
		(0xde9d9f0cc9f77177, 0x3fc41d6a02d1d67d, 0x4019742a3de2e8a8),
		(0xfdda28f4488d7a83, 0xbfc455a0bdcd9658, 0xc0192dcc96c09118),
		(0xf50af38a50f30e4c, 0x3fc4b7278305fffc, 0x4018b742599f99bd),
		(0x5cb2267a738b9206, 0xc01802b6ce056aa1, 0xbfc552ec0075b902),
		(0xc989143e4bf260b6, 0x4017a9b2fb7a0491, 0x3fc5a32358ce4607),
		(0xf819600bb7324a38, 0xbfc5fc033f10df52, 0xc0174a0a066b5f52),
		(0x7509b2527112fd5b, 0xbfc688076788f691, 0xc016b9503b90cf6c),
		(0x73028e0de36d1132, 0xc01642d4ff378b19, 0xbfc6fff2ee5689dc),
		(0xe1c86c04b0706291, 0xc01624b91bb4a760, 0xbfc71f38e7f04bea),
		(0x423c927a3f264a46, 0xbfc7934c85e3eedd, 0xc015b7b260999f02),
		(0x4b1f0b0b22dfeef3, 0xbfc830a4286c0b3e, 0xc0152a6fb053767d),
		(0xcb9bb37fc0f2a235, 0xbfc842e95009eb8c, 0xc0151a7f4f9abae8),
		(0xd6e8414566d4c52e, 0xc014a7191ae3c278, 0xbfc8ca796bb67c9c),
		(0xe79fb9553990f8be, 0x401442516c878b1e, 0x3fc945cc6022d782),
		(0x6dcb241574906b9f, 0x3fc9c6fc0108ec47, 0x4013dcc98c43328e),
		(0x4bb2a2d62ad20180, 0xbfca2782885fb0ee, 0xc013937b923e0d8d),
		(0xe62474e683c786e6, 0xc0134de7ff797441, 0xbfca85c66da38626),
		(0x468f3f43adc7a648, 0xbfcb08c355d5d83b, 0xc012f05f2b6d3816),
		(0xfddefd05372bf5b1, 0xbfcb1a25e121b44c, 0xc012e439221e5f3e),
		(0xde30e787f515ee90, 0x3fcbe4216eeb9065, 0x40125b6a11095216),
		(0x6360cbf4cc0e423a, 0x3fcc33d9e47482b3, 0x4012278629c47e06),
		(0x78a35210c57021ed, 0xc011f1def6fbdf9c, 0xbfcc882c7fe33bf1),
		(0x431b628966118011, 0x4011c83151013186, 0x3fcccb0c5fbba2bf),
		(0x7517b932422321b3, 0xbfcd37982a92dd89, 0xc01186214075d675),
		(0x71ce2347503f237b, 0xbfcdef2b5b49c97d, 0xc0111aa996e77d3d),
		(0xd3eeab6f1ce0c65f, 0xc0110bd5cf4078be, 0xbfce0934fc2e3a6e),
		(0x7332b1c80505c25d, 0xbfceaa4a800b7861, 0xc010b24a9e60f783),
		(0x50afa8bba1d961cd, 0x3fcef110d2a3c406, 0x40108c19c7572e79),
		(0xf6deca320321040f, 0xc01036b3933681fe, 0xbfcf9409f3ae8d15),
		(0xde7018284f03e03f, 0x400ff58ecd97b1cc, 0x3fd0053a4dea9fb4),
		(0x5a35f121d3d2a2e7, 0x3fd01ca658f621d6, 0x400fc7193193f7c8),
		(0x5f8789fe1295b431, 0x3fd03ff9c0820c6f, 0x400f82043cd6360d),
		(0x6b03c18f1a7b6e8a, 0x3fd0a52e5904da84, 0x400ec271b160fcbc),
		(0x67e5a3e87999944c, 0xbfd0c25d63bbab57, 0xc00e8ce1807d4ce5),
		(0x755909d7a66ec123, 0xbfd0eada0993264b, 0xc00e43c47922f882),
		(0xce7378a1c330830a, 0x3fd128c5fbe43f9f, 0x400dd68d8dd1fc71),
		(0x61229f2e883ad502, 0xc00d8c9aec55bb8d, 0xbfd153b704e7a90b),
		(0xced4e84706b222f4, 0x400d30974b14de74, 0x3fd18a5597eef25d),
		(0x5474ef4a0497c293, 0xbfd1c55dfa04175a, 0xc00ccfa05aea5cad),
		(0x64a85b58557d81d6, 0x3fd21e0ade9fa6aa, 0x400c429c5c6d1fd2),
		(0xf77724543b8b3885, 0x3fd2542b2e3b002c, 0x400bef2809369f45),
		(0x464183db1f445d09, 0xc00be3999eb1362e, 0xbfd25bc3761d6ba4),
		(0x778eae02a44000a2, 0xc00b91a5151bc992, 0xbfd29256a1f0ff97),
		(0x5cdc5f4b5e0d1940, 0xbfd2ead9b759215a, 0xc00b10a741a8f24e),
		(0x525e3d38881ed63d, 0xc00aadb8d95bd5b5, 0xbfd3310047d6f099),
		(0x5a10e8f3294cb8da, 0xc00aa0a28dbee61b, 0xbfd33a6ef6650b66),
		(0x69f6fc4f0ca39ec6, 0x3fd39ac21be3213c, 0x400a1dcdba18b71c),
		(0xf60fe4b87e3c1da9, 0x3fd3b963dc04a281, 0x4009f53e9c589989),
		(0xf57c4045e43ccaf9, 0xc009b5ddc506f67d, 0xbfd3ea0305520474),
		(0x73c33cf71af08874, 0x40097b0f54c56a4e, 0x3fd417f89e98496b),
		(0xfdbeacaff2a4886d, 0xbfd453456f2c976b, 0xc00930b7f6d7f86a),
		(0xf6c928e27302222b, 0xbfd4a6a6d3b97c7e, 0xc008cb029bb3ec39),
		(0x5c6e0f3ec20f8e7d, 0x4008898dbbd99fd5, 0x3fd4ddbdab41d462),
		(0x44438c0b81cf287e, 0x3fd50496c406f2ca, 0x40085c335bad6163),
		(0xe9eeb63337ece529, 0x3fd540fcb11eb4a5, 0x400816f9a23c2445),
		(0xd05cf079494581b4, 0xc007e89c0579cff4, 0xbfd56a345270dd18),
		(0xfeb5da20af64f306, 0x4007a27c85a6b271, 0x3fd5a9bdc193fe25),
		(0x536b65af59fbc622, 0x40076647dcdfdc29, 0x3fd5e17aa3dc4f94),
		(0xfcd5a50b4eafe1f6, 0x3fd638c6e1863d76, 0x40070a5b2ba01912),
		(0x7e36add9e924c14b, 0x3fd66668ebe3fd5a, 0x4006db6b2431c502),
		(0x72f883ad82e4a3ba, 0x4006be62fab1f37f, 0x3fd68300c86cfbc2),
		(0xf6e835bc9adeaf59, 0xbfd6cf5164e5b38b, 0xc006724b03e11174),
		(0x42ea8e91bba3889d, 0xc0065580a01f30a5, 0xbfd6ecb8d0b4f4bd),
		(0xe28b1ead713c1846, 0x4005f81eef90c072, 0x3fd74e2a329ce9c5),
		(0x5bf9ffb760361ee7, 0x4005ddd8910dabf0, 0x3fd76a2b2380d2ae),
		(0x6b9ffac3db03a107, 0xbfd7a9f1a170ad6f, 0xc005a2ea1057b86a),
		(0x6eb4d607fe115dcf, 0x40056be6a4971a46, 0x3fd7e6b7460e031b),
		(0xf7917095f9a51925, 0x3fd8258aa65c5906, 0x4005342a6a586d87),
		(0x76d55c397cac2f9d, 0xbfd86bb7872939f1, 0xc004f73c163572bd),
		(0xe8c4f20489ec8ffa, 0xc004d3779bebab91, 0xbfd895a87acf8c8a),
		(0x5fd1cfe5b08757a6, 0xbfd8b93277c1bfa9, 0xc004b587d2303bad),
		(0xc733503522b5f461, 0x3fd90ed1c765c07b, 0x40046ec49898d8d0),
		(0x697a2fac6afef92f, 0x3fd946b41ef58f1a, 0x40044197ada15b60),
		(0xc3a23c3b9032b8f3, 0xbfd961e286c44ef0, 0xc0042be69206e0dc),
		(0xc48d690c9e9f2305, 0x3fd9c6cc521e03df, 0x4003dcee4a750686),
		(0x56be9f39eac7f817, 0x4003c478b9f59a35, 0x3fd9e6b1549b7658),
		(0x4d4c51754594c5a7, 0x40038739eb41f268, 0x3fda37ecd1c42e19),
		(0x53af975d069ceebf, 0xc00375837628fefd, 0xbfda4fca655fc1f0),
		(0xbfd929812210b263, 0xbfda8b4a401ecbee, 0xc00349e53e631bbe),
		(0xf311b32b3a68939e, 0x40031feb00197de6, 0x3fdac58d8019fd53),
		(0xc8bb45b934289a6f, 0x3fdb0c1b08eecc8d, 0x4002ee07feabd489),
		(0xcf7f65187e57f8e0, 0x4002b37691192ade, 0x3fdb60d005c0ebf0),
		(0xd869ac083d0a16a5, 0xbfdb72cf0c12ea21, 0xc002a733bc84bf9e),
		(0xe63586b4c42da14f, 0xbfdbe58dd31b8bff, 0xc0025a7a487dad5b),
		(0x71bf7ddcf4d0e040, 0xc0024ba3e95ec017, 0xbfdbfc2d8849f915),
		(0xf6bb3c9916ba9b7b, 0x40021b8b9ffa115b, 0x3fdc468204bfdeb5),
		(0xd660ed6e55136cdf, 0x4001e8cb5555e3e4, 0x3fdc96a258c6d38b),
		(0xc6f8b9cd5c389bec, 0x4001dc0f3763963d, 0x3fdcab04ea35603b),
		(0x4e2d2d544b4e9749, 0xc001a8e4711d8cb3, 0xbfdcfe14e4b1dcb8),
		(0x457b0455f480dbf3, 0xbfdd3a851ad22002, 0xc00184603a2c2e09),
		(0xcb84660f30d05c41, 0xbfdd5500361e5c20, 0xc001748fbe8527f4),
		(0x76bc0ffdf6576c1d, 0x3fddb2cb62781ad6, 0x40013d6f1df2661f),
		(0x576061576fcdadfd, 0x40011fe6863ad307, 0x3fdde6035e4f9836),
		(0xe9922b0dd12503ba, 0x3fde1b9f362deb6d, 0x40010168bfcfe60a),
		(0xf090512b08c64f2b, 0xc000ccf22ac45b1a, 0xbfde79a3d5d64425),
		(0xc9064cce58144c06, 0x3fdeb945fad69a7d, 0x4000aa26459366ea),
		(0x7f2ba4659829232b, 0xc0008e9aaebc8235, 0xbfdeec631b7b2781),
		(0xc366379b9a957cdb, 0x3fdf25b1353833ee, 0x4000702471ca91a3),
		(0xf9f816554910c126, 0xc00044255f350059, 0xbfdf79f03db1f5f6),
		(0xc40021d66b2f4d61, 0x3fdf8e852ce9efce, 0x4000398973c3656f),
		(0xc76aa2fdbe146487, 0xc0001a10cf5b0ea1, 0xbfdfcc32c535fbc5),
		(0x7738dad760be3d56, 0x3fffdeed4df15e90, 0x3fe0109a8210be31),
		(0x666928445c6724e3, 0xbfffb61a9ba6cf8e, 0xbfe02548cb82b62f),
		(0xc1a41b02da9ba0ea, 0x3fff777ca9858298, 0x3fe04569c9bb4266),
		(0x7848fe3e78cb663c, 0xbfff3637f050767c, 0xbfe0677047cb2dbb),
		(0x5be9ac5535d046cc, 0xbfe08f262f95b8a2, 0xbffeeb5e979f7bf6),
		(0x7d00750f7493ec14, 0x3ffec4280177abce, 0x3fe0a44135df1990),
		(0x70b08a0803a2e4f7, 0x3fe0bdd60b0c4039, 0x3ffe952519d0df4a),
		(0x55fbd54cc4be5f3c, 0x3fe0e1a0aad88c06, 0x3ffe544de9778904),
		(0xf3554e8402f6265a, 0xbfe111e4621d3a85, 0xbffdfe8c9d7f0ba0),
		(0xd1c4f6c0576b4ceb, 0x3fe11fa43d2b9635, 0x3ffde6771af75c65),
		(0x7577c5523259981f, 0xbfe142d0f9becfee, 0xbffda988b5c492be),
		(0x75b6af03b453c0ef, 0xbfe16fdd915c91fb, 0xbffd5ce67b5edd2e),
		(0xeb073e7d1af5222d, 0x3fe18ee2b608d90e, 0x3ffd290653690906),
		(0x550e8ceaf98764b8, 0x3ffce3611c108856, 0x3fe1b9373efe3caf),
		(0x75dc9fbbd1640b6a, 0x3ffcc975824760e0, 0x3fe1c92ca429ec72),
		(0x633901c12d4cb6e1, 0x3fe1f0f9270d1256, 0x3ffc8999f7e80c9f),
		(0x7f04dacd2c2ca8ce, 0x3ffc707fe49c2ec9, 0x3fe200cf1aa3a42b),
		(0x4332ecebbe152c9a, 0x3ffc2836137657d3, 0x3fe22f07698081d6),
		(0xc94f80eb836c1307, 0x3ffbf0338691284f, 0x3fe2537bb1fa7042),
		(0xc404cdd7bc992e30, 0xbffbb536a4e0dad3, 0xbfe27a7f7c6c6344),
		(0xc53d64204fdf1db3, 0xbffb9b3ee2a4f02d, 0xbfe28be132c06bf3),
		(0xe4efa91ba9b9e968, 0xbfe2b45dea407296, 0xbffb5f7d64e821e0),
		(0x637f1d1420fea3f8, 0xbfe2e406e3980e76, 0xbffb1a6df6baf1a2),
		(0x72eae57421307d45, 0xbffaf50df59e0bba, 0xbfe2fe37d31e7efd),
		(0xc2e6fa2f34fd750b, 0xbffab9203dbe4805, 0xbfe328cfb306dd71),
		(0x61ff0525749ceb45, 0xbffa87c166523e00, 0xbfe34c771bd73054),
		(0x4d744a5ecf95fd93, 0x3fe3570aef0e3b1f, 0x3ffa793eda0a7fe5),
		(0x62fcbf662333deb3, 0xbffa515ad324e0c2, 0xbfe3745b63c100ee),
		(0xfa89d1a75f768cd0, 0x3ffa0727c5c4f9f4, 0x3fe3abd130534148),
		(0x6ce2de1511d237eb, 0xbfe3c00ae9db31f0, 0xbff9ec8041d9a2e7),
		(0x56a33b90bd51784c, 0x3fe3eacbe508524c, 0x3ff9b4da77df56fd),
		(0x4c71f17579861fde, 0xbff978184060ca52, 0xbfe41a4f7d1be713),
		(0xd2573e1a86722c43, 0x3ff959e15efdd2e6, 0x3fe432450d7c4a5f),
		(0x498c3881301c9450, 0x3ff920f594aa06e6, 0x3fe46004a0bcc88c),
		(0xde3e4fc147357cf2, 0x3fe47a694e965949, 0x3ff9009276eb7768),
		(0x4e22da5810e48e2c, 0x3ff8c5e9f63dadb2, 0x3fe4aae663098ea7),
		(0xfc2b1173d2f9d7c5, 0x3fe4b659cd95ff4a, 0x3ff8b837d228b883),
		(0x5c782c96a47e6797, 0xbff8951c12bcea82, 0xbfe4d3ee8f6c5d58),
		(0xfb85676d181e0881, 0x3fe50477049116da, 0x3ff85c5827c4e282),
		(0x6269a55fd3dcfce2, 0xbfe51d16cd6fc97d, 0xbff83feee767409d),
		(0x4598ddfdd67bf239, 0x3ff7fbbe057723d2, 0x3fe5591ee0085ea3),
		(0xd95338bde4d930aa, 0xbfe5822d4e25b75c, 0xbff7cdf636d6b0c8),
		(0x611503484c027608, 0xbff7c33c14f7c2d5, 0xbfe58be2f042fb3b),
		(0x5c2ee2e8eb412270, 0xbfe5b526acefe84a, 0xbff796104c692ece),
		(0xcb58f3d014fca0aa, 0xbff75b46900e6ad1, 0xbfe5ebc9ee50344d),
		(0x43c6b36129529847, 0x3ff74c923ad7544f, 0x3fe5f99f9e0b3d0a),
		(0xfa1614294a9f72c8, 0x3ff70d99dd8a1f18, 0x3fe635a624809779),
		(0x6d769e17aec9b01c, 0xbff6f700728c5edf, 0xbfe64b81491e4d3b),
		(0xda3899b5876d7e4c, 0x3fe665a0157cdfcc, 0x3ff6dc381ade767d),
		(0xdea2d627e9529863, 0x3ff6b24ede764eb2, 0x3fe68efbb7f423ba),
		(0xcc92e4c94a84e291, 0xbfe6b6f40b3bd7cd, 0xbff68a5eb7b8ee06),
		(0xf8aab297bc40c6d3, 0xbfe6f824ba593202, 0xbff64a65961cc5b3),
		(0x6bfb68a736eeb1b6, 0x3fe7075f6fd332d8, 0x3ff63ba7d9b8357b),
		(0xcf94cd7e76b5d43b, 0x3ff6222f4b54bb14, 0x3fe721dfbd310dc3),
		(0x605cb87016a4858e, 0xbfe75dd6ab966b3b, 0xbff5e9626960a874),
		(0x4c2f18aaaae1a9a5, 0x3ff5bf431f6a202f, 0x3fe78b18f4dd86cc),
		(0x5d83a57bdc3cdd0e, 0xbfe7b8fb49fd3969, 0xbff59532f3461951),
		(0xcfb59ea70736bcbf, 0xbff5840f8b17744d, 0xbfe7cbe0ae02d204),
		(0xc1089dc2ab12c9b4, 0xbfe7f5a1e9bfb06b, 0xbff55e908266f122),
		(0x68affef34749279e, 0x3fe8209711c62ee3, 0x3ff5388466d3ef9f),
		(0x72d7978807cae706, 0xbfe85291c100af7b, 0xbff50ce960ab4ab7),
		(0xc4a750b852001a47, 0x3ff4f6b641a2a8e6, 0x3fe86c536d8567a6),
		(0x66cfeadab1736af0, 0xbff4e155036c93d7, 0xbfe885555e56c040),
		(0xff8223b58fd12c2f, 0xbff4a692b6776ff1, 0xbfe8cb1ac1da9263),
		(0x74ea533d2ebb1aac, 0xbff4893fc1ab4b47, 0xbfe8ee81f1f3c4fb),
		(0x7e5b65a329da9204, 0xbfe91de34b0c25b5, 0xbff4628279c98889),
		(0xee3f0726908f6f7e, 0xbff44233d2075f4e, 0xbfe945f14e54dcc8),
		(0x7af275b9d87202c4, 0x3fe94b1657573c6c, 0x3ff43e14f1e4ba73),
		(0x5ab6206f24450152, 0x3ff41215d5e23105, 0x3fe9828845174281),
		(0x4e24e759fc383d3b, 0xbff3f99b9c0d4208, 0xbfe9a1cacc4b3f71),
		(0x6e6e238154fe510b, 0x3ff3be6db5d3c2e5, 0x3fe9ee9ecbc9c72c),
		(0x51115721fcb875a5, 0xbff3a1e91c8e1a9a, 0xbfea144a011e41f3),
		(0xcd0f08fce53215fe, 0x3fea3fdc281037d2, 0x3ff38152b5b8b26c),
		(0xc793de849b92e545, 0xbff3630d84adfdc4, 0xbfea68d8627834ab),
		(0xd8fdb9e8f5a2831b, 0x3ff35d39f575b15e, 0x3fea70caa0a7598a),
		(0x485b3050ec24e894, 0xbff33dacd8e66b2d, 0xbfea9c2613ca1aca),
		(0x53cdd772c04825b7, 0x3feaec063c5537cf, 0x3ff30496b5e6234f),
		(0xf3830e1d9fcb8a63, 0xbfeaf752dcf645db, 0xbff2fc9ead41769c),
		(0x4fd516dfb479c284, 0xbfeb31f070d00bb3, 0xbff2d3b23a11d388),
		(0x401c9636ba305733, 0x3ff2b79fee475ac3, 0x3feb5ab9b110014b),
		(0x74e6629d161dcdf0, 0x3ff2a9b9289117f3, 0x3feb6f19cbe183c1),
		(0xc831ccafeb5988ca, 0xbfeba1b7e0c9a4be, 0xbff2878906543222),
		(0x4c6c1ddb028d0a24, 0xbfebda5d682a67dc, 0xbff261d9c2b6d631),
		(0x50ddbc2d3d77331b, 0x3fec1c6fa9dfd3f2, 0x3ff236a54a6f7473),
		(0x7f475a5c2b07cd78, 0xbff225167cb98c22, 0xbfec37a3454ef052),
		(0xfbb16b339d0a17fe, 0x3fec729712255b64, 0x3ff1ff7c6a466364),
		(0xfe93c58449c8fd51, 0xbff1f86c842db0af, 0xbfec7dc50581afe9),
		(0xe125d9535e1d7d96, 0xbfecd23da36c0bcc, 0xbff1c3c14d3af49c),
		(0xe9492784719b40f6, 0xbff1b3f3088363ee, 0xbfecebf92a8f36c0),
		(0x76693dbf45a5c11c, 0x3ff18e43bdf45f9b, 0x3fed2a0e601005bf),
		(0x4815c52cf555dcc6, 0xbff17e592952677b, 0xbfed44974ac6a894),
		(0x49147fcad588e154, 0xbff15f3dded8be9a, 0xbfed78ffa064b041),
		(0x65cec0767168cebc, 0x3ff152b06f8600d4, 0x3fed8e5ad53d0ccb),
		(0x7c5a50d620432646, 0xbff125f49b9c4132, 0xbfeddb74c0de0fdb),
		(0xc394901bb60cd165, 0xbfee0cf91359537e, 0xbff109b2ee01353b),
		(0xefe39e4669e6b8e3, 0x3fee1d1c905094f4, 0x3ff100916565e23e),
		(0x6606d5cab1344ed4, 0xbfee6a547b6e0341, 0xbff0d5671b0a47dc),
		(0xe151f4cddef4501f, 0x3ff0ba872431bfa7, 0x3fee9b315f5e68d6),
		(0xdbeb6637b76e98b6, 0xbfeec87a200cacbf, 0xbff0a1eb3b8b38a8),
		(0x4de08bca51af503b, 0x3ff0935cf27fb96c, 0x3feee382525684bd),
		(0x43ba67829cbf5ddd, 0x3fef18839c0e31e2, 0x3ff0771bd1cb28aa),
		(0x51c3d8b11e8e3186, 0x3fef59e0cd085215, 0x3ff054c7b82fd1b6),
		(0x762158955b8d3e1f, 0xbfef981ac2ad0844, 0xbff0349d725d26aa),
		(0x6b4a97418aacc176, 0xbfefbb6cc26e10da, 0xbff02293b7c89d69),
		(0xdf22beeedddcdfc1, 0xbfefe7a8fffac117, 0xbff00c34c8c8b9e2),
	][:]

	for (x, yt, yc) : inputs
		var xf : flt64 = std.flt64frombits(x)
		var rtf, rcf
		rtf = math.tan(xf)
		rcf = math.cot(xf)

		var rtu = std.flt64bits(rtf)
		var rcu = std.flt64bits(rcf)

		testr.check(c, same64(rtu, yt),
			"tan(0x{b=16,w=16,p=0}) should be 0x{b=16,w=16,p=0}, was 0x{b=16,w=16,p=0}",
			x, yt, rtu)

		testr.check(c, same64(rcu, yc),
			"cot(0x{b=16,w=16,p=0}) should be 0x{b=16,w=16,p=0}, was 0x{b=16,w=16,p=0}",
			x, yc, rcu)
	;;

}

const tancot05 = {c
	testr.check(c, std.isnan(math.cot(std.flt64nan())), "cot(NaN64) should be NaN")
	testr.check(c, std.isnan(math.tan(std.flt64nan())), "tan(NaN64) should be NaN")
	testr.check(c, std.isnan(math.cot(std.flt32nan())), "cot(NaN32) should be NaN")
	testr.check(c, std.isnan(math.tan(std.flt32nan())), "tan(NaN32) should be NaN")
}