Remquo: reduction of arguments?

The C99 spec says remquo:

The remquo functions are intended to implement abbreviations of arguments that can use the few least significant bits of a private. Note that x can be so large in magnitude with respect to y that an accurate representation of the quotient is not practical.

What is “argument reduction” in this context and what is an example that can use the few least significant bits of a quotient?

+6
source share
1 answer

Argument reduction means mapping the argument of a periodic function to the canonical period (for example, (-π, π] or the like). If you used π / 2 as a divisor, then the least significant bits of the factor would be sufficient to determine the correct sign of /, etc. for trigger functions.

Unfortunately, however, remquo useless for implementing the standard reduction of trigonometric arguments, since π is irrational; reducing large arguments modulo approximation π will give you results without significant bits, i.e. all errors.

If you write a function f(x) defined as sin (πx) or similar, the period is now exactly represented in floating point, and remquo can do exactly what you need, while calling sin(2*M_PI*x) will directly produce results without significant bits (i.e. the whole error) when x is large.

+7
source

Source: https://habr.com/ru/post/918309/


All Articles