Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

remquo: argument reduction?

In the C99 spec it says of remquo:

The remquo functions are intended for implementing argument reductions which can exploit a few low-order bits of the quotient. Note that x may be so large in magnitude relative to y that an exact representation of the quotient is not practical.

What is an "argument reduction" in this context, and what is an example of one that can exploit a few low-order bits of the quotient?

like image 911
Andrew Tomazos Avatar asked Jun 17 '12 23:06

Andrew Tomazos


1 Answers

Argument reduction means mapping the argument of a periodic function into the canonical period (for example, (-π,π] or similar). If you used π/2 as the divisor, the low bits of the quotient would be sufficient for determining the right sign/etc. for trig functions.

Unfortunately, however, remquo is useless for implementing standard trigonometric argument reduction, because π is irrational; reducing large arguments modulo an approximation of π will give you results with no significant bits, i.e. all error.

If however you're writing a function f(x) defined as sin(πx) or similar, the period is now exactly representable in floating point, and remquo can do exactly what you need, whereas calling sin(2*M_PI*x) directly will give results with no significant bits (i.e. all error) when x is large.

like image 115
R.. GitHub STOP HELPING ICE Avatar answered Sep 18 '22 18:09

R.. GitHub STOP HELPING ICE