Solution (source code)

= Solution

Write $K=\mathbb Q(\sqrt d)$ and let $\sigma$ be its nontrivial automorphism. On the rational vector space $E(K)\otimes\mathbb Q$, the involution $\sigma$ gives the eigenspace decomposition
$$
E(K)\otimes\mathbb Q
=(E(K)\otimes\mathbb Q)^+
\oplus(E(K)\otimes\mathbb Q)^-.
$$
The positive eigenspace is $E(\mathbb Q)\otimes\mathbb Q$. Choose the <quadratic twist> $E'=E^d$ and an isomorphism $\iota:E'\to E$ over $K$ for which $\iota^\sigma=-\iota$. It maps $E'(\mathbb Q)\otimes\mathbb Q$ isomorphically onto the negative eigenspace. Taking dimensions gives
$$
\operatorname{rank}E(K)
=\operatorname{rank}E(\mathbb Q)
+\operatorname{rank}E'(\mathbb Q).
$$