From owner-freebsd-i386@FreeBSD.ORG Tue Jun 1 16:00:47 2004 Return-Path: Delivered-To: freebsd-i386@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7B81216A4D0 for ; Tue, 1 Jun 2004 16:00:47 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5ED8843D45 for ; Tue, 1 Jun 2004 16:00:47 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) i51N0lRa011593 for ; Tue, 1 Jun 2004 16:00:47 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.11/8.12.11/Submit) id i51N0lSv011591; Tue, 1 Jun 2004 16:00:47 -0700 (PDT) (envelope-from gnats) Resent-Date: Tue, 1 Jun 2004 16:00:47 -0700 (PDT) Resent-Message-Id: <200406012300.i51N0lSv011591@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-i386@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, David Schultz Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5634616A4CE for ; Tue, 1 Jun 2004 15:51:50 -0700 (PDT) Received: from VARK.homeunix.com (ar59.lsanca2-4.27.98.47.lsanca2.dsl-verizon.net [4.27.98.47]) by mx1.FreeBSD.org (Postfix) with ESMTP id 045FC43D41 for ; Tue, 1 Jun 2004 15:51:50 -0700 (PDT) (envelope-from das@VARK.homeunix.com) Received: from VARK.homeunix.com (localhost [127.0.0.1]) by VARK.homeunix.com (8.12.10/8.12.10) with ESMTP id i51Mpkkj024225 for ; Tue, 1 Jun 2004 15:51:46 -0700 (PDT) (envelope-from das@VARK.homeunix.com) Received: (from das@localhost) by VARK.homeunix.com (8.12.10/8.12.10/Submit) id i51MpkkU024224; Tue, 1 Jun 2004 15:51:46 -0700 (PDT) (envelope-from das) Message-Id: <200406012251.i51MpkkU024224@VARK.homeunix.com> Date: Tue, 1 Jun 2004 15:51:46 -0700 (PDT) From: David Schultz To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: i386/67469: src/lib/msun/i387/s_tan.S gives incorrect results for large inputs X-BeenThere: freebsd-i386@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: I386-specific issues for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Jun 2004 23:00:47 -0000 >Number: 67469 >Category: i386 >Synopsis: src/lib/msun/i387/s_tan.S gives incorrect results for large inputs >Confidential: no >Severity: serious >Priority: low >Responsible: freebsd-i386 >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Tue Jun 01 16:00:46 PDT 2004 >Closed-Date: >Last-Modified: >Originator: David Schultz >Release: FreeBSD 5.2-CURRENT i386 >Organization: >Environment: >Description: src/lib/msun/i387/s_tan.S returns wildly inaccuate results when its input has a large magnitude (>> 2*pi). For example: input s_tan.S k_tan.c 1.776524190754802e+269 1.773388446261095e+16 -1.367233274980565e+01 1.182891728897420e+57 -1.9314539773999572e-01 1.0020569035866138e+03 2.303439778835110e+202 2.8465460220132694e+00 3.5686329695133922e+00 I suspect that this is caused in the modular reduction phase, which is used for inputs with magnitude greater than 2^63. In these cases, the inputs are taken mod 2*pi, but the double precision representation of pi isn't precise enough to obtain a meaningful result for this computation. >How-To-Repeat: >Fix: One solution might involve doing the reduction using __ieee754_rem_pio4() instead of the fprem1 instruction. Unfortunately, since this uses pi/2 as the modulus, it is necessary to apply the identity tan(x + pi/2) = -1/tan(x) for odd-phase inputs. I tried this for the first example input above and got an answer that was off by 2 ulps. Close, but the MI implementation gets within 1 ulp. I'm not sure what kind of correction (if any) should be used here. This PR exists mainly as a reminder for me or anyone else who wants to look at it more carefully some lazy Saturday afternoon. I can't imagine many people care what the tangent of 10 billion is, but the tan() function *is* supposed to give the correct answer. >Release-Note: >Audit-Trail: >Unformatted: