I'm having a bit of trouble understanding the translation of affine coordinates to projective coordinates in Montgomery curve ECM. Would be very thankful if someone could explain it by expanding the derivation.
From: Speeding the Pollard and Elliptic Curve Methods of Factorization page: 261. $$\begin{equation}\tag{10.3.1.1}By^2 = x^3 + Ax^2 + x\end{equation}$$
Let $P_1 = (x_1, y_1)$ and $P_2 = (x_2, y_2)$ be two points in the curve, with $x_1 \neq x_2$ and $x_1x_2 \neq 0$. Then $P_1 + P_2 = (x_3, y_3)$ satisfies
$$x_3 = B[(y_1 - y_2)/(x_1 - x_2)]^2 - A - x_1 - x_2,$$ $$\begin{align}x_3(x_1 - x_2)^2 & = B(y_1 - y_2)^2 - (A + x_1 + x_2)(x_1 - x_2)^2 \\ & = -2By_1y_2 + x_1x_2(x_1 + x_2 + 2A) + x_1 + x_2 \\ & = B(x_2y_1 - x_1y_2)^2/x_1x_2. \end{align}$$
Similarly, $P_1 - P_2 = (x_4, y_4)$ satisfies $$x_4(x_1 - x_2)^2 = B(x_2y_1 + x_1y_2)^2/x_1x_2.$$ Multiply these equations and use (10.3.1.1) to obtain $$x_3x_4(x_1 - x_2)^2 = (x_1x_2 - 1)^2$$ after division by $(x_1 - x_2)^2$. This equation remains valid if $x_1x_2 = 0$. If $P_1 = P2$, a similar derivation yields
$$4x_1x_3(x_1^2 + Ax_1 + 1) = (x_1^2 - 1)^2$$ These equations reference only the $x_i$, not the $y_i$. Fortunately ECM does not require us to compute the $y_i$.
(I don't understand everything below this point. Could someone help me expand these derivations? Seems like it is oversimplified)
Let $P$ be an arbitrary point on the curve and let the x-coordinate of $nP$ be the rational number $X_n/Z_n$. From the ratio $(X_{m-n}:Z_{m-n}),(X_m:Z_m) and (X_n:Z_n)$, one can compute the ratio $(X_{m-n}:Z_{m-n})$ via the addition formula.
$$X_{m+n} \leftarrow Z_{m-n}(X_mX_n - Z_mZ_n)^2\\ Z_{m+n} \leftarrow X_{m-n}(X_mZ_n - Z_mX_n)^2$$
if $mP \neq nP$, and via the duplication formula $$\begin{align} X_{2n} & \leftarrow (X_n^2 - Z_n^2)^2, \\ Z_{2n} & \leftarrow 4X_nZ_n(X_n^2 + AX_nZ_n + Z_n^2) \end{align}$$
The costs drop if we store the ratios $(X_m:Z_m:X_m+Z_m:X_m-Z_m)$ and rewrite the formulae as (the right sides of the addition formula have been multiplied by 4)
$$\begin{align} X_{m+n} & \leftarrow Z_{m-n}[(X_m - Z_m)(X_n + Z_n) + (X_m + Z_m)(X_n - Z_n)]^2 \\ Z_{m+n} & \leftarrow X_{m-n}[(X_m - Z_m)(X_n + Z_n) - (X_m + Z_m)(X_n - Z_n)]^2 \\ \end{align}$$ and
$$\begin{align} 4X_nZ_n & = (X_n + Z_n)^2 - (X_n - Z_n) \\ X_{2n} & \leftarrow (X_n + Z_n)^2(X_n - Z_n)^2 \\ Z_{2n} & \leftarrow (4X_nZ_n)((X_n - Z_n)^2 + ((A + 2)/4)(4X_nZ_n)) \end{align}$$