For an odd prime p between 3 and 19, I consider an integral sum as follows
I want to check in C++ if x is smaller or greater than 0. So far, I have two ideas:
- make a double approximation and check that
- get a rational approximation a/b < cos(2*pi/p) < c/d and use these approximation to do the comparison (of course, if the rational is not good enough it is possible that I cannot decide)
First version may be subject to approximation error but second version could be slow. What do you suggest? Is there a way to use 1. and detect when the risk of error is too big in order to use 2.?