# Doubling a point on an elliptic curve

I'm working with the elliptic curve $\mathcal{E} : y^2 = x^3 + 11x^2 + 17x + 25$ over $(\mathbb{Z}_{31},+,\cdot)$ and am trying to double $P=[2,7]$.

Following the instructions here, I'm doing the following:

$$s = \frac{3\cdot2^2+17}{2\cdot7} \equiv 29\cdot14^{-1} \equiv 29\cdot20 \equiv 22 \pmod{31}$$

$$x_R = s^2 - 4 = 480 \equiv 15 \pmod{31}$$

$$y_R = s\cdot(2-x_R) - 7 \equiv 22\cdot18 - 7 \equiv 17 \pmod{31}$$

That would then give $P+P=R=[15,17]$.

However, when I verify my result with sage, it seems incorrect:

sage: E = EllipticCurve(GF(31),[0,11,0,17,25]); E
Elliptic Curve defined by y^2 = x^3 + 11*x^2 + 17*x + 25 over Finite Field of size 31
sage: P = E(2,7); P
(2 : 7 : 1)
sage: P + P
(25 : 17 : 1)


What am I doing wrong?

Note: this is a homework assignment. Please provide just a hint, if at all possible.

The formulae on the linked page deal with curves in short Weierstraß form, that is $y^2=x^3+ax+b$. Your curve is not given in this format. You can find the correct formulae for long Weierstraß curves (like yours, where the coefficients $a_1$ and $a_3$ are zero) on this page.