Independence of shifted squares mod p Given an odd prime $p$, let $S\subseteq \mathbb F_p$ be the set of quadratic residues modulo $p$. Given $a,b\in \mathbb F_p$ we write $aS+b$ for the set $$aS+b:=\{t\in\mathbb F_p:\ t=ax^2+b \text{ for some $x\in\mathbb F_p$}\}.$$

What is the cardinality of $S\cap ((S+1)\cup (2-S))$?

I would say that they are $\frac 3 8 p+ o(p)$, because of the following heuristic: 


*

*the residues of the form $x^2$ are $\sim \frac p 2$ out of $p$;

*there's small correlation between a residue mod p being of the form $x^2$ or $1+y^2$;

*so $\# S\cap (S+1)$ should be $\sim p/4$.


This in fact is quickly provable in a number of ways.


*

*similar reasoning for the equation $\# S\cap (2-S)$.


Now, one would guess that, given random $x,y,z$, the equalities $x^2=1+y^2$ and $x^2=2-z^2$ are achieved for $1/4$ of the $x^2$s. So by Inclusion-Exclusion we get the heuristic.
I expect this to be provable in finite time by standard computations and the error term would be related to Weil's bound, aka Riemann Hypothesis on finite fields.

But how is it possible to make the above heuristic reasoning rigorous up to (1+o(1)), in a simple, direct and general way? 

In other words, how to make oneself safe to assume the approximate independence of equations as above when doing this sort of ballpark estimates?
Let's restrict to linear equations between quadratic residues or to the specific example above, in this question. But of course the same question is interesting for other sets of residues that should "distribute randomly" modulo p, for example sets related to sums of characters.
Possible approaches so far: 


*

*Estimate $\# S\cap S\cap(S+1)\cap(2-S)$ via Inclusion-Exclusion after counting precisely enough the solutions of the equation $(x^2-1-y^2)(x^2-2+z^2)=0$.

*Compute first effectively the expected Weil error bound, then compute the cardinality numerically for a large enough prime.

*Transform the problem into character sums as in Jyrki Lahtonen comment below.

 A: $S \cap (S+1)$ is approximately $\frac 14 \operatorname{Card}\{(x,y) \in \Bbb F_p^2 \mid x^2 = y^2+1 \}$.
This set is an algebraic curve of dimension $1$ (and of genus $0$) so it has $p+O(1)$ points. And so $\operatorname{Card}(S \cap (S+1)) = p/4+O(1)$
Similarly, $S \cap (2-S)$ will be related to the curve $x^2 = 2-y^2$ and $(S+1) \cap (2-S)$ to $x^2+1 = 2-y^2$. They are all curves of genus $0$ so those intersections also have $p/4 + O(1)$ elements.
Finally, $S \cap (S+1) \cap (2-S)$ corresponds to a spatial curve, the intersection of $x^2 = y^2+1$ and $x^2 = 2-z^2$. At a glance, this is an elliptic curve, so the curve has $p + 2\sqrt p u(p) + O(1)$ points, where $|u(p)| \le 1$, and then the intersection has $p/8 + \sqrt p u(p)/4 + O(1)$ elements.
Gathering up everything, you get :
$\operatorname{Card}(S \cap ((S+1) \cup (2-S))) = \\
\operatorname{Card}(S \cap (S+1)) + \operatorname{Card}(S \cap (2-S)) - \operatorname{Card}(S \cap (S+1) \cap (2-S)) = \\
3p/8 - \sqrt p u(p)/4 + O(1)$
where $|u(p)| \le 1$
Note that this doesn't require $p$ to be prime, this is valid over any finite field $\Bbb F_q$
A: With the aid of character sums I can say the following, justifying Luca's heuristics (with some obvious exceptions).
Let $\eta$ be the usual multiplicative character given by the Legendre symbol, i.e. $\eta(0)=0$, and when $a\neq0$ we have $\eta(a)=\pm1$ according to whether $a$ is or is not a quadratic residue.  Below it would be a bit more convenient to have $\eta(0)=1$, but I stick to this. For the purposes of applying the Weil bound a non-trivial multiplicative character is defined to vanish at zero.
Consider the set $aS+b, a\neq0$. Let us denote by $\chi_{aS+b}:\Bbb{F}_p\to\Bbb{R}$ its characteristic function, i.e. 
$$\chi_{aS+b}(t)=\begin{cases}1,&\ \text{if $t\in aS+b$, and}\\ 0,&\ \text{otherwise.}\end{cases}$$
An element $t\in\Bbb{F}_p$ is in the set if and only if $(t-b)/a$ is a square. There we almost have the identity
$$
\chi_{aS+b}(t)=\frac12\left(1+\eta(\frac{t-b}a)\right).
$$
The only difference is at $t=b$, when we get $1/2$ in the right hand side and one in the left.
For any two or more subsets $U_1,U_2,\ldots,U_m\subseteq \Bbb{F}_p$ we can write the characteristic function of their intersection as the product
$$
\chi_{U_1\cap U_2\cap\cdots\cap U_m}=\chi_{U_1}\chi_{U_2}\cdots\chi_{U_m}.
$$
For any subset $U\subseteq\Bbb{F}_p$ we have $|U|=\sum_{t\in\Bbb{F}_p}\chi_U(t)$. Let's apply all the above to the case $U_i=a_iS+b_i, i=1,2,\ldots,m$. We shall see that we want to make the assumption $b_i\neq b_j$ whenever $i\neq j$. We get
$$
\begin{aligned}
|U_1\cap U_2\cap \cdots\cap U_m|&=\sum_{t\in\Bbb{F}_p}\chi_{U_1\cap U_2\cap\cdots\cap U_m}(t)\\
&=\frac1{2^m}\sum_{t\in\Bbb{F}_p}\prod_{i=1}^m\left(1+\eta(\frac{t-b_i}{a_i})\right)+\frac m2\\
&=\frac p{2^m}+\frac m2+\\
&+\frac1{2^m}\sum_{J\subseteq \{1,2,\ldots,m\},J\neq\emptyset}\sum_{t\in\Bbb{F}_p}\eta\left(\prod_{j\in J}(\frac{t-b_j}{a_j})\right).
\end{aligned}
$$
Here the $m/2$ comes from $1/2$-errors at $t=b_i, i=1,2,\ldots,m$. In the last sum $J$ ranges over no-empty subsets of the index set $\{1,2,\ldots,m\}$ only because the term $J=\emptyset$ gives the "main" term $p/2^m$.
Anyway, because we assumed $b_i\neq b_j$, the polynomials in all those sums of the last form have simple zeros only, and we can apply Weil's bound to all of them. The end result is the expected one:

With $b_i$s pairwise distinct, the cardinality of the intersection $\bigcap_{i=1}^m(a_iS+b_i)$ differs from $p/2^m$ by an error term whose absolute value is bounded from above by $m/2+C\sqrt p$, where $C$ is a constant depending on $m$ but independent from $p$.

Of course, for large $p$ we can more or less ignore that $m/2$ term as it is overshadowed by the error terms coming from the character sums.
Luca's specific question was about the size of the intersection $S\cap \big((S+1)\cup (2-S)\big).$ The usual exclusion-inclusion business starting with
$$
\chi_{U\cup V}=\chi_U+\chi_V-\chi_{U\cap V}
$$
reduces estimating the union to estimating the intersection. Luca's heuristics handles all that.
