Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) by h1439878.stratoserver.net (8.14.2/8.14.2/Debian-2build1) with ESMTP id rA51m2OQ025060 for ; Tue, 5 Nov 2013 02:48:03 +0100 Received: from relay2.uni-heidelberg.de ([129.206.210.211]) by mx-ha.gmx.net (mxgmx001) with ESMTPS (Nemesis) id 0LiDw3-1W0WVT27qF-00nTOm for ; Tue, 05 Nov 2013 02:47:56 +0100 Received: from listserv.uni-heidelberg.de (listserv.uni-heidelberg.de [129.206.100.94]) by relay2.uni-heidelberg.de (8.13.8/8.13.8) with ESMTP id rA51j6AO018323 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 5 Nov 2013 02:45:06 +0100 Received: from listserv.uni-heidelberg.de (listserv.uni-heidelberg.de [127.0.0.1]) by listserv.uni-heidelberg.de (8.13.8/8.13.8) with ESMTP id rA4N13BO010258; Tue, 5 Nov 2013 02:45:06 +0100 Received: by LISTSERV.UNI-HEIDELBERG.DE (LISTSERV-TCP/IP release 16.0) with spool id 10519839 for LATEX-L@LISTSERV.UNI-HEIDELBERG.DE; Tue, 5 Nov 2013 02:45:05 +0100 Received: from relay2.uni-heidelberg.de (relay2.uni-heidelberg.de [129.206.210.211]) by listserv.uni-heidelberg.de (8.13.8/8.13.8) with ESMTP id rA51j5HC016760 for ; Tue, 5 Nov 2013 02:45:05 +0100 Received: from mail-qa0-f45.google.com (mail-qa0-f45.google.com [209.85.216.45]) by relay2.uni-heidelberg.de (8.13.8/8.13.8) with ESMTP id rA51iuUX018241 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NO) for ; Tue, 5 Nov 2013 02:44:59 +0100 Received: by mail-qa0-f45.google.com with SMTP id hu16so579001qab.4 for ; Mon, 04 Nov 2013 17:44:56 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.224.64.73 with SMTP id d9mr26368131qai.83.1383615895970; Mon, 04 Nov 2013 17:44:55 -0800 (PST) Received: by 10.96.166.65 with HTTP; Mon, 4 Nov 2013 17:44:55 -0800 (PST) References: <524E7349.4030306@clear.net.nz> <524F0DA5.4040106@morningstar2.co.uk> Content-Type: text/plain; charset=ISO-8859-1 Message-ID: Date: Tue, 5 Nov 2013 02:44:55 +0100 Reply-To: Mailing list for the LaTeX3 project Sender: Mailing list for the LaTeX3 project From: Bruno Le Floch Subject: Re: Bug in l3fp for sines near 2pi To: LATEX-L@LISTSERV.UNI-HEIDELBERG.DE In-Reply-To: <524F0DA5.4040106@morningstar2.co.uk> Precedence: list List-Help: , List-Unsubscribe: List-Subscribe: List-Owner: List-Archive: Envelope-To: X-GMX-Antispam: 0 (Mail was not recognized as spam); Detail=V3; X-GMX-Antivirus: 0 (no virus found) X-UI-Filterresults: notjunk:1;V01:K0:rPtWPZA859s=:PTd5V/0LOynQgUTCWxQnYzEopk OC9Lu9gBeVrEyFMJHGTcFdWorqLmlrgid0YoMfqdPB3VOi4X6fJFGHHoJzKu6MKXEDSb25y+/ ojlMTwIa5JJWf3fr7r8WxU2+5AnqSZCslbQf8amJLcDs6Mo7KRC2tT9YsV1oBeGOpoWNosaFf 9Ym7RzFQLJZ60E1uKStvOEnQJaIh0q6Ns0WO3ghufD/f9fe7qO5Gn8H9tTb/GybuKvsvzsrbn 3QsirOBk6QrpPrshnwlHpeZlVDaSDHFHRIrQOldippHeVFb1unvXFp2k8R/pWeV/m+67YKV0F L7msICvtGDtwgz6iLiuVqvKgVjYLemRruWMLrQkfx+OIn2XJY4zvadhsTP4+IcThrhNru4Fbi V+TupndQbtEeSjsUsx2cH4SqoVREcUUhSQ1S9cQl7OYjVXv1ElDpNvDbWteVY6fxlFFI9zGIS wXgzSqLqN9ZXLJWns5wil6KUQeRDuwROPL9MI9sSKsyOZFrfDDn9Y4oA350Nc+GpxHj2Jx1aL Pk47a1IUsvC+RKM7wu59y6CN9kSLn0Qhi4RsF18pAg/L8TobcTTVWtLBLk36/BtPPFtOTlnRT 8MFDeA1LWisGVTNOzxpzVqeyGQmD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, On 10/4/13, Joseph Wright 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). 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