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:

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