Bug 772592 - tan(pi/2) eval requires too much time
Summary: tan(pi/2) eval requires too much time
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: glibc
Version: 16
Hardware: Unspecified
OS: Unspecified
unspecified
low
Target Milestone: ---
Assignee: Jeff Law
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-01-09 11:18 UTC by Gerard Torrent
Modified: 2016-11-24 16:13 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2012-02-07 18:24:32 UTC
Type: ---


Attachments (Terms of Use)
tan(pi/2) eval requires too much time (1.97 KB, text/x-csrc)
2012-01-09 11:18 UTC, Gerard Torrent
no flags Details

Description Gerard Torrent 2012-01-09 11:18:15 UTC
Created attachment 551534 [details]
tan(pi/2) eval requires too much time

Description of problem: tan(x) evaluated at x = k*M_PI/2 where k=1,2,3,... or k=-1,-2,-3,... requires 2 orders of magnitude more time than in the other cases.

Version-Release number of selected component (if applicable):
gcc (GCC) 4.6.2 20111027 (Red Hat 4.6.2-1)
glibc-2.14.90-24.fc16.4.x86_64

How reproducible: compiling and executing the attached source code

Steps to Reproduce:
1. gcc -O2 tan-pi-div-2.c -lm
2. ./a.out > data.txt
3. gnuplot (plot "data.txt" using 1:2 with lines)

Actual results: peaks at pi/2 multiples

Expected results: all values in the same range

Additional info: see attached file

Comment 1 Jeff Law 2012-02-07 18:24:32 UTC
This is the same as:

http://sources.redhat.com/bugzilla/show_bug.cgi?id=3783

In a nutshell, glibc's tan implementation first computes the result using FPU instructions.  if the maximum error is sufficiently low that result is returned.  Obviously this is fast.  If the error is potentially > than 0.5ulp, then glibc falls back to a more expensive algorithm to compute the result.

For tan, values such as pi/2 multiples will trigger the need to use the slower algorithm, thus the significantly longer times.


Note You need to log in before you can comment on or make changes to this bug.