Implementation of half-cycle trignometric functions
Steve Kargl
sgk at troutmask.apl.washington.edu
Fri Apr 28 01:01:23 UTC 2017
On Thu, Apr 27, 2017 at 04:14:11PM -0700, Steve Kargl wrote:
>
> I have attached a new diff to the bugzilla report. The
> diff is 3090 lines and won't be broadcast the mailing list.
>
> This diff includes fixes for a few inconsequential bugs
> and implements modified Estrin's method for sum a few
> ploynomials. If you want the previous Horner's method
> then add -DHORNER to your CFLAGS.
>
For those curious about testing, here are some numbers
for the Estrin's method. These were obtained on an AMD
FX(tm)-8350 @ 4018.34-MHz. The times are in microseconds
and the number in parentheses are estimated cycles.
| cospi | sinpi | tanpi
------------+--------------+--------------+--------------
float | 0.0089 (37) | 0.0130 (54) | 0.0194 (80)
double | 0.0134 (55) | 0.0160 (66) | 0.0249 (102)
long double | 0.0557 (228) | 0.0698 (287) | 0.0956 (393)
------------+--------------+--------------+--------------
The timing tests are done on the interval [0,0.25] as
this is the interval where the polynomial approximations
apply. Limited accuracy testing gives
| cospif | cospi | cospil
-----------------+------------+------------+-------------
MAX ULP | 0.88242114 | 0.89339466 | 0.88799449
Total tested | 16777214 | 16777214 | 16777214
0.8 < ULP <= 0.9 | 1613 | 1682 | 1601
0.7 < ULP <= 0.8 | 33925 | 33817 | 33843
0.6 < ULP <= 0.7 | 171799 | 172775 | 171899
-----------------+------------+------------+-------------
| sinpif | sinpi | sinpil
-----------------+------------+------------+-------------
MAX ULP | 0.80103672 | 0.79851085 | 0.77049407
Total tested | 16777214 | 16777214 | 16777214
0.8 < ULP <= 0.9 | 1 | 0 | 0
0.7 < ULP <= 0.8 | 727 | 1075 | 546
0.6 < ULP <= 0.7 | 19268 | 22722 | 19019
-----------------+------------+------------+-------------
x in [0,0.25] | tanpif | tanpi | tanpil
-----------------+------------+------------+-------------
MAX ULP | 1.37954760 | 1.37300168 | 1.38800823
Total tested | 16777214 | 16777214 | 16777214
1.0 < ULP | 39109 | 38712 | 38798
0.9 < ULP <= 1.0 | 130373 | 131086 | 130803
0.8 < ULP <= 0.9 | 342624 | 341350 | 341155
0.7 < ULP <= 0.8 | 687244 | 687122 | 686814
0.6 < ULP <= 0.7 | 1078964 | 1079881 | 1078555
-----------------+------------+------------+-------------
In the interval [0.25,0.5] tanpi[fl] is computed by
cospi / sinpi. The numbers look like
x in [0.25,0.5] | tanpif | tanpi | tanpil
-----------------+------------+------------+-------------
MAX ULP | 1.93529165 | 2.04485533 | 1.95823689
Total tested | 16777215 | 16777215 | 16777215
1.0 < ULP | 699310 | 701244 | 698946
0.9 < ULP <= 1.0 | 442978 | 443344 | 443599
0.8 < ULP <= 0.9 | 642991 | 642561 | 642601
0.7 < ULP <= 0.8 | 889357 | 890307 | 889233
0.6 < ULP <= 0.7 | 1176473 | 1177407 | 1177121
-----------------+------------+------------+-------------
--
Steve
20170425 https://www.youtube.com/watch?v=VWUpyCsUKR4
20161221 https://www.youtube.com/watch?v=IbCHE-hONow
More information about the freebsd-numerics
mailing list