= Solution
Write $A=S^2\times S^2$ and let $i:A\to X$ be its inclusion after the attachment. The <cohomology ring of a product of two spheres> is
$$
H^*(A;\mathbb Z)=\mathbb Z[a,b]/(a^2,b^2),\qquad |a|=|b|=2,
$$
where $a,b$ come from the first and second factors and $ab$ is the chosen orientation class. The diagonal pulls both $a$ and $b$ back to the same generator of $H^2(S^2;\mathbb Z)$.
There is one new three-cell. In the <cellular chain complex>, its boundary has coordinates $(1,1)$ in the two-dimensional cells. Thus the relevant differential is
$$
\mathbb Z\xrightarrow{\binom11}\mathbb Z^2,
$$
and the original four-cell still has zero boundary. This gives $H_2(X;\mathbb Z)=\mathbb Z$, $H_3(X;\mathbb Z)=0$, $H_4(X;\mathbb Z)=\mathbb Z$, and no other positive <homology groups>. Equivalently, the <relative cohomology> sequence of $(X,A)$ gives an injective restriction in degree two with image $\mathbb Z(a-b)$, and an <isomorphism> in degree four.
Choose $u\in H^2(X;\mathbb Z)$ and $v\in H^4(X;\mathbb Z)$ by $i^*u=a-b$, $i^*v=ab$. Naturality of the <cup product> gives
$$
i^*(u^2)=(a-b)^2=-2ab.
$$
Since restriction is injective in degree four, $u^2=-2v$. All further positive-degree <cup products> vanish by dimension. Therefore
$$
\boxed{H^*(X;\mathbb Z)\cong\mathbb Z[u,v]/(u^2+2v,uv,v^2),\qquad |u|=2,\quad |v|=4.}
$$
Changing the sign of $v$ would instead give $u^2=2v$; the displayed sign uses the product orientation $ab$. The factor $2$ is the characteristic feature of a <cup square after a diagonal sphere attachment>.
Back to article page