mpfr sin(pi) != 0

Jacopo Nespolo j.nespolo at
Thu Mar 1 18:51:01 CET 2012

this is slightly, but not so much, off topic, as it is a problem
related to mpfr rather than gmp strictly speaking.

I found myself calculating
           sin(pi * n * x)
with n in N and x in R. I used mpfr_const_pi for pi.
Sometimes it happens that n*x = 1, and this screwed the whole
calculation because i would get 10^-(a lot, according to working
precision) instead of zero. This was also a particularly unlucky case,
because it happened to be in the subdiagonal of a sparse matrix,
surrounded by zeros, thus the diagonalisation algorithms in Eigen
considered important to keep it.

Do you think it could be worth it to file a bug, at least to warn
about the issue in the documentation of the trigonometric functions,
or it is just expected behaviour and I got fool because I'm a newbie?

Thanks a lot,

More information about the gmp-discuss mailing list