\documentclass[12pt,reqno]{article}

\usepackage[usenames]{color}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amsfonts}
\usepackage{amscd}
\usepackage{graphicx}

\usepackage[colorlinks=true,
linkcolor=webgreen,
filecolor=webbrown,
citecolor=webgreen]{hyperref}

\definecolor{webgreen}{rgb}{0,.5,0}
\definecolor{webbrown}{rgb}{.6,0,0}

\usepackage{color}
\usepackage{fullpage}
\usepackage{float}

\usepackage{psfig}
\usepackage{graphics}
\usepackage{latexsym}
\usepackage{epsf}
\usepackage{breakurl}

\setlength{\textwidth}{6.5in}
\setlength{\oddsidemargin}{.1in}
\setlength{\evensidemargin}{.1in}
\setlength{\topmargin}{-.1in}
\setlength{\textheight}{8.4in}

\newcommand{\seqnum}[1]{\href{https://oeis.org/#1}{\rm \underline{#1}}}

\begin{document}

\begin{center}
\epsfxsize=4in
\leavevmode\epsffile{logo129.eps}
\end{center}

\theoremstyle{plain}
\newtheorem{theorem}{Theorem}
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{proposition}[theorem]{Proposition}

\theoremstyle{definition}
\newtheorem{definition}[theorem]{Definition}
\newtheorem{example}[theorem]{Example}
\newtheorem{conjecture}[theorem]{Conjecture}

\theoremstyle{remark}
\newtheorem{remark}[theorem]{Remark}

\begin{center}
\vskip .5cm{\Large\bf An Alternating Sum of the Floor Function \\
\vskip .1in
of Square Roots}
\vskip .5cm
\large
Marc Chamberland\\
Department of Mathematics\\
Grinnell College\\
Grinnell, IA 50112\\
USA\\
\href{mailto:email}{\tt chamberl@grinnell.edu} \\
\ \\
Karl Dilcher\\
Department of Mathematics and Statistics\\
Dalhousie University\\
Halifax, Nova Scotia, B3H 4R2\\
Canada\\
\href{mailto:email}{\tt dilcher@mathstat.dal.ca} \\
\end{center}

\vskip .2 in
\begin{abstract}
We show that the alternating sum of the floor function of $\sqrt{jn}$, with $j$
ranging from 1 to $n$, has an easy evaluation for all odd integers $n\geq 1$.
This is in contrast to known non-alternating sums of the same type that hold
only for a class of primes. The proof is elementary and was suggested by an
AI model. To put this result in perspective, we also prove an asymptotic
expression for the analogous sum without the floor function.
\end{abstract}

\section{Introduction}\label{sec:1}

The famous two-volume ``Problems and Theorems in Analysis" by P\'olya and 
Szeg{\H o} contains the following curious identity:
if $p\equiv 1\pmod{4}$ is a prime, then
\begin{equation}\label{1.1}
\sum_{j=1}^{\frac{p-1}{4}}\left\lfloor{\sqrt{jp}}\right\rfloor
= \frac{p^2-1}{12},
\end{equation}
where the {\it floor function} of $x\in{\mathbb R}$ is the integer 
$\lfloor{x}\rfloor$ defined by $\lfloor{x}\rfloor\leq x < \lfloor{x}\rfloor+1$.
Further remarks on this identity can be found in Section~\ref{sec:4} below.

It is a natural question to ask whether there are any similar results for 
{\it alternating} sums of the type \eqref{1.1}. While no such identity seems 
to exist for the summation limit $(p-1)/4$, numerical experiments led us to 
the following identity.

\begin{theorem}\label{thm:7.1}
For any odd integer $n\geq 1$ we have
\begin{equation}\label{7.1}
\sum_{j=1}^n(-1)^{j+1}\left\lfloor{\sqrt{jn}}\right\rfloor=\frac{n+1}{2}.
\end{equation}
\end{theorem}

This result is surprising for at least two reasons. 
First, it holds for {\it all} odd $n\geq 1$, and not just
for primes of a certain form, as is the case in \eqref{1.1}. 
Second, using standard methods from analytic number theory, we can prove
the following estimate, valid for any odd integer $n\geq 1$:
\begin{equation}\label{1.3}
\sum_{j=1}^n(-1)^{j+1}\sqrt{jn}=\frac{n}{2}
+\left(1-2\sqrt{2}\right)\zeta(-\tfrac{1}{2})\sqrt{n}
+\frac{1}{8} + O(\tfrac{1}{n})\qquad (n\rightarrow\infty),
\end{equation}
where $C:=(1-2\sqrt{2})\zeta(-1/2)\simeq 0.3801$.
Comparing \eqref{1.3} with \eqref{7.1},
we see that by putting $\sqrt{jn}$ between the floor brackets, the error term
$C\sqrt{n}+1/8+O(1/n)$ turns into the surprisingly neat constant $1/2$.

It is the main purpose of this paper to prove the identity \eqref{7.1}; this is
done in Section~\ref{sec:2}. In Section~\ref{sec:3} we prove the estimate 
\eqref{1.3}, and we conclude this paper with a few remarks in 
Section~\ref{sec:4}.

\section{Proof of Theorem~\ref{thm:7.1}}\label{sec:2}

The following proof was suggested by the AI model {\it Gemini} \cite{Ge}. It
was then verified, simplified and rewritten by us.

\begin{proof}[Proof of Theorem~\ref{thm:7.1}]
We rewrite the positive integer $\lfloor\sqrt{jn}\rfloor$ as a sum and then
change the order of summation, obtaining
\begin{align}
\sum_{j=1}^n(-1)^{j+1}\left\lfloor{\sqrt{jn}}\right\rfloor
&=\sum_{j=1}^n(-1)^{j+1}\sum_{k=1}^{\lfloor{\sqrt{jn}}\rfloor}1\nonumber\\
&=\sum_{k=1}^n\sum_{j=\lceil k^2/n\rceil}^n(-1)^{j+1},\label{2.1a}
\end{align}
where we have used the fact that $k\leq\sqrt{jn}$ is equivalent to 
$j\geq k^2/n$. Next, when $\lceil k^2/n\rceil$ is odd, then the first
summand in the inner sum on the right of \eqref{2.1a} is 1, followed by an equal
number of summands $-1$ and 1. When $\lceil k^2/n\rceil$ is even, the summands
all cancel each other, and therefore the inner sum is 1 when 
$\lceil k^2/n\rceil$ is odd and is 0 otherwise. Hence we have with~\eqref{2.1a},
\begin{equation}\label{2.2a}
\sum_{j=1}^n(-1)^{j+1}\left\lfloor{\sqrt{jn}}\right\rfloor
= \#\{1\leq k\leq n\mid \lceil k^2/n\rceil\;\hbox{is odd}\}.
\end{equation}
where as usual $\#A$ denotes the cardinality of a finite set $A$.
When $k=n$, then $\lceil k^2/n\rceil=n$ is odd. Next, we note that
\[
\left\lceil\frac{(n-k)^2}{n}\right\rceil
=\left\lceil n-2k+\frac{k^2}{n}\right\rceil
=n-2k+\left\lceil\frac{k^2}{n}\right\rceil.
\]
Since $n$ is odd, $\lceil(n-k)^2/n\rceil$ and $\lceil k^2/n\rceil$
have opposite parities, and for $1\leq k\leq (n-1)/2$, they are exactly all
the remaining elements of the set in \eqref{2.2a}. So finally, by \eqref{2.2a}
we have
\[
\sum_{j=1}^n(-1)^{j+1}\left\lfloor{\sqrt{jn}}\right\rfloor
= 1 +\frac{n-1}{2} = \frac{n+1}{2},
\]
which was to be shown.
\end{proof}

To conclude this section, we briefly explain an alternative approach to a proof
of Theorem~\ref{thm:7.1} which may be of interest in its own right.

The summand for $j=n$ in \eqref{7.1} is clearly 1, and we consider the
differences
\begin{equation}\label{2.3}
d_n(\ell):=\left\lfloor{\sqrt{2\ell n}}\right\rfloor
-\left\lfloor{\sqrt{(2\ell-1)n}}\right\rfloor,\qquad1\leq\ell\leq\frac{n-1}{2}.
\end{equation}
Then the statement of Theorem~\ref{thm:7.1} is equivalent to 
\begin{equation}\label{2.4}
\sum_{\ell=1}^{\frac{n-1}{2}}d_n(\ell)=\frac{n-1}{2}\qquad(n\;\hbox{odd}).
\end{equation}
The approach in question is now best explained by the following example. 
Let $n=33$. Table~1 shows the distribution of the values of $d_n(\ell)$.

\medskip
\begin{center}
\begin{tabular}{|c|cccccccccccccccc|}
\hline
$\ell$ & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 & 12 & 13 & 14 & 15 & 16\\
\hline
$d_{33}(\ell)$ & 3 & 2 & 2 & 1 & 1 & 0 & 1 & 0 & 1 & 0 & 0 & 1 & 1 & 1 & 1 & 1  \\
\hline
\end{tabular}

\medskip
{\bf Table~1}: $d_{33}(\ell)$ for $1\leq\ell\leq 16$.
\end{center}
\bigskip

Here the value $d_{33}(1)=3$ corresponds to the two consecutive zeros for
$\ell=10$ and 11, while $d_{33}(2)=2$ corresponds to $d_{33}(8)=0$ and 
$d_{33}(3)=2$ to $d_{33}(6)=0$. This behavior is typical and is made more
explicit in the following statement.

\begin{conjecture}\label{conj:2.1}
Let $n\geq 1$ be an odd integer, and suppose that $\delta:=d_n(\lambda)\geq 2$
for some $\lambda\geq 1$. Then each such $\lambda$ corresponds to $\delta-1$
consecutive integers $\ell_{\lambda},\ldots,\ell_{\lambda}+\delta-2$ such that
$d_n(\ell_{\lambda}+j)=0$ for $j=0,\ldots,\delta-2$. Furthermore, the sets of
these zero values are disjoint.
\end{conjecture}

This conjecture implies \eqref{2.4} and thus Theorem~\ref{thm:7.1} since
each of the sequences of zeros is filled in by the ``surplus" given by the
corresponding value of $\delta$.

Our as yet incomplete proof of Conjecture~\ref{conj:2.1} relies on a sequence
of rather complicated technical lemmas. In view of the above complete proof
of Theorem~\ref{thm:7.1}, we did not pursue this any further.

\section{Proof of Identity \eqref{1.3}}\label{sec:3}

We wish to find an asymptotic estimate for the sum
\[
S(n) := \sum_{j=1}^n (-1)^{j+1}\sqrt{jn}
\]
as $n\rightarrow\infty$ and $n$ is odd. Factoring out $\sqrt{n}$ and letting 
$n=2m+1$, we consider
\begin{equation}\label{3.1}
\sum_{j=1}^n (-1)^{j+1}\sqrt{j} 
= \sum_{j=1}^n \sqrt{j} - 2\sum_{k=1}^m \sqrt{2k} = A(n) - 2\sqrt{2}A(m),
\end{equation}
where 
\[
A(M) = \sum_{r=1}^M \sqrt{r}.
\]
The Euler-Maclaurin summation formula (see, e.g., \cite[pp.~22ff.]{Co2}) 
allows us to write 
\begin{equation}\label{3.2}
A(M) = \frac{2}{3}M^{3/2} + \frac{1}{2}M^{1/2} + \zeta(-1/2) 
+ \frac{1}{24}M^{-1/2} + O( M^{-3/2} ).
\end{equation}
Using the expansions
\begin{align*}
\left( \frac{n-1}{2} \right)^{3/2}
&= \frac{\sqrt{2}}{4}n^{3/2} - \frac{3\sqrt{2}}{8}\sqrt{n}
 + \frac{3\sqrt{2}}{32}\frac{1}{\sqrt{n}} + O( n^{-3/2} ), \\
\left( \frac{n-1}{2} \right)^{1/2}
&=\frac{\sqrt{2}}{2}\sqrt{n}-\frac{\sqrt{2}}{4}\frac{1}{\sqrt{n}}+O(n^{-3/2}),\\
\left( \frac{n-1}{2} \right)^{-1/2}
&= \frac{\sqrt{2}}{\sqrt{n}} + O( n^{-3/2} ),
\end{align*}
we obtain with \eqref{3.2},
\begin{align*}
A(n) - 2\sqrt{2}A(m)
&= \frac{2}{3}n^{3/2} + \frac{1}{2}n^{1/2} + \zeta(-1/2) 
+ \frac{1}{24}n^{-1/2} + O( n^{-3/2} ) \\
&\quad -2\sqrt{2}\left(
\frac{2}{3}
\left( \frac{n-1}{2} \right)^{3/2} + \frac{1}{2}\left( \frac{n-1}{2} \right)^{1/2} + \zeta(-1/2) \right. \\
&\quad \left. 
+ \frac{1}{24}\left( \frac{n-1}{2} \right)^{-1/2} 
+ O\left( \left( \frac{n-1}{2} \right)^{-3/2} \right)\right) \\
&=\frac{1}{2}\sqrt{n} + (1-2\sqrt{2})\,\zeta(-1/2) + \frac{1}{8\sqrt{n}}
+ O\left( n^{-3/2} \right).
\end{align*}
With \eqref{3.1}, this implies 
\[
S(n) = \frac{n}{2} + (1-2\sqrt{2})\,\zeta(-1/2)\sqrt{n} + \frac{1}{8}
+ O\left( \frac{1}{n} \right),
\]
as desired.

\section{Further remarks}\label{sec:4}

\medskip
{\bf 1.} P\'olya and Szeg{\H o} attribute the identity \eqref{1.1} to 
Bouniakowski \cite{Bou},
whose name is better known in its English transliteration Bunyakovsky.
In \cite{PS2} the identity \eqref{1.1} is the last of several exercises that
use the technique of counting lattice points (Part~8, Problem~20). A different
and more recent proof was given by Shirali \cite{Sh}.

While the identity \eqref{1.1} does not hold for primes
$p\equiv 3\pmod{4}$, there is in fact an evaluation in this case which involves
the class number of the imaginary quadratic field ${\mathbb Q}(\sqrt{-p})$.
This has been proved in \cite{CD}, along with several
other related results, all extending~\eqref{1.1}.

\medskip
\noindent
{\bf 2.} Since the summands in the identity \eqref{7.1} have little or no
arithmetic structure, we cannot expect any classical inversion formula, such as
M\"obius inversion, to apply here. However, the curious identity
\begin{equation}\label{7.21}
\left\lfloor\sqrt{k}\right\rfloor 
= \sum_{d=1}^k\lambda(d)\left\lfloor\frac{k}{d}\right\rfloor,
\end{equation}
which appears in \cite[p.~50]{DD}, could be considered an inversion of the
identity \eqref{7.1}. Here $\lambda(n)$ is the well-known
Liouville function, defined by
\[
\lambda(n) = (-1)^{\Omega(n)},
\]
where $\Omega(n)$ is the number of all prime divisors of $n$, counting
multiplicities. We have not been able to use the identity \eqref{7.21} in the
study of sums such as \eqref{7.1}.

\section{Acknowledgments}

We wish to thank Luc Chamberland for his hearty encouragement to use Google 
Gemini in our explorations. We also thank Henri Cohen for suggestions and
insight that simplified our analysis in Section~3.

\begin{thebibliography}{9}

\bibitem{Bou} V.~Bouniakowski, D\'emonstration d'un th\'eor\`eme relatif \`a
la fonction $E(x)$, {\it C. R. Acad. Sci. Paris} {\bf 94} (1882), 1459--1461.

\bibitem{CD} M.~Chamberland and K.~Dilcher, Sums of the floor function related 
to class numbers of imaginary quadratic fields. {\it Preprint.} Available at
\url{http://arxiv.org/abs/2510.04387}.

\bibitem{Co2} H.~Cohen, {\it Number Theory. Volume II: Analytic and Modern
Tools}, Springer, 2007.

\bibitem{DD} J.-M.~De Koninck and N.~Doyon, {\it The Life of Primes in 37 
Episodes}, American Mathematical Society, 2021. 

\bibitem{Ge} Gemini, Google, \url{gemini.google.com}. Accessed July 3, 2025.

\bibitem{PS2} G.~P\'olya and G.~Szeg{\H o}, {\it Problems and Theorems in 
Analysis. Vol.~II. Theory of Functions, Zeros, Polynomials, Determinants, 
Number Theory, Geometry}. Revised and enlarged translation by 
C.~E.~Billigheimer of the fourth German edition, Springer, 1976.

\bibitem{Sh} S.~A.~Shirali, A family portrait of primes---A case study in 
discrimination, {\it Math. Mag.} {\bf 70} (1997), 263--272. 

\end{thebibliography}

\bigskip
\hrule
\bigskip

\noindent 2020 {\it Mathematics Subject Classification}: 
Primary 11A25; Secondary 11B83.

\noindent \emph{Keywords: } alternating sum, floor function, square root, 
asymptotics.

\bigskip
\hrule
\bigskip

\noindent (Concerned with sequences
\seqnum{A000196} and \seqnum{A008836}.)

\bigskip
\hrule
\bigskip

\vspace*{+.1in}
\noindent
Received  October 30 2025;
revised versions received  October 31 2025; March 20 2026.
Published in {\it Journal of Integer Sequences}, March 21 2026.

\bigskip
\hrule
\bigskip

\noindent
Return to \href{https://cs.uwaterloo.ca/journals/JIS/}{Journal of Integer Sequences home page}.
\vskip .1in


\end{document}

