Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6064417
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:16:41+00:00 2026-05-23T09:16:41+00:00

As a canonical example, consider the problem of argument-reduction for trigonometric functions, as in

  • 0

As a canonical example, consider the problem of argument-reduction for trigonometric functions, as in computing x mod 2π as a first step for computing sin(x). This kind of problem is difficult in that you can’t just use fmod, because y (2π in the example) is not representible.

I came up with a simple solution that works for arbitrary values y, not just 2π, and I’m curious how it compares (in performance) with typical argument-reduction algorithms.

The basic idea is to store a table containing the value of 2n mod y for each value n in the range log2(y) to the maximum possible floating point exponent, then using the linearity of modular arithmetic, sum the values in this table over bits that are set in the value of x. It amounts to N branches and at most N additions, where N is the number of mantissa bits in your floating point type. The result is not necessarily less than y, but it’s bounded by N*y, and the procedure can be applied again to give a result that’s bounded by log2(N)*y or fmod can simply be used at this point with minimal error.

Can this be improved? And do the typical trigonometric argument reduction algorithms work for arbitrary y or only for 2π?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T09:16:42+00:00Added an answer on May 23, 2026 at 9:16 am

    State of the art implementations of the trigonometric functions in mathematical libraries work correctly across the entire input domain. They do so by representing some constant related to π, such as 2/π, to sufficient accuracy for the floating-point format used.

    For example, for a trig function reduction in IEEE double precision one needs to represent the constant to about 1150 bits, to be used in what essentially is fixed-point computation. This approach was pioneered by the authors of the following paper:

    M. Payne and R. Hanek. Radian reduction for trigonometric functions.
    SIGNUM Newsletter, 18:19–24, 1983

    The original idea has since then been modified and refined by other authors; both floating-point-based and integer-based variants are possible. The FDLIBM library provides a fully worked example here:

    http://www.netlib.org/fdlibm/e_rem_pio2.c

    The following paper by the author of FDLIBM describes the approach used in this code

    http://www.validlab.com/arg.pdf
    K.C. Ng. Argument Reduction for Huge Arguments: Good to the Last Bit

    Note that it is not necessary to carry the intermediate computation to 1150 bits. Since in a reduction, the leading bits cancel the computation only needs to involve a much smaller group of bits inside the full constant. Due to the need for multi-precision arithmetic this is still a fairly expensive operation.

    For trigonometric function argument reduction on more tightly restricted ranges other, more economical, schemes are possible, especially when the hardware supports FMA (fused multiply-add).

    The techniques used for trigonometric argument reduction seem extensible to reductions by arbitrary high-precision constants.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

A pretty silly trivial question. The canonical example is f = open('filename') , but
Hy, how can i make canonical URLs (For Facebook Parsing) with mod_rewrite. Example: I
In Executing Control Panel Items , MSDN says this: Windows Vista Canonical Names In
Here is canonical example of a program extending embedded Python 3.x in C/C++: #include
The canonical Array difference example in Ruby is: [ 1, 1, 2, 2, 3,
Canonical example: while foo.hasBar() && foo.getBar() != spam { do lots of stuff }
From this post . One obvious problem is scalability/performance. What are the other problems
Take a very simple case as an example, say I have this URL: http://www.example.com/65167.html
A canonical example of patching up an otherwise covariant class is as follows: abstract
I'm wondering if there is a more canonical way to do this in ruby

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.