On 5/11/2013 2:44 p.m., Bruno Le Floch wrote: > Hello Andrew, > > On 10/4/13, Joseph Wright <[log in to unmask]> wrote: >> On 04/10/2013 08:50, Andrew Parsloe wrote: >>> \fp_eval:n { sin( 2pi - .0001 ) } ==> 9999.999000000002 >> >> Thanks for the bug report: I've logged it as >> https://github.com/latex3/svn-mirror/issues/155, and assigned it to >> Bruno :-) (He wrote the FPU!). As I've said in the issue database, this >> looks like a range-reduction failure to me. Range reduction is known to >> be 'hard', so that's not that surprising. > > Thank you for reporting the bug (now fixed), which led me to > reconsider the implementation of trigonometric functions. I ended up > adding trigonometric functions expecting their argument in degrees > (sind, cosd, tand, cotd, secd, cscd),for which range reduction is > almost trivial, as we want to reduce modulo rational numbers > (integers, even!) rather than an irrational number. The result of > sind, cosd, etc. can thus be guaranteed to lie within 0.6 ulp of the > correct sine, cosine, etc. For the functions in radians, I would need > to either store EMAX+16 decimals of pi, where EMAX is the maximal > exponent and 16 is the precision of floating point numbers, or be able > to compute them. Right now, I am cheating, using a fixed-precision > value of 2pi (equal to twice \c_pi_fp). > "fixed precision" makes me think of the LaTeX2e package fp, 18 places before and after the decimal point. In using it I became alarmed at how rapidly errors propagated inwards when exponents were involved. > Comments welcome on the addition of sind and friends (and similarly > asind for arc-trigonometric functions, newly added), and on range > reduction in radians. > > Regards, > Bruno > sind etc, and the inverse functions, are very welcome. (But as a student of hyperbolic geometry, I especially look forward to the hyperbolic functions and inverses!) Andrew