Doubling Point Formula of Elliptic Curve is Not Working

The problem you have found with the calculation is due to a known misprint that was introduced in the second edition of Silverman's book. As Jan correctly pointed out in his answer, the formula that you are using $b_2 = a_1^2 + 4a_4$ is incorrect, and it appears on page 42 of the 2009 second edition of the book. This (along with many other misprints and typos) has been corrected for the (2016) second printing of the second edition of the book and the correct formula for $b_2$ is $$b_2 = a_1^2 +4a_2.$$

You can find this correction on the List of Errata for the book on Silverman's webpage.


Well, first of all, it is just a variable that you got wrong in your code. Line 4 of your first code shows: b_2=a_1**2+4*a_4; and it must be b_2=a_1**2+4*a_2; according to page 52 in book The Arithmetic of Elliptic Curves by Joseph H. Silverman.

I ran your code again and got the following value:

x_2p=((-4)^4-(2*(-25)+0*0)*(-4)^2-2*(0^2+4*0)*(-4)-((0^2)*0+
4*0*0- 0*0*(-25)+0*0^2-(-25)^2))/(4*(-4)^3+(0^2+4*0)*(-4)^2+
2*(2*(-25)+0*0)*(-4)+(0^2+4*0))=1681/144