Loading [MathJax]/jax/output/HTML-CSS/jax.js

Tuesday, July 28, 2015

Closest integer square

Given a real number x0, consider the following 2 functions: f(x) is the closest square of an integer to x, and g(x) is the integer closest to x.
In other words, f(x)=y where y=m2 for an integer m and |xy||xn2| for all integers n.  In case of a tie, i.e. x (resp. x) is midway between two successive squares (resp. integers), we define f(x) (resp. g(x)) to be the smallest such square (resp. integer).

The question we like to ask is: is g(x)2=f(x) true?  For arbitrary real numbers x, the answer is no.

The midpoint between two successive integers a and a+1 is a+12 whose square is a2+a+14.  On the other hand, the midpoint between two successive squares a2 and (a+1)2 is a2+a+12.  It is interesting to note that the difference between the 2 midpoints is always 14 regardless of what a is (this is true even if a is not an integer).
Graphically this is illustrated as:


This means that for a2+a+14<x<a2+a+12, g(x)=f(x)+1.  For instance 2.375 is closer to 1 than to 4, but 2.375=1.541... is closer to  2 than to 1.

On the other hand if
a2x<a2+a+14 or a2+a+12<x(a+1)2,
then g(x)2=f(x).

This analysis also shows the following facts:

  • If x is an integer, then evaluating f(x) and g(x) do not result in a tie, as the 2 midpoints above are not integers.
  • If x is an integer, then g(x)2=f(x) as the interval [a2+a+14,a2+a+12] does not contain any integers.




No comments:

Post a Comment