LATEX-L Archives

Mailing list for the LaTeX3 project


Options: Use Classic View

Use Monospaced Font
Show HTML Part by Default
Show All Mail Headers

Topic: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Bruno Le Floch <[log in to unmask]>
Tue, 5 Nov 2013 02:44:55 +0100
text/plain (32 lines)
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
>, 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).

Comments welcome on the addition of sind and friends (and similarly
asind for arc-trigonometric functions, newly added), and on range
reduction in radians.