In a recently published paper I have encountered the following equality. Let $U$ be a random variable uniformly distributed in $[0,1]$ and let $Z$ be a Gaussian variable with mean zero and standard deviation $\sigma$. Let $\lfloor x\rfloor$ be the floor function and let $\left\{x\right\}=x-\lfloor x\rfloor$ be the fractional part of x. I want to show that
$$ \mathbb{E}\left[\lfloor U+Z\rfloor^2\mid Z\right] = \left(Z-\left\{Z\right\}\right)^2\,\left(1-\left\{Z\right\}\right)+\left(Z+1-\left\{Z\right\}\right)^2\,\left\{Z\right\}. $$
In order to prove the above equality I have tried to use
$$ \lfloor U+Z\rfloor^2\ = \left(U+Z-\left\{U+Z\right\}\right)^2 = U^2+Z^2+2\,U\,Z+\left\{U+Z\right\}^2-2\,\left(U+Z\right)\,\left\{U+Z\right\} $$
and the fact that the expected value is conditioned on the value of $Z$, but unfortunately I am not able to exactly recover the result.
We can assume the variables are independent, is that right?
We know that $U$ is distributed uniformly on $[0,1]$. For a given value of $Z$, then, $U + Z$ is uniformly distributed on $[Z, Z+1].$ But $$[Z, Z+1] = [Z, \lfloor Z + 1 \rfloor] \cup [\lfloor Z + 1 \rfloor, Z + 1]$$ and the size of $[\lfloor Z + 1 \rfloor, Z + 1]$ is $$(Z + 1) - \lfloor Z + 1 \rfloor = \{Z\},$$ so $$P(\lfloor U + Z \rfloor = \lfloor Z + 1 \rfloor\mid Z) = P(U + Z \ge \lfloor Z + 1 \rfloor\mid Z) = \{Z\}$$ and $$P(\lfloor U + Z \rfloor = \lfloor Z \rfloor\mid Z) = P(U + Z < \lfloor Z + 1 \rfloor\mid Z) = 1 - \{Z\}.$$ That's the entire probability distribution of $\lfloor U + Z \rfloor,$ so we can easily find the distribution of $\lfloor U + Z \rfloor^2$ and compute its expectation directly.