# HG changeset patch
# User Chris Wuthrich <christian.wuthrich@gmail.com>
# Date 1219856885 -3600
# Node ID d01af117744c490ed8a0dbe3b04c19f1726da723
# Parent 1e92b2104a79c3790dd81d6d28ac1c90b490638a
small cahnges for trac 3883
diff -r 1e92b2104a79 -r d01af117744c sage/schemes/elliptic_curves/ell_generic.py
|
a
|
b
|
|
| 1829 | 1829 | # self.__divpoly2[m] = f |
| 1830 | 1830 | # return f |
| 1831 | 1831 | |
| 1832 | | def multiple_x_numerator(self, n, x=None, cache=None): |
| | 1832 | def _multiple_x_numerator(self, n, x=None, cache=None): |
| 1833 | 1833 | r""" |
| 1834 | 1834 | Returns the numerator of the x-coordinate of the nth multiple of |
| 1835 | 1835 | a point, using torsion polynomials (division polynomials). |
| … |
… |
|
| 1839 | 1839 | The result is adjusted to be correct for both even and odd n. |
| 1840 | 1840 | |
| 1841 | 1841 | WARNING: -- There may of course be cancellation between the |
| 1842 | | numerator and the denominator (multiple_x_denominator()). Be |
| 1843 | | careful. For more information on how to avoid cancellation, |
| 1844 | | see Chris Wuthrich's thesis. |
| | 1842 | numerator and the denominator (_multiple_x_denominator()). Be |
| | 1843 | careful. E.g. if a point on an elliptic curve with coefficients in |
| | 1844 | ZZ reduces to a singular point modulo a prime, then there will be cancellation, otherwise not, see Chris Wuthrich ``p-adic heights in families of elliptic curves''. |
| 1845 | 1845 | |
| 1846 | 1846 | SEE ALSO: |
| 1847 | | -- multiple_x_denominator() |
| | 1847 | -- _multiple_x_denominator() |
| 1848 | 1848 | |
| 1849 | 1849 | AUTHORS: |
| 1850 | 1850 | -- David Harvey (2006-09-24) |
| … |
… |
|
| 1856 | 1856 | |
| 1857 | 1857 | sage: (35*P)[0] |
| 1858 | 1858 | -804287518035141565236193151/1063198259901027900600665796 |
| 1859 | | sage: E.multiple_x_numerator(35, x) |
| | 1859 | sage: E._multiple_x_numerator(35, x) |
| 1860 | 1860 | -804287518035141565236193151 |
| 1861 | | sage: E.multiple_x_denominator(35, x) |
| | 1861 | sage: E._multiple_x_denominator(35, x) |
| 1862 | 1862 | 1063198259901027900600665796 |
| 1863 | 1863 | |
| 1864 | 1864 | sage: (36*P)[0] |
| 1865 | 1865 | 54202648602164057575419038802/15402543997324146892198790401 |
| 1866 | | sage: E.multiple_x_numerator(36, x) |
| | 1866 | sage: E._multiple_x_numerator(36, x) |
| 1867 | 1867 | 54202648602164057575419038802 |
| 1868 | | sage: E.multiple_x_denominator(36, x) |
| | 1868 | sage: E._multiple_x_denominator(36, x) |
| 1869 | 1869 | 15402543997324146892198790401 |
| 1870 | 1870 | |
| 1871 | 1871 | An example where cancellation occurs: |
| 1872 | 1872 | sage: E = EllipticCurve("88a1") |
| 1873 | 1873 | sage: P = E([2,2]) # fixed choice of generator |
| 1874 | | sage: n = E.multiple_x_numerator(11, P[0]); n |
| | 1874 | sage: n = E._multiple_x_numerator(11, P[0]); n |
| 1875 | 1875 | 442446784738847563128068650529343492278651453440 |
| 1876 | | sage: d = E.multiple_x_denominator(11, P[0]); d |
| | 1876 | sage: d = E._multiple_x_denominator(11, P[0]); d |
| 1877 | 1877 | 1427247692705959881058285969449495136382746624 |
| 1878 | 1878 | sage: n/d |
| 1879 | 1879 | 310 |
| … |
… |
|
| 1902 | 1902 | return x * cache[n]**2 - cache[-1] * cache[n-1] * cache[n+1] |
| 1903 | 1903 | |
| 1904 | 1904 | |
| 1905 | | def multiple_x_denominator(self, n, x=None, cache=None): |
| | 1905 | def _multiple_x_denominator(self, n, x=None, cache=None): |
| 1906 | 1906 | r""" |
| 1907 | 1907 | Returns the denominator of the x-coordinate of the nth multiple of |
| 1908 | 1908 | a point, using torsion polynomials (division polynomials). |
| … |
… |
|
| 1912 | 1912 | The result is adjusted to be correct for both even and odd n. |
| 1913 | 1913 | |
| 1914 | 1914 | SEE ALSO: |
| 1915 | | -- multiple_x_numerator() |
| | 1915 | -- _multiple_x_numerator() |
| 1916 | 1916 | |
| 1917 | 1917 | TODO: the numerator and denominator versions share a calculation, |
| 1918 | 1918 | namely squaring $\psi_n$. Maybe would be good to offer a combined |
| 1919 | 1919 | version to make this more efficient. |
| 1920 | 1920 | |
| 1921 | 1921 | EXAMPLES: |
| 1922 | | -- see multiple_x_numerator() |
| | 1922 | -- see _multiple_x_numerator() |
| 1923 | 1923 | |
| 1924 | 1924 | AUTHORS: |
| 1925 | 1925 | -- David Harvey (2006-09-24) |
| … |
… |
|
| 2036 | 2036 | # the x-coordonate does not depend on the sign of m. The work |
| 2037 | 2037 | # here is done by functions defined earlier: |
| 2038 | 2038 | |
| 2039 | | mx = self.multiple_x_numerator(m.abs(),x) / self.multiple_x_denominator(m.abs(),x) |
| | 2039 | mx = self._multiple_x_numerator(m.abs(),x) / self._multiple_x_denominator(m.abs(),x) |
| 2040 | 2040 | |
| 2041 | 2041 | if x_only: |
| 2042 | 2042 | # Return it if the optional parameter x_only is set. |
diff -r 1e92b2104a79 -r d01af117744c sage/schemes/elliptic_curves/ell_point.py
|
a
|
b
|
|
| 592 | 592 | g = E.division_polynomial(m) |
| 593 | 593 | else: |
| 594 | 594 | # The poly g here is 0 at x(Q) iff x(m*Q) = x(P). |
| 595 | | g = E.multiple_x_numerator(m) - P[0]*E.multiple_x_denominator(m) |
| | 595 | g = E._multiple_x_numerator(m) - P[0]*E._multiple_x_denominator(m) |
| 596 | 596 | |
| 597 | 597 | # When 2*P=0, then -Q is a solution iff Q is. For even m, |
| 598 | 598 | # no 2-torsion point is a solution, so that g is the |