analytics

Wednesday, March 20, 2013

Finding the number of integer points on a curve

I found this function that works very well for indicating whether a number is an integer or not:

It evaluates to 1 if a number is an integer and something close to 0 if a number is not.
For instance:
f(.999999)~=0.00002+.00001I
f(1)=1
f(1.000001)~=0.000004

So you can see the transition from near 0 to 1 is very close to the integer in question. 

I think this function could be useful in a lot of situations but here is just one example. Suppose you want to know how many integer points there are on a circle on a grid like so:

you simply:

This is just plugging the equation for the circle into the function I described, and it outputs:
12 + 3*10^-30

So very close to 12. 

Indeed there are 12 integer points that lie exactly on the circle:




No comments:

Post a Comment