Solution (source code)

= Solution

We take $d\in\mathbb Q^\times$, as required for this rational <elliptic curve>. The tangent at $O=(1:-1:0)$ is $X+Y=0$. Its intersection with the curve has $dZ^3=0$, so it meets the curve three times at $O$: the identity is an <inflection point of a plane cubic>.

For $P,Q$, let their chord meet the <diagonal cubic elliptic curve> at the third point $R$, using the tangent if $P=Q$ and counting <intersection multiplicities>. Then join $R$ to $O$ and take the third intersection $S$. Define $P+Q=S$. Equivalently, three collinear intersection points satisfy $P+Q+R=O$.

Here inversion has the particularly simple form
$$
\boxed{-(X:Y:Z)=(Y:X:Z).}
$$
Indeed $P$, its displayed inverse, and $O$ lie on the same line, since swapping $X,Y$ preserves both the curve and $X+Y$. Thus \b[addition is the chord or tangent operation followed by swapping the first two coordinates]. The rule includes limiting cases involving $O$ and repeated intersections. Its <associativity> follows from the <elliptic curve group law from Riemann-Roch>: the identification $P\mapsto[P-O]$ with the degree-zero <Picard group> turns the line-intersection <Weil divisor> relation into addition of <divisor classes>. Since a line cuts a <Weil divisor> linearly equivalent to $3O$, that relation is exactly the chord rule just described.