Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

166

167

168

169

170

171

172

173

174

175

176

177

178

179

180

181

182

183

184

185

186

187

188

189

190

191

192

193

194

195

196

197

198

199

200

201

202

203

204

205

206

207

208

209

210

211

212

213

214

215

216

217

218

219

220

221

222

223

224

225

226

227

228

229

230

231

232

233

234

235

236

237

238

239

240

241

242

243

244

245

246

247

248

249

250

251

252

253

254

255

256

257

258

259

260

261

262

263

264

265

266

267

268

269

270

271

272

273

274

275

276

277

278

279

280

281

282

283

284

285

286

287

288

289

290

291

292

293

294

295

296

297

298

299

300

301

302

303

304

305

306

307

308

309

310

311

312

313

314

315

316

317

318

319

320

321

322

323

324

325

326

327

328

329

330

331

332

333

334

335

336

337

338

339

340

341

342

343

344

345

346

347

348

349

350

351

352

353

354

355

356

357

358

359

360

361

362

363

364

365

366

367

368

369

370

371

372

373

374

375

376

377

378

379

380

381

382

383

384

385

386

387

388

389

390

391

392

393

394

395

396

397

398

399

400

401

402

403

404

405

406

407

408

409

410

411

412

413

414

415

416

417

418

419

420

421

422

423

424

425

426

427

428

429

430

431

432

433

434

435

436

437

438

439

440

441

442

443

444

445

446

447

448

449

450

451

452

453

454

455

456

457

458

459

460

461

462

463

464

465

466

467

468

469

470

471

472

473

474

475

476

477

478

479

480

481

482

483

484

485

486

487

488

489

490

491

492

493

494

495

496

497

498

499

500

501

502

503

504

505

506

507

508

509

510

511

512

513

514

515

516

517

518

519

520

521

522

523

524

525

526

527

528

529

530

531

532

533

534

535

536

537

538

539

540

541

542

543

544

545

546

547

548

549

550

551

552

553

554

555

556

557

558

559

560

561

562

563

564

565

566

567

568

569

570

571

572

573

574

575

576

577

578

579

580

581

582

583

584

585

586

587

588

589

590

591

592

593

594

595

596

597

598

599

600

601

602

603

604

605

606

607

608

609

610

611

612

613

614

615

616

617

618

619

620

621

622

623

624

625

626

627

628

629

630

631

632

633

634

635

636

637

638

639

640

641

642

643

644

645

646

647

648

649

650

651

652

653

654

655

656

657

658

659

660

661

662

663

664

665

666

667

668

669

670

671

672

673

674

675

676

677

678

679

680

681

682

683

684

685

686

687

688

689

690

691

692

693

694

695

696

697

698

699

700

701

702

703

704

705

706

707

708

709

710

711

712

713

714

715

716

717

718

719

720

721

722

723

724

725

726

727

728

729

730

731

732

733

734

735

736

737

738

739

740

741

742

743

744

745

746

747

748

749

750

751

752

753

754

755

756

757

758

759

760

761

762

763

764

765

766

767

768

769

770

771

772

773

774

775

776

777

778

779

780

781

782

783

784

785

786

787

788

789

790

791

792

793

794

795

796

797

798

799

800

801

802

803

804

805

806

807

808

809

810

811

812

813

814

815

816

817

818

819

820

821

822

823

824

825

826

827

828

829

830

831

832

833

834

835

836

837

838

839

840

841

842

843

844

845

846

847

848

849

850

851

852

853

854

855

856

857

858

859

860

861

862

863

864

865

866

867

868

869

870

871

872

873

874

875

876

877

878

879

880

881

882

883

884

885

886

887

888

889

890

891

892

893

894

895

896

897

898

899

900

901

902

903

904

905

906

907

908

909

910

911

912

913

914

915

916

917

918

919

920

921

922

923

924

925

926

927

928

929

930

931

932

933

934

935

936

937

938

939

940

941

942

943

944

945

946

947

948

949

950

951

952

953

954

955

956

957

958

959

960

961

962

963

964

965

966

967

968

969

970

971

972

973

974

975

976

977

978

979

980

981

982

983

984

985

986

987

988

989

990

991

992

993

994

995

996

997

998

999

1000

1001

1002

1003

1004

1005

1006

1007

1008

1009

1010

1011

1012

1013

1014

1015

1016

1017

1018

1019

1020

1021

1022

1023

1024

1025

1026

1027

1028

1029

1030

1031

1032

1033

1034

1035

1036

1037

1038

1039

1040

1041

1042

1043

1044

1045

1046

1047

1048

1049

1050

1051

1052

1053

1054

1055

1056

1057

1058

1059

1060

1061

1062

1063

1064

1065

1066

1067

1068

1069

1070

1071

1072

1073

1074

1075

1076

1077

1078

1079

1080

1081

1082

1083

1084

1085

1086

1087

1088

1089

1090

1091

1092

1093

1094

1095

1096

1097

1098

1099

1100

1101

1102

1103

1104

1105

1106

1107

1108

1109

1110

1111

1112

1113

1114

1115

1116

1117

1118

1119

1120

1121

1122

1123

1124

1125

1126

1127

1128

1129

1130

1131

1132

1133

1134

1135

1136

1137

1138

1139

1140

1141

1142

1143

1144

1145

1146

1147

1148

1149

1150

1151

1152

1153

1154

1155

1156

1157

1158

1159

1160

1161

1162

1163

1164

1165

1166

1167

1168

1169

1170

1171

1172

1173

1174

1175

1176

1177

1178

1179

1180

1181

1182

1183

1184

1185

1186

1187

1188

1189

1190

1191

1192

1193

1194

1195

1196

1197

1198

1199

1200

1201

1202

1203

1204

1205

1206

1207

1208

1209

1210

1211

1212

1213

1214

1215

1216

1217

1218

1219

1220

1221

1222

1223

1224

1225

1226

1227

1228

1229

1230

1231

1232

1233

1234

1235

1236

1237

1238

1239

1240

1241

1242

1243

1244

1245

1246

1247

1248

1249

1250

1251

1252

1253

1254

1255

1256

1257

1258

1259

1260

1261

1262

1263

1264

1265

1266

1267

1268

1269

1270

1271

1272

1273

1274

1275

1276

1277

1278

1279

1280

1281

1282

1283

1284

1285

1286

1287

1288

1289

1290

1291

1292

1293

1294

1295

1296

1297

1298

1299

1300

1301

1302

1303

1304

1305

1306

1307

1308

1309

1310

1311

1312

1313

1314

1315

1316

1317

1318

1319

1320

1321

1322

1323

1324

1325

1326

1327

1328

1329

1330

1331

1332

1333

1334

1335

1336

1337

1338

1339

1340

1341

1342

1343

1344

1345

1346

1347

1348

1349

1350

1351

1352

1353

1354

1355

1356

1357

1358

1359

1360

1361

1362

1363

1364

1365

1366

1367

1368

1369

1370

1371

1372

1373

1374

1375

1376

1377

1378

1379

1380

1381

1382

1383

1384

1385

1386

1387

1388

1389

1390

1391

1392

1393

1394

1395

1396

1397

1398

1399

1400

1401

1402

1403

1404

1405

1406

1407

1408

1409

1410

1411

1412

1413

1414

1415

1416

1417

1418

1419

1420

1421

1422

1423

1424

1425

1426

1427

1428

1429

1430

1431

1432

1433

1434

1435

1436

1437

1438

1439

1440

1441

1442

1443

1444

1445

1446

1447

1448

1449

1450

1451

1452

1453

1454

1455

1456

1457

1458

1459

1460

1461

1462

1463

1464

1465

1466

1467

1468

1469

1470

1471

1472

1473

1474

1475

1476

1477

1478

1479

1480

1481

1482

1483

1484

1485

1486

1487

1488

1489

1490

1491

1492

1493

1494

1495

1496

1497

1498

1499

1500

1501

1502

1503

1504

1505

1506

1507

1508

1509

1510

1511

1512

1513

1514

1515

1516

1517

1518

1519

1520

1521

1522

1523

1524

1525

1526

1527

1528

1529

1530

1531

1532

1533

1534

1535

1536

1537

1538

1539

1540

1541

1542

1543

1544

1545

1546

1547

1548

1549

1550

1551

1552

1553

1554

1555

1556

1557

1558

1559

1560

1561

1562

1563

1564

1565

1566

1567

1568

1569

1570

1571

1572

1573

1574

1575

1576

1577

1578

1579

1580

1581

1582

1583

1584

1585

1586

1587

1588

1589

1590

1591

1592

1593

1594

1595

1596

1597

1598

1599

1600

1601

1602

1603

1604

1605

1606

1607

1608

1609

1610

1611

1612

1613

1614

1615

1616

1617

1618

1619

1620

1621

1622

1623

1624

1625

1626

1627

1628

1629

1630

1631

1632

1633

1634

1635

1636

1637

1638

1639

1640

1641

1642

1643

1644

1645

1646

1647

1648

1649

1650

1651

1652

1653

1654

1655

1656

1657

1658

1659

1660

1661

1662

1663

1664

1665

1666

1667

1668

1669

1670

1671

1672

1673

1674

1675

1676

1677

1678

1679

1680

1681

1682

1683

1684

1685

1686

1687

1688

1689

1690

1691

1692

1693

1694

1695

1696

1697

1698

1699

1700

1701

1702

1703

1704

1705

1706

1707

1708

1709

1710

1711

1712

1713

1714

1715

1716

1717

1718

1719

1720

1721

1722

1723

1724

1725

1726

1727

1728

1729

1730

1731

1732

1733

1734

1735

1736

1737

1738

1739

1740

1741

1742

1743

1744

1745

1746

1747

1748

1749

1750

1751

1752

1753

1754

1755

1756

1757

1758

1759

1760

1761

1762

1763

1764

1765

1766

1767

1768

1769

1770

1771

1772

1773

1774

1775

1776

1777

1778

1779

1780

1781

1782

1783

1784

1785

1786

1787

1788

1789

1790

1791

1792

1793

1794

1795

1796

1797

1798

1799

1800

1801

1802

1803

1804

1805

1806

1807

1808

1809

1810

1811

1812

1813

1814

1815

1816

1817

1818

1819

1820

1821

1822

1823

1824

1825

1826

1827

1828

1829

1830

1831

1832

1833

1834

1835

1836

1837

1838

1839

1840

1841

1842

1843

1844

1845

1846

1847

1848

1849

1850

1851

1852

1853

1854

1855

1856

1857

1858

1859

1860

1861

1862

1863

1864

1865

1866

1867

1868

1869

1870

1871

1872

1873

1874

1875

1876

1877

1878

1879

1880

1881

1882

1883

1884

1885

1886

1887

1888

1889

1890

1891

1892

1893

1894

1895

1896

1897

1898

1899

1900

1901

1902

1903

1904

1905

1906

1907

1908

1909

1910

1911

1912

1913

1914

1915

1916

1917

1918

1919

1920

1921

1922

1923

1924

1925

1926

1927

1928

1929

1930

1931

1932

1933

1934

1935

1936

1937

1938

1939

1940

1941

1942

1943

1944

1945

1946

1947

1948

1949

1950

1951

1952

1953

1954

1955

1956

1957

1958

1959

1960

1961

1962

1963

1964

1965

1966

1967

1968

1969

1970

1971

1972

1973

1974

1975

1976

1977

1978

1979

1980

1981

1982

1983

1984

1985

1986

1987

1988

1989

1990

1991

1992

1993

1994

1995

1996

1997

1998

1999

2000

2001

2002

2003

2004

2005

2006

2007

2008

2009

2010

2011

2012

2013

2014

2015

2016

2017

2018

2019

2020

2021

2022

2023

2024

2025

2026

2027

2028

2029

2030

2031

2032

2033

2034

2035

2036

2037

2038

2039

2040

2041

2042

2043

2044

2045

2046

2047

2048

2049

2050

2051

2052

2053

2054

2055

2056

2057

2058

2059

2060

2061

2062

2063

2064

2065

2066

2067

2068

2069

2070

2071

2072

2073

2074

2075

2076

2077

2078

2079

2080

2081

2082

2083

2084

2085

2086

2087

2088

2089

2090

2091

2092

2093

2094

2095

2096

2097

2098

2099

2100

2101

2102

2103

2104

2105

2106

2107

2108

2109

2110

2111

2112

2113

2114

2115

2116

2117

2118

2119

2120

2121

2122

2123

2124

2125

2126

2127

2128

2129

2130

2131

2132

2133

2134

2135

2136

2137

2138

2139

2140

2141

2142

2143

2144

2145

2146

2147

2148

2149

2150

2151

2152

2153

2154

2155

2156

2157

2158

2159

2160

2161

2162

2163

2164

2165

2166

2167

2168

2169

2170

2171

2172

2173

2174

2175

2176

2177

2178

2179

2180

2181

2182

2183

2184

2185

2186

2187

2188

2189

2190

2191

2192

2193

2194

2195

2196

2197

2198

2199

2200

2201

2202

2203

2204

2205

2206

2207

2208

2209

2210

2211

2212

2213

2214

2215

2216

2217

2218

2219

2220

2221

2222

2223

2224

2225

2226

2227

2228

2229

2230

2231

2232

2233

2234

2235

2236

2237

2238

2239

2240

2241

2242

2243

2244

2245

2246

2247

2248

2249

2250

2251

2252

2253

2254

2255

2256

2257

2258

2259

2260

2261

2262

2263

2264

2265

2266

2267

2268

2269

2270

2271

2272

2273

2274

2275

2276

2277

2278

2279

2280

2281

2282

2283

2284

2285

2286

2287

2288

2289

2290

2291

2292

2293

2294

2295

2296

2297

2298

2299

2300

2301

2302

2303

2304

2305

2306

2307

2308

2309

2310

2311

2312

2313

2314

2315

2316

2317

2318

2319

2320

2321

2322

2323

2324

2325

2326

2327

2328

2329

2330

2331

2332

2333

2334

2335

2336

2337

2338

2339

2340

2341

2342

2343

2344

2345

2346

2347

2348

2349

2350

2351

2352

2353

2354

2355

2356

2357

2358

2359

2360

2361

2362

2363

2364

2365

2366

2367

2368

2369

2370

2371

2372

2373

2374

2375

2376

2377

2378

2379

2380

2381

2382

2383

2384

2385

2386

2387

2388

2389

2390

2391

2392

2393

2394

2395

2396

2397

2398

2399

2400

2401

2402

2403

2404

2405

2406

2407

2408

2409

2410

2411

2412

2413

2414

2415

2416

2417

2418

2419

2420

2421

2422

2423

2424

2425

2426

2427

2428

2429

2430

2431

2432

2433

2434

2435

2436

2437

2438

2439

2440

2441

2442

2443

2444

2445

2446

2447

2448

2449

2450

2451

2452

2453

2454

2455

2456

2457

2458

2459

2460

2461

2462

2463

2464

2465

2466

2467

2468

2469

2470

2471

2472

2473

2474

2475

2476

2477

2478

2479

2480

2481

2482

2483

2484

2485

2486

2487

2488

2489

2490

2491

2492

2493

2494

2495

2496

2497

2498

2499

2500

2501

2502

2503

2504

2505

2506

2507

2508

2509

2510

2511

2512

2513

2514

2515

2516

2517

2518

2519

2520

2521

2522

2523

2524

2525

2526

2527

2528

2529

2530

2531

2532

2533

2534

2535

2536

2537

2538

2539

2540

2541

2542

2543

2544

2545

2546

2547

2548

2549

2550

2551

2552

2553

2554

2555

2556

2557

2558

2559

2560

2561

2562

2563

2564

2565

2566

2567

2568

2569

2570

2571

2572

2573

2574

2575

2576

2577

2578

2579

2580

2581

2582

2583

2584

2585

2586

2587

2588

2589

2590

2591

2592

2593

2594

2595

2596

2597

2598

2599

2600

2601

2602

2603

2604

2605

2606

2607

2608

2609

2610

2611

2612

2613

2614

2615

2616

2617

2618

2619

2620

2621

2622

2623

2624

2625

2626

2627

2628

2629

2630

2631

2632

2633

2634

2635

2636

2637

2638

2639

2640

2641

2642

2643

2644

2645

2646

2647

2648

2649

2650

2651

2652

2653

2654

2655

2656

2657

2658

2659

2660

2661

2662

2663

2664

2665

2666

2667

2668

2669

2670

2671

2672

2673

2674

2675

2676

2677

2678

2679

2680

2681

2682

2683

2684

2685

2686

2687

2688

2689

2690

2691

2692

2693

2694

2695

2696

2697

2698

2699

2700

2701

2702

2703

2704

2705

2706

2707

2708

2709

2710

2711

2712

2713

2714

2715

2716

2717

2718

2719

2720

2721

2722

2723

2724

2725

2726

2727

2728

2729

2730

2731

2732

2733

2734

2735

2736

2737

2738

2739

2740

2741

2742

2743

2744

2745

2746

2747

2748

2749

2750

2751

2752

2753

2754

2755

2756

2757

2758

2759

2760

2761

2762

2763

2764

2765

2766

2767

2768

2769

2770

2771

2772

2773

2774

2775

2776

2777

2778

2779

2780

2781

2782

2783

2784

2785

2786

2787

2788

2789

2790

2791

2792

2793

2794

2795

2796

2797

2798

2799

2800

2801

2802

2803

2804

2805

2806

2807

2808

2809

2810

2811

2812

2813

2814

2815

2816

2817

2818

2819

2820

2821

2822

2823

2824

2825

2826

2827

2828

2829

2830

2831

2832

2833

2834

2835

2836

2837

2838

2839

2840

2841

2842

2843

2844

2845

2846

2847

2848

2849

2850

2851

2852

2853

2854

2855

2856

2857

2858

2859

2860

2861

2862

2863

2864

2865

2866

2867

2868

2869

2870

2871

2872

2873

2874

2875

2876

2877

2878

2879

2880

2881

2882

2883

2884

2885

2886

2887

2888

2889

2890

2891

2892

2893

2894

2895

2896

2897

2898

2899

2900

2901

2902

2903

2904

2905

2906

2907

2908

2909

2910

2911

2912

2913

2914

2915

2916

2917

2918

2919

2920

2921

2922

2923

2924

2925

2926

2927

2928

2929

2930

2931

2932

2933

2934

2935

2936

2937

2938

2939

2940

2941

2942

2943

2944

2945

2946

2947

2948

2949

2950

2951

2952

2953

2954

2955

2956

2957

2958

2959

2960

2961

2962

2963

2964

2965

2966

2967

2968

2969

2970

2971

2972

2973

2974

2975

2976

2977

2978

2979

2980

2981

2982

2983

2984

2985

2986

2987

2988

2989

2990

2991

2992

2993

2994

2995

2996

2997

2998

2999

3000

3001

3002

3003

3004

3005

3006

3007

3008

3009

3010

3011

3012

3013

3014

3015

3016

3017

3018

3019

3020

3021

3022

3023

3024

3025

3026

3027

3028

3029

3030

3031

3032

3033

3034

3035

3036

3037

3038

3039

3040

3041

3042

3043

3044

3045

3046

3047

3048

3049

3050

3051

3052

3053

3054

3055

3056

3057

3058

3059

3060

3061

3062

3063

3064

3065

3066

3067

3068

3069

3070

3071

3072

3073

3074

3075

3076

3077

3078

3079

3080

3081

3082

3083

3084

3085

3086

3087

3088

3089

3090

3091

3092

3093

3094

3095

3096

3097

3098

3099

3100

3101

3102

3103

3104

3105

3106

3107

3108

3109

3110

3111

3112

3113

3114

3115

3116

3117

3118

3119

3120

3121

3122

3123

3124

3125

3126

3127

3128

3129

3130

3131

3132

3133

3134

3135

3136

3137

3138

3139

3140

3141

3142

3143

3144

3145

3146

3147

3148

3149

3150

3151

3152

3153

3154

3155

3156

3157

3158

3159

3160

3161

3162

3163

3164

3165

3166

3167

3168

3169

3170

3171

3172

3173

3174

3175

3176

3177

3178

3179

3180

3181

3182

3183

3184

3185

3186

3187

3188

3189

3190

3191

3192

3193

3194

3195

3196

3197

3198

3199

3200

3201

3202

3203

3204

3205

3206

3207

3208

3209

3210

3211

3212

3213

3214

3215

3216

3217

3218

3219

3220

3221

3222

3223

3224

3225

3226

3227

3228

3229

3230

3231

3232

3233

3234

3235

3236

3237

3238

3239

3240

3241

3242

3243

3244

3245

3246

3247

3248

3249

3250

3251

3252

3253

3254

3255

3256

3257

3258

3259

3260

3261

3262

3263

3264

3265

3266

3267

3268

3269

3270

3271

3272

3273

3274

3275

3276

3277

3278

3279

3280

3281

3282

3283

3284

3285

3286

3287

3288

3289

3290

3291

3292

3293

3294

3295

3296

3297

3298

3299

3300

3301

3302

3303

3304

3305

3306

3307

3308

3309

3310

3311

3312

3313

3314

3315

3316

3317

3318

3319

3320

3321

3322

3323

3324

3325

3326

3327

3328

3329

3330

3331

3332

3333

3334

3335

3336

3337

3338

3339

3340

3341

3342

3343

3344

3345

3346

3347

3348

3349

3350

3351

3352

3353

3354

3355

3356

3357

3358

3359

3360

3361

3362

3363

3364

3365

3366

3367

3368

3369

3370

3371

3372

3373

3374

3375

3376

3377

3378

3379

3380

3381

3382

3383

3384

3385

3386

3387

3388

3389

3390

3391

3392

3393

3394

3395

3396

3397

3398

3399

3400

3401

3402

3403

3404

3405

3406

3407

3408

3409

3410

3411

3412

3413

3414

3415

3416

3417

3418

3419

3420

3421

3422

3423

3424

3425

3426

3427

3428

3429

3430

3431

3432

3433

3434

3435

3436

3437

3438

3439

3440

3441

3442

3443

3444

3445

3446

3447

3448

3449

3450

3451

3452

3453

3454

3455

3456

3457

3458

3459

3460

3461

3462

3463

3464

3465

3466

3467

3468

3469

3470

3471

3472

3473

3474

3475

3476

3477

3478

3479

3480

3481

3482

3483

3484

3485

3486

3487

3488

3489

3490

3491

3492

3493

3494

3495

3496

3497

3498

3499

3500

3501

3502

3503

3504

3505

3506

3507

3508

3509

3510

3511

3512

3513

3514

3515

3516

3517

3518

3519

3520

3521

3522

3523

3524

3525

3526

3527

3528

3529

3530

3531

3532

3533

3534

3535

3536

3537

3538

3539

3540

3541

3542

3543

3544

3545

3546

3547

3548

3549

3550

3551

3552

3553

3554

3555

3556

3557

3558

3559

3560

3561

3562

3563

3564

3565

3566

3567

3568

3569

3570

3571

3572

3573

3574

3575

3576

3577

3578

3579

3580

3581

3582

3583

3584

3585

3586

3587

3588

3589

3590

3591

3592

3593

3594

3595

3596

3597

3598

3599

3600

3601

3602

3603

3604

3605

3606

3607

3608

3609

3610

3611

3612

3613

3614

3615

3616

3617

3618

3619

3620

3621

3622

3623

3624

3625

3626

3627

3628

3629

3630

3631

3632

3633

3634

3635

3636

3637

3638

3639

3640

3641

3642

3643

3644

3645

3646

3647

3648

3649

3650

3651

3652

3653

3654

3655

3656

3657

3658

3659

3660

3661

3662

3663

3664

3665

3666

3667

3668

3669

3670

3671

3672

3673

3674

3675

3676

3677

3678

3679

3680

3681

3682

3683

3684

3685

3686

3687

3688

3689

3690

3691

3692

3693

3694

3695

3696

3697

3698

3699

3700

3701

3702

3703

3704

3705

3706

3707

3708

3709

3710

3711

3712

3713

3714

3715

3716

3717

3718

3719

3720

3721

3722

3723

3724

3725

3726

3727

3728

3729

3730

3731

3732

3733

3734

3735

3736

3737

3738

3739

3740

3741

3742

3743

3744

3745

3746

3747

3748

3749

3750

3751

3752

3753

3754

3755

3756

3757

3758

3759

3760

3761

3762

3763

3764

3765

3766

3767

3768

3769

3770

3771

3772

3773

3774

3775

3776

3777

3778

3779

3780

3781

3782

3783

3784

3785

3786

3787

3788

3789

3790

3791

3792

3793

3794

3795

3796

3797

3798

3799

3800

3801

3802

3803

3804

3805

3806

3807

3808

3809

3810

3811

3812

3813

3814

3815

3816

3817

3818

3819

3820

3821

3822

3823

3824

3825

3826

3827

3828

3829

3830

3831

3832

3833

3834

3835

3836

3837

3838

3839

3840

3841

3842

3843

3844

3845

3846

3847

3848

3849

3850

3851

3852

3853

3854

3855

3856

3857

3858

3859

3860

3861

3862

3863

3864

3865

3866

3867

3868

3869

3870

3871

3872

3873

3874

3875

3876

3877

3878

3879

3880

3881

3882

3883

3884

3885

3886

3887

3888

3889

3890

3891

3892

3893

3894

3895

3896

3897

3898

3899

3900

3901

3902

3903

3904

3905

3906

3907

3908

3909

3910

3911

3912

3913

3914

3915

3916

3917

3918

3919

3920

3921

3922

3923

3924

3925

3926

3927

3928

3929

3930

3931

3932

3933

3934

3935

3936

3937

3938

3939

3940

3941

3942

3943

3944

3945

3946

3947

3948

3949

3950

3951

3952

3953

3954

3955

3956

3957

3958

3959

3960

3961

3962

3963

3964

3965

3966

3967

3968

3969

3970

3971

3972

3973

3974

3975

3976

3977

3978

3979

3980

3981

3982

3983

3984

3985

3986

3987

3988

3989

3990

3991

3992

3993

3994

3995

3996

3997

3998

3999

4000

4001

4002

4003

4004

4005

4006

4007

4008

4009

4010

4011

4012

4013

4014

4015

4016

4017

4018

4019

4020

4021

4022

4023

4024

4025

4026

4027

4028

4029

4030

4031

4032

4033

4034

4035

4036

4037

4038

4039

4040

4041

4042

4043

4044

4045

4046

4047

4048

4049

4050

4051

4052

4053

4054

4055

4056

4057

4058

4059

4060

4061

4062

4063

4064

4065

4066

4067

4068

4069

4070

4071

4072

4073

4074

4075

4076

4077

4078

4079

4080

4081

4082

4083

4084

4085

4086

4087

4088

4089

4090

4091

4092

4093

4094

4095

4096

4097

4098

4099

4100

4101

4102

4103

4104

4105

4106

4107

4108

4109

4110

4111

4112

4113

4114

4115

4116

4117

4118

4119

4120

4121

4122

4123

4124

4125

4126

4127

4128

4129

4130

4131

4132

4133

4134

4135

4136

4137

4138

4139

4140

4141

4142

4143

4144

4145

4146

4147

4148

4149

4150

4151

4152

4153

4154

4155

4156

4157

4158

4159

4160

4161

4162

4163

4164

4165

4166

4167

4168

4169

4170

4171

4172

4173

4174

4175

4176

4177

4178

4179

4180

4181

4182

4183

4184

4185

4186

4187

4188

4189

4190

4191

4192

4193

4194

4195

4196

4197

4198

4199

4200

4201

4202

4203

4204

4205

4206

4207

4208

4209

4210

4211

4212

4213

4214

4215

4216

4217

4218

4219

4220

4221

4222

4223

4224

4225

4226

4227

4228

4229

4230

4231

4232

4233

4234

4235

4236

4237

4238

4239

4240

4241

4242

4243

4244

4245

4246

4247

4248

4249

4250

4251

4252

4253

4254

4255

4256

4257

4258

4259

4260

4261

4262

4263

4264

4265

4266

4267

4268

4269

4270

4271

4272

4273

4274

4275

4276

4277

4278

4279

4280

4281

4282

4283

4284

4285

4286

4287

4288

4289

4290

4291

4292

4293

4294

4295

4296

4297

4298

4299

4300

4301

4302

4303

4304

4305

4306

4307

4308

4309

4310

4311

4312

4313

4314

4315

4316

4317

4318

4319

4320

4321

4322

4323

4324

4325

4326

4327

4328

4329

4330

4331

4332

4333

4334

4335

4336

4337

4338

4339

4340

4341

4342

4343

4344

4345

4346

4347

4348

4349

4350

4351

4352

4353

4354

4355

4356

4357

4358

4359

4360

4361

4362

4363

4364

4365

4366

4367

4368

4369

4370

4371

4372

4373

4374

4375

4376

4377

4378

4379

4380

4381

4382

4383

4384

4385

4386

4387

4388

4389

4390

4391

4392

4393

4394

4395

4396

4397

4398

4399

4400

4401

4402

4403

4404

4405

4406

4407

4408

4409

4410

4411

4412

4413

4414

4415

4416

4417

4418

4419

4420

4421

4422

4423

4424

4425

4426

4427

4428

4429

4430

4431

4432

4433

4434

4435

4436

4437

4438

4439

4440

4441

4442

4443

4444

4445

4446

4447

4448

4449

4450

4451

4452

4453

4454

4455

4456

4457

4458

4459

4460

4461

4462

4463

4464

4465

4466

4467

4468

4469

4470

4471

4472

4473

4474

4475

4476

4477

4478

4479

4480

4481

4482

4483

4484

4485

4486

4487

4488

4489

4490

4491

4492

4493

4494

4495

4496

4497

4498

4499

4500

4501

4502

4503

4504

4505

4506

4507

4508

4509

4510

4511

4512

4513

4514

4515

4516

4517

4518

4519

4520

4521

4522

4523

4524

4525

4526

4527

4528

4529

4530

4531

4532

4533

4534

4535

4536

4537

4538

4539

4540

4541

4542

4543

4544

4545

4546

4547

4548

4549

4550

4551

4552

4553

4554

4555

4556

4557

4558

4559

4560

4561

4562

4563

4564

4565

4566

4567

4568

4569

4570

4571

4572

4573

4574

4575

4576

4577

4578

4579

4580

4581

4582

4583

4584

4585

4586

4587

4588

4589

4590

4591

4592

4593

4594

4595

4596

4597

4598

4599

4600

4601

4602

4603

4604

4605

4606

4607

4608

4609

4610

4611

4612

4613

4614

4615

4616

4617

4618

4619

4620

4621

4622

4623

4624

4625

4626

4627

4628

4629

4630

4631

4632

4633

4634

4635

4636

4637

4638

4639

4640

4641

4642

4643

4644

4645

4646

4647

4648

4649

4650

4651

4652

4653

4654

4655

4656

4657

4658

4659

4660

4661

4662

4663

4664

4665

4666

4667

4668

4669

4670

4671

4672

4673

4674

4675

4676

4677

4678

4679

4680

4681

4682

4683

4684

4685

4686

4687

4688

4689

4690

4691

4692

4693

4694

4695

4696

4697

4698

4699

4700

4701

4702

4703

4704

4705

4706

4707

4708

4709

4710

4711

4712

4713

4714

4715

4716

4717

4718

4719

4720

4721

4722

4723

4724

4725

4726

4727

4728

4729

4730

4731

4732

4733

4734

4735

4736

4737

4738

4739

4740

4741

4742

4743

4744

4745

4746

4747

4748

4749

4750

4751

4752

4753

4754

4755

4756

4757

4758

4759

4760

4761

4762

4763

4764

4765

4766

4767

4768

4769

4770

4771

4772

4773

4774

4775

4776

4777

4778

4779

4780

4781

4782

4783

4784

4785

4786

4787

4788

4789

4790

4791

4792

4793

4794

4795

4796

4797

4798

4799

4800

4801

4802

4803

4804

4805

4806

4807

4808

4809

4810

4811

4812

4813

4814

4815

4816

4817

4818

4819

4820

4821

4822

4823

4824

4825

4826

4827

4828

4829

4830

4831

4832

4833

4834

4835

4836

4837

4838

4839

4840

4841

4842

4843

4844

4845

4846

4847

4848

4849

4850

4851

4852

4853

4854

4855

4856

4857

4858

4859

4860

4861

4862

4863

4864

4865

4866

4867

4868

4869

4870

4871

4872

4873

4874

4875

4876

4877

4878

4879

4880

4881

4882

4883

4884

4885

4886

4887

4888

4889

4890

4891

4892

4893

4894

4895

4896

4897

4898

4899

4900

4901

4902

4903

4904

4905

4906

4907

4908

4909

4910

4911

4912

4913

4914

4915

4916

4917

4918

4919

4920

4921

4922

4923

4924

4925

4926

4927

4928

4929

4930

4931

4932

4933

4934

4935

4936

4937

4938

4939

4940

4941

4942

4943

4944

4945

4946

4947

4948

4949

4950

4951

4952

4953

4954

4955

4956

4957

4958

4959

4960

4961

4962

4963

4964

4965

4966

4967

4968

4969

4970

4971

4972

4973

4974

4975

4976

4977

4978

4979

4980

4981

4982

4983

4984

4985

4986

4987

4988

4989

4990

4991

4992

4993

4994

4995

4996

4997

4998

4999

5000

5001

5002

5003

5004

5005

5006

5007

5008

5009

5010

5011

5012

5013

5014

5015

5016

5017

5018

5019

5020

5021

5022

5023

5024

5025

5026

5027

5028

5029

5030

5031

5032

5033

5034

5035

5036

5037

5038

5039

5040

5041

5042

5043

5044

5045

5046

5047

5048

5049

5050

5051

5052

5053

5054

5055

5056

5057

5058

5059

5060

5061

5062

5063

5064

5065

5066

5067

5068

5069

5070

5071

5072

5073

5074

5075

5076

5077

5078

5079

5080

5081

5082

5083

5084

5085

5086

5087

5088

5089

5090

5091

5092

5093

5094

5095

5096

5097

5098

5099

5100

5101

5102

5103

5104

5105

5106

5107

5108

5109

5110

5111

5112

5113

5114

5115

5116

5117

5118

5119

5120

5121

5122

5123

5124

5125

5126

5127

5128

5129

5130

5131

5132

5133

5134

5135

5136

5137

5138

5139

5140

5141

5142

5143

5144

5145

5146

5147

5148

5149

5150

5151

5152

5153

5154

5155

5156

5157

5158

5159

5160

5161

5162

5163

5164

5165

5166

5167

5168

5169

5170

5171

5172

5173

5174

5175

5176

5177

5178

5179

5180

5181

5182

5183

5184

5185

5186

5187

5188

5189

5190

5191

5192

5193

5194

5195

5196

5197

5198

5199

5200

5201

5202

5203

5204

5205

5206

5207

5208

5209

5210

5211

5212

5213

5214

5215

5216

5217

5218

5219

5220

5221

5222

5223

5224

5225

5226

5227

5228

5229

5230

5231

5232

5233

5234

5235

5236

5237

5238

5239

5240

5241

5242

5243

5244

5245

5246

5247

5248

5249

5250

5251

5252

5253

5254

5255

5256

5257

5258

5259

5260

5261

5262

5263

5264

5265

5266

5267

5268

5269

5270

5271

5272

5273

5274

5275

5276

5277

5278

5279

5280

5281

5282

5283

5284

5285

5286

5287

5288

5289

5290

5291

5292

5293

5294

5295

5296

5297

5298

5299

5300

5301

5302

5303

5304

5305

5306

5307

5308

5309

5310

5311

5312

5313

5314

5315

5316

5317

5318

5319

5320

5321

5322

5323

5324

5325

5326

5327

5328

5329

5330

5331

5332

5333

5334

5335

5336

5337

5338

5339

5340

5341

5342

5343

5344

5345

5346

5347

5348

5349

5350

5351

5352

5353

5354

5355

5356

5357

5358

5359

5360

5361

5362

5363

5364

5365

5366

5367

5368

5369

5370

5371

5372

5373

5374

5375

5376

5377

5378

5379

5380

5381

5382

5383

5384

5385

5386

5387

5388

5389

5390

5391

5392

5393

5394

5395

5396

5397

5398

5399

5400

5401

5402

5403

5404

5405

5406

5407

5408

5409

5410

5411

5412

5413

5414

5415

5416

5417

5418

5419

5420

5421

5422

5423

5424

5425

5426

5427

5428

5429

5430

5431

5432

5433

5434

5435

5436

5437

5438

5439

5440

5441

5442

5443

5444

5445

5446

5447

5448

5449

5450

5451

5452

5453

5454

5455

5456

5457

5458

5459

5460

5461

5462

5463

5464

5465

5466

5467

5468

5469

5470

5471

5472

5473

5474

5475

5476

5477

5478

5479

5480

5481

5482

5483

5484

5485

5486

5487

5488

5489

5490

5491

5492

5493

5494

5495

5496

5497

5498

5499

5500

5501

5502

5503

5504

5505

5506

5507

5508

5509

5510

5511

5512

5513

5514

5515

5516

5517

5518

5519

5520

5521

5522

5523

5524

5525

5526

5527

5528

5529

5530

5531

5532

5533

5534

5535

5536

5537

5538

5539

5540

5541

5542

5543

5544

5545

5546

5547

5548

5549

5550

5551

5552

5553

5554

5555

5556

5557

5558

5559

5560

5561

5562

5563

5564

5565

5566

5567

5568

5569

5570

5571

5572

5573

5574

5575

5576

5577

5578

5579

5580

5581

5582

5583

5584

5585

5586

5587

5588

5589

5590

5591

5592

5593

5594

5595

5596

5597

5598

5599

5600

5601

5602

5603

5604

5605

5606

5607

5608

5609

5610

5611

5612

5613

5614

5615

5616

5617

5618

5619

5620

5621

5622

5623

5624

5625

5626

5627

5628

5629

5630

5631

5632

5633

5634

5635

5636

5637

5638

5639

5640

5641

5642

5643

5644

5645

5646

5647

5648

5649

5650

5651

5652

5653

5654

5655

5656

5657

5658

5659

5660

5661

5662

5663

5664

5665

5666

5667

5668

5669

5670

5671

5672

5673

5674

5675

5676

5677

5678

5679

5680

5681

5682

5683

5684

5685

5686

5687

5688

5689

5690

5691

5692

5693

5694

5695

5696

5697

5698

5699

5700

5701

5702

5703

5704

5705

5706

5707

5708

5709

5710

5711

5712

5713

5714

5715

5716

5717

5718

5719

5720

5721

5722

5723

5724

5725

5726

5727

5728

5729

5730

5731

5732

5733

5734

5735

5736

5737

5738

5739

5740

5741

5742

5743

5744

5745

5746

5747

5748

5749

5750

5751

5752

5753

5754

5755

5756

5757

5758

5759

5760

5761

5762

5763

5764

5765

5766

5767

5768

5769

5770

5771

5772

5773

5774

5775

5776

5777

5778

5779

5780

5781

5782

5783

5784

5785

5786

5787

5788

5789

5790

5791

5792

5793

5794

5795

5796

5797

5798

5799

5800

5801

5802

5803

5804

5805

5806

5807

5808

5809

5810

5811

5812

5813

5814

5815

5816

5817

5818

5819

5820

5821

5822

5823

5824

5825

5826

5827

5828

5829

5830

5831

5832

5833

5834

5835

5836

5837

5838

5839

5840

5841

5842

5843

5844

5845

5846

5847

5848

5849

5850

5851

5852

5853

5854

5855

5856

5857

5858

5859

5860

5861

5862

5863

5864

5865

5866

5867

5868

5869

5870

5871

5872

5873

5874

5875

5876

5877

5878

5879

5880

5881

5882

5883

5884

5885

5886

5887

5888

5889

5890

5891

5892

5893

5894

5895

5896

5897

5898

5899

5900

5901

5902

5903

5904

5905

5906

5907

5908

5909

5910

5911

5912

5913

5914

5915

5916

5917

5918

5919

5920

5921

5922

5923

5924

5925

5926

5927

5928

5929

5930

5931

5932

5933

5934

5935

5936

5937

5938

5939

5940

5941

5942

5943

5944

5945

5946

5947

5948

5949

5950

5951

5952

5953

5954

5955

5956

5957

5958

5959

5960

5961

5962

5963

5964

5965

5966

5967

5968

5969

5970

5971

5972

5973

5974

5975

5976

5977

5978

5979

5980

5981

5982

5983

5984

5985

5986

5987

5988

5989

5990

5991

5992

5993

5994

5995

5996

5997

5998

5999

6000

6001

6002

6003

6004

6005

6006

6007

6008

6009

6010

6011

6012

6013

6014

6015

6016

6017

6018

6019

6020

6021

6022

6023

6024

6025

6026

6027

6028

6029

6030

6031

6032

6033

6034

6035

6036

6037

6038

6039

6040

6041

6042

6043

6044

6045

6046

6047

6048

6049

6050

6051

6052

6053

6054

6055

6056

6057

6058

6059

6060

6061

6062

6063

6064

6065

6066

6067

6068

6069

6070

6071

6072

6073

6074

6075

6076

6077

6078

6079

6080

6081

6082

6083

6084

6085

6086

6087

6088

6089

6090

6091

6092

6093

6094

6095

6096

6097

6098

6099

6100

6101

6102

6103

6104

6105

6106

6107

6108

6109

6110

6111

6112

6113

6114

6115

6116

6117

6118

6119

6120

6121

6122

6123

6124

6125

6126

6127

6128

6129

6130

6131

6132

6133

6134

6135

6136

6137

6138

6139

6140

6141

6142

6143

6144

6145

6146

6147

6148

6149

6150

6151

6152

6153

6154

6155

6156

6157

6158

6159

6160

6161

6162

6163

6164

6165

6166

6167

6168

6169

6170

6171

6172

6173

6174

6175

6176

6177

6178

6179

6180

6181

6182

6183

6184

6185

6186

6187

6188

6189

6190

6191

6192

6193

6194

6195

6196

6197

6198

6199

6200

6201

6202

6203

6204

6205

6206

6207

6208

6209

6210

6211

6212

6213

6214

6215

6216

6217

6218

6219

6220

6221

6222

6223

6224

6225

6226

6227

6228

6229

6230

6231

6232

6233

6234

6235

6236

6237

6238

6239

6240

6241

6242

6243

6244

6245

6246

6247

6248

6249

6250

6251

6252

6253

6254

6255

6256

6257

6258

6259

6260

6261

6262

6263

6264

6265

6266

6267

6268

6269

6270

6271

6272

6273

6274

6275

6276

6277

6278

6279

6280

6281

6282

6283

6284

6285

6286

6287

6288

6289

6290

6291

6292

6293

6294

6295

6296

6297

6298

6299

6300

6301

6302

6303

6304

6305

6306

6307

6308

6309

6310

6311

6312

6313

6314

6315

6316

6317

6318

6319

6320

6321

6322

6323

6324

6325

6326

6327

6328

6329

6330

6331

6332

6333

6334

6335

6336

6337

6338

6339

6340

6341

6342

6343

6344

6345

6346

6347

6348

6349

6350

6351

6352

6353

6354

6355

6356

6357

6358

6359

6360

6361

6362

6363

6364

6365

6366

6367

6368

6369

6370

6371

6372

6373

6374

6375

6376

6377

6378

6379

6380

6381

6382

6383

6384

6385

6386

6387

6388

6389

6390

6391

6392

6393

6394

6395

6396

6397

6398

6399

6400

6401

6402

6403

6404

6405

6406

6407

6408

6409

6410

6411

6412

6413

6414

6415

6416

6417

6418

6419

6420

6421

6422

6423

6424

6425

6426

6427

6428

6429

6430

6431

6432

6433

6434

6435

6436

6437

6438

6439

6440

6441

6442

6443

6444

6445

6446

6447

6448

6449

6450

6451

6452

6453

6454

6455

6456

6457

6458

6459

6460

6461

6462

6463

6464

6465

6466

6467

6468

6469

6470

6471

6472

6473

6474

6475

6476

6477

6478

6479

6480

6481

6482

6483

6484

6485

6486

6487

6488

6489

6490

6491

6492

6493

6494

6495

6496

6497

6498

6499

6500

6501

6502

6503

6504

6505

6506

6507

6508

6509

6510

6511

6512

6513

6514

6515

6516

6517

6518

6519

6520

6521

6522

6523

6524

6525

6526

6527

6528

6529

6530

6531

6532

6533

6534

6535

6536

6537

6538

6539

6540

6541

6542

6543

6544

6545

6546

6547

6548

6549

6550

6551

6552

6553

6554

6555

6556

6557

6558

6559

6560

6561

6562

6563

6564

6565

6566

6567

6568

6569

6570

6571

6572

6573

6574

6575

6576

6577

6578

6579

6580

6581

6582

6583

6584

6585

6586

6587

6588

6589

6590

6591

6592

6593

6594

6595

6596

6597

6598

6599

6600

6601

6602

6603

6604

6605

6606

6607

6608

6609

6610

6611

6612

6613

6614

6615

6616

6617

6618

6619

6620

6621

6622

6623

6624

6625

6626

6627

6628

6629

6630

6631

6632

6633

6634

6635

6636

6637

6638

6639

6640

6641

6642

6643

6644

6645

6646

6647

6648

6649

6650

6651

6652

6653

6654

6655

6656

6657

6658

6659

6660

6661

6662

6663

6664

6665

6666

6667

6668

6669

6670

6671

6672

6673

6674

6675

6676

6677

6678

6679

6680

6681

6682

6683

6684

6685

6686

6687

6688

6689

6690

6691

6692

6693

6694

6695

6696

6697

6698

6699

6700

6701

6702

6703

6704

6705

6706

6707

6708

6709

6710

6711

6712

6713

6714

6715

6716

6717

6718

6719

6720

6721

6722

6723

6724

6725

6726

6727

6728

6729

6730

6731

6732

6733

6734

6735

6736

6737

6738

6739

6740

6741

6742

6743

6744

6745

6746

6747

6748

6749

6750

6751

6752

6753

6754

6755

6756

6757

6758

6759

6760

6761

6762

6763

6764

6765

6766

6767

6768

6769

6770

6771

6772

6773

6774

6775

6776

6777

6778

6779

6780

6781

6782

6783

6784

6785

6786

6787

6788

6789

6790

6791

6792

6793

6794

6795

6796

6797

6798

6799

6800

6801

6802

6803

6804

6805

6806

6807

6808

6809

6810

6811

6812

6813

6814

6815

6816

6817

6818

6819

6820

6821

6822

6823

6824

6825

6826

6827

6828

6829

6830

6831

6832

6833

6834

6835

6836

6837

6838

6839

6840

6841

6842

6843

6844

6845

6846

6847

6848

6849

6850

6851

6852

6853

6854

6855

6856

6857

6858

6859

6860

6861

6862

6863

6864

6865

6866

6867

6868

6869

6870

6871

6872

6873

6874

6875

6876

6877

6878

6879

6880

6881

6882

6883

6884

6885

6886

6887

6888

6889

6890

6891

6892

6893

6894

6895

6896

6897

6898

6899

6900

6901

6902

6903

6904

6905

6906

6907

6908

6909

6910

6911

6912

6913

6914

6915

6916

6917

6918

6919

6920

6921

6922

6923

6924

6925

6926

6927

6928

6929

6930

6931

6932

6933

6934

6935

6936

6937

6938

6939

6940

6941

6942

6943

6944

6945

6946

6947

6948

6949

6950

6951

6952

6953

6954

6955

6956

6957

6958

6959

6960

6961

6962

6963

6964

6965

6966

6967

6968

6969

6970

6971

6972

6973

6974

6975

6976

6977

6978

6979

6980

6981

6982

6983

6984

6985

6986

6987

6988

6989

6990

6991

6992

6993

6994

6995

6996

6997

6998

6999

7000

7001

7002

7003

7004

7005

7006

7007

7008

7009

7010

7011

7012

7013

7014

7015

7016

7017

7018

7019

7020

7021

7022

7023

7024

7025

7026

7027

7028

7029

7030

7031

7032

7033

7034

7035

7036

7037

7038

7039

7040

7041

7042

7043

7044

7045

7046

7047

7048

7049

7050

7051

7052

7053

7054

7055

7056

7057

7058

# -*- coding: utf-8 -*- 

""" 

Elliptic curves over the rational numbers 

 

AUTHORS: 

 

- William Stein (2005): first version 

 

- William Stein (2006-02-26): fixed Lseries_extended which didn't work 

because of changes elsewhere in Sage. 

 

- David Harvey (2006-09): Added padic_E2, padic_sigma, padic_height, 

padic_regulator methods. 

 

- David Harvey (2007-02): reworked padic-height related code 

 

- Christian Wuthrich (2007): added padic sha computation 

 

- David Roe (2007-09): moved sha, l-series and p-adic functionality to 

separate files. 

 

- John Cremona (2008-01) 

 

- Tobias Nagel and Michael Mardaus (2008-07): added integral_points 

 

- John Cremona (2008-07): further work on integral_points 

 

- Christian Wuthrich (2010-01): moved Galois reps and modular 

parametrization in a separate file 

 

- Simon Spicer (2013-03): Added code for modular degrees and congruence 

numbers of higher level 

 

- Simon Spicer (2014-08): Added new analytic rank computation functionality 

 

""" 

 

############################################################################## 

# Copyright (C) 2005,2006,2007 William Stein <wstein@gmail.com> 

# 

# Distributed under the terms of the GNU General Public License (GPL) 

# 

# This code is distributed in the hope that it will be useful, 

# but WITHOUT ANY WARRANTY; without even the implied warranty of 

# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 

# General Public License for more details. 

# 

# The full text of the GPL is available at: 

# 

# http://www.gnu.org/licenses/ 

############################################################################## 

from __future__ import print_function, division, absolute_import 

from six import integer_types, iteritems 

from six.moves import range 

 

from . import constructor 

from . import BSD 

from .ell_generic import is_EllipticCurve 

from . import ell_modular_symbols 

from .ell_number_field import EllipticCurve_number_field 

from . import ell_point 

from . import ell_tate_curve 

from . import ell_torsion 

from . import heegner 

from .gp_simon import simon_two_descent 

from .lseries_ell import Lseries_ell 

from . import mod5family 

from .modular_parametrization import ModularParameterization 

from . import padic_lseries 

from . import padics 

 

from sage.modular.modsym.modsym import ModularSymbols 

from sage.modular.pollack_stevens.space import ps_modsym_from_elliptic_curve 

 

from sage.lfunctions.zero_sums import LFunctionZeroSum_EllipticCurve 

 

import sage.modular.modform.constructor 

import sage.modular.modform.element 

import sage.libs.eclib.all as mwrank 

import sage.databases.cremona 

 

import sage.arith.all as arith 

import sage.rings.all as rings 

from sage.rings.all import ( 

PowerSeriesRing, 

infinity as oo, 

ZZ, QQ, 

Integer, 

IntegerRing, RealField, 

ComplexField, RationalField) 

 

import sage.misc.all as misc 

from sage.misc.all import verbose 

 

from sage.functions.log import log 

 

import sage.matrix.all as matrix 

from sage.libs.pari.all import pari 

from sage.functions.gamma import gamma_inc 

from math import sqrt 

from sage.interfaces.all import gp 

from sage.misc.cachefunc import cached_method 

from copy import copy 

 

Q = RationalField() 

C = ComplexField() 

R = RealField() 

Z = IntegerRing() 

IR = rings.RealIntervalField(20) 

 

_MAX_HEIGHT=21 

 

# complex multiplication dictionary: 

# CMJ is a dict of pairs (j,D) where j is a rational CM j-invariant 

# and D is the corresponding quadratic discriminant 

 

CMJ={ 0: -3, 54000: -12, -12288000: -27, 1728: -4, 287496: -16, 

-3375: -7, 16581375: -28, 8000: -8, -32768: -11, -884736: -19, 

-884736000: -43, -147197952000: -67, -262537412640768000: -163} 

 

 

class EllipticCurve_rational_field(EllipticCurve_number_field): 

r""" 

Elliptic curve over the Rational Field. 

 

INPUT: 

 

- ``ainvs`` -- a list or tuple `[a_1, a_2, a_3, a_4, a_6]` of 

Weierstrass coefficients. 

 

.. note:: 

 

This class should not be called directly; use 

:class:`sage.constructor.EllipticCurve` to construct 

elliptic curves. 

 

EXAMPLES: 

 

Construction from Weierstrass coefficients (`a`-invariants), long form:: 

 

sage: E = EllipticCurve([1,2,3,4,5]); E 

Elliptic Curve defined by y^2 + x*y + 3*y = x^3 + 2*x^2 + 4*x + 5 over Rational Field 

 

Construction from Weierstrass coefficients (`a`-invariants), 

short form (sets `a_1 = a_2 = a_3 = 0`):: 

 

sage: EllipticCurve([4,5]).ainvs() 

(0, 0, 0, 4, 5) 

 

Constructor from a Cremona label:: 

 

sage: EllipticCurve('389a1') 

Elliptic Curve defined by y^2 + y = x^3 + x^2 - 2*x over Rational Field 

 

Constructor from an LMFDB label:: 

 

sage: EllipticCurve('462.f3') 

Elliptic Curve defined by y^2 + x*y = x^3 - 363*x + 1305 over Rational Field 

 

""" 

def __init__(self, ainvs, **kwds): 

r""" 

Constructor for the EllipticCurve_rational_field class. 

 

TESTS: 

 

When constructing a curve from the large database using a 

label, we must be careful that the copied generators have the 

right curve (see :trac:`10999`: the following used not to work when 

the large database was installed):: 

 

sage: E = EllipticCurve('389a1') 

sage: [P.curve() is E for P in E.gens()] 

[True, True] 

 

""" 

# Cached values for the generators, rank and regulator. 

# The format is a tuple (value, proven). "proven" is a boolean 

# which says whether or not the value was proven. 

self.__gens = None 

self.__rank = None 

self.__regulator = None 

 

# Other cached values 

self.__generalized_modular_degree = {} 

self.__generalized_congruence_number = {} 

self._isoclass = {} 

 

EllipticCurve_number_field.__init__(self, Q, ainvs) 

 

if 'conductor' in kwds: 

self._set_conductor(kwds['conductor']) 

if 'cremona_label' in kwds: 

self._set_cremona_label(kwds['cremona_label']) 

if 'gens' in kwds: 

self._set_gens(kwds['gens']) 

if 'lmfdb_label' in kwds: 

self._lmfdb_label = kwds['lmfdb_label'] 

if 'modular_degree' in kwds: 

self._set_modular_degree(kwds['modular_degree']) 

if 'rank' in kwds: 

self._set_rank(kwds['rank']) 

if 'regulator' in kwds: 

self.__regulator = (kwds['regulator'], True) 

if 'torsion_order' in kwds: 

self._set_torsion_order(kwds['torsion_order']) 

 

def _set_rank(self, r): 

""" 

Internal function to set the cached rank of this elliptic curve to 

r. 

 

.. warning:: 

 

No checking is done! Not intended for use by users. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('37a1') 

sage: E._set_rank(99) # bogus value -- not checked 

sage: E.rank() # returns bogus cached value 

99 

sage: E._EllipticCurve_rational_field__rank = None # undo the damage 

sage: E.rank() # the correct rank 

1 

""" 

self.__rank = (Integer(r), True) 

 

def _set_torsion_order(self, t): 

""" 

Internal function to set the cached torsion order of this elliptic 

curve to t. 

 

.. warning:: 

 

No checking is done! Not intended for use by users. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('37a1') 

sage: E._set_torsion_order(99) # bogus value -- not checked 

sage: E.torsion_order() # returns bogus cached value 

99 

sage: T = E.torsion_subgroup() # causes actual torsion to be computed 

sage: E.torsion_order() # the correct value 

1 

""" 

self.__torsion_order = Integer(t) 

 

def _set_cremona_label(self, L): 

""" 

Internal function to set the cached label of this elliptic curve to 

L. 

 

.. warning:: 

 

No checking is done! Not intended for use by users. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('37a1') 

sage: E._set_cremona_label('bogus') 

sage: E.label() 

'bogus' 

sage: label = E.database_attributes()['cremona_label']; label 

'37a1' 

sage: E.label() # no change 

'bogus' 

sage: E._set_cremona_label(label) 

sage: E.label() # now it is correct 

'37a1' 

""" 

self.__cremona_label = L 

 

def _set_conductor(self, N): 

""" 

Internal function to set the cached conductor of this elliptic 

curve to N. 

 

.. warning:: 

 

No checking is done! Not intended for use by users. 

Setting to the wrong value will cause strange problems (see 

examples). 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('37a1') 

sage: E._set_conductor(99) # bogus value -- not checked 

sage: E.conductor() # returns bogus cached value 

99 

sage: E._set_conductor(37) 

""" 

self.__conductor_pari = Integer(N) 

 

def _set_modular_degree(self, deg): 

""" 

Internal function to set the cached modular degree of this elliptic 

curve to deg. 

 

.. warning:: 

 

No checking is done! 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('5077a1') 

sage: E.modular_degree() 

1984 

sage: E._set_modular_degree(123456789) 

sage: E.modular_degree() 

123456789 

sage: E._set_modular_degree(1984) 

""" 

self.__modular_degree = Integer(deg) 

 

def _set_gens(self, gens): 

""" 

Internal function to set the cached generators of this elliptic 

curve to gens. 

 

.. warning:: 

 

No checking is done! 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('5077a1') 

sage: E.rank() 

3 

sage: E.gens() # random 

[(-2 : 3 : 1), (-7/4 : 25/8 : 1), (1 : -1 : 1)] 

sage: E._set_gens([]) # bogus list 

sage: E.rank() # unchanged 

3 

sage: E._set_gens([E(-2,3), E(-1,3), E(0,2)]) 

sage: E.gens() 

[(-2 : 3 : 1), (-1 : 3 : 1), (0 : 2 : 1)] 

""" 

gens = sorted(self.point(x, check=True) for x in gens) 

self.__gens = (gens, True) 

 

def lmfdb_page(self): 

r""" 

Open the LMFDB web page of the elliptic curve in a browser. 

 

See http://www.lmfdb.org 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('5077a1') 

sage: E.lmfdb_page() # optional -- webbrowser 

""" 

import webbrowser 

lmfdb_url = 'http://www.lmfdb.org/EllipticCurve/Q/{}' 

if hasattr(self, "_lmfdb_label") and self._lmfdb_label: 

url = lmfdb_url.format(self._lmfdb_label) 

else: 

url = lmfdb_url.format(self.cremona_label()) 

webbrowser.open(url) 

 

def is_p_integral(self, p): 

r""" 

Return ``True`` if this elliptic curve has `p`-integral 

coefficients. 

 

INPUT: 

 

- ``p`` -- a prime integer 

 

EXAMPLES:: 

 

sage: E = EllipticCurve(QQ,[1,1]); E 

Elliptic Curve defined by y^2 = x^3 + x + 1 over Rational Field 

sage: E.is_p_integral(2) 

True 

sage: E2=E.change_weierstrass_model(2,0,0,0); E2 

Elliptic Curve defined by y^2 = x^3 + 1/16*x + 1/64 over Rational Field 

sage: E2.is_p_integral(2) 

False 

sage: E2.is_p_integral(3) 

True 

""" 

if not arith.is_prime(p): 

raise ArithmeticError("p must be prime") 

if self.is_integral(): 

return True 

return bool(misc.mul([x.valuation(p) >= 0 for x in self.ainvs()])) 

 

def is_integral(self): 

""" 

Return ``True`` if this elliptic curve has integral coefficients (in 

Z). 

 

EXAMPLES:: 

 

sage: E = EllipticCurve(QQ,[1,1]); E 

Elliptic Curve defined by y^2 = x^3 + x + 1 over Rational Field 

sage: E.is_integral() 

True 

sage: E2=E.change_weierstrass_model(2,0,0,0); E2 

Elliptic Curve defined by y^2 = x^3 + 1/16*x + 1/64 over Rational Field 

sage: E2.is_integral() 

False 

""" 

try: 

return self.__is_integral 

except AttributeError: 

one = Integer(1) 

self.__is_integral = bool(misc.mul([x.denominator() == 1 for x in self.ainvs()])) 

return self.__is_integral 

 

 

def mwrank(self, options=''): 

r""" 

Run Cremona's mwrank program on this elliptic curve and return the 

result as a string. 

 

INPUT: 

 

 

- ``options`` (string) -- run-time options passed when starting mwrank. 

The format is as follows (see below for examples of usage): 

 

- ``-v n`` (verbosity level) sets verbosity to n (default=1) 

- ``-o`` (PARI/GP style output flag) turns ON extra PARI/GP short output (default is OFF) 

- ``-p n`` (precision) sets precision to `n` decimals (default=15) 

- ``-b n`` (quartic bound) bound on quartic point search (default=10) 

- ``-x n`` (n_aux) number of aux primes used for sieving (default=6) 

- ``-l`` (generator list flag) turns ON listing of points (default ON unless v=0) 

- ``-s`` (selmer_only flag) if set, computes Selmer rank only (default: not set) 

- ``-d`` (skip_2nd_descent flag) if set, skips the second descent for curves with 2-torsion (default: not set) 

- ``-S n`` (sat_bd) upper bound on saturation primes (default=100, -1 for automatic) 

 

OUTPUT: 

 

- ``string`` - output of mwrank on this curve 

 

 

.. note:: 

 

The output is a raw string and completely illegible using 

automatic display, so it is recommended to use print for 

legible output. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('37a1') 

sage: E.mwrank() #random 

... 

sage: print(E.mwrank()) 

Curve [0,0,1,-1,0] : Basic pair: I=48, J=-432 

disc=255744 

... 

Generator 1 is [0:-1:1]; height 0.05111... 

 

Regulator = 0.05111... 

 

The rank and full Mordell-Weil basis have been determined unconditionally. 

... 

 

Options to mwrank can be passed:: 

 

sage: E = EllipticCurve([0,0,0,877,0]) 

 

Run mwrank with 'verbose' flag set to 0 but list generators if 

found 

 

:: 

 

sage: print(E.mwrank('-v0 -l')) 

Curve [0,0,0,877,0] : 0 <= rank <= 1 

Regulator = 1 

 

Run mwrank again, this time with a higher bound for point searching 

on homogeneous spaces:: 

 

sage: print(E.mwrank('-v0 -l -b11')) 

Curve [0,0,0,877,0] : Rank = 1 

Generator 1 is [29604565304828237474403861024284371796799791624792913256602210:-256256267988926809388776834045513089648669153204356603464786949:490078023219787588959802933995928925096061616470779979261000]; height 95.980371987964 

Regulator = 95.980371987964 

""" 

if options == "": 

from sage.interfaces.all import mwrank 

else: 

from sage.interfaces.all import Mwrank 

mwrank = Mwrank(options=options) 

return mwrank(list(self.a_invariants())) 

 

def conductor(self, algorithm="pari"): 

""" 

Return the conductor of the elliptic curve. 

 

INPUT: 

 

 

- ``algorithm`` - str, (default: "pari") 

 

- ``"pari"`` - use the PARI C-library ellglobalred 

implementation of Tate's algorithm 

 

- ``"mwrank"`` - use Cremona's mwrank implementation 

of Tate's algorithm; can be faster if the curve has integer 

coefficients (TODO: limited to small conductor until mwrank gets 

integer factorization) 

 

- ``"gp"`` - use the GP interpreter. 

 

- ``"generic"`` - use the general number field 

implementation 

 

- ``"all"`` - use all four implementations, verify 

that the results are the same (or raise an error), and output the 

common value. 

 

 

EXAMPLES:: 

 

sage: E = EllipticCurve([1, -1, 1, -29372, -1932937]) 

sage: E.conductor(algorithm="pari") 

3006 

sage: E.conductor(algorithm="mwrank") 

3006 

sage: E.conductor(algorithm="gp") 

3006 

sage: E.conductor(algorithm="generic") 

3006 

sage: E.conductor(algorithm="all") 

3006 

 

.. note:: 

 

The conductor computed using each algorithm is cached 

separately. Thus calling ``E.conductor('pari')``, then 

``E.conductor('mwrank')`` and getting the same result 

checks that both systems compute the same answer. 

 

TESTS:: 

 

sage: E.conductor(algorithm="bogus") 

Traceback (most recent call last): 

... 

ValueError: algorithm 'bogus' is not known 

""" 

if algorithm == "pari": 

try: 

return self.__conductor_pari 

except AttributeError: 

self.__conductor_pari = Integer(self.pari_mincurve().ellglobalred()[0]) 

return self.__conductor_pari 

 

elif algorithm == "gp": 

try: 

return self.__conductor_gp 

except AttributeError: 

self.__conductor_gp = Integer(gp.eval('ellglobalred(ellinit(%s,0))[1]'%list(self.a_invariants()))) 

return self.__conductor_gp 

 

elif algorithm == "mwrank": 

try: 

return self.__conductor_mwrank 

except AttributeError: 

if self.is_integral(): 

self.__conductor_mwrank = Integer(self.mwrank_curve().conductor()) 

else: 

self.__conductor_mwrank = Integer(self.minimal_model().mwrank_curve().conductor()) 

return self.__conductor_mwrank 

 

elif algorithm == "generic": 

try: 

return self.__conductor_generic 

except AttributeError: 

self.__conductor_generic = sage.schemes.elliptic_curves.ell_number_field.EllipticCurve_number_field.conductor(self).gen() 

return self.__conductor_generic 

 

elif algorithm == "all": 

N1 = self.conductor("pari") 

N2 = self.conductor("mwrank") 

N3 = self.conductor("gp") 

N4 = self.conductor("generic") 

if N1 != N2 or N2 != N3 or N2 != N4: 

raise ArithmeticError("PARI, mwrank, gp and Sage compute different conductors (%s,%s,%s,%s) for %s"%( 

N1, N2, N3, N4, self)) 

return N1 

else: 

raise ValueError("algorithm %r is not known"%algorithm) 

 

#################################################################### 

# Access to PARI curves related to this curve. 

#################################################################### 

 

def pari_curve(self): 

""" 

Return the PARI curve corresponding to this elliptic curve. 

 

INPUT: 

 

- ``prec`` -- Deprecated 

 

- ``factor`` -- Deprecated 

 

EXAMPLES:: 

 

sage: E = EllipticCurve([0, 0, 1, -1, 0]) 

sage: e = E.pari_curve() 

sage: type(e) 

<... 'cypari2.gen.Gen'> 

sage: e.type() 

't_VEC' 

sage: e.ellan(10) 

[1, -2, -3, 2, -2, 6, -1, 0, 6, 4] 

 

:: 

 

sage: E = EllipticCurve(RationalField(), ['1/3', '2/3']) 

sage: e = E.pari_curve() 

sage: e[:5] 

[0, 0, 0, 1/3, 2/3] 

 

When doing certain computations, PARI caches the results:: 

 

sage: E = EllipticCurve('37a1') 

sage: _ = E.__dict__.pop('_pari_curve', None) # clear cached data 

sage: Epari = E.pari_curve() 

sage: Epari 

[0, 0, 1, -1, 0, 0, -2, 1, -1, 48, -216, 37, 110592/37, Vecsmall([1]), [Vecsmall([64, 1])], [0, 0, 0, 0, 0, 0, 0, 0]] 

sage: Epari.omega() 

[2.99345864623196, -2.45138938198679*I] 

sage: Epari 

[0, 0, 1, -1, 0, 0, -2, 1, -1, 48, -216, 37, 110592/37, Vecsmall([1]), [Vecsmall([64, 1])], [[2.99345864623196, -2.45138938198679*I], 0, [0.837565435283323, 0.269594436405445, -1.10715987168877, 1.37675430809421, 1.94472530697209, 0.567970998877878]~, 0, 0, 0, 0, 0]] 

 

This shows that the bug uncovered by :trac:`4715` is fixed:: 

 

sage: Ep = EllipticCurve('903b3').pari_curve() 

 

This still works, even when the curve coefficients are large 

(see :trac:`13163`):: 

 

sage: E = EllipticCurve([4382696457564794691603442338788106497, 28, 3992, 16777216, 298]) 

sage: E.pari_curve() 

[4382696457564794691603442338788106497, 28, 3992, 16777216, 298, ...] 

sage: E.minimal_model() 

Elliptic Curve defined by y^2 + x*y + y = x^3 + x^2 - 7686423934083797390675981169229171907674183588326184511391146727143672423167091484392497987721106542488224058921302964259990799229848935835464702*x + 8202280443553761483773108648734271851215988504820214784899752662100459663011709992446860978259617135893103951840830254045837355547141096270521198994389833928471736723050112419004202643591202131091441454709193394358885 over Rational Field 

""" 

try: 

return self._pari_curve 

except AttributeError: 

self._pari_curve = pari(self.a_invariants()).ellinit() 

return self._pari_curve 

 

def pari_mincurve(self): 

""" 

Return the PARI curve corresponding to a minimal model for this 

elliptic curve. 

 

INPUT: 

 

- ``prec`` -- Deprecated 

 

- ``factor`` -- Deprecated 

 

EXAMPLES:: 

 

sage: E = EllipticCurve(RationalField(), ['1/3', '2/3']) 

sage: e = E.pari_mincurve() 

sage: e[:5] 

[0, 0, 0, 27, 486] 

sage: E.conductor() 

47232 

sage: e.ellglobalred() 

[47232, [1, 0, 0, 0], 2, [2, 7; 3, 2; 41, 1], [[7, 2, 0, 1], [2, -3, 0, 2], [1, 5, 0, 1]]] 

""" 

try: 

return self._pari_mincurve 

except AttributeError: 

mc, change = self.pari_curve().ellminimalmodel() 

self._pari_mincurve = mc 

return self._pari_mincurve 

 

@cached_method 

def database_attributes(self): 

""" 

Return a dictionary containing information about ``self`` in 

the elliptic curve database. 

 

If there is no elliptic curve isomorphic to ``self`` in the 

database, a ``LookupError`` is raised. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve((0, 0, 1, -1, 0)) 

sage: data = E.database_attributes() 

sage: data['conductor'] 

37 

sage: data['cremona_label'] 

'37a1' 

sage: data['rank'] 

1 

sage: data['torsion_order'] 

1 

 

sage: E = EllipticCurve((8, 13, 21, 34, 55)) 

sage: E.database_attributes() 

Traceback (most recent call last): 

... 

LookupError: Cremona database does not contain entry for Elliptic Curve defined by y^2 + 8*x*y + 21*y = x^3 + 13*x^2 + 34*x + 55 over Rational Field 

""" 

from sage.databases.cremona import CremonaDatabase 

ainvs = self.minimal_model().ainvs() 

try: 

return CremonaDatabase().data_from_coefficients(ainvs) 

except RuntimeError: 

raise LookupError("Cremona database does not contain entry for " + repr(self)) 

 

def database_curve(self): 

""" 

Return the curve in the elliptic curve database isomorphic to this 

curve, if possible. Otherwise raise a ``LookupError`` exception. 

 

Since :trac:`11474`, this returns exactly the same curve as 

:meth:`minimal_model`; the only difference is the additional 

work of checking whether the curve is in the database. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve([0,1,2,3,4]) 

sage: E.database_curve() 

Elliptic Curve defined by y^2 = x^3 + x^2 + 3*x + 5 over Rational Field 

 

.. note:: 

 

The model of the curve in the database can be different 

from the Weierstrass model for this curve, e.g., database 

models are always minimal. 

""" 

try: 

return self.__database_curve 

except AttributeError: 

misc.verbose("Looking up %s in the database."%self) 

D = sage.databases.cremona.CremonaDatabase() 

ainvs = list(self.minimal_model().ainvs()) 

try: 

self.__database_curve = D.elliptic_curve_from_ainvs(ainvs) 

except RuntimeError: 

raise RuntimeError("Elliptic curve %s not in the database."%self) 

return self.__database_curve 

 

def Np(self, p): 

r""" 

The number of points on `E` modulo `p`. 

 

INPUT: 

 

- ``p`` (int) -- a prime, not necessarily of good reduction. 

 

 

OUTPUT: 

 

(int) The number ofpoints on the reduction of `E` modulo `p` 

(including the singular point when `p` is a prime of bad 

reduction). 

 

EXAMPLES:: 

 

sage: E = EllipticCurve([0, -1, 1, -10, -20]) 

sage: E.Np(2) 

5 

sage: E.Np(3) 

5 

sage: E.conductor() 

11 

sage: E.Np(11) 

11 

 

This even works when the prime is large:: 

 

sage: E = EllipticCurve('37a') 

sage: E.Np(next_prime(10^30)) 

1000000000000001426441464441649 

""" 

if self.conductor() % p == 0: 

return p + 1 - self.ap(p) 

return p+1 - self.ap(p) 

 

#################################################################### 

# Access to mwrank 

#################################################################### 

def mwrank_curve(self, verbose=False): 

""" 

Construct an mwrank_EllipticCurve from this elliptic curve 

 

The resulting mwrank_EllipticCurve has available methods from John 

Cremona's eclib library. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('11a1') 

sage: EE = E.mwrank_curve() 

sage: EE 

y^2+ y = x^3 - x^2 - 10*x - 20 

sage: type(EE) 

<class 'sage.libs.eclib.interface.mwrank_EllipticCurve'> 

sage: EE.isogeny_class() 

([[0, -1, 1, -10, -20], [0, -1, 1, -7820, -263580], [0, -1, 1, 0, 0]], 

[[0, 5, 5], [5, 0, 0], [5, 0, 0]]) 

""" 

try: 

return self.__mwrank_curve 

except AttributeError: 

pass 

self.__mwrank_curve = mwrank.mwrank_EllipticCurve( 

list(self.ainvs()), verbose=verbose) 

return self.__mwrank_curve 

 

def two_descent(self, verbose=True, 

selmer_only = False, 

first_limit = 20, 

second_limit = 8, 

n_aux = -1, 

second_descent = 1): 

""" 

Compute 2-descent data for this curve. 

 

INPUT: 

 

 

- ``verbose`` - (default: True) print what mwrank is 

doing. If False, **no output** is printed. 

 

- ``selmer_only`` - (default: ``False``) selmer_only 

switch 

 

- ``first_limit`` - (default: 20) firstlim is bound 

on x+z second_limit- (default: 8) secondlim is bound on log max 

x,z , i.e. logarithmic 

 

- ``n_aux`` - (default: -1) n_aux only relevant for 

general 2-descent when 2-torsion trivial; n_aux=-1 causes default 

to be used (depends on method) 

 

- ``second_descent`` - (default: True) 

second_descent only relevant for descent via 2-isogeny 

 

 

OUTPUT: 

 

Return ``True`` if the descent succeeded, i.e. if the lower bound and 

the upper bound for the rank are the same. In this case, generators and 

the rank are cached. A return value of ``False`` indicates that either 

rational points were not found, or that Sha[2] is nontrivial and mwrank 

was unable to determine this for sure. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('37a1') 

sage: E.two_descent(verbose=False) 

True 

 

""" 

misc.verbose("Calling mwrank C++ library.") 

C = self.mwrank_curve() 

C.two_descent(verbose, selmer_only, 

first_limit, second_limit, 

n_aux, second_descent) 

if C.certain(): 

gens = sorted(self.point(x, check=True) for x in C.gens()) 

self.__gens = (gens, True) 

self.__rank = (Integer(len(gens)), True) 

return C.certain() 

 

#################################################################### 

# Etc. 

#################################################################### 

 

def aplist(self, n, python_ints=False): 

r""" 

The Fourier coefficients `a_p` of the modular form 

attached to this elliptic curve, for all primes `p\leq n`. 

 

INPUT: 

 

 

- ``n`` - integer 

 

- ``python_ints`` - bool (default: ``False``); if ``True`` 

return a list of Python ints instead of Sage integers. 

 

 

OUTPUT: list of integers 

 

EXAMPLES:: 

 

sage: e = EllipticCurve('37a') 

sage: e.aplist(1) 

[] 

sage: e.aplist(2) 

[-2] 

sage: e.aplist(10) 

[-2, -3, -2, -1] 

sage: v = e.aplist(13); v 

[-2, -3, -2, -1, -5, -2] 

sage: type(v[0]) 

<... 'sage.rings.integer.Integer'> 

sage: type(e.aplist(13, python_ints=True)[0]) 

<... 'int'> 

""" 

e = self.pari_mincurve() 

v = e.ellaplist(n, python_ints=True) 

if python_ints: 

return v 

else: 

return [Integer(a) for a in v] 

 

 

 

def anlist(self, n, python_ints=False): 

""" 

The Fourier coefficients up to and including `a_n` of the 

modular form attached to this elliptic curve. The i-th element of 

the return list is a[i]. 

 

INPUT: 

 

 

- ``n`` - integer 

 

- ``python_ints`` - bool (default: ``False``); if ``True`` 

return a list of Python ints instead of Sage integers. 

 

 

OUTPUT: list of integers 

 

EXAMPLES:: 

 

sage: E = EllipticCurve([0, -1, 1, -10, -20]) 

sage: E.anlist(3) 

[0, 1, -2, -1] 

 

:: 

 

sage: E = EllipticCurve([0,1]) 

sage: E.anlist(20) 

[0, 1, 0, 0, 0, 0, 0, -4, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 8, 0] 

""" 

n = int(n) 

e = self.pari_mincurve() 

if n >= 2147483648: 

raise RuntimeError("anlist: n (=%s) must be < 2147483648."%n) 

 

v = [0] + e.ellan(n, python_ints=True) 

if not python_ints: 

v = [Integer(x) for x in v] 

return v 

 

 

# There is some overheard associated with coercing the PARI 

# list back to Python, but it's not bad. It's better to do it 

# this way instead of trying to eval the whole list, since the 

# int conversion is done very sensibly. NOTE: This would fail 

# if a_n won't fit in a C int, i.e., is bigger than 

# 2147483648; however, we wouldn't realistically compute 

# anlist for n that large anyway. 

# 

# Some relevant timings: 

# 

# E <--> [0, 1, 1, -2, 0] 389A 

# E = EllipticCurve([0, 1, 1, -2, 0]); // Sage or MAGMA 

# e = E.pari_mincurve() 

# f = ellinit([0,1,1,-2,0]); 

# 

# Computation Time (1.6Ghz Pentium-4m laptop) 

# time v:=TracesOfFrobenius(E,10000); // MAGMA 0.120 

# gettime;v=ellan(f,10000);gettime/1000 0.046 

# time v=e.ellan (10000) 0.04 

# time v=E.anlist(10000) 0.07 

 

# time v:=TracesOfFrobenius(E,100000); // MAGMA 1.620 

# gettime;v=ellan(f,100000);gettime/1000 0.676 

# time v=e.ellan (100000) 0.7 

# time v=E.anlist(100000) 0.83 

 

# time v:=TracesOfFrobenius(E,1000000); // MAGMA 20.850 

# gettime;v=ellan(f,1000000);gettime/1000 9.238 

# time v=e.ellan (1000000) 9.61 

# time v=E.anlist(1000000) 10.95 (13.171 in cygwin vmware) 

 

# time v:=TracesOfFrobenius(E,10000000); //MAGMA 257.850 

# gettime;v=ellan(f,10000000);gettime/1000 FAILS no matter how many allocatemem()'s!! 

# time v=e.ellan (10000000) 139.37 

# time v=E.anlist(10000000) 136.32 

# 

# The last Sage comp retries with stack size 40MB, 

# 80MB, 160MB, and succeeds last time. It's very interesting that this 

# last computation is *not* possible in GP, but works in py_pari! 

# 

 

def q_expansion(self, prec): 

r""" 

Return the `q`-expansion to precision prec of the newform 

attached to this elliptic curve. 

 

INPUT: 

 

 

- ``prec`` - an integer 

 

 

OUTPUT: 

 

a power series (in the variable 'q') 

 

.. note:: 

 

If you want the output to be a modular form and not just a 

`q`-expansion, use :meth:`.modular_form`. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('37a1') 

sage: E.q_expansion(20) 

q - 2*q^2 - 3*q^3 + 2*q^4 - 2*q^5 + 6*q^6 - q^7 + 6*q^9 + 4*q^10 - 5*q^11 - 6*q^12 - 2*q^13 + 2*q^14 + 6*q^15 - 4*q^16 - 12*q^18 + O(q^20) 

""" 

return PowerSeriesRing(Q, 'q')(self.anlist(prec), prec, check=True) 

 

def modular_form(self): 

r""" 

Return the cuspidal modular form associated to this elliptic 

curve. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('37a') 

sage: f = E.modular_form() 

sage: f 

q - 2*q^2 - 3*q^3 + 2*q^4 - 2*q^5 + O(q^6) 

 

If you need to see more terms in the `q`-expansion:: 

 

sage: f.q_expansion(20) 

q - 2*q^2 - 3*q^3 + 2*q^4 - 2*q^5 + 6*q^6 - q^7 + 6*q^9 + 4*q^10 - 5*q^11 - 6*q^12 - 2*q^13 + 2*q^14 + 6*q^15 - 4*q^16 - 12*q^18 + O(q^20) 

 

.. note:: 

 

If you just want the `q`-expansion, use 

:meth:`.q_expansion`. 

""" 

try: 

return self.__modular_form 

except AttributeError: 

M = sage.modular.modform.constructor.ModularForms(self.conductor(),weight=2) 

f = sage.modular.modform.element.ModularFormElement_elliptic_curve(M, self) 

self.__modular_form = f 

return f 

 

def modular_symbol_space(self, sign=1, base_ring=Q, bound=None): 

r""" 

Return the space of cuspidal modular symbols associated to this 

elliptic curve, with given sign and base ring. 

 

INPUT: 

 

 

- ``sign`` - 0, -1, or 1 

 

- ``base_ring`` - a ring 

 

 

EXAMPLES:: 

 

sage: f = EllipticCurve('37b') 

sage: f.modular_symbol_space() 

Modular Symbols subspace of dimension 1 of Modular Symbols space of dimension 3 for Gamma_0(37) of weight 2 with sign 1 over Rational Field 

sage: f.modular_symbol_space(-1) 

Modular Symbols subspace of dimension 1 of Modular Symbols space of dimension 2 for Gamma_0(37) of weight 2 with sign -1 over Rational Field 

sage: f.modular_symbol_space(0, bound=3) 

Modular Symbols subspace of dimension 2 of Modular Symbols space of dimension 5 for Gamma_0(37) of weight 2 with sign 0 over Rational Field 

 

.. note:: 

 

If you just want the `q`-expansion, use 

:meth:`.q_expansion`. 

""" 

typ = (sign, base_ring) 

try: 

return self.__modular_symbol_space[typ] 

except AttributeError: 

self.__modular_symbol_space = {} 

except KeyError: 

pass 

M = ell_modular_symbols.modular_symbol_space(self, sign, base_ring, bound=bound) 

self.__modular_symbol_space[typ] = M 

return M 

 

def abelian_variety(self): 

r""" 

Return self as a modular abelian variety. 

 

OUTPUT: 

 

- a modular abelian variety 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('11a') 

sage: E.abelian_variety() 

Abelian variety J0(11) of dimension 1 

 

sage: E = EllipticCurve('33a') 

sage: E.abelian_variety() 

Abelian subvariety of dimension 1 of J0(33) 

""" 

return self.modular_symbol_space(sign=0).abelian_variety() 

 

def _modular_symbol_normalize(self, sign, use_eclib, normalize, implementation): 

r""" 

Normalize parameters for :meth:`modular_symbol`. 

 

TESTS:: 

 

sage: E = EllipticCurve('37a1') 

sage: E.modular_symbol(implementation = 'eclib') is E.modular_symbol(implementation = 'eclib', normalize = 'L_ratio') 

True 

""" 

if use_eclib is not None: 

from sage.misc.superseded import deprecation 

deprecation(20864, "Use the option 'implementation' instead of 'use_eclib'") 

if use_eclib: 

implementation = 'eclib' 

else: 

implementation = 'sage' 

if sign not in [1,-1]: 

raise ValueError("The sign of a modular symbol must be 1 or -1") 

sign = ZZ(sign) 

if normalize is None: 

normalize = "L_ratio" 

if normalize not in ["L_ratio", "period", "none"]: 

raise ValueError("normalize should be one of 'L_ratio', 'period' or 'none'") 

if implementation not in ["sage", "eclib"]: 

raise ValueError("Implementation should be one of 'sage' or 'eclib'") 

return (sign, normalize, implementation) 

 

@cached_method(key = _modular_symbol_normalize) 

def modular_symbol(self, sign = +1, use_eclib = None, normalize = None, implementation = 'eclib'): 

r""" 

Return the modular symbol associated to this elliptic curve, 

with given sign. 

 

INPUT: 

 

- ``sign`` - +1 (default) or -1. 

 

- ``use_eclib`` - Deprecated. Use the ``implementation`` parameter instead. 

 

- ``normalize`` - (default: None); either 'L_ratio', 'period', 

or 'none' when ``implementation`` is 'sage'; ignored if 

``implementation`` is ``eclib``. For 'L_ratio', the 

modular symbol tries to normalize correctly as explained 

below by comparing it to ``L_ratio`` for the curve and some 

small twists. The normalization 'period' uses the 

``integral_period_map`` for modular symbols which is known 

to be equal to the desired normalization, up to the sign 

and a possible power of 2. With normalization 'none', the 

modular symbol is almost certainly not correctly 

normalized, i.e. all values will be a fixed scalar multiple 

of what they should be. However, the initial computation 

of the modular symbol is much faster when implementation 

``sage`` is chosen, though evaluation of it after computing 

it is no faster. 

 

- ``implementation`` - either 'eclib' (default) or 

'sage'. Here 'eclib' uses John Cremona's implementation in 

the eclib library, while 'sage' uses an implementation 

in Sage which is often quite a bit slower. 

 

.. SEEALSO:: 

 

:meth:`modular_symbol_numerical` 

 

.. note:: 

 

The value at a rational number `r` is proportional to the 

real or imaginary part of the integral of `2 \pi i f(z) dz` 

from `\infty` to `r`, where `f` is the newform attached to 

`E`, suitably normalized so that all values of this map 

take values in `\QQ`. 

 

The normalization is such that for sign +1, the value at 

the cusp `r` is equal to the quotient of the real part of 

`\int_{\infty}^{r}2\pi i f(z)dz` by the least positive 

period of `E`, where `f` is the newform attached to the 

isogeny class of `E`. This is in contrast to the method 

``L_ratio`` of ``lseries()``, where the value is also 

divided by the number of connected components of 

`E(\RR)`). In particular the modular symbol depends on `E` 

and not only the isogeny class of `E`. For negative 

modular symbols, the value is the quotient of the imaginary 

part of the above integral by the imaginary part of the 

smallest positive imaginary period. 

 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('37a1') 

sage: M = E.modular_symbol(); M 

Modular symbol with sign 1 over Rational Field attached to Elliptic Curve defined by y^2 + y = x^3 - x over Rational Field 

sage: M(1/2) 

0 

sage: M(1/5) 

1 

 

:: 

 

sage: E = EllipticCurve('121b1') 

sage: M = E.modular_symbol(implementation="sage") 

Warning : Could not normalize the modular symbols, maybe all further results will be multiplied by -1 and a power of 2 

sage: M(1/7) 

-1/2 

 

Different curves in an isogeny class have modular symbols 

which differ by a nonzero rational factor:: 

 

sage: E1 = EllipticCurve('11a1') 

sage: M1 = E1.modular_symbol() 

sage: M1(0) 

1/5 

sage: E2 = EllipticCurve('11a2') 

sage: M2 = E2.modular_symbol() 

sage: M2(0) 

1 

sage: E3 = EllipticCurve('11a3') 

sage: M3 = E3.modular_symbol() 

sage: M3(0) 

1/25 

sage: all(5*M1(r)==M2(r)==25*M3(r) for r in QQ.range_by_height(10)) 

True 

 

With the default implementation using ``eclib``, the symbols 

are correctly normalized automatically. With the ``Sage`` 

implementation we can choose to normalize using the L-ratio, 

unless that is 0 (for curves of positive rank) or using 

periods. Here is an example where the symbol is already 

normalized:: 

 

sage: E = EllipticCurve('11a2') 

sage: E.modular_symbol(implementation = 'eclib')(0) 

1 

sage: E.modular_symbol(implementation = 'sage', normalize='L_ratio')(0) 

1 

sage: E.modular_symbol(implementation = 'sage', normalize='none')(0) 

1 

sage: E.modular_symbol(implementation = 'sage', normalize='period')(0) 

1 

 

Here is an example where both normalization methods work, 

while the non-normalized symbol is incorrect:: 

 

sage: E = EllipticCurve('11a3') 

sage: E.modular_symbol(implementation = 'eclib')(0) 

1/25 

sage: E.modular_symbol(implementation = 'sage', normalize='none')(0) 

1 

sage: E.modular_symbol(implementation = 'sage', normalize='L_ratio')(0) 

1/25 

sage: E.modular_symbol(implementation = 'sage', normalize='period')(0) 

1/25 

 

 

Since :trac:`10256`, the interface for negative modular symbols in eclib is available:: 

 

sage: E = EllipticCurve('11a1') 

sage: Mplus = E.modular_symbol(+1); Mplus 

Modular symbol with sign 1 over Rational Field attached to Elliptic Curve defined by y^2 + y = x^3 - x^2 - 10*x - 20 over Rational Field 

sage: [Mplus(1/i) for i in [1..11]] 

[1/5, -4/5, -3/10, 7/10, 6/5, 6/5, 7/10, -3/10, -4/5, 1/5, 0] 

sage: Mminus = E.modular_symbol(-1); Mminus 

Modular symbol with sign -1 over Rational Field attached to Elliptic Curve defined by y^2 + y = x^3 - x^2 - 10*x - 20 over Rational Field 

sage: [Mminus(1/i) for i in [1..11]] 

[0, 0, 1/2, 1/2, 0, 0, -1/2, -1/2, 0, 0, 0] 

 

""" 

sign, normalize, implementation = self._modular_symbol_normalize(sign, use_eclib, normalize, implementation) 

if implementation == 'eclib': 

M = ell_modular_symbols.ModularSymbolECLIB(self, sign) 

else: # implementation == 'sage': 

M = ell_modular_symbols.ModularSymbolSage(self, sign, normalize=normalize) 

return M 

 

def _modsym(self, tau, prec=53): 

r""" 

Compute the modular symbol `\{\infty, \tau\}` analytically. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('11a1') 

sage: E._modsym(0) # abs tol 1e-14 

0.253841860855911 - 2.86184184507043e-17*I 

sage: E = EllipticCurve('17a1') 

sage: E._modsym(0) # abs tol 1e-14 

0.386769938387780 - 4.26353246509333e-17*I 

""" 

from sage.modular.cusps import Cusps 

from sage.sets.all import Primes 

N = self.conductor() 

# Find a prime p that is suitable, along with matrices M[i]. 

for p in Primes(): 

if N % p == 0: 

continue 

# Are the cusps tau, p*tau, and (tau+j)/p for j = 0, ..., p-1 

# all equivalent? 

t = Cusps(tau) 

M = [] 

b, m = t.is_gamma0_equiv(p * tau, N, transformation='matrix') 

if not b: 

continue 

M.append(m) 

good = True 

for j in range(p): 

b, m = t.is_gamma0_equiv((tau + j) / p, N, 

transformation='matrix') 

if not b: 

good = False 

break 

M.append(m) 

if good: 

# Found it! 

break 

f = self.newform() 

return -sum(f.period(m, prec) for m in M) / (1 + p - self.ap(p)) 

 

def modular_symbol_numerical(self, sign=1, prec=53): 

""" 

Return the modular symbol as a numerical function. 

 

.. NOTE:: 

 

This method does not compute spaces of modular symbols, so 

it is suitable for curves of larger conductor than can be 

handled by :meth:`modular_symbol`. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('19a1') 

sage: f = E.modular_symbol_numerical(1) 

sage: g = E.modular_symbol() 

sage: f(0), g(0) # abs tol 1e-14 

(0.333333333333330, 1/3) 

sage: f(oo), g(oo) 

(-0.000000000000000, 0) 

 

sage: E = EllipticCurve('79a1') 

sage: f = E.modular_symbol_numerical(-1) 

sage: g = E.modular_symbol(-1, implementation="sage") 

sage: f(1/3), g(1/3) # abs tol 1e-13 

(1.00000000000001, 1) 

sage: f(oo), g(oo) 

(0.000000000000000, 0) 

""" 

lam = self.period_lattice().basis(prec=prec) 

if sign == 1: 

P = lam[0].real() 

return lambda a: self._modsym(a, prec).real() / P 

else: 

P = lam[1].imag() 

return lambda a: self._modsym(a, prec).imag() / P 

 

 

def pollack_stevens_modular_symbol(self, sign=0, implementation='eclib'): 

""" 

Create the modular symbol attached to the elliptic curve, 

suitable for overconvergent calculations. 

 

INPUT: 

 

- ``sign`` -- +1 or -1 or 0 (default), in which case this it 

is the sum of the two 

 

- ``implementation`` -- either 'eclib' (default) or 'sage'. 

This determines classical modular symbols which implementation 

of the underlying classical modular symbols is used 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('113a1') 

sage: symb = E.pollack_stevens_modular_symbol() 

sage: symb 

Modular symbol of level 113 with values in Sym^0 Q^2 

sage: symb.values() 

[-1/2, 1, -1, 0, 0, 1, 1, -1, 0, -1, 0, 0, 0, 1, -1, 0, 0, 0, 1, 0, 0] 

 

sage: E = EllipticCurve([0,1]) 

sage: symb = E.pollack_stevens_modular_symbol(+1) 

sage: symb.values() 

[-1/6, 1/12, 0, 1/6, 1/12, 1/3, -1/12, 0, -1/6, -1/12, -1/4, -1/6, 1/12] 

""" 

typ = (sign, implementation) 

try: 

return self.__modular_symbol[typ] # Doesn't collide with original implementation because tuple is length two here. 

except AttributeError: 

self.__modular_symbol = {} 

except KeyError: 

pass 

M = ps_modsym_from_elliptic_curve(self, sign, implementation=implementation) 

self.__modular_symbol[typ] = M 

return M 

 

_normalize_padic_lseries = padics._normalize_padic_lseries 

padic_lseries = padics.padic_lseries 

 

def newform(self): 

r""" 

Same as ``self.modular_form()``. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('37a1') 

sage: E.newform() 

q - 2*q^2 - 3*q^3 + 2*q^4 - 2*q^5 + O(q^6) 

sage: E.newform() == E.modular_form() 

True 

""" 

return self.modular_form() 

 

def q_eigenform(self, prec): 

r""" 

Synonym for ``self.q_expansion(prec)``. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('37a1') 

sage: E.q_eigenform(10) 

q - 2*q^2 - 3*q^3 + 2*q^4 - 2*q^5 + 6*q^6 - q^7 + 6*q^9 + O(q^10) 

sage: E.q_eigenform(10) == E.q_expansion(10) 

True 

""" 

return self.q_expansion(prec) 

 

def analytic_rank(self, algorithm="pari", leading_coefficient=False): 

r""" 

Return an integer that is *probably* the analytic rank of this 

elliptic curve. 

 

INPUT: 

 

- ``algorithm`` -- (default: 'pari'), String 

 

- ``'pari'`` -- use the PARI library function. 

- ``'sympow'`` -- use Watkins's program sympow 

- ``'rubinstein'`` -- use Rubinstein's L-function C++ program lcalc. 

- ``'magma'`` -- use MAGMA 

- ``'zero_sum'`` -- Use the rank bounding zero sum method implemented 

in self.analytic_rank_upper_bound() 

- ``'all'`` -- compute with PARI, sympow and lcalc, check that 

the answers agree, and return the common answer. 

 

- ``leading_coefficient`` -- (default: ``False``) Boolean; if set to 

True, return a tuple `(rank, lead)` where `lead` is the value of 

the first non-zero derivative of the L-function of the elliptic 

curve. Only implemented for algorithm='pari'. 

 

.. note:: 

 

If the curve is loaded from the large Cremona database, 

then the modular degree is taken from the database. 

 

Of the first three algorithms above, probably Rubinstein's is the 

most efficient (in some limited testing done). The zero sum method 

is often *much* faster, but can return a value which is strictly 

larger than the analytic rank. For curves with conductor <=10^9 

using default parameters, testing indicates that for 99.75% of 

curves the returned rank bound is the true rank. 

 

.. note:: 

 

If you use set_verbose(1), extra information about the computation 

will be printed when algorithm='zero_sum'. 

 

.. note:: 

 

It is an open problem to *prove* that *any* particular 

elliptic curve has analytic rank `\geq 4`. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('389a') 

sage: E.analytic_rank(algorithm='pari') 

2 

sage: E.analytic_rank(algorithm='rubinstein') 

2 

sage: E.analytic_rank(algorithm='sympow') 

2 

sage: E.analytic_rank(algorithm='magma') # optional - magma 

2 

sage: E.analytic_rank(algorithm='zero_sum') 

2 

sage: E.analytic_rank(algorithm='all') 

2 

 

With the optional parameter leading_coefficient set to ``True``, a 

tuple of both the analytic rank and the leading term of the 

L-series at `s = 1` is returned. This only works for algorithm=='pari':: 

 

sage: EllipticCurve([0,-1,1,-10,-20]).analytic_rank(leading_coefficient=True) 

(0, 0.25384186085591068...) 

sage: EllipticCurve([0,0,1,-1,0]).analytic_rank(leading_coefficient=True) 

(1, 0.30599977383405230...) 

sage: EllipticCurve([0,1,1,-2,0]).analytic_rank(leading_coefficient=True) 

(2, 1.518633000576853...) 

sage: EllipticCurve([0,0,1,-7,6]).analytic_rank(leading_coefficient=True) 

(3, 10.39109940071580...) 

sage: EllipticCurve([0,0,1,-7,36]).analytic_rank(leading_coefficient=True) 

(4, 196.170903794579...) 

 

TESTS: 

 

When the input is horrendous, some of the algorithms just bomb out with a RuntimeError:: 

 

sage: EllipticCurve([1234567,89101112]).analytic_rank(algorithm='rubinstein') 

Traceback (most recent call last): 

... 

RuntimeError: unable to compute analytic rank using rubinstein algorithm (unable to convert ' 6.19283e+19 and is too large' to an integer) 

sage: EllipticCurve([1234567,89101112]).analytic_rank(algorithm='sympow') 

Traceback (most recent call last): 

... 

RuntimeError: failed to compute analytic rank 

""" 

if algorithm == 'pari': 

rank_lead = self.pari_curve().ellanalyticrank() 

if leading_coefficient: 

return (rings.Integer(rank_lead[0]), rank_lead[1].sage()) 

else: 

return rings.Integer(self.pari_curve().ellanalyticrank()[0]) 

elif algorithm == 'rubinstein': 

if leading_coefficient: 

raise NotImplementedError("Cannot compute leading coefficient using rubinstein algorithm") 

try: 

from sage.lfunctions.lcalc import lcalc 

return lcalc.analytic_rank(L=self) 

except TypeError as msg: 

raise RuntimeError("unable to compute analytic rank using rubinstein algorithm (%s)"%msg) 

elif algorithm == 'sympow': 

if leading_coefficient: 

raise NotImplementedError("Cannot compute leading coefficient using sympow") 

from sage.lfunctions.sympow import sympow 

return sympow.analytic_rank(self)[0] 

elif algorithm == 'magma': 

if leading_coefficient: 

raise NotImplementedError("Cannot compute leading coefficient using magma") 

from sage.interfaces.all import magma 

return rings.Integer(magma(self).AnalyticRank()) 

elif algorithm == 'zero_sum': 

if leading_coefficient: 

s = "Cannot compute leading coefficient using the zero sum method" 

raise NotImplementedError(s) 

return self.analytic_rank_upper_bound() 

elif algorithm == 'all': 

if leading_coefficient: 

S = set([self.analytic_rank('pari', True)]) 

else: 

S = set([self.analytic_rank('pari'), 

self.analytic_rank('rubinstein'), self.analytic_rank('sympow')]) 

if len(S) != 1: 

raise RuntimeError("Bug in analytic_rank; algorithms don't agree! (E=%s)"%self) 

return list(S)[0] 

else: 

raise ValueError("algorithm %s not defined"%algorithm) 

 

def analytic_rank_upper_bound(self, 

max_Delta=None, 

adaptive=True, 

N=None, 

root_number="compute", 

bad_primes=None, 

ncpus=None): 

r""" 

Return an upper bound for the analytic rank of self, conditional on 

the Generalized Riemann Hypothesis, via computing 

the zero sum `\sum_{\gamma} f(\Delta\gamma),` where `\gamma` 

ranges over the imaginary parts of the zeros of `L(E,s)` 

along the critical strip, `f(x) = (\sin(\pi x)/(\pi x))^2`, 

and `\Delta` is the tightness parameter whose maximum value is specified 

by ``max_Delta``. This computation can be run on curves with very large 

conductor (so long as the conductor is known or quickly computable) 

when `\Delta` is not too large (see below). 

Uses Bober's rank bounding method as described in [Bob13]_. 

 

INPUT: 

 

- ``max_Delta`` -- (default: None) If not None, a positive real value 

specifying the maximum Delta value used in the zero sum; larger 

values of Delta yield better bounds - but runtime is exponential in 

Delta. If left as None, Delta is set 

to `\min\{\frac{1}{\pi}(\log(N+1000)/2-\log(2\pi)-\eta), 2.5\}`, 

where `N` is the conductor of the curve attached to self, and `\eta` 

is the Euler-Mascheroni constant `= 0.5772...`; the crossover 

point is at conductor around `8.3 \cdot 10^8`. For the former value, 

empirical results show that for about 99.7% of all curves the returned 

value is the actual analytic rank. 

 

- ``adaptive`` -- (default: True) Boolean 

 

- ``True`` -- the computation is first run with small and then 

successively larger `\Delta` values up to max_Delta. If at any 

point the computed bound is 0 (or 1 when root_number is -1 

or True), the computation halts and that value is returned; 

otherwise the minimum of the computed bounds is returned. 

- ``False`` -- the computation is run a single time with `\Delta` 

equal to ``max_Delta``, and the resulting bound returned. 

 

- ``N`` -- (default: None) If not None, a positive integer equal to 

the conductor of self. This is passable so that rank estimation 

can be done for curves whose (large) conductor has been precomputed. 

 

- ``root_number`` -- (default: "compute") String or integer 

 

- ``"compute"`` -- the root number of self is computed and used to 

(possibly) lower ther analytic rank estimate by 1. 

- ``"ignore"`` -- the above step is omitted 

- ``1`` -- this value is assumed to be the root number of 

self. This is passable so that rank estimation can be done for 

curves whose root number has been precomputed. 

- ``-1`` -- this value is assumed to be the root number of 

self. This is passable so that rank estimation can be done for 

curves whose root number has been precomputed. 

 

- ``bad_primes`` -- (default: None) If not None, a list of the primes 

of bad reduction for the curve attached to self. This is passable 

so that rank estimation can be done for curves of large conductor 

whose bad primes have been precomputed. 

 

- ``ncpus`` - (default: None) If not None, a positive integer 

defining the maximum number of CPUs to be used for the computation. 

If left as None, the maximum available number of CPUs will be used. 

Note: Due to parallelization overhead, multiple processors will 

only be used for Delta values `\ge 1.75`. 

 

.. NOTE:: 

 

Output will be incorrect if the incorrect conductor or root number 

is specified. 

 

.. WARNING:: 

 

Zero sum computation time is exponential in the tightness 

parameter `\Delta`, roughly doubling for every increase of 0.1 

thereof. Using `\Delta=1` (and adaptive=False) will yield a runtime 

of a few milliseconds; `\Delta=2` takes a few seconds, and `\Delta=3` 

may take upwards of an hour. Increase beyond this at your own risk! 

 

OUTPUT: 

 

A non-negative integer greater than or equal to the analytic rank of 

self. 

 

.. NOTE:: 

 

If you use set_verbose(1), extra information about the computation 

will be printed. 

 

.. SEEALSO:: 

 

:func:`LFunctionZeroSum` 

:meth:`.root_number` 

:func:`set_verbose` 

 

EXAMPLES: 

 

For most elliptic curves with small conductor the central zero(s) 

of `L_E(s)` are fairly isolated, so small values of `\Delta` 

will yield tight rank estimates. 

 

:: 

 

sage: E = EllipticCurve("11a") 

sage: E.rank() 

0 

sage: E.analytic_rank_upper_bound(max_Delta=1,adaptive=False) 

0 

sage: E = EllipticCurve([-39,123]) 

sage: E.rank() 

1 

sage: E.analytic_rank_upper_bound(max_Delta=1,adaptive=True) 

1 

 

This is especially true for elliptic curves with large rank. 

 

:: 

 

sage: for r in range(9): 

....: E = elliptic_curves.rank(r)[0] 

....: print((r, E.analytic_rank_upper_bound(max_Delta=1, 

....: adaptive=False,root_number="ignore"))) 

(0, 0) 

(1, 1) 

(2, 2) 

(3, 3) 

(4, 4) 

(5, 5) 

(6, 6) 

(7, 7) 

(8, 8) 

 

However, some curves have `L`-functions with low-lying zeroes, and for these 

larger values of `\Delta` must be used to get tight estimates. 

 

:: 

 

sage: E = EllipticCurve("974b1") 

sage: r = E.rank(); r 

0 

sage: E.analytic_rank_upper_bound(max_Delta=1,root_number="ignore") 

1 

sage: E.analytic_rank_upper_bound(max_Delta=1.3,root_number="ignore") 

0 

 

Knowing the root number of `E` allows us to use smaller Delta values 

to get tight bounds, thus speeding up runtime considerably. 

 

:: 

 

sage: E.analytic_rank_upper_bound(max_Delta=0.6,root_number="compute") 

0 

 

There are a small number of curves which have pathologically low-lying 

zeroes. For these curves, this method will produce a bound that is 

strictly larger than the analytic rank, unless very large values of 

Delta are used. The following curve ("256944c1" in the Cremona tables) 

is a rank 0 curve with a zero at 0.0256...; the smallest Delta value 

for which the zero sum is strictly less than 2 is ~2.815. 

 

:: 

 

sage: E = EllipticCurve([0, -1, 0, -7460362000712, -7842981500851012704]) 

sage: N,r = E.conductor(),E.analytic_rank(); N, r 

(256944, 0) 

sage: E.analytic_rank_upper_bound(max_Delta=1,adaptive=False) 

2 

sage: E.analytic_rank_upper_bound(max_Delta=2,adaptive=False) 

2 

 

This method is can be called on curves with large conductor. 

 

:: 

 

sage: E = EllipticCurve([-2934,19238]) 

sage: E.analytic_rank_upper_bound() 

1 

 

And it can bound rank on curves with *very* large conductor, so long as 

you know beforehand/can easily compute the conductor and primes of bad 

reduction less than `e^{2\pi\Delta}`. The example below is of the rank 

28 curve discovered by Elkies that is the elliptic curve of (currently) 

largest known rank. 

 

:: 

 

sage: a4 = -20067762415575526585033208209338542750930230312178956502 

sage: a6 = 34481611795030556467032985690390720374855944359319180361266008296291939448732243429 

sage: E = EllipticCurve([1,-1,1,a4,a6]) 

sage: bad_primes = [2,3,5,7,11,13,17,19,48463] 

sage: N = 3455601108357547341532253864901605231198511505793733138900595189472144724781456635380154149870961231592352897621963802238155192936274322687070 

sage: E.analytic_rank_upper_bound(max_Delta=2.37,adaptive=False, # long time 

....: N=N,root_number=1,bad_primes=bad_primes,ncpus=2) # long time 

32 

 

REFERENCES: 

 

.. [Bob13] \J.W. Bober. Conditionally bounding analytic ranks of elliptic curves. 

ANTS 10. http://msp.org/obs/2013/1-1/obs-v1-n1-p07-s.pdf 

 

""" 

Z = LFunctionZeroSum_EllipticCurve(self, N) 

bound = Z.analytic_rank_upper_bound(max_Delta=max_Delta, 

adaptive=adaptive, 

root_number=root_number, 

bad_primes=bad_primes, 

ncpus=ncpus) 

return bound 

 

def simon_two_descent(self, verbose=0, lim1=5, lim3=50, limtriv=3, 

maxprob=20, limbigprime=30, known_points=None): 

r""" 

Return lower and upper bounds on the rank of the Mordell-Weil 

group `E(\QQ)` and a list of points of infinite order. 

 

INPUT: 

 

- ``self`` -- an elliptic curve `E` over `\QQ` 

 

- ``verbose`` -- 0, 1, 2, or 3 (default: 0), the verbosity level 

 

- ``lim1`` -- (default: 5) limit on trivial points on quartics 

 

- ``lim3`` -- (default: 50) limit on points on ELS quartics 

 

- ``limtriv`` -- (default: 3) limit on trivial points on `E` 

 

- ``maxprob`` -- (default: 20) 

 

- ``limbigprime`` - (default: 30) to distinguish between small 

and large prime numbers. Use probabilistic tests for large 

primes. If 0, don't any probabilistic tests. 

 

- ``known_points`` -- (default: None) list of known points on 

the curve 

 

OUTPUT: a triple ``(lower, upper, list)`` consisting of 

 

- ``lower`` (integer) -- lower bound on the rank 

 

- ``upper`` (integer) -- upper bound on the rank 

 

- ``list`` -- list of points of infinite order in `E(\QQ)` 

 

The integer ``upper`` is in fact an upper bound on the 

dimension of the 2-Selmer group, hence on the dimension of 

`E(\QQ)/2E(\QQ)`. It is equal to the dimension of the 

2-Selmer group except possibly if `E(\QQ)[2]` has dimension 1. 

In that case, ``upper`` may exceed the dimension of the 

2-Selmer group by an even number, due to the fact that the 

algorithm does not perform a second descent. 

 

To obtain a list of generators, use E.gens(). 

 

IMPLEMENTATION: Uses Denis Simon's PARI/GP scripts from 

http://www.math.unicaen.fr/~simon/ 

 

EXAMPLES: 

 

We compute the ranks of the curves of lowest known conductor up to 

rank `8`. Amazingly, each of these computations finishes 

almost instantly! 

 

:: 

 

sage: E = EllipticCurve('11a1') 

sage: E.simon_two_descent() 

(0, 0, []) 

sage: E = EllipticCurve('37a1') 

sage: E.simon_two_descent() 

(1, 1, [(0 : 0 : 1)]) 

sage: E = EllipticCurve('389a1') 

sage: E._known_points = [] # clear cached points 

sage: E.simon_two_descent() 

(2, 2, [(1 : 0 : 1), (-11/9 : 28/27 : 1)]) 

sage: E = EllipticCurve('5077a1') 

sage: E.simon_two_descent() 

(3, 3, [(1 : 0 : 1), (2 : 0 : 1), (0 : 2 : 1)]) 

 

In this example Simon's program does not find any points, though it 

does correctly compute the rank of the 2-Selmer group. 

 

:: 

 

sage: E = EllipticCurve([1, -1, 0, -751055859, -7922219731979]) 

sage: E.simon_two_descent() 

(1, 1, []) 

 

The rest of these entries were taken from Tom Womack's page 

http://tom.womack.net/maths/conductors.htm 

 

:: 

 

sage: E = EllipticCurve([1, -1, 0, -79, 289]) 

sage: E.simon_two_descent() 

(4, 4, [(6 : -1 : 1), (4 : 3 : 1), (5 : -2 : 1), (8 : 7 : 1)]) 

sage: E = EllipticCurve([0, 0, 1, -79, 342]) 

sage: E.simon_two_descent() # long time (9s on sage.math, 2011) 

(5, 5, [(5 : 8 : 1), (10 : 23 : 1), (3 : 11 : 1), (-3 : 23 : 1), (0 : 18 : 1)]) 

sage: E = EllipticCurve([1, 1, 0, -2582, 48720]) 

sage: r, s, G = E.simon_two_descent(); r,s 

(6, 6) 

sage: E = EllipticCurve([0, 0, 0, -10012, 346900]) 

sage: r, s, G = E.simon_two_descent(); r,s 

(7, 7) 

sage: E = EllipticCurve([0, 0, 1, -23737, 960366]) 

sage: r, s, G = E.simon_two_descent(); r,s 

(8, 8) 

 

Example from :trac:`10832`:: 

 

sage: E = EllipticCurve([1,0,0,-6664,86543]) 

sage: E.simon_two_descent() 

(2, 3, [(-1/4 : 2377/8 : 1), (323/4 : 1891/8 : 1)]) 

sage: E.rank() 

2 

sage: E.gens() 

[(-1/4 : 2377/8 : 1), (323/4 : 1891/8 : 1)] 

 

Example where the lower bound is known to be 1 

despite that the algorithm has not found any 

points of infinite order :: 

 

sage: E = EllipticCurve([1, 1, 0, -23611790086, 1396491910863060]) 

sage: E.simon_two_descent() 

(1, 2, []) 

sage: E.rank() 

1 

sage: E.gens() # uses mwrank 

[(4311692542083/48594841 : -13035144436525227/338754636611 : 1)] 

 

Example for :trac:`5153`:: 

 

sage: E = EllipticCurve([3,0]) 

sage: E.simon_two_descent() 

(1, 2, [(1 : 2 : 1)]) 

 

The upper bound on the 2-Selmer rank returned by this method 

need not be sharp. In following example, the upper bound 

equals the actual 2-Selmer rank plus 2 (see :trac:`10735`):: 

 

sage: E = EllipticCurve('438e1') 

sage: E.simon_two_descent() 

(0, 3, []) 

sage: E.selmer_rank() # uses mwrank 

1 

 

""" 

t = EllipticCurve_number_field.simon_two_descent(self, verbose=verbose, 

lim1=lim1, lim3=lim3, limtriv=limtriv, 

maxprob=maxprob, limbigprime=limbigprime, 

known_points=known_points) 

rank_low_bd = t[0] 

two_selmer_rank = t[1] 

pts = t[2] 

if rank_low_bd == two_selmer_rank - self.two_torsion_rank(): 

if verbose>0: 

print("Rank determined successfully, saturating...") 

gens = self.saturation(pts)[0] 

if len(gens) == rank_low_bd: 

self.__gens = (gens, True) 

self.__rank = (Integer(rank_low_bd), True) 

 

return rank_low_bd, two_selmer_rank, pts 

 

two_descent_simon = simon_two_descent 

 

def three_selmer_rank(self, algorithm='UseSUnits'): 

r""" 

Return the 3-selmer rank of this elliptic curve, computed using 

Magma. 

 

INPUT: 

 

 

- ``algorithm`` - 'Heuristic' (which is usually much 

faster in large examples), 'FindCubeRoots', or 'UseSUnits' 

(default) 

 

 

OUTPUT: nonnegative integer 

 

EXAMPLES: A rank 0 curve:: 

 

sage: EllipticCurve('11a').three_selmer_rank() # optional - magma 

0 

 

A rank 0 curve with rational 3-isogeny but no 3-torsion 

 

:: 

 

sage: EllipticCurve('14a3').three_selmer_rank() # optional - magma 

0 

 

A rank 0 curve with rational 3-torsion:: 

 

sage: EllipticCurve('14a1').three_selmer_rank() # optional - magma 

1 

 

A rank 1 curve with rational 3-isogeny:: 

 

sage: EllipticCurve('91b').three_selmer_rank() # optional - magma 

2 

 

A rank 0 curve with nontrivial 3-Sha. The Heuristic option makes 

this about twice as fast as without it. 

 

:: 

 

sage: EllipticCurve('681b').three_selmer_rank(algorithm='Heuristic') # long time (10 seconds); optional - magma 

2 

""" 

from sage.interfaces.all import magma 

E = magma(self) 

return Integer(E.ThreeSelmerGroup(MethodForFinalStep = magma('"%s"'%algorithm)).Ngens()) 

 

def rank(self, use_database=True, verbose=False, 

only_use_mwrank=True, 

algorithm='mwrank_lib', 

proof=None): 

""" 

Return the rank of this elliptic curve, assuming no conjectures. 

 

If we fail to provably compute the rank, raises a RuntimeError 

exception. 

 

INPUT: 

 

- ``use_database (bool)`` -- (default: ``True``), if 

``True``, try to look up the rank in the Cremona database. 

 

- ``verbose`` - (default: ``False``), if specified changes 

the verbosity of mwrank computations. 

 

- ``algorithm`` - (default: 'mwrank_lib'), one of: 

 

- ``'mwrank_shell'`` - call mwrank shell command 

 

- ``'mwrank_lib'`` - call mwrank c library 

 

- ``only_use_mwrank`` - (default: True) if False try 

using analytic rank methods first. 

 

- ``proof`` - bool or None (default: None, see 

proof.elliptic_curve or sage.structure.proof). Note that results 

obtained from databases are considered proof = True 

 

OUTPUT: the rank of the elliptic curve as :class:`Integer` 

 

IMPLEMENTATION: Uses L-functions, mwrank, and databases. 

 

EXAMPLES:: 

 

sage: EllipticCurve('11a').rank() 

0 

sage: EllipticCurve('37a').rank() 

1 

sage: EllipticCurve('389a').rank() 

2 

sage: EllipticCurve('5077a').rank() 

3 

sage: EllipticCurve([1, -1, 0, -79, 289]).rank() # This will use the default proof behavior of True 

4 

sage: EllipticCurve([0, 0, 1, -79, 342]).rank(proof=False) 

5 

sage: EllipticCurve([0, 0, 1, -79, 342]).simon_two_descent()[0] # long time (7s on sage.math, 2012) 

5 

 

Examples with denominators in defining equations:: 

 

sage: E = EllipticCurve([0, 0, 0, 0, -675/4]) 

sage: E.rank() 

0 

sage: E = EllipticCurve([0, 0, 1/2, 0, -1/5]) 

sage: E.rank() 

1 

sage: E.minimal_model().rank() 

1 

 

A large example where mwrank doesn't determine the result with certainty:: 

 

sage: EllipticCurve([1,0,0,0,37455]).rank(proof=False) 

0 

sage: EllipticCurve([1,0,0,0,37455]).rank(proof=True) 

Traceback (most recent call last): 

... 

RuntimeError: rank not provably correct (lower bound: 0) 

 

TESTS:: 

 

sage: EllipticCurve([1,10000]).rank(algorithm="garbage") 

Traceback (most recent call last): 

... 

ValueError: unknown algorithm 'garbage' 

 

Since :trac:`23962`, the default is to use the Cremona 

database. We also check that the result is cached correctly:: 

 

sage: E = EllipticCurve([-517, -4528]) # 1888b1 

sage: E.rank(use_database=False) 

Traceback (most recent call last): 

... 

RuntimeError: rank not provably correct (lower bound: 0) 

sage: E._EllipticCurve_rational_field__rank 

(0, False) 

sage: E.rank() 

0 

sage: E._EllipticCurve_rational_field__rank 

(0, True) 

""" 

if proof is None: 

from sage.structure.proof.proof import get_flag 

proof = get_flag(proof, "elliptic_curve") 

else: 

proof = bool(proof) 

 

if self.__rank: 

rank, proven = self.__rank 

if proven or not proof: 

return rank 

 

if use_database: 

try: 

rank = Integer(self.database_attributes()['rank']) 

except LookupError: 

# curve not in database, or rank not known 

pass 

else: 

self.__rank = (rank, True) 

return rank 

 

if not only_use_mwrank: 

# Try zero sum rank bound first; if this is 0 or 1 it's the 

# true rank 

rank_bound = self.analytic_rank_upper_bound() 

if rank_bound <= 1: 

misc.verbose("rank %s due to zero sum bound and parity"%rank_bound) 

rank = Integer(rank_bound) 

self.__rank = (rank, proof) 

return rank 

# Next try evaluate the L-function or its derivative at the 

# central point 

N = self.conductor() 

prec = int(4*float(sqrt(N))) + 10 

if self.root_number() == 1: 

L, err = self.lseries().at1(prec) 

if abs(L) > err + R(0.0001): # definitely doesn't vanish 

misc.verbose("rank 0 because L(E,1)=%s"%L) 

rank = Integer(0) 

self.__rank = (rank, proof) 

return rank 

else: 

Lprime, err = self.lseries().deriv_at1(prec) 

if abs(Lprime) > err + R(0.0001): # definitely doesn't vanish 

misc.verbose("rank 1 because L'(E,1)=%s"%Lprime) 

rank = Integer(1) 

self.__rank = (rank, proof) 

return rank 

 

if algorithm == 'mwrank_lib': 

misc.verbose("using mwrank lib") 

if self.is_integral(): E = self 

else: E = self.integral_model() 

C = E.mwrank_curve() 

C.set_verbose(verbose) 

rank = Integer(C.rank()) 

proven = C.certain() 

self.__rank = (rank, proven) 

if not proven: 

if proof: 

print("Unable to compute the rank with certainty (lower bound=%s)." % rank) 

print("This could be because Sha(E/Q)[2] is nontrivial.") 

print("Try calling something like two_descent(second_limit=13) on the") 

print("curve then trying this command again. You could also try rank") 

print("with only_use_mwrank=False.") 

del E.__mwrank_curve 

raise RuntimeError('rank not provably correct (lower bound: {})'.format(rank)) 

else: 

misc.verbose("Warning -- rank not proven correct", level=1) 

return rank 

 

if algorithm == 'mwrank_shell': 

misc.verbose("using mwrank shell") 

X = self.mwrank() 

if 'determined unconditionally' not in X or 'only a lower bound of' in X: 

if proof: 

X= "".join(X.split("\n")[-4:-2]) 

print(X) 

raise RuntimeError('rank not provably correct') 

else: 

misc.verbose("Warning -- rank not proven correct", level=1) 

 

s = "lower bound of" 

X = X[X.rfind(s)+len(s)+1:] 

rank = Integer(X.split()[0]) 

else: 

if proof is False: 

proof = True #since we actually provably found the rank 

match = 'Rank =' 

i = X.find(match) 

if i == -1: 

match = 'found points of rank' 

i = X.find(match) 

if i == -1: 

raise RuntimeError("%s\nbug -- tried to find 'Rank =' or 'found points of rank' in mwrank output but couldn't."%X) 

j = i + X[i:].find('\n') 

rank = Integer(X[i+len(match)+1:j]) 

self.__rank = (rank, proof) 

return rank 

 

raise ValueError("unknown algorithm {!r}".format(algorithm)) 

 

def gens(self, proof=None, **kwds): 

""" 

Return generators for the Mordell-Weil group E(Q) *modulo* 

torsion. 

 

INPUT: 

 

- ``proof`` -- bool or None (default None), see 

``proof.elliptic_curve`` or ``sage.structure.proof`` 

 

- ``verbose`` - (default: None), if specified changes the 

verbosity of mwrank computations 

 

- ``rank1_search`` - (default: 10), if the curve has analytic 

rank 1, try to find a generator by a direct search up to 

this logarithmic height. If this fails, the usual mwrank 

procedure is called. 

 

- algorithm -- one of the following: 

 

- ``'mwrank_shell'`` (default) -- call mwrank shell command 

 

- ``'mwrank_lib'`` -- call mwrank C library 

 

- ``only_use_mwrank`` -- bool (default True) if False, first 

attempts to use more naive, natively implemented methods 

 

- ``use_database`` -- bool (default True) if True, attempts to 

find curve and gens in the (optional) database 

 

- ``descent_second_limit`` -- (default: 12) used in 2-descent 

 

- ``sat_bound`` -- (default: 1000) bound on primes used in 

saturation. If the computed bound on the index of the 

points found by two-descent in the Mordell-Weil group is 

greater than this, a warning message will be displayed. 

 

OUTPUT: 

 

- ``generators`` - list of generators for the Mordell-Weil 

group modulo torsion 

 

.. NOTE:: 

 

If you call this with ``proof=False``, then you can use the 

:meth:`~gens_certain` method to find out afterwards 

whether the generators were proved. 

 

IMPLEMENTATION: Uses Cremona's mwrank C library. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('389a') 

sage: E.gens() # random output 

[(-1 : 1 : 1), (0 : 0 : 1)] 

 

A non-integral example:: 

 

sage: E = EllipticCurve([-3/8,-2/3]) 

sage: E.gens() # random (up to sign) 

[(10/9 : 29/54 : 1)] 

 

A non-minimal example:: 

 

sage: E = EllipticCurve('389a1') 

sage: E1 = E.change_weierstrass_model([1/20,0,0,0]); E1 

Elliptic Curve defined by y^2 + 8000*y = x^3 + 400*x^2 - 320000*x over Rational Field 

sage: E1.gens() # random (if database not used) 

[(-400 : 8000 : 1), (0 : -8000 : 1)] 

""" 

if proof is None: 

from sage.structure.proof.proof import get_flag 

proof = get_flag(proof, "elliptic_curve") 

else: 

proof = bool(proof) 

 

# If the gens are already cached, return them: 

if self.__gens: 

gens, proven = self.__gens 

if proven or not proof: 

return list(gens) # Return a copy 

 

gens, proved = self._compute_gens(proof, **kwds) 

self.__gens = (gens, proved) 

self.__rank = (Integer(len(gens)), proved) 

self._known_points = gens 

return list(gens) 

 

def _compute_gens(self, proof, 

verbose=False, 

rank1_search=10, 

algorithm='mwrank_lib', 

only_use_mwrank=True, 

use_database=True, 

descent_second_limit=12, 

sat_bound=1000): 

""" 

Return generators for the Mordell-Weil group E(Q) *modulo* 

torsion. 

 

INPUT: 

 

Same as for :meth:`~gens`, except ``proof`` must be either 

``True`` or ``False`` (not ``None``). 

 

OUTPUT: 

 

A tuple ``(generators, proved)``, where ``generators`` is a 

probable list of generators for the Mordell-Weil group modulo 

torsion, and ``proved`` is ``True`` or ``False`` depending on 

whether the result is provably correct. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve([-3/8, -2/3]) 

sage: gens, proved = E._compute_gens(proof=False) 

sage: proved 

True 

 

""" 

# If the optional extended database is installed and an 

# isomorphic curve is in the database then its gens will be 

# known; if only the default database is installed, the rank 

# will be known but not the gens. 

 

if use_database: 

try: 

E = self.minimal_model() 

data = self.database_attributes() 

iso = E.isomorphism_to(self) 

return [iso(E(P)) for P in data['gens']], True 

except LookupError: 

# curve not in database, or generators not known 

pass 

 

if self.conductor() > 10**7: 

only_use_mwrank = True 

 

if not only_use_mwrank: 

try: 

misc.verbose("Trying to compute rank.") 

r = self.rank(only_use_mwrank = False) 

misc.verbose("Got r = %s."%r) 

if r == 0: 

misc.verbose("Rank = 0, so done.") 

return [], True 

if r == 1 and rank1_search: 

misc.verbose("Rank = 1, so using direct search.") 

h = 6 

while h <= rank1_search: 

misc.verbose("Trying direct search up to height %s"%h) 

G = self.point_search(h, verbose) 

G = [P for P in G if P.order() == oo] 

if len(G) > 0: 

misc.verbose("Direct search succeeded.") 

G, _, _ = self.saturation(G, verbose=verbose) 

misc.verbose("Computed saturation.") 

return G, True 

h += 2 

misc.verbose("Direct search FAILED.") 

except RuntimeError: 

pass 

# end if (not_use_mwrank) 

if algorithm == "mwrank_lib": 

misc.verbose("Calling mwrank C++ library.") 

if not self.is_integral(): 

xterm = 1; yterm = 1 

ai = self.a_invariants() 

for a in ai: 

if not a.is_integral(): 

for p, _ in a.denom().factor(): 

e = min([(ai[i].valuation(p)/[1,2,3,4,6][i]) for i in range(5)]).floor() 

ai = [ai[i]/p**(e*[1,2,3,4,6][i]) for i in range(5)] 

xterm *= p**(2*e) 

yterm *= p**(3*e) 

E = constructor.EllipticCurve(list(ai)) 

else: 

E = self; xterm = 1; yterm = 1 

C = E.mwrank_curve(verbose) 

if not (verbose is None): 

C.set_verbose(verbose) 

C.two_descent(verbose=verbose, second_limit=descent_second_limit) 

C.saturate(bound=sat_bound) 

G = C.gens() 

if proof is True and C.certain() is False: 

del self.__mwrank_curve 

raise RuntimeError("Unable to compute the rank, hence generators, with certainty (lower bound=%s, generators found=%s). This could be because Sha(E/Q)[2] is nontrivial."%(C.rank(),G) + \ 

"\nTry increasing descent_second_limit then trying this command again.") 

proved = C.certain() 

G = [[x*xterm,y*yterm,z] for x,y,z in G] 

else: 

# when gens() calls mwrank it passes the command-line 

# parameter "-p 100" which helps curves with large 

# coefficients and 2-torsion and is otherwise harmless. 

# This is pending a more intelligent handling of mwrank 

# options in gens() (which is nontrivial since gens() needs 

# to parse the output from mwrank and this is seriously 

# affected by what parameters the user passes!). 

# In fact it would be much better to avoid the mwrank console at 

# all for gens() and just use the library. This is in 

# progress (see trac #1949). 

X = self.mwrank('-p 100 -S '+str(sat_bound)) 

misc.verbose("Calling mwrank shell.") 

if not 'The rank and full Mordell-Weil basis have been determined unconditionally' in X: 

msg = 'Generators not provably computed.' 

if proof: 

raise RuntimeError('%s\n%s'%(X,msg)) 

else: 

misc.verbose("Warning -- %s"%msg, level=1) 

proved = False 

else: 

proved = True 

G = [] 

i = X.find('Generator ') 

while i != -1: 

j = i + X[i:].find(';') 

k = i + X[i:].find('[') 

G.append(eval(X[k:j].replace(':',','))) 

X = X[j:] 

i = X.find('Generator ') 

G = sorted([self.point(x, check=True) for x in G]) 

return G, proved 

 

def gens_certain(self): 

""" 

Return ``True`` if the generators have been proven correct. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('37a1') 

sage: E.gens() # random (up to sign) 

[(0 : -1 : 1)] 

sage: E.gens_certain() 

True 

 

TESTS:: 

 

sage: E = EllipticCurve([2, 4, 6, 8, 10]) 

sage: E.gens_certain() 

Traceback (most recent call last): 

... 

RuntimeError: no generators have been computed yet 

""" 

if not self.__gens: 

raise RuntimeError("no generators have been computed yet") 

return self.__gens[1] 

 

def ngens(self, proof=None): 

""" 

Return the number of generators of this elliptic curve. 

 

.. NOTE:: 

 

See :meth:`gens` for further documentation. The function 

:meth:`ngens` calls :meth:`gens` if not already done, but 

only with default parameters. Better results may be 

obtained by calling :meth:`mwrank` with carefully chosen 

parameters. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('37a1') 

sage: E.ngens() 

1 

 

sage: E = EllipticCurve([0,0,0,877,0]) 

sage: E.ngens() 

1 

 

sage: print(E.mwrank('-v0 -b12 -l')) 

Curve [0,0,0,877,0] : Rank = 1 

Generator 1 is [29604565304828237474403861024284371796799791624792913256602210:-256256267988926809388776834045513089648669153204356603464786949:490078023219787588959802933995928925096061616470779979261000]; height 95.980371987964 

Regulator = 95.980... 

""" 

return len(self.gens(proof = proof)) 

 

def regulator(self, proof=None, precision=53, **kwds): 

r""" 

Return the regulator of this curve, which must be defined over `\QQ`. 

 

INPUT: 

 

- ``proof`` -- bool or ``None`` (default: ``None``, see 

proof.[tab] or sage.structure.proof). Note that results from 

databases are considered proof = True 

 

- ``precision`` -- (int, default 53): the precision in bits of 

the result 

 

- ``**kwds`` -- passed to :meth:`gens()` method 

 

EXAMPLES:: 

 

sage: E = EllipticCurve([0, 0, 1, -1, 0]) 

sage: E.regulator() 

0.0511114082399688 

sage: EllipticCurve('11a').regulator() 

1.00000000000000 

sage: EllipticCurve('37a').regulator() 

0.0511114082399688 

sage: EllipticCurve('389a').regulator() 

0.152460177943144 

sage: EllipticCurve('5077a').regulator() 

0.41714355875838... 

sage: EllipticCurve([1, -1, 0, -79, 289]).regulator() 

1.50434488827528 

sage: EllipticCurve([0, 0, 1, -79, 342]).regulator(proof=False) # long time (6s on sage.math, 2011) 

14.790527570131... 

""" 

R = rings.RealField(precision) 

 

if proof is None: 

from sage.structure.proof.proof import get_flag 

proof = get_flag(proof, "elliptic_curve") 

else: 

proof = bool(proof) 

 

# We return a cached value if it exists and has sufficient precision: 

if self.__regulator: 

reg, proven = self.__regulator 

if proven or not proof: 

# Coerce to the target field R. This will fail if the 

# precision was too low. 

try: 

return R.coerce(reg) 

except TypeError: 

pass 

 

G = self.gens(proof=proof, **kwds) 

 

# Compute the regulator of the generators found: 

reg = self.regulator_of_points(G, precision=precision) 

self.__regulator = (reg, self.gens_certain()) 

assert reg.parent() is R 

return reg 

 

def saturation(self, points, verbose=False, max_prime=0, odd_primes_only=False): 

""" 

Given a list of rational points on E, compute the saturation in 

E(Q) of the subgroup they generate. 

 

INPUT: 

 

 

- ``points (list)`` - list of points on E 

 

- ``verbose (bool)`` - (default: ``False``), if ``True``, give 

verbose output 

 

- ``max_prime (int)`` - (default: 0), saturation is 

performed for all primes up to max_prime. If max_prime==0, 

perform saturation at *all* primes, i.e., compute the true 

saturation. 

 

- ``odd_primes_only (bool)`` - only do saturation at 

odd primes 

 

 

OUTPUT: 

 

 

- ``saturation (list)`` - points that form a basis for 

the saturation 

 

- ``index (int)`` - the index of the group generated 

by points in their saturation 

 

- ``regulator (real with default precision)`` - 

regulator of saturated points. 

 

 

ALGORITHM: Uses Cremona's ``mwrank`` package. With ``max_prime=0``, 

we call ``mwrank`` with successively larger prime bounds until the full 

saturation is provably found. The results of saturation at the 

previous primes is stored in each case, so this should be 

reasonably fast. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('37a1') 

sage: P=E(0,0) 

sage: Q=5*P; Q 

(1/4 : -5/8 : 1) 

sage: E.saturation([Q]) 

([(0 : 0 : 1)], 5, 0.0511114082399688) 

 

TESTS: 

 

See :trac:`10590`. This example would loop forever at default precision:: 

 

sage: E = EllipticCurve([1, 0, 1, -977842, -372252745]) 

sage: P = E([-192128125858676194585718821667542660822323528626273/336995568430319276695106602174283479617040716649, 70208213492933395764907328787228427430477177498927549075405076353624188436/195630373799784831667835900062564586429333568841391304129067339731164107, 1]) 

sage: P.height() 

113.302910926080 

sage: E.saturation([P]) 

([(-192128125858676194585718821667542660822323528626273/336995568430319276695106602174283479617040716649 : 70208213492933395764907328787228427430477177498927549075405076353624188436/195630373799784831667835900062564586429333568841391304129067339731164107 : 1)], 1, 113.302910926080) 

sage: (Q,), ind, reg = E.saturation([2*P]) # needs higher precision, handled by eclib 

sage: 2*Q == 2*P 

True 

sage: ind 

2 

sage: reg 

113.302910926080 

 

See :trac:`10840`. This used to cause eclib to crash since the 

curve is non-minimal at 2:: 

 

sage: E = EllipticCurve([0,0,0,-13711473216,0]) 

sage: P = E([-19992,16313472]) 

sage: Q = E([-24108,-17791704]) 

sage: R = E([-97104,-20391840]) 

sage: S = E([-113288,-9969344]) 

sage: E.saturation([P,Q,R,S]) 

([(-19992 : 16313472 : 1), (-24108 : -17791704 : 1), (-97104 : -20391840 : 1), (-113288 : -9969344 : 1)], 1, 172.792031341679) 

 

""" 

if not isinstance(points, list): 

raise TypeError("points (=%s) must be a list."%points) 

if len(points) == 0: 

return [], None, R(1) 

 

v = [] 

for P in points: 

if not isinstance(P, ell_point.EllipticCurvePoint_field): 

P = self(P) 

elif P.curve() != self: 

raise ArithmeticError("point (=%s) must be %s."%(P,self)) 

 

minimal = True 

if not self.is_minimal(): 

minimal = False 

Emin = self.minimal_model() 

phi = self.isomorphism_to(Emin) 

points = [phi(P) for P in points] 

else: 

Emin = self 

 

for P in points: 

x, y = P.xy() 

d = x.denominator().lcm(y.denominator()) 

v.append((x*d, y*d, d)) 

 

c = Emin.mwrank_curve() 

mw = mwrank.mwrank_MordellWeil(c, verbose) 

mw.process(v) 

repeat_until_saturated = False 

if max_prime == 0: 

repeat_until_saturated = True 

max_prime = 9973 

from sage.libs.all import mwrank_get_precision, mwrank_set_precision 

prec0 = mwrank_get_precision() 

prec = 100 

if prec0<prec: 

mwrank_set_precision(prec) 

else: 

prec = prec0 

while True: 

ok, index, unsat = mw.saturate(max_prime=max_prime, odd_primes_only = odd_primes_only) 

reg = mw.regulator() 

if ok or not repeat_until_saturated: break 

max_prime = arith.next_prime(max_prime + 1000) 

prec += 50 

mwrank_set_precision(prec) 

if prec!=prec0: mwrank_set_precision(prec0) 

sat = mw.points() 

sat = [Emin(P) for P in sat] 

if not minimal: 

phi_inv = ~phi 

sat = [phi_inv(P) for P in sat] 

reg = self.regulator_of_points(sat) 

return sat, index, R(reg) 

 

 

def CPS_height_bound(self): 

r""" 

Return the Cremona-Prickett-Siksek height bound. This is a 

floating point number B such that if P is a rational point on 

the curve, then `h(P) \le \hat{h}(P) + B`, where `h(P)` is 

the naive logarithmic height of `P` and `\hat{h}(P)` is the 

canonical height. 

 

.. SEEALSO:: 

 

:meth:`silverman_height_bound` for a bound that also works for 

points over number fields. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve("11a") 

sage: E.CPS_height_bound() 

2.8774743273580445 

sage: E = EllipticCurve("5077a") 

sage: E.CPS_height_bound() 

0.0 

sage: E = EllipticCurve([1,2,3,4,1]) 

sage: E.CPS_height_bound() 

Traceback (most recent call last): 

... 

RuntimeError: curve must be minimal. 

sage: F = E.quadratic_twist(-19) 

sage: F 

Elliptic Curve defined by y^2 + x*y + y = x^3 - x^2 + 1376*x - 130 over Rational Field 

sage: F.CPS_height_bound() 

0.6555158376972852 

 

IMPLEMENTATION: 

 

Call the corresponding mwrank C++ library function. Note that 

the formula in the [CPS]_ paper is given for number fields. It is 

only the implementation in Sage that restricts to the rational 

field. 

""" 

if not self.is_minimal(): 

raise RuntimeError("curve must be minimal.") 

return self.mwrank_curve().CPS_height_bound() 

 

 

def silverman_height_bound(self, algorithm='default'): 

r""" 

Return the Silverman height bound. This is a positive real 

(floating point) number B such that for all points `P` on the 

curve over any number field, `|h(P) - \hat{h}(P)| \leq B`, 

where `h(P)` is the naive logarithmic height of `P` and 

`\hat{h}(P)` is the canonical height. 

 

INPUT: 

 

- ``algorithm`` -- 

 

- 'default' (default) -- compute using a Python 

implementation in Sage 

 

- 'mwrank' -- use a C++ implementation in the mwrank 

library 

 

NOTES: 

 

- The CPS_height_bound is often better (i.e. smaller) than 

the Silverman bound, but it only applies for points over 

the base field, whereas the Silverman bound works over 

all number fields. 

 

- The Silverman bound is also fairly straightforward to 

compute over number fields, but isn't implemented here. 

 

- Silverman's paper is 'The Difference Between the Weil 

Height and the Canonical Height on Elliptic Curves', 

Math. Comp., Volume 55, Number 192, pages 723-743. We 

use a correction by Bremner with 0.973 replaced by 0.961, 

as explained in the source code to mwrank (htconst.cc). 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('37a1') 

sage: E.silverman_height_bound() 

4.825400758180918 

sage: E.silverman_height_bound(algorithm='mwrank') 

4.825400758180918 

sage: E.CPS_height_bound() 

0.16397076103046915 

""" 

if algorithm == 'default': 

Delta = self.discriminant() 

j = self.j_invariant() 

b2 = self.b2() 

twostar = 2 if b2 else 1 

from math import log 

def h(x): 

return log(max(abs(x.numerator()), abs(x.denominator()))) 

def h_oo(x): 

return log(max(abs(x),1)) 

mu = h(Delta)/12 + h_oo(j)/12 + h_oo(b2/12)/2 + log(twostar)/2 

lower = 2*(-h(j)/24 - mu - 0.961) 

upper = 2*(mu + 1.07) 

return max(abs(lower), abs(upper)) 

elif algorithm == 'mwrank': 

return self.mwrank_curve().silverman_bound() 

else: 

raise ValueError("unknown algorithm '%s'"%algorithm) 

 

def point_search(self, height_limit, verbose=False, rank_bound=None): 

""" 

Search for points on a curve up to an input bound on the naive 

logarithmic height. 

 

INPUT: 

 

 

- ``height_limit (float)`` - bound on naive height 

 

- ``verbose (bool)`` - (default: ``False``) 

 

If ``True``, report on the saturation process. 

 

If ``False``, just return the result. 

 

- ``rank_bound (bool)`` - (default: ``None``) 

 

If provided, stop saturating once we find this many 

independent nontorsion points. 

 

OUTPUT: points (list) - list of independent points which generate 

the subgroup of the Mordell-Weil group generated by the points 

found and then saturated. 

 

.. warning:: 

 

height_limit is logarithmic, so increasing by 1 will cause 

the running time to increase by a factor of approximately 

4.5 (=exp(1.5)). 

 

IMPLEMENTATION: Uses Michael Stoll's ratpoints module in PARI/GP. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('389a1') 

sage: E.point_search(5, verbose=False) 

[(-1 : 1 : 1), (0 : 0 : 1)] 

 

Increasing the height_limit takes longer, but finds no more 

points:: 

 

sage: E.point_search(10, verbose=False) 

[(-1 : 1 : 1), (0 : 0 : 1)] 

 

In fact this curve has rank 2 so no more than 2 points will ever be 

output, but we are not using this fact. 

 

:: 

 

sage: E.saturation(_) 

([(-1 : 1 : 1), (0 : 0 : 1)], 1, 0.152460177943144) 

 

What this shows is that if the rank is 2 then the points listed do 

generate the Mordell-Weil group (mod torsion). Finally, 

 

:: 

 

sage: E.rank() 

2 

 

If we only need one independent generator:: 

 

sage: E.point_search(5, verbose=False, rank_bound=1) 

[(-2 : 0 : 1)] 

""" 

# Convert logarithmic height to height 

# max(|p|,|q|) <= H, if x = p/q coprime 

H = pari.exp(height_limit).floor() 

 

points = [] 

for x, y in self.pari_curve().ellratpoints(H): 

P = self((x, y, 1)) 

points.append(P) 

if rank_bound is not None: 

points = self.saturation(points, verbose=verbose)[0] 

if len(points) >= rank_bound: 

return points 

if rank_bound is None: 

points = self.saturation(points, verbose=verbose)[0] 

return points 

 

def selmer_rank(self): 

""" 

The rank of the 2-Selmer group of the curve. 

 

EXAMPLES: The following is the curve 960D1, which has rank 0, but 

Sha of order 4. 

 

:: 

 

sage: E = EllipticCurve([0, -1, 0, -900, -10098]) 

sage: E.selmer_rank() 

3 

 

Here the Selmer rank is equal to the 2-torsion rank (=1) plus 

the 2-rank of Sha (=2), and the rank itself is zero:: 

 

sage: E.rank() 

0 

 

In contrast, for the curve 571A, also with rank 0 and Sha of 

order 4, we get a worse bound:: 

 

sage: E = EllipticCurve([0, -1, 1, -929, -10595]) 

sage: E.selmer_rank() 

2 

sage: E.rank_bound() 

2 

 

To establish that the rank is in fact 0 in this case, we would 

need to carry out a higher descent:: 

 

sage: E.three_selmer_rank() # optional: magma 

0 

 

Or use the L-function to compute the analytic rank:: 

 

sage: E.rank(only_use_mwrank=False) 

0 

 

""" 

try: 

return self.__selmer_rank 

except AttributeError: 

C = self.mwrank_curve() 

self.__selmer_rank = C.selmer_rank() 

return self.__selmer_rank 

 

def rank_bound(self): 

""" 

Upper bound on the rank of the curve, computed using 

2-descent. In many cases, this is the actual rank of the 

curve. If the curve has no 2-torsion it is the same as the 

2-selmer rank. 

 

EXAMPLES: The following is the curve 960D1, which has rank 0, but 

Sha of order 4. 

 

:: 

 

sage: E = EllipticCurve([0, -1, 0, -900, -10098]) 

sage: E.rank_bound() 

0 

 

It gives 0 instead of 2, because it knows Sha is nontrivial. In 

contrast, for the curve 571A, also with rank 0 and Sha of order 4, 

we get a worse bound:: 

 

sage: E = EllipticCurve([0, -1, 1, -929, -10595]) 

sage: E.rank_bound() 

2 

sage: E.rank(only_use_mwrank=False) # uses L-function 

0 

 

""" 

try: 

return self.__rank_bound 

except AttributeError: 

C = self.mwrank_curve() 

self.__rank_bound = C.rank_bound() 

return self.__rank_bound 

 

def an(self, n): 

""" 

The n-th Fourier coefficient of the modular form corresponding to 

this elliptic curve, where n is a positive integer. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('37a1') 

sage: [E.an(n) for n in range(20) if n>0] 

[1, -2, -3, 2, -2, 6, -1, 0, 6, 4, -5, -6, -2, 2, 6, -4, 0, -12, 0] 

""" 

return Integer(self.pari_mincurve().ellak(n)) 

 

def ap(self, p): 

""" 

The p-th Fourier coefficient of the modular form corresponding to 

this elliptic curve, where p is prime. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('37a1') 

sage: [E.ap(p) for p in prime_range(50)] 

[-2, -3, -2, -1, -5, -2, 0, 0, 2, 6, -4, -1, -9, 2, -9] 

""" 

if not arith.is_prime(p): 

raise ArithmeticError("p must be prime") 

return Integer(self.pari_mincurve().ellap(p)) 

 

def quadratic_twist(self, D): 

""" 

Return the quadratic twist of this elliptic curve by D. 

 

D must be a nonzero rational number. 

 

.. note:: 

 

This function overrides the generic ``quadratic_twist()`` 

function for elliptic curves, returning a minimal model. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('37a1') 

sage: E2=E.quadratic_twist(2); E2 

Elliptic Curve defined by y^2 = x^3 - 4*x + 2 over Rational Field 

sage: E2.conductor() 

2368 

sage: E2.quadratic_twist(2) == E 

True 

""" 

return EllipticCurve_number_field.quadratic_twist(self, D).minimal_model() 

 

def minimal_model(self): 

r""" 

Return the unique minimal Weierstrass equation for this elliptic 

curve. 

 

This is the model with minimal discriminant and 

`a_1,a_2,a_3 \in \{0,\pm 1\}`. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve([10,100,1000,10000,1000000]) 

sage: E.minimal_model() 

Elliptic Curve defined by y^2 + x*y + y = x^3 + x^2 + x + 1 over Rational Field 

""" 

try: 

return self.__minimal_model 

except AttributeError: 

F = self.pari_mincurve() 

self.__minimal_model = constructor.EllipticCurve([Q(F[i]) for i in range(5)]) 

return self.__minimal_model 

 

def is_minimal(self): 

r""" 

Return ``True`` iff this elliptic curve is a reduced minimal model. 

 

The unique minimal Weierstrass equation for this elliptic curve. 

This is the model with minimal discriminant and 

`a_1,a_2,a_3 \in \{0,\pm 1\}`. 

 

.. TODO:: 

 

This is not very efficient since it just computes the 

minimal model and compares. A better implementation using the 

Kraus conditions would be preferable. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve([10,100,1000,10000,1000000]) 

sage: E.is_minimal() 

False 

sage: E = E.minimal_model() 

sage: E.is_minimal() 

True 

""" 

return self.ainvs() == self.minimal_model().ainvs() 

 

def is_p_minimal(self, p): 

""" 

Tests if curve is p-minimal at a given prime p. 

 

INPUT: p - a prime 

 

OUTPUT: True - if curve is p-minimal 

 

 

- ``False`` - if curve isn't p-minimal 

 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('441a2') 

sage: E.is_p_minimal(7) 

True 

 

:: 

 

sage: E = EllipticCurve([0,0,0,0,(2*5*11)**10]) 

sage: [E.is_p_minimal(p) for p in prime_range(2,24)] 

[False, True, False, True, False, True, True, True, True] 

""" 

if not p.is_prime(): 

raise ValueError("p must be prime") 

if not self.is_p_integral(p): 

return False 

if p > 3: 

return ((self.discriminant().valuation(p) < 12) or (self.c4().valuation(p) < 4)) 

# else p = 2,3 

Emin = self.minimal_model() 

return self.discriminant().valuation(p) == Emin.discriminant().valuation(p) 

 

def kodaira_type(self, p): 

""" 

Local Kodaira type of the elliptic curve at `p`. 

 

INPUT: 

 

- p -- an integral prime 

 

OUTPUT: 

 

- the Kodaira type of this elliptic curve at p, 

as a KodairaSymbol. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('124a') 

sage: E.kodaira_type(2) 

IV 

""" 

return self.local_data(p).kodaira_symbol() 

 

kodaira_symbol = kodaira_type 

 

def kodaira_type_old(self, p): 

""" 

Local Kodaira type of the elliptic curve at `p`. 

 

INPUT: 

 

 

- p, an integral prime 

 

 

OUTPUT: 

 

- the Kodaira type of this elliptic curve at p, 

as a KodairaSymbol. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('124a') 

sage: E.kodaira_type_old(2) 

IV 

""" 

if not arith.is_prime(p): 

raise ArithmeticError("p must be prime") 

try: 

self.__kodaira_type 

except AttributeError: 

self.__kodaira_type = {} 

self.__tamagawa_number = {} 

if p not in self.__kodaira_type: 

v = self.pari_mincurve().elllocalred(p) 

from .kodaira_symbol import KodairaSymbol 

self.__kodaira_type[p] = KodairaSymbol(v[1]) 

self.__tamagawa_number[p] = Integer(v[3]) 

return self.__kodaira_type[p] 

 

def tamagawa_number(self, p): 

r""" 

The Tamagawa number of the elliptic curve at `p`. 

 

This is the order of the component group 

`E(\QQ_p)/E^0(\QQ_p)`. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('11a') 

sage: E.tamagawa_number(11) 

5 

sage: E = EllipticCurve('37b') 

sage: E.tamagawa_number(37) 

3 

""" 

return self.local_data(p).tamagawa_number() 

 

def tamagawa_number_old(self, p): 

r""" 

The Tamagawa number of the elliptic curve at `p`. 

 

This is the order of the component group 

`E(\QQ_p)/E^0(\QQ_p)`. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('11a') 

sage: E.tamagawa_number_old(11) 

5 

sage: E = EllipticCurve('37b') 

sage: E.tamagawa_number_old(37) 

3 

""" 

if not arith.is_prime(p): 

raise ArithmeticError("p must be prime") 

try: 

return self.__tamagawa_number[p] 

except (AttributeError, KeyError): 

self.kodaira_type_old(p) 

return self.__tamagawa_number[p] 

 

def tamagawa_exponent(self, p): 

""" 

The Tamagawa index of the elliptic curve at `p`. 

 

This is the index of the component group 

`E(\QQ_p)/E^0(\QQ_p)`. It equals the 

Tamagawa number (as the component group is cyclic) except for types 

`I_m^*` (`m` even) when the group can be 

`C_2 \times C_2`. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('816a1') 

sage: E.tamagawa_number(2) 

4 

sage: E.tamagawa_exponent(2) 

2 

sage: E.kodaira_symbol(2) 

I2* 

 

:: 

 

sage: E = EllipticCurve('200c4') 

sage: E.kodaira_symbol(5) 

I4* 

sage: E.tamagawa_number(5) 

4 

sage: E.tamagawa_exponent(5) 

2 

 

See :trac:`4715`:: 

 

sage: E = EllipticCurve('117a3') 

sage: E.tamagawa_exponent(13) 

4 

""" 

if not arith.is_prime(p): 

raise ArithmeticError("p must be prime") 

cp = self.tamagawa_number(p) 

if not cp==4: 

return cp 

ks = self.kodaira_type(p) 

if ks._roman==1 and ks._n%2==0 and ks._starred: 

return 2 

return 4 

 

def tamagawa_product(self): 

""" 

Return the product of the Tamagawa numbers. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('54a') 

sage: E.tamagawa_product () 

3 

""" 

try: 

return self.__tamagawa_product 

except AttributeError: 

self.__tamagawa_product = Integer(self.pari_mincurve().ellglobalred()[2].sage()) 

return self.__tamagawa_product 

 

def real_components(self): 

""" 

Return 1 if there is 1 real component and 2 if there are 2. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('37a') 

sage: E.real_components () 

2 

sage: E = EllipticCurve('37b') 

sage: E.real_components () 

2 

sage: E = EllipticCurve('11a') 

sage: E.real_components () 

1 

""" 

invs = self.short_weierstrass_model().ainvs() 

x = rings.polygen(self.base_ring()) 

f = x**3 + invs[3]*x + invs[4] 

if f.discriminant() > 0: 

return 2 

else: 

return 1 

 

def has_good_reduction_outside_S(self, S=[]): 

r""" 

Test if this elliptic curve has good reduction outside `S`. 

 

INPUT: 

 

- `S` -- list of primes (default: empty list). 

 

.. note:: 

 

Primality of elements of S is not checked, and the output 

is undefined if S is not a list or contains non-primes. 

 

This only tests the given model, so should only be applied to 

minimal models. 

 

EXAMPLES:: 

 

sage: EllipticCurve('11a1').has_good_reduction_outside_S([11]) 

True 

sage: EllipticCurve('11a1').has_good_reduction_outside_S([2]) 

False 

sage: EllipticCurve('2310a1').has_good_reduction_outside_S([2,3,5,7]) 

False 

sage: EllipticCurve('2310a1').has_good_reduction_outside_S([2,3,5,7,11]) 

True 

""" 

return self.discriminant().is_S_unit(S) 

 

def period_lattice(self, embedding=None): 

r""" 

Return the period lattice of the elliptic curve with respect to 

the differential `dx/(2y + a_1x + a_3)`. 

 

INPUT: 

 

- ``embedding`` - ignored (for compatibility with the 

period_lattice function for elliptic_curve_number_field) 

 

OUTPUT: 

 

(period lattice) The PeriodLattice_ell object associated to 

this elliptic curve (with respect to the natural embedding of 

`\QQ` into `\RR`). 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('37a') 

sage: E.period_lattice() 

Period lattice associated to Elliptic Curve defined by y^2 + y = x^3 - x over Rational Field 

""" 

try: 

return self._period_lattice 

except AttributeError: 

from sage.schemes.elliptic_curves.period_lattice import PeriodLattice_ell 

self._period_lattice = PeriodLattice_ell(self) 

return self._period_lattice 

 

def elliptic_exponential(self, z, embedding=None): 

r""" 

Compute the elliptic exponential of a complex number with respect to the elliptic curve. 

 

INPUT: 

 

- ``z`` (complex) -- a complex number 

 

- ``embedding`` - ignored (for compatibility with the 

period_lattice function for elliptic_curve_number_field) 

 

OUTPUT: 

 

The image of `z` modulo `L` under the Weierstrass parametrization 

`\CC/L \to E(\CC)`. 

 

.. note:: 

 

The precision is that of the input ``z``, or the default 

precision of 53 bits if ``z`` is exact. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve([1,1,1,-8,6]) 

sage: P = E([1,-2]) 

sage: z = P.elliptic_logarithm() # default precision is 100 here 

sage: E.elliptic_exponential(z) 

(1.0000000000000000000000000000 : -2.0000000000000000000000000000 : 1.0000000000000000000000000000) 

sage: z = E([1,-2]).elliptic_logarithm(precision=201) 

sage: E.elliptic_exponential(z) 

(1.00000000000000000000000000000000000000000000000000000000000 : -2.00000000000000000000000000000000000000000000000000000000000 : 1.00000000000000000000000000000000000000000000000000000000000) 

 

:: 

 

sage: E = EllipticCurve('389a') 

sage: Q = E([3,5]) 

sage: E.elliptic_exponential(Q.elliptic_logarithm()) 

(3.0000000000000000000000000000 : 5.0000000000000000000000000000 : 1.0000000000000000000000000000) 

sage: P = E([-1,1]) 

sage: P.elliptic_logarithm() 

0.47934825019021931612953301006 + 0.98586885077582410221120384908*I 

sage: E.elliptic_exponential(P.elliptic_logarithm()) 

(-1.0000000000000000000000000000 : 1.0000000000000000000000000000 : 1.0000000000000000000000000000) 

 

 

Some torsion examples:: 

 

sage: w1,w2 = E.period_lattice().basis() 

sage: E.two_division_polynomial().roots(CC,multiplicities=False) 

[-2.0403022002854..., 0.13540924022175..., 0.90489296006371...] 

sage: [E.elliptic_exponential((a*w1+b*w2)/2)[0] for a,b in [(0,1),(1,1),(1,0)]] 

[-2.0403022002854..., 0.13540924022175..., 0.90489296006371...] 

 

sage: E.division_polynomial(3).roots(CC,multiplicities=False) 

[-2.88288879135..., 

1.39292799513..., 

0.078313731444316... - 0.492840991709...*I, 

0.078313731444316... + 0.492840991709...*I] 

sage: [E.elliptic_exponential((a*w1+b*w2)/3)[0] for a,b in [(0,1),(1,0),(1,1),(2,1)]] 

[-2.8828887913533..., 1.39292799513138, 

0.0783137314443... - 0.492840991709...*I, 

0.0783137314443... + 0.492840991709...*I] 

 

Observe that this is a group homomorphism (modulo rounding error):: 

 

sage: z = CC.random_element() 

sage: 2 * E.elliptic_exponential(z) 

(-1.52184235874404 - 0.0581413944316544*I : 0.948655866506124 - 0.0381469928565030*I : 1.00000000000000) 

sage: E.elliptic_exponential(2 * z) 

(-1.52184235874404 - 0.0581413944316562*I : 0.948655866506128 - 0.0381469928565034*I : 1.00000000000000) 

""" 

return self.period_lattice().elliptic_exponential(z) 

 

def lseries(self): 

""" 

Return the L-series of this elliptic curve. 

 

Further documentation is available for the functions which apply to 

the L-series. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('37a1') 

sage: E.lseries() 

Complex L-series of the Elliptic Curve defined by y^2 + y = x^3 - x over Rational Field 

""" 

try: 

return self.__lseries 

except AttributeError: 

from .lseries_ell import Lseries_ell 

self.__lseries = Lseries_ell(self) 

return self.__lseries 

 

def lseries_gross_zagier(self, A): 

""" 

Return the Gross-Zagier L-series attached to ``self`` 

and an ideal class `A`. 

 

INPUT: 

 

- ``A`` -- an ideal class in an imaginary quadratic number field `K` 

 

This L-series `L(E,A,s)` is defined as the product of a shifted L-function of the 

quadratic character associated to `K` and the Dirichlet series whose `n`-th 

coefficient is the product of the `n`-th factor of the L-series of `E` and 

the number of integral ideal in `A` of norm `n`. For any character `\chi` 

on the class group of `K`, one gets `L_K(E,\chi,s) = \sum_{A} \chi(A) L(E,A,s)` 

where `A` runs through the class group of `K`. 

 

For the exact definition see section IV of [GrossZagier]_. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('37a') 

sage: K.<a> = QuadraticField(-40) 

sage: A = K.class_group().gen(0); A 

Fractional ideal class (2, 1/2*a) 

sage: L = E.lseries_gross_zagier(A) ; L 

Gross Zagier L-series attached to Elliptic Curve defined by y^2 + y = x^3 - x over Rational Field with ideal class Fractional ideal class (2, 1/2*a) 

sage: L(1) 

0.000000000000000 

sage: L.taylor_series(1, 5) 

0.000000000000000 - 5.51899839494458*z + 13.6297841350649*z^2 - 16.2292417817675*z^3 + 7.94788823722712*z^4 + O(z^5) 

 

These should be equal:: 

 

sage: L(2) + E.lseries_gross_zagier(A^2)(2) 

0.502803417587467 

sage: E.lseries()(2) * E.quadratic_twist(-40).lseries()(2) 

0.502803417587467 

 

REFERENCES: 

 

.. [GrossZagier] \B. Gross and D. Zagier, *Heegner points and 

derivatives of L-series.* Invent. Math. 84 (1986), no. 2, 225-320. 

""" 

try: 

return self.__lseries_gross_zagier[A] 

except AttributeError: 

self.__lseries_gross_zagier = {} 

except KeyError: 

pass 

 

from sage.modular.modform.l_series_gross_zagier import GrossZagierLseries 

self.__lseries_gross_zagier[A] = GrossZagierLseries(self, A) 

return self.__lseries_gross_zagier[A] 

 

def Lambda(self, s, prec): 

r""" 

Return the value of the Lambda-series of the elliptic curve E at 

s, where s can be any complex number. 

 

IMPLEMENTATION: Fairly *slow* computation using the definitions 

and implemented in Python. 

 

Uses prec terms of the power series. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('389a') 

sage: E.Lambda(1.4+0.5*I, 50) 

-0.354172680517... + 0.874518681720...*I 

""" 

from sage.all import pi 

 

s = C(s) 

N = self.conductor() 

pi = R(pi) 

a = self.anlist(prec) 

eps = self.root_number() 

sqrtN = float(N.sqrt()) 

 

def _F(n, t): 

return gamma_inc(t+1, 2*pi*n/sqrtN) * C(sqrtN/(2*pi*n))**(t+1) 

return sum(a[n]*(_F(n,s-1) + eps*_F(n,1-s)) for n in range(1, prec+1)) 

 

def is_local_integral_model(self,*p): 

r""" 

Tests if self is integral at the prime `p`, or at all the 

primes if `p` is a list or tuple of primes 

 

EXAMPLES:: 

 

sage: E = EllipticCurve([1/2,1/5,1/5,1/5,1/5]) 

sage: [E.is_local_integral_model(p) for p in (2,3,5)] 

[False, True, False] 

sage: E.is_local_integral_model(2,3,5) 

False 

sage: Eint2=E.local_integral_model(2) 

sage: Eint2.is_local_integral_model(2) 

True 

""" 

if len(p) == 1: 

p = p[0] 

if isinstance(p, (tuple, list)): 

return all(self.is_local_integral_model(x) for x in p) 

assert p.is_prime(), "p must be prime in is_local_integral_model()" 

return all(x.valuation(p) >= 0 for x in self.ainvs()) 

 

def local_integral_model(self,p): 

r""" 

Return a model of self which is integral at the prime `p`. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve([0, 0, 1/216, -7/1296, 1/7776]) 

sage: E.local_integral_model(2) 

Elliptic Curve defined by y^2 + 1/27*y = x^3 - 7/81*x + 2/243 over Rational Field 

sage: E.local_integral_model(3) 

Elliptic Curve defined by y^2 + 1/8*y = x^3 - 7/16*x + 3/32 over Rational Field 

sage: E.local_integral_model(2).local_integral_model(3) == EllipticCurve('5077a1') 

True 

""" 

assert p.is_prime(), "p must be prime in local_integral_model()" 

ai = self.a_invariants() 

e = min([(ai[i].valuation(p)/[1,2,3,4,6][i]) for i in range(5)]).floor() 

return constructor.EllipticCurve([ai[i]/p**(e*[1,2,3,4,6][i]) for i in range(5)]) 

 

def is_global_integral_model(self): 

r""" 

Return ``True`` iff ``self`` is integral at all primes. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve([1/2,1/5,1/5,1/5,1/5]) 

sage: E.is_global_integral_model() 

False 

sage: Emin=E.global_integral_model() 

sage: Emin.is_global_integral_model() 

True 

""" 

return self.is_integral() 

 

def global_integral_model(self): 

r""" 

Return a model of self which is integral at all primes. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve([0, 0, 1/216, -7/1296, 1/7776]) 

sage: F = E.global_integral_model(); F 

Elliptic Curve defined by y^2 + y = x^3 - 7*x + 6 over Rational Field 

sage: F == EllipticCurve('5077a1') 

True 

""" 

ai = self.a_invariants() 

for a in ai: 

if not a.is_integral(): 

for p, _ in a.denom().factor(): 

e = min([(ai[i].valuation(p)/[1,2,3,4,6][i]) for i in range(5)]).floor() 

ai = [ai[i]/p**(e*[1,2,3,4,6][i]) for i in range(5)] 

for z in ai: 

assert z.denominator() == 1, "bug in global_integral_model: %s" % ai 

return constructor.EllipticCurve(list(ai)) 

 

integral_model = global_integral_model 

 

def integral_short_weierstrass_model(self): 

r""" 

Return a model of the form `y^2 = x^3 + ax + b` for this 

curve with `a,b\in\ZZ`. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('17a1') 

sage: E.integral_short_weierstrass_model() 

Elliptic Curve defined by y^2 = x^3 - 11*x - 890 over Rational Field 

""" 

F = self.minimal_model().short_weierstrass_model() 

_,_,_,A,B = F.ainvs() 

for p in [2,3]: 

e=min(A.valuation(p)/4,B.valuation(p)/6).floor() 

A /= Integer(p**(4*e)) 

B /= Integer(p**(6*e)) 

return constructor.EllipticCurve([A,B]) 

 

# deprecated function replaced by integral_short_weierstrass_model, see trac 3974. 

def integral_weierstrass_model(self): 

r""" 

Return a model of the form `y^2 = x^3 + ax + b` for this 

curve with `a,b\in\ZZ`. 

 

Note that this function is deprecated, and that you should use 

integral_short_weierstrass_model instead as this will be 

disappearing in the near future. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('17a1') 

sage: E.integral_weierstrass_model() #random 

doctest:...: DeprecationWarning: integral_weierstrass_model is deprecated, use integral_short_weierstrass_model instead! 

Elliptic Curve defined by y^2 = x^3 - 11*x - 890 over Rational Field 

""" 

from sage.misc.superseded import deprecation 

deprecation(3974, "integral_weierstrass_model is deprecated, use integral_short_weierstrass_model instead!") 

return self.integral_short_weierstrass_model() 

 

 

def _generalized_congmod_numbers(self, M, invariant="both"): 

""" 

Internal method to compute the generalized modular degree and congruence number 

at level `MN`, where `N` is the conductor of `E`. 

Values obtained are cached. 

 

This function is called by self.modular_degree() and self.congruence_number() when 

`M>1`. Since so much of the computation of the two values is shared, this method 

by default computes and caches both. 

 

INPUT: 

 

- ``M`` - Non-negative integer; this function is only ever called on M>1, although 

the algorithm works fine for the case `M==1` 

 

- ``invariant`` - String; default "both". Options are: 

 

- "both" - Both modular degree and congruence number at level `MN` are computed 

 

- "moddeg" - Only modular degree is computed 

 

- "congnum" - Only congruence number is computed 

 

OUTPUT: 

 

- A dictionary containing either the modular degree (a positive integer) at index "moddeg", 

or the congruence number (a positive integer) at index "congnum", or both. 

 

As far as we know there is no other implementation for this algorithm, so as yet 

there is nothing to check the below examples against. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('37a') 

sage: for M in range(2,8): # long time (22s on 2009 MBP) 

....: print((M, E.modular_degree(M=M),E.congruence_number(M=M))) 

(2, 5, 20) 

(3, 7, 28) 

(4, 50, 400) 

(5, 32, 128) 

(6, 1225, 19600) 

(7, 63, 252) 

""" 

# Check invariant specification before we get going 

if invariant not in ["moddeg", "congnum", "both"]: 

raise ValueError("Invalid invariant specification") 

 

# Cuspidal space at level MN 

N = self.conductor() 

S = ModularSymbols(N*M,sign=1).cuspidal_subspace() 

 

# Cut out the subspace by hitting it with T_p for enough p 

A = S 

d = self.dimension()*arith.sigma(M,0) 

p = 2 

while A.dimension() > d: 

while N*M % p == 0: 

p = arith.next_prime(p) 

Tp = A.hecke_operator(p) 

A = (Tp - self.ap(p)).kernel() 

p = arith.next_prime(p) 

B = A.complement().cuspidal_submodule() 

 

L = {} 

if invariant in ["moddeg", "both"]: 

V = A.integral_structure() 

W = B.integral_structure() 

moddeg = (V + W).index_in(S.integral_structure()) 

L["moddeg"] = moddeg 

self.__generalized_modular_degree[M] = moddeg 

 

if invariant in ["congnum", "both"]: 

congnum = A.congruence_number(B) 

L["congnum"] = congnum 

self.__generalized_congruence_number[M] = congnum 

 

return L 

 

 

def modular_degree(self, algorithm='sympow', M=1): 

r""" 

Return the modular degree at level `MN` of this elliptic curve. The case 

`M==1` corresponds to the classical definition of modular degree. 

 

When `M>1`, the function returns the degree of the map from `X_0(MN) \to A`, where 

A is the abelian variety generated by embeddings of `E` into `J_0(MN)`. 

 

The result is cached. Subsequent calls, even with a different 

algorithm, just returned the cached result. The algorithm argument is ignored 

when `M>1`. 

 

INPUT: 

 

- ``algorithm`` - string: 

 

- ``'sympow'`` - (default) use Mark Watkin's (newer) C 

program sympow 

 

- ``'magma'`` - requires that MAGMA be installed (also 

implemented by Mark Watkins) 

 

- ``M`` - Non-negative integer; the modular degree at level `MN` is returned 

(see above) 

 

.. note:: 

 

On 64-bit computers ec does not work, so Sage uses sympow 

even if ec is selected on a 64-bit computer. 

 

The correctness of this function when called with algorithm "sympow" 

is subject to the following three hypothesis: 

 

 

- Manin's conjecture: the Manin constant is 1 

 

- Steven's conjecture: the `X_1(N)`-optimal quotient is 

the curve with minimal Faltings height. (This is proved in most 

cases.) 

 

- The modular degree fits in a machine double, so it better be 

less than about 50-some bits. (If you use sympow this constraint 

does not apply.) 

 

 

Moreover for all algorithms, computing a certain value of an 

`L`-function 'uses a heuristic method that discerns when 

the real-number approximation to the modular degree is within 

epsilon [=0.01 for algorithm='sympow'] of the same integer for 3 

consecutive trials (which occur maybe every 25000 coefficients or 

so). Probably it could just round at some point. For rigour, you 

would need to bound the tail by assuming (essentially) that all the 

`a_n` are as large as possible, but in practice they 

exhibit significant (square root) cancellation. One difficulty is 

that it doesn't do the sum in 1-2-3-4 order; it uses 

1-2-4-8--3-6-12-24-9-18- (Euler product style) instead, and so you 

have to guess ahead of time at what point to curtail this 

expansion.' (Quote from an email of Mark Watkins.) 

 

.. note:: 

 

If the curve is loaded from the large Cremona database, 

then the modular degree is taken from the database. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve([0, -1, 1, -10, -20]) 

sage: E 

Elliptic Curve defined by y^2 + y = x^3 - x^2 - 10*x - 20 over Rational Field 

sage: E.modular_degree() 

1 

sage: E = EllipticCurve('5077a') 

sage: E.modular_degree() 

1984 

sage: factor(1984) 

2^6 * 31 

 

:: 

 

sage: EllipticCurve([0, 0, 1, -7, 6]).modular_degree() 

1984 

sage: EllipticCurve([0, 0, 1, -7, 6]).modular_degree(algorithm='sympow') 

1984 

sage: EllipticCurve([0, 0, 1, -7, 6]).modular_degree(algorithm='magma') # optional - magma 

1984 

 

We compute the modular degree of the curve with rank 4 having 

smallest (known) conductor:: 

 

sage: E = EllipticCurve([1, -1, 0, -79, 289]) 

sage: factor(E.conductor()) # conductor is 234446 

2 * 117223 

sage: factor(E.modular_degree()) 

2^7 * 2617 

 

Higher level cases:: 

 

sage: E = EllipticCurve('11a') 

sage: for M in range(1,11): print(E.modular_degree(M=M)) # long time (20s on 2009 MBP) 

1 

1 

3 

2 

7 

45 

12 

16 

54 

245 

""" 

# Case 1: standard modular degree 

if M==1: 

try: 

return self.__modular_degree 

 

except AttributeError: 

if algorithm == 'sympow': 

from sage.lfunctions.all import sympow 

m = sympow.modular_degree(self) 

elif algorithm == 'magma': 

from sage.interfaces.all import magma 

m = rings.Integer(magma(self).ModularDegree()) 

else: 

raise ValueError("unknown algorithm %s"%algorithm) 

self.__modular_degree = m 

return m 

 

# Case 2: M > 1 

else: 

try: 

return self.__generalized_modular_degree[M] 

except KeyError: 

# self._generalized_congmod_numbers() also populates cache 

return self._generalized_congmod_numbers(M)["moddeg"] 

 

 

def modular_parametrization(self): 

r""" 

Return the modular parametrization of this elliptic curve, which is 

a map from `X_0(N)` to self, where `N` is the conductor of self. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('15a') 

sage: phi = E.modular_parametrization(); phi 

Modular parameterization from the upper half plane to Elliptic Curve defined by y^2 + x*y + y = x^3 + x^2 - 10*x - 10 over Rational Field 

sage: z = 0.1 + 0.2j 

sage: phi(z) 

(8.20822465478531 - 13.1562816054682*I : -8.79855099049364 + 69.4006129342200*I : 1.00000000000000) 

 

This map is actually a map on `X_0(N)`, so equivalent representatives 

in the upper half plane map to the same point:: 

 

sage: phi((-7*z-1)/(15*z+2)) 

(8.20822465478524 - 13.1562816054681*I : -8.79855099049... + 69.4006129342...*I : 1.00000000000000) 

 

We can also get a series expansion of this modular parameterization:: 

 

sage: E = EllipticCurve('389a1') 

sage: X,Y=E.modular_parametrization().power_series() 

sage: X 

q^-2 + 2*q^-1 + 4 + 7*q + 13*q^2 + 18*q^3 + 31*q^4 + 49*q^5 + 74*q^6 + 111*q^7 + 173*q^8 + 251*q^9 + 379*q^10 + 560*q^11 + 824*q^12 + 1199*q^13 + 1773*q^14 + 2548*q^15 + 3722*q^16 + 5374*q^17 + O(q^18) 

sage: Y 

-q^-3 - 3*q^-2 - 8*q^-1 - 17 - 33*q - 61*q^2 - 110*q^3 - 186*q^4 - 320*q^5 - 528*q^6 - 861*q^7 - 1383*q^8 - 2218*q^9 - 3472*q^10 - 5451*q^11 - 8447*q^12 - 13020*q^13 - 19923*q^14 - 30403*q^15 - 46003*q^16 + O(q^17) 

 

The following should give 0, but only approximately:: 

 

sage: q = X.parent().gen() 

sage: E.defining_polynomial()(X,Y,1) + O(q^11) == 0 

True 

""" 

return ModularParameterization(self) 

 

def congruence_number(self, M=1): 

r""" 

The case `M==1` corresponds to the classical definition of congruence number: 

Let `X` be the subspace of `S_2(\Gamma_0(N))` spanned by the newform 

associated with this elliptic curve, and `Y` be orthogonal compliment 

of `X` under the Petersson inner product. Let `S_X` and `S_Y` be the 

intersections of `X` and `Y` with `S_2(\Gamma_0(N), \ZZ)`. The congruence 

number is defined to be `[S_X \oplus S_Y : S_2(\Gamma_0(N),\ZZ)]`. 

It measures congruences between `f` and elements of `S_2(\Gamma_0(N),\ZZ)` 

orthogonal to `f`. 

 

The congruence number for higher levels, when M>1, is defined as above, but 

instead considers `X` to be the subspace of `S_2(\Gamma_0(MN))` spanned by 

embeddings into `S_2(\Gamma_0(MN))` of the newform associated with this 

elliptic curve; this subspace has dimension `\sigma_0(M)`, i.e. the number 

of divisors of `M`. Let `Y` be the orthogonal complement in `S_2(\Gamma_0(MN))` 

of `X` under the Petersson inner product, and `S_X` and `S_Y` the intersections 

of `X` and `Y` with `S_2(\Gamma_0(MN), \ZZ)` respectively. Then the congruence 

number at level `MN` is `[S_X \oplus S_Y : S_2(\Gamma_0(MN),\ZZ)]`. 

 

INPUT: 

 

- `M` -- Non-negative integer; congruence number is computed 

at level `MN`, where `N` is the conductor of ``self``. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('37a') 

sage: E.congruence_number() 

2 

sage: E.congruence_number() 

2 

sage: E = EllipticCurve('54b') 

sage: E.congruence_number() 

6 

sage: E.modular_degree() 

2 

sage: E = EllipticCurve('242a1') 

sage: E.modular_degree() 

16 

sage: E.congruence_number() # long time (4s on sage.math, 2011) 

176 

 

Higher level cases:: 

 

sage: E = EllipticCurve('11a') 

sage: for M in range(1,11): print(E.congruence_number(M)) # long time (20s on 2009 MBP) 

1 

1 

3 

2 

7 

45 

12 

4 

18 

245 

 

It is a theorem of Ribet that the congruence number (at level `N`) is equal 

to the modular degree in the case of square free conductor. It is a conjecture 

of Agashe, Ribet, and Stein that `ord_p(c_f/m_f) \le ord_p(N)/2`. 

 

TESTS:: 

 

sage: E = EllipticCurve('11a') 

sage: E.congruence_number() 

1 

""" 

# Case 1: M==1 

if M==1: 

try: 

return self.__congruence_number 

except AttributeError: 

pass 

# Currently this is *much* faster to compute 

m = self.modular_degree() 

if self.conductor().is_squarefree(): 

self.__congruence_number = m 

else: 

W = self.modular_symbol_space(sign=1) 

V = W.complement().cuspidal_subspace() 

self.__congruence_number = W.congruence_number(V) 

if not m.divides(self.__congruence_number): 

# We should never get here 

raise ValueError("BUG in modular degree or congruence number computation of: %s" % self) 

return self.__congruence_number 

 

# Case 2: M > 1 

else: 

try: 

return self.__generalized_congruence_number[M] 

except KeyError: 

# self._generalized_congmod_numbers() also populates cache 

return self._generalized_congmod_numbers(M)["congnum"] 

 

 

def cremona_label(self, space=False): 

""" 

Return the Cremona label associated to (the minimal model) of this 

curve, if it is known. If not, raise a ``LookupError`` exception. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('389a1') 

sage: E.cremona_label() 

'389a1' 

 

The default database only contains conductors up to 10000, so any 

curve with conductor greater than that will cause an error to be 

raised. The optional package ``database_cremona_ellcurve`` 

contains many more curves. 

 

:: 

 

sage: E = EllipticCurve([1, -1, 0, -79, 289]) 

sage: E.conductor() 

234446 

sage: E.cremona_label() # optional - database_cremona_ellcurve 

'234446a1' 

sage: E = EllipticCurve((0, 0, 1, -79, 342)) 

sage: E.conductor() 

19047851 

sage: E.cremona_label() 

Traceback (most recent call last): 

... 

LookupError: Cremona database does not contain entry for Elliptic Curve defined by y^2 + y = x^3 - 79*x + 342 over Rational Field 

""" 

try: 

label = self.__cremona_label 

except AttributeError: 

label = self.database_attributes()['cremona_label'] 

self.__cremona_label = label 

if not space: 

return label.replace(' ', '') 

return label 

 

label = cremona_label 

 

def reduction(self,p): 

""" 

Return the reduction of the elliptic curve at a prime of good 

reduction. 

 

.. note:: 

 

The actual reduction is done in ``self.change_ring(GF(p))``; 

the reduction is performed after changing to a model which 

is minimal at p. 

 

INPUT: 

 

- ``p`` - a (positive) prime number 

 

 

OUTPUT: an elliptic curve over the finite field GF(p) 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('389a1') 

sage: E.reduction(2) 

Elliptic Curve defined by y^2 + y = x^3 + x^2 over Finite Field of size 2 

sage: E.reduction(3) 

Elliptic Curve defined by y^2 + y = x^3 + x^2 + x over Finite Field of size 3 

sage: E.reduction(5) 

Elliptic Curve defined by y^2 + y = x^3 + x^2 + 3*x over Finite Field of size 5 

sage: E.reduction(38) 

Traceback (most recent call last): 

... 

AttributeError: p must be prime. 

sage: E.reduction(389) 

Traceback (most recent call last): 

... 

AttributeError: The curve must have good reduction at p. 

sage: E = EllipticCurve([5^4,5^6]) 

sage: E.reduction(5) 

Elliptic Curve defined by y^2 = x^3 + x + 1 over Finite Field of size 5 

""" 

p = rings.Integer(p) 

if not p.is_prime(): 

raise AttributeError("p must be prime.") 

disc = self.discriminant() 

if not disc.valuation(p) == 0: 

local_data=self.local_data(p) 

if local_data.has_good_reduction(): 

return local_data.minimal_model().change_ring(rings.GF(p)) 

raise AttributeError("The curve must have good reduction at p.") 

return self.change_ring(rings.GF(p)) 

 

def torsion_order(self): 

""" 

Return the order of the torsion subgroup. 

 

EXAMPLES:: 

 

sage: e = EllipticCurve('11a') 

sage: e.torsion_order() 

5 

sage: type(e.torsion_order()) 

<... 'sage.rings.integer.Integer'> 

sage: e = EllipticCurve([1,2,3,4,5]) 

sage: e.torsion_order() 

1 

sage: type(e.torsion_order()) 

<... 'sage.rings.integer.Integer'> 

""" 

try: 

return self.__torsion_order 

except AttributeError: 

self.__torsion_order = self.torsion_subgroup().order() 

return self.__torsion_order 

 

def _torsion_bound(self,number_of_places = 20): 

r""" 

Compute an upper bound on the order of the torsion group of the 

elliptic curve by counting points modulo several primes of good 

reduction. 

 

Note that the upper bound returned by this function is a 

multiple of the order of the torsion group. 

 

INPUT: 

 

- ``number_of_places (default = 20)`` - the number 

of places that will be used to find the bound 

 

OUTPUT: 

 

- ``integer`` - the upper bound 

 

EXAMPLES: 

""" 

E = self 

bound = Integer(0) 

k = 0 

p = Integer(2) # will run through odd primes 

while k < number_of_places : 

p = p.next_prime() 

# check if the formal group at the place is torsion-free 

# if so the torsion injects into the reduction 

while not E.is_local_integral_model(p) or not E.is_good(p): p = p.next_prime() 

bound = arith.gcd(bound,E.reduction(p).cardinality()) 

if bound == 1: 

return bound 

k += 1 

return bound 

 

def torsion_subgroup(self, algorithm=None): 

""" 

Return the torsion subgroup of this elliptic curve. 

 

OUTPUT: The EllipticCurveTorsionSubgroup instance associated to 

this elliptic curve. 

 

.. note:: 

 

To see the torsion points as a list, use :meth:`.torsion_points`. 

 

EXAMPLES:: 

 

sage: EllipticCurve('11a').torsion_subgroup() 

Torsion Subgroup isomorphic to Z/5 associated to the Elliptic Curve defined by y^2 + y = x^3 - x^2 - 10*x - 20 over Rational Field 

sage: EllipticCurve('37b').torsion_subgroup() 

Torsion Subgroup isomorphic to Z/3 associated to the Elliptic Curve defined by y^2 + y = x^3 + x^2 - 23*x - 50 over Rational Field 

 

:: 

 

sage: e = EllipticCurve([-1386747,368636886]);e 

Elliptic Curve defined by y^2 = x^3 - 1386747*x + 368636886 over Rational Field 

sage: G = e.torsion_subgroup(); G 

Torsion Subgroup isomorphic to Z/8 + Z/2 associated to the 

Elliptic Curve defined by y^2 = x^3 - 1386747*x + 368636886 over 

Rational Field 

sage: G.0*3 + G.1 

(1227 : 22680 : 1) 

sage: G.1 

(282 : 0 : 1) 

sage: list(G) 

[(0 : 1 : 0), (147 : 12960 : 1), (2307 : 97200 : 1), (-933 : 29160 : 1), (1011 : 0 : 1), (-933 : -29160 : 1), (2307 : -97200 : 1), (147 : -12960 : 1), (282 : 0 : 1), (8787 : 816480 : 1), (-285 : 27216 : 1), (1227 : 22680 : 1), (-1293 : 0 : 1), (1227 : -22680 : 1), (-285 : -27216 : 1), (8787 : -816480 : 1)] 

""" 

try: 

return self.__torsion_subgroup 

except AttributeError: 

# algorithm is deprecated: if not None, this will give a warning. 

# deprecation(20219) 

self.__torsion_subgroup = ell_torsion.EllipticCurveTorsionSubgroup(self, algorithm) 

self.__torsion_order = self.__torsion_subgroup.order() 

return self.__torsion_subgroup 

 

def torsion_points(self, algorithm=None): 

""" 

Return the torsion points of this elliptic curve as a sorted 

list. 

 

OUTPUT: A list of all the torsion points on this elliptic curve. 

 

EXAMPLES:: 

 

sage: EllipticCurve('11a').torsion_points() 

[(0 : 1 : 0), (5 : -6 : 1), (5 : 5 : 1), (16 : -61 : 1), (16 : 60 : 1)] 

sage: EllipticCurve('37b').torsion_points() 

[(0 : 1 : 0), (8 : -19 : 1), (8 : 18 : 1)] 

 

Some curves with large torsion groups:: 

 

sage: E = EllipticCurve([-1386747, 368636886]) 

sage: T = E.torsion_subgroup(); T 

Torsion Subgroup isomorphic to Z/8 + Z/2 associated to the 

Elliptic Curve defined by y^2 = x^3 - 1386747*x + 368636886 over 

Rational Field 

sage: T == E.torsion_subgroup(algorithm="doud") 

True 

sage: T == E.torsion_subgroup(algorithm="lutz_nagell") 

True 

sage: E.torsion_points() 

[(-1293 : 0 : 1), 

(-933 : -29160 : 1), 

(-933 : 29160 : 1), 

(-285 : -27216 : 1), 

(-285 : 27216 : 1), 

(0 : 1 : 0), 

(147 : -12960 : 1), 

(147 : 12960 : 1), 

(282 : 0 : 1), 

(1011 : 0 : 1), 

(1227 : -22680 : 1), 

(1227 : 22680 : 1), 

(2307 : -97200 : 1), 

(2307 : 97200 : 1), 

(8787 : -816480 : 1), 

(8787 : 816480 : 1)] 

sage: EllipticCurve('210b5').torsion_points() 

[(-41/4 : 37/8 : 1), 

(-5 : -103 : 1), 

(-5 : 107 : 1), 

(0 : 1 : 0), 

(10 : -208 : 1), 

(10 : 197 : 1), 

(37 : -397 : 1), 

(37 : 359 : 1), 

(100 : -1153 : 1), 

(100 : 1052 : 1), 

(415 : -8713 : 1), 

(415 : 8297 : 1)] 

sage: EllipticCurve('210e2').torsion_points() 

[(-36 : 18 : 1), 

(-26 : -122 : 1), 

(-26 : 148 : 1), 

(-8 : -122 : 1), 

(-8 : 130 : 1), 

(0 : 1 : 0), 

(4 : -62 : 1), 

(4 : 58 : 1), 

(31/4 : -31/8 : 1), 

(28 : -14 : 1), 

(34 : -122 : 1), 

(34 : 88 : 1), 

(64 : -482 : 1), 

(64 : 418 : 1), 

(244 : -3902 : 1), 

(244 : 3658 : 1)] 

""" 

# algorithm is deprecated: if not None, this will give a warning. 

# deprecation(20219) 

return sorted(self.torsion_subgroup(algorithm).points()) 

 

@cached_method 

def root_number(self, p=None): 

""" 

Return the root number of this elliptic curve. 

 

This is 1 if the order of vanishing of the L-function L(E,s) at 1 

is even, and -1 if it is odd. 

 

INPUT: 

 

- `p` -- optional, default (None); if given, return the local 

root number at `p` 

 

EXAMPLES:: 

 

sage: EllipticCurve('11a1').root_number() 

1 

sage: EllipticCurve('37a1').root_number() 

-1 

sage: EllipticCurve('389a1').root_number() 

1 

sage: type(EllipticCurve('389a1').root_number()) 

<... 'sage.rings.integer.Integer'> 

 

sage: E = EllipticCurve('100a1') 

sage: E.root_number(2) 

-1 

sage: E.root_number(5) 

1 

sage: E.root_number(7) 

1 

 

The root number is cached:: 

 

sage: E.root_number(2) is E.root_number(2) 

True 

sage: E.root_number() 

1 

""" 

e = self.pari_mincurve() 

if p is None: 

return Integer(e.ellrootno()) 

else: 

return Integer(e.ellrootno(p)) 

 

def has_cm(self): 

""" 

Return whether or not this curve has a CM `j`-invariant. 

 

OUTPUT: 

 

``True`` if the `j`-invariant of this curve is the 

`j`-invariant of an imaginary quadratic order, otherwise 

``False``. 

 

.. SEEALSO:: 

 

:meth:`cm_discriminant()` and :meth:`has_rational_cm` 

 

.. note:: 

 

Even if `E` has CM in this sense (that its `j`-invariant is 

a CM `j`-invariant), since the associated negative 

discriminant `D` is not a square in `\QQ`, the extra 

endomorphisms will not be defined over `\QQ`. See also the 

method :meth:`has_rational_cm` which tests whether `E` has 

extra endomorphisms defined over `\QQ` or a given extension 

of `\QQ`. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('37a1') 

sage: E.has_cm() 

False 

sage: E = EllipticCurve('32a1') 

sage: E.has_cm() 

True 

sage: E.j_invariant() 

1728 

""" 

return self.j_invariant() in CMJ 

 

def cm_discriminant(self): 

""" 

Return the associated quadratic discriminant if this elliptic 

curve has Complex Multiplication over the algebraic closure. 

 

A ValueError is raised if the curve does not have CM (see the 

function :meth:`has_cm()`). 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('32a1') 

sage: E.cm_discriminant() 

-4 

sage: E = EllipticCurve('121b1') 

sage: E.cm_discriminant() 

-11 

sage: E = EllipticCurve('37a1') 

sage: E.cm_discriminant() 

Traceback (most recent call last): 

... 

ValueError: Elliptic Curve defined by y^2 + y = x^3 - x over Rational Field does not have CM 

""" 

 

try: 

return ZZ(CMJ[self.j_invariant()]) 

except KeyError: 

raise ValueError("%s does not have CM"%self) 

 

def has_rational_cm(self, field=None): 

""" 

Return whether or not this curve has CM defined over `\QQ` 

or the given field. 

 

INPUT: 

 

- ``field`` -- a field, which should be an extension of `\QQ`. 

If ``field`` is ``None`` (the default), it is taken to be 

`\QQ`. 

 

OUTPUT: 

 

``True`` if the ring of endomorphisms of this curve over 

the given field is larger than `\ZZ`; otherwise ``False``. 

If ``field`` is ``None`` the output will always be ``False``. 

See also :meth:`cm_discriminant()` and :meth:`has_cm`. 

 

.. note:: 

 

If `E` has CM but the discriminant `D` is not a square in 

the given field `K`, which will certainly be the case for 

`K=\QQ` since `D<0`, then the extra endomorphisms will not 

be defined over `K`, and this function will return 

``False``. See also :meth:`has_cm`. To obtain the CM 

discriminant, use :meth:`cm_discriminant()`. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve(j=0) 

sage: E.has_cm() 

True 

sage: E.has_rational_cm() 

False 

sage: D = E.cm_discriminant(); D 

-3 

 

If we extend scalars to a field in which the discriminant is a 

square, the CM becomes rational:: 

 

sage: E.has_rational_cm(QuadraticField(-3)) 

True 

 

sage: E = EllipticCurve(j=8000) 

sage: E.has_cm() 

True 

sage: E.has_rational_cm() 

False 

sage: D = E.cm_discriminant(); D 

-8 

 

Again, we may extend scalars to a field in which the 

discriminant is a square, where the CM becomes rational:: 

 

sage: E.has_rational_cm(QuadraticField(-2)) 

True 

 

The field need not be a number field provided that it is an 

extension of `\QQ`:: 

 

sage: E.has_rational_cm(RR) 

False 

sage: E.has_rational_cm(CC) 

True 

 

An error is raised if a field is given which is not an 

extension of `\QQ`, i.e., not of characteristic `0`:: 

 

sage: E.has_rational_cm(GF(2)) 

Traceback (most recent call last): 

... 

ValueError: Error in has_rational_cm: Finite Field of size 2 is not an extension field of QQ 

""" 

if field is None: 

return False 

try: 

D = self.cm_discriminant() 

except ValueError: 

return False 

try: 

if field.characteristic()==0: 

D = field(D) 

return D.is_square() 

raise ValueError("Error in has_rational_cm: %s is not an extension field of QQ" % field) 

except AttributeError: 

raise ValueError("Error in has_rational_cm: %s is not an extension field of QQ" % field) 

 

def quadratic_twist(self, D): 

""" 

Return the global minimal model of the quadratic twist of this 

curve by D. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('37a1') 

sage: E7=E.quadratic_twist(7); E7 

Elliptic Curve defined by y^2 = x^3 - 784*x + 5488 over Rational Field 

sage: E7.conductor() 

29008 

sage: E7.quadratic_twist(7) == E 

True 

""" 

return EllipticCurve_number_field.quadratic_twist(self, D).minimal_model() 

 

def minimal_quadratic_twist(self): 

r""" 

Determine a quadratic twist with minimal conductor. Return a 

global minimal model of the twist and the fundamental 

discriminant of the quadratic field over which they are 

isomorphic. 

 

.. note:: 

 

If there is more than one curve with minimal conductor, the 

one returned is the one with smallest label (if in the 

database), or the one with minimal `a`-invariant list 

(otherwise). 

 

.. note:: 

 

For curves with `j`-invariant 0 or 1728 the curve returned 

is the minimal quadratic twist, not necessarily the minimal 

twist (which would have conductor 27 or 32 respectively). 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('121d1') 

sage: E.minimal_quadratic_twist() 

(Elliptic Curve defined by y^2 + y = x^3 - x^2 over Rational Field, -11) 

sage: Et, D = EllipticCurve('32a1').minimal_quadratic_twist() 

sage: D 

1 

 

sage: E = EllipticCurve('11a1') 

sage: Et, D = E.quadratic_twist(-24).minimal_quadratic_twist() 

sage: E == Et 

True 

sage: D 

-24 

 

sage: E = EllipticCurve([0,0,0,0,1000]) 

sage: E.minimal_quadratic_twist() 

(Elliptic Curve defined by y^2 = x^3 + 1 over Rational Field, 40) 

sage: E = EllipticCurve([0,0,0,1600,0]) 

sage: E.minimal_quadratic_twist() 

(Elliptic Curve defined by y^2 = x^3 + 4*x over Rational Field, 5) 

 

If the curve has square-free conductor then it is already minimal (see :trac:`14060`):: 

 

sage: E = next(cremona_optimal_curves([2*3*5*7*11])) 

sage: (E, 1) == E.minimal_quadratic_twist() 

True 

 

An example where the minimal quadratic twist is not the 

minimal twist (which has conductor 27):: 

 

sage: E = EllipticCurve([0,0,0,0,7]) 

sage: E.j_invariant() 

0 

sage: E.minimal_quadratic_twist()[0].conductor() 

5292 

""" 

if self.conductor().is_squarefree(): 

return self, Integer(1) 

j = self.j_invariant() 

if j!=0 and j!=1728: 

# the constructor from j will give the minimal twist 

Et = constructor.EllipticCurve_from_j(j) 

else: 

if j==0: # divide c6 by largest cube 

c = -2*self.c6() 

for p in c.support(): 

e = c.valuation(p)//3 

c /= p**(3*e) 

E1 = constructor.EllipticCurve([0,0,0,0,c]) 

elif j==1728: # divide c4 by largest square 

c = -3*self.c4() 

for p in c.support(): 

e = c.valuation(p)//2 

c /= p**(2*e) 

E1 = constructor.EllipticCurve([0,0,0,c,0]) 

tw = [-1,2,-2,3,-3,6,-6] 

Elist = [E1] + [E1.quadratic_twist(t) for t in tw] 

Elist.sort(key=lambda E: E.conductor()) 

Et = Elist[0] 

 

Et = Et.minimal_model() 

 

D = self.is_quadratic_twist(Et) # 1 or square-free 

if D % 4 != 1: 

D *= 4 

 

return Et, D 

 

 

########################################################## 

# Isogeny class 

########################################################## 

def isogeny_class(self, algorithm="sage", order=None): 

r""" 

Return the `\QQ`-isogeny class of this elliptic curve. 

 

INPUT: 

 

- ``algorithm`` - string: one of the following: 

 

- "database" - use the Cremona database (only works if 

curve is isomorphic to a curve in the database) 

 

- "sage" (default) - use the native Sage implementation. 

 

- ``order`` -- None, string, or list of curves (default: 

None): If not None then the curves in the class are 

reordered after being computed. Note that if the order is 

None then the resulting order will depend on the algorithm. 

 

- if ``order`` is "database" or "sage", then the reordering 

is so that the order of curves matches the order produced 

by that algorithm. 

 

- if ``order`` is "lmfdb" then the curves are sorted 

lexicographically by a-invariants, in the LMFDB database. 

 

- if ``order`` is a list of curves, then the curves in the 

class are reordered to be isomorphic with the specified 

list of curves. 

 

OUTPUT: 

 

An instance of the class 

:class:`sage.schemes.elliptic_curves.isogeny_class.IsogenyClass_EC_Rational`. 

This object models a list of minimal models (with containment, 

index, etc based on isomorphism classes). It also has methods 

for computing the isogeny matrix and the list of isogenies 

between curves in this class. 

 

.. note:: 

 

The curves in the isogeny class will all be standard 

minimal models. 

 

EXAMPLES:: 

 

sage: isocls = EllipticCurve('37b').isogeny_class(order="lmfdb") 

sage: isocls 

Elliptic curve isogeny class 37b 

sage: isocls.curves 

(Elliptic Curve defined by y^2 + y = x^3 + x^2 - 1873*x - 31833 over Rational Field, 

Elliptic Curve defined by y^2 + y = x^3 + x^2 - 23*x - 50 over Rational Field, 

Elliptic Curve defined by y^2 + y = x^3 + x^2 - 3*x + 1 over Rational Field) 

sage: isocls.matrix() 

[1 3 9] 

[3 1 3] 

[9 3 1] 

 

:: 

 

sage: isocls = EllipticCurve('37b').isogeny_class('database', order="lmfdb"); isocls.curves 

(Elliptic Curve defined by y^2 + y = x^3 + x^2 - 1873*x - 31833 over Rational Field, 

Elliptic Curve defined by y^2 + y = x^3 + x^2 - 23*x - 50 over Rational Field, 

Elliptic Curve defined by y^2 + y = x^3 + x^2 - 3*x + 1 over Rational Field) 

 

This is an example of a curve with a `37`-isogeny:: 

 

sage: E = EllipticCurve([1,1,1,-8,6]) 

sage: isocls = E.isogeny_class(); isocls 

Isogeny class of Elliptic Curve defined by y^2 + x*y + y = x^3 + x^2 - 8*x + 6 over Rational Field 

sage: isocls.matrix() 

[ 1 37] 

[37 1] 

sage: print("\n".join([repr(E) for E in isocls.curves])) 

Elliptic Curve defined by y^2 + x*y + y = x^3 + x^2 - 8*x + 6 over Rational Field 

Elliptic Curve defined by y^2 + x*y + y = x^3 + x^2 - 208083*x - 36621194 over Rational Field 

 

This curve had numerous `2`-isogenies:: 

 

sage: e=EllipticCurve([1,0,0,-39,90]) 

sage: isocls = e.isogeny_class(); isocls.matrix() 

[1 2 4 4 8 8] 

[2 1 2 2 4 4] 

[4 2 1 4 8 8] 

[4 2 4 1 2 2] 

[8 4 8 2 1 4] 

[8 4 8 2 4 1] 

 

See http://math.harvard.edu/~elkies/nature.html for more 

interesting examples of isogeny structures. 

 

:: 

 

sage: E = EllipticCurve(j = -262537412640768000) 

sage: isocls = E.isogeny_class(); isocls.matrix() 

[ 1 163] 

[163 1] 

sage: print("\n".join([repr(C) for C in isocls.curves])) 

Elliptic Curve defined by y^2 + y = x^3 - 2174420*x + 1234136692 over Rational Field 

Elliptic Curve defined by y^2 + y = x^3 - 57772164980*x - 5344733777551611 over Rational Field 

 

 

The degrees of isogenies are invariant under twists:: 

 

sage: E = EllipticCurve(j = -262537412640768000) 

sage: E1 = E.quadratic_twist(6584935282) 

sage: isocls = E1.isogeny_class(); isocls.matrix() 

[ 1 163] 

[163 1] 

sage: E1.conductor() 

18433092966712063653330496 

 

:: 

 

sage: E = EllipticCurve('14a1') 

sage: isocls = E.isogeny_class(); isocls.matrix() 

[ 1 2 3 3 6 6] 

[ 2 1 6 6 3 3] 

[ 3 6 1 9 2 18] 

[ 3 6 9 1 18 2] 

[ 6 3 2 18 1 9] 

[ 6 3 18 2 9 1] 

sage: print("\n".join([repr(C) for C in isocls.curves])) 

Elliptic Curve defined by y^2 + x*y + y = x^3 + 4*x - 6 over Rational Field 

Elliptic Curve defined by y^2 + x*y + y = x^3 - 36*x - 70 over Rational Field 

Elliptic Curve defined by y^2 + x*y + y = x^3 - x over Rational Field 

Elliptic Curve defined by y^2 + x*y + y = x^3 - 171*x - 874 over Rational Field 

Elliptic Curve defined by y^2 + x*y + y = x^3 - 11*x + 12 over Rational Field 

Elliptic Curve defined by y^2 + x*y + y = x^3 - 2731*x - 55146 over Rational Field 

sage: isocls2 = isocls.reorder('lmfdb'); isocls2.matrix() 

[ 1 2 3 9 18 6] 

[ 2 1 6 18 9 3] 

[ 3 6 1 3 6 2] 

[ 9 18 3 1 2 6] 

[18 9 6 2 1 3] 

[ 6 3 2 6 3 1] 

sage: print("\n".join([repr(C) for C in isocls2.curves])) 

Elliptic Curve defined by y^2 + x*y + y = x^3 - 2731*x - 55146 over Rational Field 

Elliptic Curve defined by y^2 + x*y + y = x^3 - 171*x - 874 over Rational Field 

Elliptic Curve defined by y^2 + x*y + y = x^3 - 36*x - 70 over Rational Field 

Elliptic Curve defined by y^2 + x*y + y = x^3 - 11*x + 12 over Rational Field 

Elliptic Curve defined by y^2 + x*y + y = x^3 - x over Rational Field 

Elliptic Curve defined by y^2 + x*y + y = x^3 + 4*x - 6 over Rational Field 

 

:: 

 

sage: E = EllipticCurve('11a1') 

sage: isocls = E.isogeny_class(); isocls.matrix() 

[ 1 5 5] 

[ 5 1 25] 

[ 5 25 1] 

sage: f = isocls.isogenies()[0][1]; f.kernel_polynomial() 

x^2 + x - 29/5 

""" 

try: 

isoclass = self._isoclass[algorithm] 

except KeyError: 

from sage.schemes.elliptic_curves.isogeny_class import IsogenyClass_EC_Rational 

if hasattr(self, "_lmfdb_label") and self._lmfdb_label: 

label = self._lmfdb_label[:-1] 

elif hasattr(self, "_EllipticCurve_rational_field__cremona_label") and self.__cremona_label: 

label = self.__cremona_label[:-1] 

else: 

label = None 

 

isoclass = IsogenyClass_EC_Rational(self, algorithm, label) 

self._isoclass[algorithm] = isoclass 

 

if order: 

isoclass = isoclass.reorder(order) 

 

return isoclass 

 

def isogenies_prime_degree(self, l=None): 

r""" 

Return a list of `\ell`-isogenies from self, where `\ell` is a 

prime. 

 

INPUT: 

 

- ``l`` -- either None or a prime or a list of primes. 

 

OUTPUT: 

 

(list) `\ell`-isogenies for the given `\ell` or if `\ell` is None, all 

`\ell`-isogenies. 

 

.. note:: 

 

The codomains of the isogenies returned are standard 

minimal models. This is because the functions 

:meth:`isogenies_prime_degree_genus_0()` and 

:meth:`isogenies_sporadic_Q()` are implemented that way for 

curves defined over `\QQ`. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve([45,32]) 

sage: E.isogenies_prime_degree() 

[] 

sage: E = EllipticCurve(j = -262537412640768000) 

sage: E.isogenies_prime_degree() 

[Isogeny of degree 163 from Elliptic Curve defined by y^2 + y = x^3 - 2174420*x + 1234136692 over Rational Field to Elliptic Curve defined by y^2 + y = x^3 - 57772164980*x - 5344733777551611 over Rational Field] 

sage: E1 = E.quadratic_twist(6584935282) 

sage: E1.isogenies_prime_degree() 

[Isogeny of degree 163 from Elliptic Curve defined by y^2 = x^3 - 94285835957031797981376080*x + 352385311612420041387338054224547830898 over Rational Field to Elliptic Curve defined by y^2 = x^3 - 2505080375542377840567181069520*x - 1526091631109553256978090116318797845018020806 over Rational Field] 

 

sage: E = EllipticCurve('14a1') 

sage: E.isogenies_prime_degree(2) 

[Isogeny of degree 2 from Elliptic Curve defined by y^2 + x*y + y = x^3 + 4*x - 6 over Rational Field to Elliptic Curve defined by y^2 + x*y + y = x^3 - 36*x - 70 over Rational Field] 

sage: E.isogenies_prime_degree(3) 

[Isogeny of degree 3 from Elliptic Curve defined by y^2 + x*y + y = x^3 + 4*x - 6 over Rational Field to Elliptic Curve defined by y^2 + x*y + y = x^3 - x over Rational Field, Isogeny of degree 3 from Elliptic Curve defined by y^2 + x*y + y = x^3 + 4*x - 6 over Rational Field to Elliptic Curve defined by y^2 + x*y + y = x^3 - 171*x - 874 over Rational Field] 

sage: E.isogenies_prime_degree(5) 

[] 

sage: E.isogenies_prime_degree(11) 

[] 

sage: E.isogenies_prime_degree(29) 

[] 

sage: E.isogenies_prime_degree(4) 

Traceback (most recent call last): 

... 

ValueError: 4 is not prime. 

 

""" 

from .isogeny_small_degree import isogenies_prime_degree_genus_0, isogenies_sporadic_Q 

 

if l in [2, 3, 5, 7, 13]: 

return isogenies_prime_degree_genus_0(self, l) 

elif l is not None and not isinstance(l, list): 

try: 

if l.is_prime(proof=False): 

return isogenies_sporadic_Q(self, l) 

else: 

raise ValueError("%s is not prime."%l) 

except AttributeError: 

raise ValueError("%s is not prime."%l) 

if l is None: 

isogs = isogenies_prime_degree_genus_0(self) 

if isogs != []: 

return isogs 

else: 

return isogenies_sporadic_Q(self) 

if isinstance(l, list): 

isogs = [] 

i = 0 

while i<len(l): 

isogenies = [f for f in self.isogenies_prime_degree(l[i]) if not f in isogs] 

isogs.extend(isogenies) 

i = i+1 

return isogs 

 

def is_isogenous(self, other, proof=True, maxp=200): 

""" 

Return whether or not self is isogenous to other. 

 

INPUT: 

 

- ``other`` -- another elliptic curve. 

 

- ``proof`` (default True) -- If ``False``, the function will 

return ``True`` whenever the two curves have the same 

conductor and are isogenous modulo `p` for `p` up to ``maxp``. 

If ``True``, this test is followed by a rigorous test (which 

may be more time-consuming). 

 

- ``maxp`` (int, default 200) -- The maximum prime `p` for 

which isogeny modulo `p` will be checked. 

 

OUTPUT: 

 

(bool) True if there is an isogeny from curve ``self`` to 

curve ``other``. 

 

METHOD: 

 

First the conductors are compared as well as the Traces of 

Frobenius for good primes up to ``maxp``. If any of these 

tests fail, ``False`` is returned. If they all pass and 

``proof`` is ``False`` then ``True`` is returned, otherwise a 

complete set of curves isogenous to ``self`` is computed and 

``other`` is checked for isomorphism with any of these, 

 

EXAMPLES:: 

 

sage: E1 = EllipticCurve('14a1') 

sage: E6 = EllipticCurve('14a6') 

sage: E1.is_isogenous(E6) 

True 

sage: E1.is_isogenous(EllipticCurve('11a1')) 

False 

 

:: 

 

sage: EllipticCurve('37a1').is_isogenous(EllipticCurve('37b1')) 

False 

 

:: 

 

sage: E = EllipticCurve([2, 16]) 

sage: EE = EllipticCurve([87, 45]) 

sage: E.is_isogenous(EE) 

False 

""" 

if not is_EllipticCurve(other): 

raise ValueError("Second argument is not an Elliptic Curve.") 

if not other.base_field() is QQ: 

raise ValueError("If first argument is an elliptic curve over QQ then the second argument must be also.") 

 

if self.is_isomorphic(other): 

return True 

 

E1 = self.minimal_model() 

E2 = other.minimal_model() 

D1 = E1.discriminant() 

D2 = E2.discriminant() 

 

if any([E1.change_ring(rings.GF(p)).cardinality() != E2.change_ring(rings.GF(p)).cardinality() for p in [p for p in rings.prime_range(2,maxp) if D1.valuation(p) == 0 and D2.valuation(p) == 0]]): 

return False 

 

if E1.conductor() != E2.conductor(): 

return False 

 

if not proof: 

return True 

else: 

return E2 in E1.isogeny_class().curves 

 

def isogeny_degree(self, other): 

""" 

Return the minimal degree of an isogeny between self and 

other. 

 

INPUT: 

 

- ``other`` -- another elliptic curve. 

 

OUTPUT: 

 

(int) The minimal degree of an isogeny from ``self`` to 

``other``, or 0 if the curves are not isogenous. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve([-1056, 13552]) 

sage: E2 = EllipticCurve([-127776, -18037712]) 

sage: E.isogeny_degree(E2) 

11 

 

:: 

 

sage: E1 = EllipticCurve('14a1') 

sage: E2 = EllipticCurve('14a2') 

sage: E3 = EllipticCurve('14a3') 

sage: E4 = EllipticCurve('14a4') 

sage: E5 = EllipticCurve('14a5') 

sage: E6 = EllipticCurve('14a6') 

sage: E3.isogeny_degree(E1) 

3 

sage: E3.isogeny_degree(E2) 

6 

sage: E3.isogeny_degree(E3) 

1 

sage: E3.isogeny_degree(E4) 

9 

sage: E3.isogeny_degree(E5) 

2 

sage: E3.isogeny_degree(E6) 

18 

 

:: 

 

sage: E1 = EllipticCurve('30a1') 

sage: E2 = EllipticCurve('30a2') 

sage: E3 = EllipticCurve('30a3') 

sage: E4 = EllipticCurve('30a4') 

sage: E5 = EllipticCurve('30a5') 

sage: E6 = EllipticCurve('30a6') 

sage: E7 = EllipticCurve('30a7') 

sage: E8 = EllipticCurve('30a8') 

sage: E1.isogeny_degree(E1) 

1 

sage: E1.isogeny_degree(E2) 

2 

sage: E1.isogeny_degree(E3) 

3 

sage: E1.isogeny_degree(E4) 

4 

sage: E1.isogeny_degree(E5) 

4 

sage: E1.isogeny_degree(E6) 

6 

sage: E1.isogeny_degree(E7) 

12 

sage: E1.isogeny_degree(E8) 

12 

 

:: 

 

sage: E1 = EllipticCurve('15a1') 

sage: E2 = EllipticCurve('15a2') 

sage: E3 = EllipticCurve('15a3') 

sage: E4 = EllipticCurve('15a4') 

sage: E5 = EllipticCurve('15a5') 

sage: E6 = EllipticCurve('15a6') 

sage: E7 = EllipticCurve('15a7') 

sage: E8 = EllipticCurve('15a8') 

sage: E1.isogeny_degree(E1) 

1 

sage: E7.isogeny_degree(E2) 

8 

sage: E7.isogeny_degree(E3) 

2 

sage: E7.isogeny_degree(E4) 

8 

sage: E7.isogeny_degree(E5) 

16 

sage: E7.isogeny_degree(E6) 

16 

sage: E7.isogeny_degree(E8) 

4 

 

0 is returned when the curves are not isogenous:: 

 

sage: A = EllipticCurve('37a1') 

sage: B = EllipticCurve('37b1') 

sage: A.isogeny_degree(B) 

0 

sage: A.is_isogenous(B) 

False 

""" 

E1 = self.minimal_model() 

E2 = other.minimal_model() 

 

if not E1.is_isogenous(E2, proof=False): 

return Integer(0) 

 

isocls = E1.isogeny_class() 

try: 

return isocls.matrix(fill=True)[0,isocls.index(E2)] 

except ValueError: 

return Integer(0) 

 

# 

# The following function can be implemented once composition of 

# isogenies has been implemented. 

# 

# def construct_isogeny(self, other): 

# """ 

# Return an isogeny from self to other if the two curves are in 

# the same isogeny class. 

# """ 

 

 

def optimal_curve(self): 

""" 

Given an elliptic curve that is in the installed Cremona 

database, return the optimal curve isogenous to it. 

 

EXAMPLES: 

 

The following curve is not optimal:: 

 

sage: E = EllipticCurve('11a2'); E 

Elliptic Curve defined by y^2 + y = x^3 - x^2 - 7820*x - 263580 over Rational Field 

sage: E.optimal_curve() 

Elliptic Curve defined by y^2 + y = x^3 - x^2 - 10*x - 20 over Rational Field 

sage: E.optimal_curve().cremona_label() 

'11a1' 

 

Note that 990h is the special case where the optimal curve 

isn't the first in the Cremona labeling:: 

 

sage: E = EllipticCurve('990h4'); E 

Elliptic Curve defined by y^2 + x*y + y = x^3 - x^2 + 6112*x - 41533 over Rational Field 

sage: F = E.optimal_curve(); F 

Elliptic Curve defined by y^2 + x*y + y = x^3 - x^2 - 1568*x - 4669 over Rational Field 

sage: F.cremona_label() 

'990h3' 

sage: EllipticCurve('990a1').optimal_curve().cremona_label() # a isn't h. 

'990a1' 

 

If the input curve is optimal, this function returns that 

curve (not just a copy of it or a curve isomorphic to it!):: 

 

sage: E = EllipticCurve('37a1') 

sage: E.optimal_curve() is E 

True 

 

Also, if this curve is optimal but not given by a minimal 

model, this curve will still be returned, so this function 

need not return a minimal model in general. 

 

:: 

 

sage: F = E.short_weierstrass_model(); F 

Elliptic Curve defined by y^2 = x^3 - 16*x + 16 over Rational Field 

sage: F.optimal_curve() 

Elliptic Curve defined by y^2 = x^3 - 16*x + 16 over Rational Field 

""" 

label = self.cremona_label() 

N, isogeny, number = sage.databases.cremona.parse_cremona_label(label) 

if N == 990 and isogeny == 'h': 

optimal_label = '990h3' 

else: 

optimal_label = '%s%s1'%(N,isogeny) 

if optimal_label == label: return self 

return constructor.EllipticCurve(optimal_label) 

 

def isogeny_graph(self, order=None): 

r""" 

Return a graph representing the isogeny class of this elliptic 

curve, where the vertices are isogenous curves over 

`\QQ` and the edges are prime degree isogenies. 

 

.. note:: 

 

The vertices are labeled 1 to n rather than 0 to n-1 to 

correspond to LMFDB and Cremona labels. 

 

EXAMPLES:: 

 

sage: LL = [] 

sage: for e in cremona_optimal_curves(range(1, 38)): # long time 

....: G = e.isogeny_graph() 

....: already = False 

....: for H in LL: 

....: if G.is_isomorphic(H): 

....: already = True 

....: break 

....: if not already: 

....: LL.append(G) 

sage: graphs_list.show_graphs(LL) # long time 

 

:: 

 

sage: E = EllipticCurve('195a') 

sage: G = E.isogeny_graph() 

sage: for v in G: print("{} {}".format(v, G.get_vertex(v))) 

... 

1 Elliptic Curve defined by y^2 + x*y = x^3 - 110*x + 435 over Rational Field 

2 Elliptic Curve defined by y^2 + x*y = x^3 - 115*x + 392 over Rational Field 

3 Elliptic Curve defined by y^2 + x*y = x^3 + 210*x + 2277 over Rational Field 

4 Elliptic Curve defined by y^2 + x*y = x^3 - 520*x - 4225 over Rational Field 

5 Elliptic Curve defined by y^2 + x*y = x^3 + 605*x - 19750 over Rational Field 

6 Elliptic Curve defined by y^2 + x*y = x^3 - 8125*x - 282568 over Rational Field 

7 Elliptic Curve defined by y^2 + x*y = x^3 - 7930*x - 296725 over Rational Field 

8 Elliptic Curve defined by y^2 + x*y = x^3 - 130000*x - 18051943 over Rational Field 

sage: G.plot(edge_labels=True) 

Graphics object consisting of 23 graphics primitives 

""" 

return self.isogeny_class(order=order).graph() 

 

def manin_constant(self): 

r""" 

Return the Manin constant of this elliptic curve. 

 

If `\phi: X_0(N) \to E` is the modular 

parametrization of minimal degree, then the Manin constant `c` is defined to be the rational 

number `c` such that `\phi^*(\omega_E) = c\cdot \omega_f` where `\omega_E` is a Néron differential and `\omega_f = f(q) dq/q` is the differential on `X_0(N)` corresponding to the 

newform `f` attached to the isogeny class of `E`. 

 

It is known that the Manin constant is an integer. It is conjectured that in each class there is at least one, more precisely the so-called strong Weil curve or `X_0(N)`-optimal curve, that has Manin constant `1`. 

 

OUTPUT: 

 

an integer 

 

This function only works if the curve is in the installed 

Cremona database. Sage includes by default a small database; 

for the full database you have to install an optional package. 

 

EXAMPLES:: 

 

sage: EllipticCurve('11a1').manin_constant() 

1 

sage: EllipticCurve('11a2').manin_constant() 

1 

sage: EllipticCurve('11a3').manin_constant() 

5 

 

Check that it works even if the curve is non-minimal:: 

 

sage: EllipticCurve('11a3').change_weierstrass_model([1/35,0,0,0]).manin_constant() 

5 

 

Rather complicated examples (see :trac:`12080`) :: 

 

sage: [ EllipticCurve('27a%s'%i).manin_constant() for i in [1,2,3,4]] 

[1, 1, 3, 3] 

sage: [ EllipticCurve('80b%s'%i).manin_constant() for i in [1,2,3,4]] 

[1, 2, 1, 2] 

 

""" 

from sage.databases.cremona import CremonaDatabase 

 

if self.conductor() > CremonaDatabase().largest_conductor(): 

raise NotImplementedError("The Manin constant can only be evaluated for curves in Cremona's tables. If you have not done so, you may wish to install the optional large database.") 

 

E = self.minimal_model() 

C = self.optimal_curve() 

m = C.isogeny_class().matrix() 

ma = max(max(x) for x in m) 

OmC = C.period_lattice().basis() 

OmE = E.period_lattice().basis() 

q_plus = QQ(gp.bestappr(OmE[0]/OmC[0],ma+1) ) 

n_plus = q_plus.numerator() 

 

cinf_E = E.real_components() 

cinf_C = C.real_components() 

OmC_minus = OmC[1].imag() 

if cinf_C == 1: 

OmC_minus *= 2 

OmE_minus = OmE[1].imag() 

if cinf_E == 1: 

OmE_minus *= 2 

q_minus = QQ(gp.bestappr(OmE_minus/OmC_minus, ma+1)) 

n_minus = q_minus.numerator() 

n = ZZ(n_minus * n_plus) 

 

if cinf_C == cinf_E: 

return n 

# otherwise they have different number of connected component and we have to adjust for this 

elif cinf_C > cinf_E: 

if ZZ(n_plus) % 2 == 0 and ZZ(n_minus) % 2 == 0: 

return n // 2 

else: 

return n 

else: #if cinf_C < cinf_E: 

if q_plus.denominator() % 2 == 0 and q_minus.denominator() % 2 == 0: 

return n 

else: 

return n*2 

 

def _shortest_paths(self): 

r""" 

Technical internal function that returns the list of isogenies 

curves and corresponding dictionary of shortest isogeny paths 

from self to each other curve in the isogeny class. 

 

OUTPUT: 

 

list, dict 

 

EXAMPLES:: 

 

sage: EllipticCurve('11a1')._shortest_paths() 

((Elliptic Curve defined by y^2 + y = x^3 - x^2 - 10*x - 20 over Rational Field, 

Elliptic Curve defined by y^2 + y = x^3 - x^2 over Rational Field, 

Elliptic Curve defined by y^2 + y = x^3 - x^2 - 7820*x - 263580 over Rational Field), 

{0: 0, 1: 5, 2: 5}) 

sage: EllipticCurve('11a2')._shortest_paths() 

((Elliptic Curve defined by y^2 + y = x^3 - x^2 - 7820*x - 263580 over Rational Field, 

Elliptic Curve defined by y^2 + y = x^3 - x^2 - 10*x - 20 over Rational Field, 

Elliptic Curve defined by y^2 + y = x^3 - x^2 over Rational Field), 

{0: 0, 1: 5, 2: 25}) 

""" 

from sage.graphs.graph import Graph 

from sage.rings.real_mpfr import RR 

isocls = self.isogeny_class() 

M = isocls.matrix(fill=True).change_ring(rings.RR) 

# see trac #4889 for nebulous M.list() --> M.entries() change... 

# Take logs here since shortest path minimizes the *sum* of the weights -- not the product. 

M = M.parent()([a.log() if a else 0 for a in M.list()]) 

G = Graph(M, format='weighted_adjacency_matrix') 

G.set_vertices(dict([(v,isocls[v]) for v in G.vertices()])) 

v = G.shortest_path_lengths(0, by_weight=True) 

# Now exponentiate and round to get degrees of isogenies 

v = dict([(i, j.exp().round() if j else 0) for i,j in iteritems(v)]) 

return isocls.curves, v 

 

def _multiple_of_degree_of_isogeny_to_optimal_curve(self): 

r""" 

Internal function returning an integer m such that the degree of 

the isogeny between this curve and the optimal curve in its 

isogeny class is a divisor of m. 

 

.. warning:: 

 

The result is *not* provably correct, in the 

sense that when the numbers are huge isogenies could be 

missed because of precision issues. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('11a1') 

sage: E._multiple_of_degree_of_isogeny_to_optimal_curve() 

5 

sage: E = EllipticCurve('11a2') 

sage: E._multiple_of_degree_of_isogeny_to_optimal_curve() 

25 

sage: E = EllipticCurve('11a3') 

sage: E._multiple_of_degree_of_isogeny_to_optimal_curve() 

25 

""" 

_, v = self._shortest_paths() 

# Compute the degree of an isogeny from self to anything else 

# in the isogeny class of self. Assuming the isogeny 

# enumeration is complete (which need not be the case a priori!), the LCM 

# of these numbers is a multiple of the degree of the isogeny 

# to the optimal curve. 

v = [deg for num, deg in iteritems(v) if deg] # get just the degrees 

return arith.LCM(v) 

 

########################################################## 

# Galois Representations 

########################################################## 

 

def galois_representation(self): 

r""" 

The compatible family of the Galois representation 

attached to this elliptic curve. 

 

Given an elliptic curve `E` over `\QQ` 

and a rational prime number `p`, the `p^n`-torsion 

`E[p^n]` points of `E` is a representation of the 

absolute Galois group of `\QQ`. As `n` varies 

we obtain the Tate module `T_p E` which is a 

a representation of `G_K` on a free `\ZZ_p`-module 

of rank `2`. As `p` varies the representations 

are compatible. 

 

EXAMPLES:: 

 

sage: rho = EllipticCurve('11a1').galois_representation() 

sage: rho 

Compatible family of Galois representations associated to the Elliptic Curve defined by y^2 + y = x^3 - x^2 - 10*x - 20 over Rational Field 

sage: rho.is_irreducible(7) 

True 

sage: rho.is_irreducible(5) 

False 

sage: rho.is_surjective(11) 

True 

sage: rho.non_surjective() 

[5] 

sage: rho = EllipticCurve('37a1').galois_representation() 

sage: rho.non_surjective() 

[] 

sage: rho = EllipticCurve('27a1').galois_representation() 

sage: rho.is_irreducible(7) 

True 

sage: rho.non_surjective() # cm-curve 

[0] 

 

""" 

try: 

return self.__rho 

except AttributeError: 

from .gal_reps import GaloisRepresentation 

self.__rho = GaloisRepresentation(self) 

return self.__rho 

 

def is_semistable(self): 

""" 

Return ``True`` iff this elliptic curve is semi-stable at all primes. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('37a1') 

sage: E.is_semistable() 

True 

sage: E = EllipticCurve('90a1') 

sage: E.is_semistable() 

False 

""" 

return self.conductor().is_squarefree() 

 

def is_ordinary(self, p, ell=None): 

""" 

Return ``True`` precisely when the mod-p representation attached to 

this elliptic curve is ordinary at ell. 

 

INPUT: 

 

- ``p`` - a prime ell - a prime (default: p) 

 

OUTPUT: bool 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('37a1') 

sage: E.is_ordinary(37) 

True 

sage: E = EllipticCurve('32a1') 

sage: E.is_ordinary(2) 

False 

sage: [p for p in prime_range(50) if E.is_ordinary(p)] 

[5, 13, 17, 29, 37, 41] 

""" 

if ell is None: 

ell = p 

return self.ap(ell) % p != 0 

 

def is_good(self, p, check=True): 

""" 

Return ``True`` if `p` is a prime of good reduction for `E`. 

 

INPUT: 

 

- ``p`` - a prime 

 

OUTPUT: bool 

 

EXAMPLES:: 

 

sage: e = EllipticCurve('11a') 

sage: e.is_good(-8) 

Traceback (most recent call last): 

... 

ValueError: p must be prime 

sage: e.is_good(-8, check=False) 

True 

 

""" 

if check: 

if not arith.is_prime(p): 

raise ValueError("p must be prime") 

return self.conductor() % p != 0 

 

 

def is_supersingular(self, p, ell=None): 

""" 

Return ``True`` precisely when p is a prime of good reduction and the 

mod-p representation attached to this elliptic curve is 

supersingular at ell. 

 

INPUT: 

 

- ``p`` - a prime ell - a prime (default: p) 

 

OUTPUT: bool 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('37a1') 

sage: E.is_supersingular(37) 

False 

sage: E = EllipticCurve('32a1') 

sage: E.is_supersingular(2) 

False 

sage: E.is_supersingular(7) 

True 

sage: [p for p in prime_range(50) if E.is_supersingular(p)] 

[3, 7, 11, 19, 23, 31, 43, 47] 

 

""" 

if ell is None: 

ell = p 

return self.is_good(p) and not self.is_ordinary(p, ell) 

 

def supersingular_primes(self, B): 

""" 

Return a list of all supersingular primes for this elliptic curve 

up to and possibly including B. 

 

EXAMPLES:: 

 

sage: e = EllipticCurve('11a') 

sage: e.aplist(20) 

[-2, -1, 1, -2, 1, 4, -2, 0] 

sage: e.supersingular_primes(1000) 

[2, 19, 29, 199, 569, 809] 

 

:: 

 

sage: e = EllipticCurve('27a') 

sage: e.aplist(20) 

[0, 0, 0, -1, 0, 5, 0, -7] 

sage: e.supersingular_primes(97) 

[2, 5, 11, 17, 23, 29, 41, 47, 53, 59, 71, 83, 89] 

sage: e.ordinary_primes(97) 

[7, 13, 19, 31, 37, 43, 61, 67, 73, 79, 97] 

sage: e.supersingular_primes(3) 

[2] 

sage: e.supersingular_primes(2) 

[2] 

sage: e.supersingular_primes(1) 

[] 

""" 

v = self.aplist(max(B, 3)) 

P = rings.prime_range(max(B,3)+1) 

N = self.conductor() 

return [P[i] for i in [0,1] if P[i] <= B and v[i]%P[i]==0 and N%P[i] != 0] + \ 

[P[i] for i in range(2,len(v)) if v[i] == 0 and N%P[i] != 0] 

 

def ordinary_primes(self, B): 

""" 

Return a list of all ordinary primes for this elliptic curve up to 

and possibly including B. 

 

EXAMPLES:: 

 

sage: e = EllipticCurve('11a') 

sage: e.aplist(20) 

[-2, -1, 1, -2, 1, 4, -2, 0] 

sage: e.ordinary_primes(97) 

[3, 5, 7, 11, 13, 17, 23, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97] 

sage: e = EllipticCurve('49a') 

sage: e.aplist(20) 

[1, 0, 0, 0, 4, 0, 0, 0] 

sage: e.supersingular_primes(97) 

[3, 5, 13, 17, 19, 31, 41, 47, 59, 61, 73, 83, 89, 97] 

sage: e.ordinary_primes(97) 

[2, 11, 23, 29, 37, 43, 53, 67, 71, 79] 

sage: e.ordinary_primes(3) 

[2] 

sage: e.ordinary_primes(2) 

[2] 

sage: e.ordinary_primes(1) 

[] 

""" 

v = self.aplist(max(B, 3) ) 

P = rings.prime_range(max(B,3) +1) 

return [P[i] for i in [0,1] if P[i] <= B and v[i]%P[i]!=0] +\ 

[P[i] for i in range(2,len(v)) if v[i] != 0] 

 

def eval_modular_form(self, points, prec): 

r""" 

Evaluate the modular form of this elliptic curve at points in `\CC`. 

 

INPUT: 

 

 

- ``points`` - a list of points in the half-plane of 

convergence 

 

- ``prec`` - precision 

 

 

OUTPUT: A list of values L(E,s) for s in points 

 

.. note:: 

 

Better examples are welcome. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('37a1') 

sage: E.eval_modular_form([1.5+I,2.0+I,2.5+I],0.000001) 

[0, 0, 0] 

""" 

if not isinstance(points, list): 

try: 

points = list(points) 

except TypeError: 

return self.eval_modular_form([points], prec) 

an = self.pari_mincurve().ellan(prec) 

s = 0 

c = pari('2 * Pi * I') 

ans = [] 

for z in points: 

s = pari(0) 

r0 = (c*z).exp() 

r = r0 

for n in range(1, prec): 

s += an[n-1]*r 

r *= r0 

ans.append(s.sage()) 

return ans 

 

 

######################################################################## 

# The Tate-Shafarevich group 

######################################################################## 

 

def sha(self): 

""" 

Return an object of class 

'sage.schemes.elliptic_curves.sha_tate.Sha' attached to this 

elliptic curve. 

 

This can be used in functions related to bounding the order of Sha 

(The Tate-Shafarevich group of the curve). 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('37a1') 

sage: S=E.sha() 

sage: S 

Tate-Shafarevich group for the Elliptic Curve defined by y^2 + y = x^3 - x over Rational Field 

sage: S.bound_kolyvagin() 

([2], 1) 

""" 

try: 

return self.__sha 

except AttributeError: 

from .sha_tate import Sha 

self.__sha = Sha(self) 

return self.__sha 

 

################################################################################# 

# Functions related to Heegner points################################################################################# 

heegner_point = heegner.ell_heegner_point 

kolyvagin_point = heegner.kolyvagin_point 

 

heegner_discriminants = heegner.ell_heegner_discriminants 

heegner_discriminants_list = heegner.ell_heegner_discriminants_list 

satisfies_heegner_hypothesis = heegner.satisfies_heegner_hypothesis 

 

heegner_point_height = heegner.heegner_point_height 

 

heegner_index = heegner.heegner_index 

_adjust_heegner_index = heegner._adjust_heegner_index 

heegner_index_bound = heegner.heegner_index_bound 

_heegner_index_in_EK = heegner._heegner_index_in_EK 

 

heegner_sha_an = heegner.heegner_sha_an 

 

_heegner_forms_list = heegner._heegner_forms_list 

_heegner_best_tau = heegner._heegner_best_tau 

 

################################################################################# 

# p-adic functions 

################################################################################# 

 

padic_regulator = padics.padic_regulator 

 

padic_height_pairing_matrix = padics.padic_height_pairing_matrix 

 

padic_height = padics.padic_height 

padic_height_via_multiply = padics.padic_height_via_multiply 

 

padic_sigma = padics.padic_sigma 

padic_sigma_truncated = padics.padic_sigma_truncated 

 

padic_E2 = padics.padic_E2 

 

matrix_of_frobenius = padics.matrix_of_frobenius 

 

def mod5family(self): 

""" 

Return the family of all elliptic curves with the same mod-5 

representation as self. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('32a1') 

sage: E.mod5family() 

Elliptic Curve defined by y^2 = x^3 + 4*x over Fraction Field of Univariate Polynomial Ring in t over Rational Field 

""" 

E = self.short_weierstrass_model() 

a = E.a4() 

b = E.a6() 

return mod5family.mod5family(a,b) 

 

def tate_curve(self, p): 

r""" 

Create the Tate curve over the `p`-adics associated to 

this elliptic curve. 

 

This Tate curve is a `p`-adic curve with split multiplicative 

reduction of the form `y^2+xy=x^3+s_4 x+s_6` which is 

isomorphic to the given curve over the algebraic closure of 

`\QQ_p`. Its points over `\QQ_p` 

are isomorphic to `\QQ_p^{\times}/q^{\ZZ}` 

for a certain parameter `q \in \ZZ_p`. 

 

INPUT: 

 

- `p` -- a prime where the curve has split multiplicative 

reduction 

 

EXAMPLES:: 

 

sage: e = EllipticCurve('130a1') 

sage: e.tate_curve(2) 

2-adic Tate curve associated to the Elliptic Curve defined by y^2 + x*y + y = x^3 - 33*x + 68 over Rational Field 

 

The input curve must have multiplicative reduction at the prime. 

 

:: 

 

sage: e.tate_curve(3) 

Traceback (most recent call last): 

... 

ValueError: The elliptic curve must have multiplicative reduction at 3 

 

We compute with `p=5`:: 

 

sage: T = e.tate_curve(5); T 

5-adic Tate curve associated to the Elliptic Curve defined by y^2 + x*y + y = x^3 - 33*x + 68 over Rational Field 

 

We find the Tate parameter `q`:: 

 

sage: T.parameter(prec=5) 

3*5^3 + 3*5^4 + 2*5^5 + 2*5^6 + 3*5^7 + O(5^8) 

 

We compute the `\mathcal{L}`-invariant of the curve:: 

 

sage: T.L_invariant(prec=10) 

5^3 + 4*5^4 + 2*5^5 + 2*5^6 + 2*5^7 + 3*5^8 + 5^9 + O(5^10) 

""" 

try: 

return self._tate_curve[p] 

except AttributeError: 

self._tate_curve = {} 

except KeyError: 

pass 

 

Eq = ell_tate_curve.TateCurve(self, p) 

self._tate_curve[p] = Eq 

return Eq 

 

def height(self, precision=None): 

""" 

Return the real height of this elliptic curve. This is used in 

integral_points() 

 

INPUT: 

 

 

- ``precision`` - desired real precision of the result 

(default real precision if None) 

 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('5077a1') 

sage: E.height() 

17.4513334798896 

sage: E.height(100) 

17.451333479889612702508579399 

sage: E = EllipticCurve([0,0,0,0,1]) 

sage: E.height() 

1.38629436111989 

sage: E = EllipticCurve([0,0,0,1,0]) 

sage: E.height() 

7.45471994936400 

""" 

if precision is None: 

precision = RealField().precision() 

R = RealField(precision) 

c4 = self.c4() 

c6 = self.c6() 

j = self.j_invariant() 

log_g2 = R((c4/12)).abs().log() 

log_g3 = R((c6/216)).abs().log() 

 

if j == 0: 

h_j = R(1) 

else: 

h_j = max(log(R(abs(j.numerator()))), log(R(abs(j.denominator())))) 

if (self.c4() != 0) and (self.c6() != 0): 

h_gs = max(1, log_g2, log_g3) 

elif c4 == 0: 

if c6 == 0: 

return max(1,h_j) 

h_gs = max(1, log_g3) 

else: 

h_gs = max(1, log_g2) 

return max(R(1),h_j, h_gs) 

 

def antilogarithm(self, z, max_denominator=None): 

r""" 

Return the rational point (if any) associated to this complex 

number; the inverse of the elliptic logarithm function. 

 

INPUT: 

 

- ``z`` -- a complex number representing an element of 

`\CC/L` where `L` is the period lattice of the elliptic curve 

 

- ``max_denominator`` (int or None) -- parameter controlling 

the attempted conversion of real numbers to rationals. If 

None, ``simplest_rational()`` will be used; otherwise, 

``nearby_rational()`` will be used with this value of 

``max_denominator``. 

 

OUTPUT: 

 

- point on the curve: the rational point which is the 

image of `z` under the Weierstrass parametrization, if it 

exists and can be determined from `z` and the given value 

of max_denominator (if any); otherwise a ValueError exception 

is raised. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('389a') 

sage: P = E(-1,1) 

sage: z = P.elliptic_logarithm() 

sage: E.antilogarithm(z) 

(-1 : 1 : 1) 

sage: Q = E(0,-1) 

sage: z = Q.elliptic_logarithm() 

sage: E.antilogarithm(z) 

Traceback (most recent call last): 

... 

ValueError: approximated point not on the curve 

sage: E.antilogarithm(z, max_denominator=10) 

(0 : -1 : 1) 

 

sage: E = EllipticCurve('11a1') 

sage: w1,w2 = E.period_lattice().basis() 

sage: [E.antilogarithm(a*w1/5,1) for a in range(5)] 

[(0 : 1 : 0), (16 : -61 : 1), (5 : -6 : 1), (5 : 5 : 1), (16 : 60 : 1)] 

""" 

if z.is_zero(): 

return self(0) 

expZ = self.elliptic_exponential(z) 

xy = [t.real() for t in expZ[:2]] 

if max_denominator is None: 

xy = [t.simplest_rational() for t in xy] 

else: 

xy = [t.nearby_rational(max_denominator=max_denominator) for t in xy] 

try: 

return self(xy) 

except TypeError: 

raise ValueError("approximated point not on the curve") 

 

def integral_x_coords_in_interval(self,xmin,xmax): 

r""" 

Return the set of integers `x` with `xmin\le x\le xmax` which are 

`x`-coordinates of rational points on this curve. 

 

INPUT: 

 

- ``xmin``, ``xmax`` (integers) -- two integers. 

 

OUTPUT: 

 

(set) The set of integers `x` with `xmin\le x\le xmax` which 

are `x`-coordinates of rational points on the elliptic curve. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve([0, 0, 1, -7, 6]) 

sage: xset = E.integral_x_coords_in_interval(-100,100) 

sage: sorted(xset) 

[-3, -2, -1, 0, 1, 2, 3, 4, 8, 11, 14, 21, 37, 52, 93] 

sage: xset = E.integral_x_coords_in_interval(-100, 0) 

sage: sorted(xset) 

[-3, -2, -1, 0] 

 

TESTS: 

 

The bug reported on :trac:`22719` is now fixed:: 

 

sage: E = EllipticCurve("141d1") 

sage: E.integral_points() 

[(0 : 0 : 1), (2 : 1 : 1)] 

""" 

xmin = pari(xmin) 

xmax = pari(xmax) 

H = max(1, abs(xmin), abs(xmax)) 

S = set() 

for pt in self.pari_curve().ellratpoints([H, 1]): 

x = pt[0] 

if xmin <= x <= xmax: 

S.add(ZZ(x)) 

return S 

 

prove_BSD = BSD.prove_BSD 

 

def integral_points(self, mw_base='auto', both_signs=False, verbose=False): 

""" 

Compute all integral points (up to sign) on this elliptic curve. 

 

INPUT: 

 

 

- ``mw_base`` - list of EllipticCurvePoint generating 

the Mordell-Weil group of E (default: 'auto' - calls self.gens()) 

 

- ``both_signs`` - True/False (default False): if 

True the output contains both P and -P, otherwise only one of each 

pair. 

 

- ``verbose`` - True/False (default False): if True, 

some details of the computation are output 

 

 

OUTPUT: A sorted list of all the integral points on E (up to sign 

unless both_signs is True) 

 

.. note:: 

 

The complexity increases exponentially in the rank of curve 

E. The computation time (but not the output!) depends on 

the Mordell-Weil basis. If mw_base is given but is not a 

basis for the Mordell-Weil group (modulo torsion), integral 

points which are not in the subgroup generated by the given 

points will almost certainly not be listed. 

 

EXAMPLES: A curve of rank 3 with no torsion points 

 

:: 

 

sage: E = EllipticCurve([0,0,1,-7,6]) 

sage: P1=E.point((2,0)); P2=E.point((-1,3)); P3=E.point((4,6)) 

sage: a=E.integral_points([P1,P2,P3]); a 

[(-3 : 0 : 1), (-2 : 3 : 1), (-1 : 3 : 1), (0 : 2 : 1), (1 : 0 : 1), (2 : 0 : 1), (3 : 3 : 1), (4 : 6 : 1), (8 : 21 : 1), (11 : 35 : 1), (14 : 51 : 1), (21 : 95 : 1), (37 : 224 : 1), (52 : 374 : 1), (93 : 896 : 1), (342 : 6324 : 1), (406 : 8180 : 1), (816 : 23309 : 1)] 

 

:: 

 

sage: a = E.integral_points([P1,P2,P3], verbose=True) 

Using mw_basis [(2 : 0 : 1), (3 : -4 : 1), (8 : -22 : 1)] 

e1,e2,e3: -3.0124303725933... 1.0658205476962... 1.94660982489710 

Minimal and maximal eigenvalues of height pairing matrix: 0.637920814585005,2.31982967525725 

x-coords of points on compact component with -3 <=x<= 1 

[-3, -2, -1, 0, 1] 

x-coords of points on non-compact component with 2 <=x<= 6 

[2, 3, 4] 

starting search of remaining points using coefficient bound 5 and |x| bound 1.53897183921009e25 

x-coords of extra integral points: 

[2, 3, 4, 8, 11, 14, 21, 37, 52, 93, 342, 406, 816] 

Total number of integral points: 18 

 

It is not necessary to specify mw_base; if it is not provided, 

then the Mordell-Weil basis must be computed, which may take 

much longer. 

 

:: 

 

sage: E = EllipticCurve([0,0,1,-7,6]) 

sage: a=E.integral_points(both_signs=True); a 

[(-3 : -1 : 1), (-3 : 0 : 1), (-2 : -4 : 1), (-2 : 3 : 1), (-1 : -4 : 1), (-1 : 3 : 1), (0 : -3 : 1), (0 : 2 : 1), (1 : -1 : 1), (1 : 0 : 1), (2 : -1 : 1), (2 : 0 : 1), (3 : -4 : 1), (3 : 3 : 1), (4 : -7 : 1), (4 : 6 : 1), (8 : -22 : 1), (8 : 21 : 1), (11 : -36 : 1), (11 : 35 : 1), (14 : -52 : 1), (14 : 51 : 1), (21 : -96 : 1), (21 : 95 : 1), (37 : -225 : 1), (37 : 224 : 1), (52 : -375 : 1), (52 : 374 : 1), (93 : -897 : 1), (93 : 896 : 1), (342 : -6325 : 1), (342 : 6324 : 1), (406 : -8181 : 1), (406 : 8180 : 1), (816 : -23310 : 1), (816 : 23309 : 1)] 

 

An example with negative discriminant:: 

 

sage: EllipticCurve('900d1').integral_points() 

[(-11 : 27 : 1), (-4 : 34 : 1), (4 : 18 : 1), (16 : 54 : 1)] 

 

Another example with rank 5 and no torsion points:: 

 

sage: E = EllipticCurve([-879984,319138704]) 

sage: P1=E.point((540,1188)); P2=E.point((576,1836)) 

sage: P3=E.point((468,3132)); P4=E.point((612,3132)) 

sage: P5=E.point((432,4428)) 

sage: a=E.integral_points([P1,P2,P3,P4,P5]); len(a) # long time (18s on sage.math, 2011) 

54 

 

TESTS: 

 

The bug reported on :trac:`4525` is now fixed:: 

 

sage: EllipticCurve('91b1').integral_points() 

[(-1 : 3 : 1), (1 : 0 : 1), (3 : 4 : 1)] 

 

:: 

 

sage: [len(e.integral_points(both_signs=False)) for e in cremona_curves([11..100])] # long time (15s on sage.math, 2011) 

[2, 0, 2, 3, 2, 1, 3, 0, 2, 4, 2, 4, 3, 0, 0, 1, 2, 1, 2, 0, 2, 1, 0, 1, 3, 3, 1, 1, 4, 2, 3, 2, 0, 0, 5, 3, 2, 2, 1, 1, 1, 0, 1, 3, 0, 1, 0, 1, 1, 3, 6, 1, 2, 2, 2, 0, 0, 2, 3, 1, 2, 2, 1, 1, 0, 3, 2, 1, 0, 1, 0, 1, 3, 3, 1, 1, 5, 1, 0, 1, 1, 0, 1, 2, 0, 2, 0, 1, 1, 3, 1, 2, 2, 4, 4, 2, 1, 0, 0, 5, 1, 0, 1, 2, 0, 2, 2, 0, 0, 0, 1, 0, 3, 1, 5, 1, 2, 4, 1, 0, 1, 0, 1, 0, 1, 0, 2, 2, 0, 0, 1, 0, 1, 1, 4, 1, 0, 1, 1, 0, 4, 2, 0, 1, 1, 2, 3, 1, 1, 1, 1, 6, 2, 1, 1, 0, 2, 0, 6, 2, 0, 4, 2, 2, 0, 0, 1, 2, 0, 2, 1, 0, 3, 1, 2, 1, 4, 6, 3, 2, 1, 0, 2, 2, 0, 0, 5, 4, 1, 0, 0, 1, 0, 2, 2, 0, 0, 2, 3, 1, 3, 1, 1, 0, 1, 0, 0, 1, 2, 2, 0, 2, 0, 0, 1, 2, 0, 0, 4, 1, 0, 1, 1, 0, 1, 2, 0, 1, 4, 3, 1, 2, 2, 1, 1, 1, 1, 6, 3, 3, 3, 3, 1, 1, 1, 1, 1, 0, 7, 3, 0, 1, 3, 2, 1, 0, 3, 2, 1, 0, 2, 2, 6, 0, 0, 6, 2, 2, 3, 3, 5, 5, 1, 0, 6, 1, 0, 3, 1, 1, 2, 3, 1, 2, 1, 1, 0, 1, 0, 1, 0, 5, 5, 2, 2, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1] 

 

The bug reported at :trac:`4897` is now fixed:: 

 

sage: [P[0] for P in EllipticCurve([0,0,0,-468,2592]).integral_points()] 

[-24, -18, -14, -6, -3, 4, 6, 18, 21, 24, 36, 46, 102, 168, 186, 381, 1476, 2034, 67246] 

 

 

See :trac:`22063`:: 

 

sage: for n in [67,71,74,91]: 

....: assert 4*n^6+4*n^2 in [P[0] for P in EllipticCurve([0,0,0,2,n^2]).integral_points()] 

 

 

.. NOTE:: 

 

This function uses the algorithm given in [Coh2007I]_. 

 

AUTHORS: 

 

- Michael Mardaus (2008-07) 

 

- Tobias Nagel (2008-07) 

 

- John Cremona (2008-07) 

""" 

##################################################################### 

# INPUT CHECK ####################################################### 

if not self.is_integral(): 

raise ValueError("integral_points() can only be called on an integral model") 

 

if mw_base=='auto': 

try: 

mw_base = self.gens() 

except RuntimeError: 

raise RuntimeError("Unable to compute Mordell-Weil basis of {}, hence unable to compute integral points.".format(self)) 

r = len(mw_base) 

else: 

try: 

r = len(mw_base) 

except TypeError: 

raise TypeError('mw_base must be a list') 

if not all([P.curve() is self for P in mw_base]): 

raise ValueError("points are not on the correct curve") 

 

tors_points = self.torsion_points() 

 

# END INPUT-CHECK#################################################### 

##################################################################### 

 

##################################################################### 

# INTERNAL FUNCTIONS ################################################ 

 

############################## begin ################################ 

def point_preprocessing(free,tor): 

r""" 

Transforms the mw_basis ``free`` into a `\ZZ`-basis for 

`E(\QQ)\cap E^0(`\RR)`. If there is a torsion point on the 

"egg" we add it to any of the gens on the egg; otherwise 

we replace the free generators with generators of a 

subgroup of index 2. 

""" 

r = len(free) 

newfree = [Q for Q in free] # copy 

tor_egg = [T for T in tor if not T.is_on_identity_component()] 

free_id = [P.is_on_identity_component() for P in free] 

if any(tor_egg): 

T = tor_egg[0] 

for i in range(r): 

if not free_id[i]: 

newfree[i] += T 

else: 

if not all(free_id): 

i0 = free_id.index(False) 

P = free[i0] 

for i in range(r): 

if not free_id[i]: 

if i==i0: 

newfree[i] = 2*newfree[i] 

else: 

newfree[i] += P 

return newfree 

############################## end ################################ 

 

# END Internal functions ############################################# 

###################################################################### 

 

if (r == 0): 

int_points = [P for P in tors_points if not P.is_zero()] 

int_points = [P for P in int_points if P[0].is_integral()] 

if not both_signs: 

xlist = set([P[0] for P in int_points]) 

int_points = [self.lift_x(x) for x in xlist] 

int_points.sort() 

if verbose: 

print('Total number of integral points:', len(int_points)) 

return int_points 

 

if verbose: 

import sys # so we can flush stdout for debugging 

 

g2 = self.c4()/12 

g3 = self.c6()/216 

disc = self.discriminant() 

j = self.j_invariant() 

b2 = self.b2() 

 

Qx = rings.PolynomialRing(RationalField(),'x') 

pol = Qx([-self.c6()/216,-self.c4()/12,0,4]) 

if disc > 0: # two real component -> 3 roots in RR 

#on curve 897e4, only one root is found with default precision! 

RR = R 

prec = RR.precision() 

ei = pol.roots(RR,multiplicities=False) 

while len(ei)<3: 

prec*=2 

RR=RealField(prec) 

ei = pol.roots(RR,multiplicities=False) 

e1,e2,e3 = ei 

if r >= 1: #preprocessing of mw_base only necessary if rank > 0 

mw_base = point_preprocessing(mw_base, tors_points) 

#at most one point in E^{egg} 

 

elif disc < 0: # one real component => 1 root in RR (=: e3), 

# 2 roots in C (e1,e2) 

roots = pol.roots(C,multiplicities=False) 

e3 = pol.roots(R,multiplicities=False)[0] 

roots.remove(e3) 

e1,e2 = roots 

 

from sage.all import pi 

e = R(1).exp() 

pi = R(pi) 

 

M = self.height_pairing_matrix(mw_base) 

mw_base, U = self.lll_reduce(mw_base,M) 

M = U.transpose()*M*U 

 

if verbose: 

print("Using mw_basis ", mw_base) 

print("e1,e2,e3: ", e1, e2, e3) 

sys.stdout.flush() 

 

# Algorithm presented in [Coh2007I] 

h_E = self.height() 

w1, w2 = self.period_lattice().basis() 

mu = R(disc).abs().log() / 6 

if j!=0: 

mu += max(R(1),R(j).abs().log()) / 6 

if b2!=0: 

mu += max(R(1),R(b2).abs().log()) 

mu += log(R(2)) 

else: 

mu += 1 

 

c1 = (mu + 2.14).exp() 

height_pairing_eigs = M.charpoly ().roots(multiplicities=False) 

c2 = min(height_pairing_eigs) 

max_eig = max(height_pairing_eigs) 

if verbose: 

print("Minimal and maximal eigenvalues of height pairing matrix: {},{}".format(c2,max_eig)) 

sys.stdout.flush() 

 

c3 = (w1**2)*R(b2).abs()/48 + 8 

c5 = (c1*c3).sqrt() 

c7 = abs((3*pi)/((w1**2) * (w1/w2).imag())) 

 

mw_base_log = [] #contains \Phi(Q_i) 

mod_h_list = [] #contains h_m(Q_i) 

c9_help_list = [] 

for i in range(r): 

mw_base_log.append(mw_base[i].elliptic_logarithm().abs()) 

mod_h_list.append(max(mw_base[i].height(),h_E,c7*mw_base_log[i]**2)) 

c9_help_list.append((mod_h_list[i]).sqrt()/mw_base_log[i]) 

c8 = max(e*h_E,max(mod_h_list)) 

c9 = e/c7.sqrt() * min(c9_help_list) 

n=r+1 

c10 = R(2 * 10**(8+7*n) * R((2/e)**(2 * n**2)) * (n+1)**(4 * n**2 + 10 * n) * log(c9)**(-2*n - 1) * misc.prod(mod_h_list)) 

 

top = Z(128) #arbitrary first upper bound 

bottom = Z(0) 

log_c9=log(c9); log_c5=log(c5) 

log_r_top = log(R(r*(10**top))) 

 

while R(c10*(log_r_top+log_c9)*(log(log_r_top)+h_E+log_c9)**(n+1)) > R(c2/2 * (10**top)**2 - log_c5): 

#initial bound 'top' too small, upshift of search interval 

bottom = top 

top = 2*top 

while top >= bottom: #binary-search like search for fitting exponent (bound) 

bound = (bottom + (top - bottom)/2).floor() 

log_r_bound = log(R(r*(10**bound))) 

if R(c10*(log_r_bound+log_c9)*(log(log_r_bound)+h_E+log_c9)**(n+1)) > R(c2/2 * (10**bound)**2 - log_c5): 

bottom = bound + 1 

else: 

top = bound - 1 

 

H_q = R(10)**bound 

break_cond = 0 #at least one reduction step 

#reduction via LLL 

M = matrix.MatrixSpace(Z,n) 

while break_cond < 0.9: #as long as the improvement of the new bound in comparison to the old is greater than 10% 

c = R((H_q**n)*10) #c has to be greater than H_q^n 

m = copy(M.identity_matrix()) 

for i in range(r): 

m[i, r] = R(c*mw_base_log[i]).round() 

m[r,r] = max(Z(1),R(c*w1).round()) #ensures that m isn't singular 

 

#LLL - implemented in sage - operates on rows not on columns 

m_LLL = m.LLL() 

m_gram = m_LLL.gram_schmidt()[0] 

b1_norm = R(m_LLL.row(0).norm()) 

 

#compute constant c1 ~ c1_LLL of Corollary 2.3.17 and hence d(L,0)^2 ~ d_L_0 

c1_LLL = -R.one() 

for i in range(n): 

tmp = R(b1_norm/(m_gram.row(i).norm())) 

if tmp > c1_LLL: 

c1_LLL = tmp 

 

if c1_LLL < 0: 

raise RuntimeError('Unexpected intermediate result. Please try another Mordell-Weil base') 

 

d_L_0 = R(b1_norm**2 / c1_LLL) 

 

#Reducing of upper bound 

Q = r * H_q**2 

T = (1 + (Z(3)/2*r*H_q))/2 

if d_L_0 < R(T**2+Q): 

d_L_0 = 10*(T**2*Q) 

low_bound = (R(d_L_0 - Q).sqrt() - T) / c 

 

#new bound according to low_bound and upper bound 

#[c_5 exp((-c_2*H_q^2)/2)] provided by Corollary 8.7.3 

if low_bound != 0: 

H_q_new = R((log(low_bound/c5)/(-c2/2))).sqrt() 

H_q_new = H_q_new.ceil() 

if H_q_new == 1: 

break_cond = 1 # stops reduction 

else: 

break_cond = R(H_q_new/H_q) 

H_q = H_q_new 

else: 

break_cond = 1 # stops reduction, so using last H_q > 0 

#END LLL-Reduction loop 

 

b2_12 = b2/12 

if disc > 0: 

##Points in egg have X(P) between e1 and e2 [X(P)=x(P)+b2/12]: 

x_int_points = self.integral_x_coords_in_interval((e1-b2_12).ceil(), (e2-b2_12).floor()) 

if verbose: 

print('x-coords of points on compact component with ',(e1-b2_12).ceil(),'<=x<=',(e2-b2_12).floor()) 

L = sorted(x_int_points) # to have the order 

print(L) 

sys.stdout.flush() 

else: 

x_int_points = set() 

 

##Points in noncompact component with X(P)< 2*max(|e1|,|e2|,|e3|) , espec. X(P)>=e3 

x0 = (e3-b2_12).ceil() 

x1 = (2*max(abs(e1),abs(e2),abs(e3)) - b2_12).ceil() 

x_int_points2 = self.integral_x_coords_in_interval(x0, x1) 

x_int_points = x_int_points.union(x_int_points2) 

if verbose: 

print('x-coords of points on non-compact component with ',x0,'<=x<=',x1-1) 

L = sorted(x_int_points2) 

print(L) 

sys.stdout.flush() 

 

# The CPS bound is better but only implemented for minimal models: 

try: 

ht_diff_bnd = self.CPS_height_bound() 

except RuntimeError: 

ht_diff_bnd = self.silverman_height_bound() 

x_bound = (ht_diff_bnd+max_eig*H_q**2).exp() 

if verbose: 

print('starting search of remaining points using coefficient bound {} and |x| bound {}'.format(H_q,x_bound)) 

sys.stdout.flush() 

x_int_points3 = integral_points_with_bounded_mw_coeffs(self,mw_base,H_q,x_bound) 

x_int_points = x_int_points.union(x_int_points3) 

if verbose: 

print('x-coords of extra integral points:') 

L = sorted(x_int_points3) 

print(L) 

sys.stdout.flush() 

 

if len(tors_points)>1: 

x_int_points_t = set() 

for x in x_int_points: 

P = self.lift_x(x) 

for T in tors_points: 

Q = P+T 

if not Q.is_zero() and Q[0].is_integral(): 

x_int_points_t = x_int_points_t.union([Q[0]]) 

x_int_points = x_int_points.union(x_int_points_t) 

 

# Now we have all the x-coordinates of integral points, and we 

# construct the points, depending on the parameter both_signs: 

if both_signs: 

int_points = sum([self.lift_x(x,all=True) for x in x_int_points],[]) 

else: 

int_points = [self.lift_x(x) for x in x_int_points] 

int_points.sort() 

if verbose: 

print('Total number of integral points:',len(int_points)) 

return int_points 

 

def S_integral_points(self, S, mw_base='auto', both_signs=False, verbose=False, proof=None): 

""" 

Compute all S-integral points (up to sign) on this elliptic curve. 

 

INPUT: 

 

- ``S`` - list of primes 

 

- ``mw_base`` - list of EllipticCurvePoint generating the 

Mordell-Weil group of E (default: 'auto' - calls 

:meth:`.gens`) 

 

- ``both_signs`` - True/False (default False): if True the 

output contains both P and -P, otherwise only one of each 

pair. 

 

- ``verbose`` - True/False (default False): if True, some 

details of the computation are output. 

 

- ``proof`` - True/False (default True): if True ALL 

S-integral points will be returned. If False, the MW basis 

will be computed with the proof=False flag, and also the 

time-consuming final call to 

S_integral_x_coords_with_abs_bounded_by(abs_bound) is 

omitted. Use this only if the computation takes too long, 

but be warned that then it cannot be guaranteed that all 

S-integral points will be found. 

 

OUTPUT: 

 

A sorted list of all the S-integral points on E (up to sign 

unless both_signs is True) 

 

.. note:: 

 

The complexity increases exponentially in the rank of curve 

E and in the length of S. The computation time (but not 

the output!) depends on the Mordell-Weil basis. If mw_base 

is given but is not a basis for the Mordell-Weil group 

(modulo torsion), S-integral points which are not in the 

subgroup generated by the given points will almost 

certainly not be listed. 

 

EXAMPLES: 

 

A curve of rank 3 with no torsion points:: 

 

sage: E = EllipticCurve([0,0,1,-7,6]) 

sage: P1=E.point((2,0)); P2=E.point((-1,3)); P3=E.point((4,6)) 

sage: a=E.S_integral_points(S=[2,3], mw_base=[P1,P2,P3], verbose=True);a 

max_S: 3 len_S: 3 len_tors: 1 

lambda 0.485997517468... 

k1,k2,k3,k4 7.65200453902598e234 1.31952866480763 3.54035317966420e9 2.42767548272846e17 

p= 2 : trying with p_prec = 30 

mw_base_p_log_val = [2, 2, 1] 

min_psi = 2 + 2^3 + 2^6 + 2^7 + 2^8 + 2^9 + 2^11 + 2^12 + 2^13 + 2^16 + 2^17 + 2^19 + 2^20 + 2^21 + 2^23 + 2^24 + 2^28 + O(2^30) 

p= 3 : trying with p_prec = 30 

mw_base_p_log_val = [1, 2, 1] 

min_psi = 3 + 3^2 + 2*3^3 + 3^6 + 2*3^7 + 2*3^8 + 3^9 + 2*3^11 + 2*3^12 + 2*3^13 + 3^15 + 2*3^16 + 3^18 + 2*3^19 + 2*3^22 + 2*3^23 + 2*3^24 + 2*3^27 + 3^28 + 3^29 + O(3^30) 

mw_base [(1 : -1 : 1), (2 : 0 : 1), (0 : -3 : 1)] 

mw_base_log [0.667789378224099, 0.552642660712417, 0.818477222895703] 

mp [5, 7] 

mw_base_p_log [[2^2 + 2^3 + 2^6 + 2^7 + 2^8 + 2^9 + 2^14 + 2^15 + 2^18 + 2^19 + 2^24 + 2^29 + O(2^30), 2^2 + 2^3 + 2^5 + 2^6 + 2^9 + 2^11 + 2^12 + 2^14 + 2^15 + 2^16 + 2^18 + 2^20 + 2^22 + 2^23 + 2^26 + 2^27 + 2^29 + O(2^30), 2 + 2^3 + 2^6 + 2^7 + 2^8 + 2^9 + 2^11 + 2^12 + 2^13 + 2^16 + 2^17 + 2^19 + 2^20 + 2^21 + 2^23 + 2^24 + 2^28 + O(2^30)], [2*3^2 + 2*3^5 + 2*3^6 + 2*3^7 + 3^8 + 3^9 + 2*3^10 + 3^12 + 2*3^14 + 3^15 + 3^17 + 2*3^19 + 2*3^23 + 3^25 + 3^28 + O(3^30), 2*3 + 2*3^2 + 2*3^3 + 2*3^4 + 2*3^6 + 2*3^7 + 2*3^8 + 3^10 + 2*3^12 + 3^13 + 2*3^14 + 3^15 + 3^18 + 3^22 + 3^25 + 2*3^26 + 3^27 + 3^28 + O(3^30), 3 + 3^2 + 2*3^3 + 3^6 + 2*3^7 + 2*3^8 + 3^9 + 2*3^11 + 2*3^12 + 2*3^13 + 3^15 + 2*3^16 + 3^18 + 2*3^19 + 2*3^22 + 2*3^23 + 2*3^24 + 2*3^27 + 3^28 + 3^29 + O(3^30)]] 

k5,k6,k7 0.321154513240... 1.55246328915... 0.161999172489... 

initial bound 2.8057927340...e117 

bound_list [58, 58, 58] 

bound_list [8, 9, 9] 

bound_list [9, 7, 7] 

starting search of points using coefficient bound 9 

x-coords of S-integral points via linear combination of mw_base and torsion: 

[-3, -26/9, -8159/2916, -2759/1024, -151/64, -1343/576, -2, -7/4, -1, -47/256, 0, 1/4, 4/9, 9/16, 58/81, 7/9, 6169/6561, 1, 17/16, 2, 33/16, 172/81, 9/4, 25/9, 3, 31/9, 4, 25/4, 1793/256, 8, 625/64, 11, 14, 21, 37, 52, 6142/81, 93, 4537/36, 342, 406, 816, 207331217/4096] 

starting search of extra S-integer points with absolute value bounded by 3.89321964979420 

x-coords of points with bounded absolute value 

[-3, -2, -1, 0, 1, 2] 

Total number of S-integral points: 43 

[(-3 : 0 : 1), (-26/9 : 28/27 : 1), (-8159/2916 : 233461/157464 : 1), (-2759/1024 : 60819/32768 : 1), (-151/64 : 1333/512 : 1), (-1343/576 : 36575/13824 : 1), (-2 : 3 : 1), (-7/4 : 25/8 : 1), (-1 : 3 : 1), (-47/256 : 9191/4096 : 1), (0 : 2 : 1), (1/4 : 13/8 : 1), (4/9 : 35/27 : 1), (9/16 : 69/64 : 1), (58/81 : 559/729 : 1), (7/9 : 17/27 : 1), (6169/6561 : 109871/531441 : 1), (1 : 0 : 1), (17/16 : -25/64 : 1), (2 : 0 : 1), (33/16 : 17/64 : 1), (172/81 : 350/729 : 1), (9/4 : 7/8 : 1), (25/9 : 64/27 : 1), (3 : 3 : 1), (31/9 : 116/27 : 1), (4 : 6 : 1), (25/4 : 111/8 : 1), (1793/256 : 68991/4096 : 1), (8 : 21 : 1), (625/64 : 14839/512 : 1), (11 : 35 : 1), (14 : 51 : 1), (21 : 95 : 1), (37 : 224 : 1), (52 : 374 : 1), (6142/81 : 480700/729 : 1), (93 : 896 : 1), (4537/36 : 305425/216 : 1), (342 : 6324 : 1), (406 : 8180 : 1), (816 : 23309 : 1), (207331217/4096 : 2985362173625/262144 : 1)] 

 

It is not necessary to specify mw_base; if it is not provided, 

then the Mordell-Weil basis must be computed, which may take 

much longer. 

 

:: 

 

sage: a = E.S_integral_points([2,3]) 

sage: len(a) 

43 

 

An example with negative discriminant:: 

 

sage: EllipticCurve('900d1').S_integral_points([17], both_signs=True) 

[(-11 : -27 : 1), (-11 : 27 : 1), (-4 : -34 : 1), (-4 : 34 : 1), (4 : -18 : 1), (4 : 18 : 1), (2636/289 : -98786/4913 : 1), (2636/289 : 98786/4913 : 1), (16 : -54 : 1), (16 : 54 : 1)] 

 

Output checked with Magma (corrected in 3 cases):: 

 

sage: [len(e.S_integral_points([2], both_signs=False)) for e in cremona_curves([11..100])] # long time (17s on sage.math, 2011) 

[2, 0, 2, 3, 3, 1, 3, 1, 3, 5, 3, 5, 4, 1, 1, 2, 2, 2, 3, 1, 2, 1, 0, 1, 3, 3, 1, 1, 5, 3, 4, 2, 1, 1, 5, 3, 2, 2, 1, 1, 1, 0, 1, 3, 0, 1, 0, 1, 1, 3, 7, 1, 3, 3, 3, 1, 1, 2, 3, 1, 2, 3, 1, 2, 1, 3, 3, 1, 1, 1, 0, 1, 3, 3, 1, 1, 7, 1, 0, 1, 1, 0, 1, 2, 0, 3, 1, 2, 1, 3, 1, 2, 2, 4, 5, 3, 2, 1, 1, 6, 1, 0, 1, 3, 1, 3, 3, 1, 1, 1, 1, 1, 3, 1, 5, 1, 2, 4, 1, 1, 1, 1, 1, 0, 1, 0, 2, 2, 0, 0, 1, 0, 1, 1, 6, 1, 0, 1, 1, 0, 4, 3, 1, 2, 1, 2, 3, 1, 1, 1, 1, 8, 3, 1, 2, 1, 2, 0, 8, 2, 0, 6, 2, 3, 1, 1, 1, 3, 1, 3, 2, 1, 3, 1, 2, 1, 6, 9, 3, 3, 1, 1, 2, 3, 1, 1, 5, 5, 1, 1, 0, 1, 1, 2, 3, 1, 1, 2, 3, 1, 3, 1, 1, 1, 1, 0, 0, 1, 3, 3, 1, 3, 1, 1, 2, 2, 0, 0, 6, 1, 0, 1, 1, 1, 1, 3, 1, 2, 6, 3, 1, 2, 2, 1, 1, 1, 1, 7, 5, 4, 3, 3, 1, 1, 1, 1, 1, 1, 8, 5, 1, 1, 3, 3, 1, 1, 3, 3, 1, 1, 2, 3, 6, 1, 1, 7, 3, 3, 4, 5, 9, 6, 1, 0, 7, 1, 1, 3, 1, 1, 2, 3, 1, 2, 1, 1, 1, 1, 1, 1, 1, 7, 8, 2, 3, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1] 

 

An example from [PZGH]_:: 

 

sage: E = EllipticCurve([0,0,0,-172,505]) 

sage: E.rank(), len(E.S_integral_points([3,5,7])) # long time (5s on sage.math, 2011) 

(4, 72) 

 

This is curve "7690e1" which failed until :trac:`4805` was fixed:: 

 

sage: EllipticCurve([1,1,1,-301,-1821]).S_integral_points([13,2]) 

[(-13 : 16 : 1), 

(-9 : 20 : 1), 

(-7 : 4 : 1), 

(21 : 30 : 1), 

(23 : 52 : 1), 

(63 : 452 : 1), 

(71 : 548 : 1), 

(87 : 756 : 1), 

(2711 : 139828 : 1), 

(7323 : 623052 : 1), 

(17687 : 2343476 : 1)] 

 

REFERENCES: 

 

.. [PZGH] Petho A., Zimmer H.G., Gebel J. and Herrmann E., 

Computing all S-integral points on elliptic curves 

Math. Proc. Camb. Phil. Soc. (1999), 127, 383-402 

 

- Some parts of this implementation are partially based on the 

function integral_points() 

 

AUTHORS: 

 

- Tobias Nagel (2008-12) 

 

- Michael Mardaus (2008-12) 

 

- John Cremona (2008-12) 

""" 

# INPUT CHECK ####################################################### 

 

if proof is None: 

from sage.structure.proof.proof import get_flag 

proof = get_flag(proof, "elliptic_curve") 

else: 

proof = bool(proof) 

 

 

if not self.is_integral(): 

raise ValueError("S_integral_points() can only be called on an integral model") 

if not all([self.is_p_minimal(s) for s in S]): 

raise ValueError("%s must be p-minimal for all primes in S"%self) 

 

try: 

len_S = len(S) 

if len_S == 0: 

return self.integral_points(mw_base, both_signs, verbose) 

if not all([s.is_prime() for s in S]): 

raise ValueError("All elements of S must be prime") 

S.sort() 

except TypeError: 

raise TypeError('S must be a list of primes') 

except AttributeError:#catches: <tuple>.sort(), <!ZZ>.is_prime() 

raise AttributeError('S must be a list of primes') 

 

if mw_base=='auto': 

if verbose: 

print("Starting computation of MW basis") 

try: 

mw_base = self.gens(proof=proof) 

except RuntimeError: 

raise RuntimeError("Unable to compute Mordell-Weil basis of {}, hence unable to compute integral points.".format(self)) 

r = len(mw_base) 

if verbose: 

print("Finished computation of MW basis; rank is ", r) 

else: 

try: 

r = len(mw_base) 

except TypeError: 

raise TypeError('mw_base must be a list') 

if not all([P.curve() is self for P in mw_base]): 

raise ValueError("mw_base-points are not on the correct curve") 

 

#End Input-Check ###################################################### 

 

#Internal functions ################################################### 

def reduction_at(p): 

r""" 

Reducing the bound `H_q` at the finite place p in S via LLL 

""" 

indexp = S.index(p) 

pc = Z(p**(R(c.log()/log(p,e)).ceil())) 

m = copy(M.identity_matrix()) 

for i in range(r): 

try: 

m[i, r] = Z((beta[indexp][i])%pc) 

except ZeroDivisionError: #If Inverse doesn't exist, change denominator (which is only approx) 

val_nu = (beta[indexp][i]).numerator() 

val_de = (beta[indexp][i]).denominator() 

m[i, r] = Z((val_nu/(val_de+1))%pc) 

m[r,r] = max(Z(1), pc) 

 

#LLL - implemented in sage - operates on rows not on columns 

m_LLL = m.LLL() 

m_gram = m_LLL.gram_schmidt()[0] 

b1_norm = R(m_LLL.row(0).norm()) 

 

c1_LLL = -R.one() 

for i in range(n): 

tmp = R(b1_norm/(m_gram.row(i).norm())) 

if tmp > c1_LLL: 

c1_LLL = tmp 

if c1_LLL < 0: 

raise RuntimeError('Unexpected intermediate result. Please try another Mordell-Weil base') 

d_L_0 = R(b1_norm**2 / c1_LLL) 

 

#Reducing of upper bound 

Q = r * H_q**2 

T = (1 + (Z(3)/2*r*H_q))/2 

if d_L_0 < R(T**2+Q): 

d_L_0 = 10*(T**2*Q) 

low_bound = (R(d_L_0 - Q).sqrt() - T) / c 

 

##new bound according to low_bound and upper bound 

##[k5*k6 exp(-k7**H_q^2)] 

if low_bound != 0: 

H_q_infinity = R(((low_bound/(k6)).log()/(-k7)).sqrt()) 

return (H_q_infinity.ceil()) 

else: 

return (H_q) 

#<------------------------------------------------------------------------- 

#>------------------------------------------------------------------------- 

def S_integral_points_with_bounded_mw_coeffs(): 

r""" 

Return the set of S-integers x which are x-coordinates of 

points on the curve which are linear combinations of the 

generators (basis and torsion points) with coefficients 

bounded by `H_q`. The bound `H_q` will be computed at 

runtime. 

(Modified version of integral_points_with_bounded_mw_coeffs() in 

integral_points() ) 

 

TODO: Make this more efficient. In the case ``S=[]`` we 

worked over the reals and only computed a combination 

exactly if the real coordinates were approximately 

integral. We need a version of this which works for 

S-integral points, probably by finding a bound on the 

denominator. 

""" 

from sage.groups.generic import multiples 

xs=set() 

N=H_q 

 

def test(P): 

""" 

Record x-coord of a point if S-integral. 

""" 

if not P.is_zero(): 

xP = P[0] 

if xP.is_S_integral(S): 

xs.add(xP) 

 

def test_with_T(R): 

""" 

Record x-coords of a 'point+torsion' if S-integral. 

""" 

for T in tors_points: 

test(R+T) 

 

# For small rank and small H_q perform simple search 

if r==1 and N<=10: 

for P in multiples(mw_base[0],N+1): 

test_with_T(P) 

return xs 

 

# explicit computation and testing linear combinations 

# ni loops through all tuples (n_1,...,n_r) with |n_i| <= N 

# stops when (0,0,...,0) is reached because after that, only inverse points of 

# previously tested points would be tested 

 

E0=E(0) 

ni = [-N for i in range(r)] 

mw_baseN = [-N*P for P in mw_base] 

Pi = [0 for j in range(r)] 

Pi[0] = mw_baseN[0] 

for i in range(1,r): 

Pi[i] = Pi[i-1] + mw_baseN[i] 

 

while True: 

if all([n==0 for n in ni]): 

test_with_T(E0) 

break 

 

# test the ni-combination which is Pi[r-1] 

test_with_T(Pi[r-1]) 

 

# increment indices and stored points 

i0 = r-1 

while ni[i0]==N: 

ni[i0] = -N 

i0 -= 1 

ni[i0] += 1 

if all([n==0 for n in ni[0:i0+1]]): 

Pi[i0] = E0 

else: 

Pi[i0] += mw_base[i0] 

for i in range(i0+1,r): 

Pi[i] = Pi[i-1] + mw_baseN[i] 

 

return xs 

#<------------------------------------------------------------------------- 

#>------------------------------------------------------------------------- 

def S_integral_x_coords_with_abs_bounded_by(abs_bound): 

r""" 

Extra search of points with `|x|< ` abs_bound, assuming 

that `x` is `S`-integral and `|x|\ge|x|_q` for all primes 

`q` in `S`. (Such points are not covered by the main part 

of the code). We know 

 

.. MATH:: 

 

x=\frac{\xi}{\p_1^{\alpha_1} \cdot \dots \cdot \p_s^{\alpha_s}},\ (gcd(\xi,\p_i)=1),\ p_i \in S 

 

so a bound of `\alpha_i` can be found in terms of 

abs_bound. Additionally each `\alpha` must be even, giving 

another restriction. This gives a finite list of 

denominators to test, and for each, a range of numerators. 

All candidates for `x` resulting from this theory are then 

tested, and a list of the ones which are `x`-coordinates 

of (`S`-integral) points is returned. 

 

TODO: Make this more efficient. If we had an efficient 

function for searching for integral points (for example, 

by wrapping Stoll's ratpoint program) then it should be 

better to scale the equation by the maximum denominator 

and search for integral points on the scaled model. 

 

""" 

x_min = min(self.two_division_polynomial().roots(R,multiplicities=False)) 

x_min_neg = bool(x_min<0) 

x_min_pos = not x_min_neg 

log_ab = R(abs_bound.log()) 

alpha = [(log_ab/R(log(p,e))).floor() for p in S] 

if all([alpha_i <= 1 for alpha_i in alpha]): # so alpha_i must be 0 to satisfy that denominator is a square 

return set([x for x in range(-abs_bound,abs_bound) if E.is_x_coord(x)]) 

else: 

xs = [] 

alpha_max_even = [y-y%2 for y in alpha] 

p_pow_alpha = [] 

list_alpha = [] 

for i in range(len_S-1): 

list_alpha.append(range(0,alpha_max_even[i]+2,2)) 

p_pow_alpha.append([S[i]**list_alpha[i][j] for j in range(len(list_alpha[i]))]) 

if verbose: 

print(list_alpha, p_pow_alpha) 

# denom_maxpa is a list of pairs (d,q) where d runs 

# through possible denominators, and q=p^a is the 

# maximum prime power divisor of d: 

denom_maxpa = [(misc.prod(tmp),max(tmp)) for tmp in cartesian_product_iterator(p_pow_alpha)] 

# The maximum denominator is this (not used): 

# denom = [misc.prod([pp[-1] for pp in p_pow_alpha],1)] 

for de,maxpa in denom_maxpa: 

n_max = (abs_bound*de).ceil() 

n_min = maxpa*de 

if x_min_pos: 

pos_n_only = True 

if x_min > maxpa: 

n_min = (x_min*de).floor() 

else: 

pos_n_only = False 

neg_n_max = (x_min.abs()*de).ceil() 

 

for n in arith.xsrange(n_min,n_max+1): 

tmp = n/de # to save time, do not check de is the exact denominator 

if E.is_x_coord(tmp): 

xs+=[tmp] 

if not pos_n_only: 

if n <= neg_n_max: 

if E.is_x_coord(-tmp): 

xs+=[-tmp] 

 

return set(xs) 

#<------------------------------------------------------------------------- 

#End internal functions ############################################### 

from sage.misc.all import cartesian_product_iterator 

 

E = self 

tors_points = E.torsion_points() 

 

if (r==0):#only Torsionpoints to consider 

int_points = [P for P in tors_points if not P.is_zero()] 

int_points = [P for P in int_points if P[0].is_S_integral(S)] 

if not both_signs: 

xlist = set([P[0] for P in int_points]) 

int_points = [E.lift_x(x) for x in xlist] 

int_points.sort() 

if verbose: 

print('Total number of S-integral points:', len(int_points)) 

return int_points 

 

if verbose: 

import sys # so we can flush stdout for debugging 

 

e = R(1).exp() 

a1, a2, a3, a4, a6 = E.a_invariants() 

b2, b4, b6, b8 = E.b_invariants() 

c4, c6 = E.c_invariants() 

disc = E.discriminant() 

#internal function is doing only a comparison of E and E.short_weierstass_model() so the following is easier 

if a1 == a2 == a3 == 0: 

is_short = True 

else: 

is_short = False 

 

w1, w2 = E.period_lattice().basis() 

 

Qx = rings.PolynomialRing(RationalField(),'x') 

pol = Qx([-54*c6,-27*c4,0,1]) 

if disc > 0: # two real component -> 3 roots in RR 

# it is possible that only one root is found with default precision! (see integral_points()) 

RR = R 

prec = RR.precision() 

ei = pol.roots(RR,multiplicities=False) 

while len(ei)<3: 

prec*=2 

RR=RealField(prec) 

ei = pol.roots(RR,multiplicities=False) 

e1,e2,e3 = ei 

elif disc < 0: # one real component => 1 root in RR (=: e3), 

# 2 roots in C (e1,e2) 

roots = pol.roots(C,multiplicities=False) 

e3 = pol.roots(R,multiplicities=False)[0] 

roots.remove(e3) 

e1,e2 = roots 

 

len_tors = len(tors_points) 

n = r + 1 

 

M = E.height_pairing_matrix(mw_base) 

mw_base, U = E.lll_reduce(mw_base,M) 

M = U.transpose()*M*U 

 

# NB "lambda" is a reserved word in Python! 

lamda = min(M.charpoly(algorithm="hessenberg").roots(multiplicities = False)) 

max_S = max(S) 

len_S += 1 #Counting infinity (always "included" in S) 

if verbose: 

print('max_S:',max_S,'len_S:',len_S,'len_tors:',len_tors) 

print('lambda', lamda) 

sys.stdout.flush() 

 

if is_short: 

disc_0_abs = R((4*a4**3 + 27*a6**2).abs()) 

k4 = R(10**4 * max(16*a4**2, 256*disc_0_abs.sqrt()**3)) 

k3 = R(32/3 * disc_0_abs.sqrt() * (8 + 0.5*disc_0_abs.log())**4) 

else: 

disc_sh = R(E.short_weierstrass_model().discriminant()) #computes y^2=x^3 -27c4x -54c6 

k4 = R(20**4 * max(3**6 * c4**2, 16*(disc_sh.abs().sqrt())**3)) 

k3 = R(32/3 * disc_sh.abs().sqrt() * (8 + 0.5*disc_sh.abs().log())**4) 

 

 

k2 = max(R(b2.abs()), R(b4.abs().sqrt()), R(b6.abs()**(1/3)), R(b8.abs()**(1/4))).log() 

k1 = R(7 * 10**(38*len_S+49)) * R(len_S**(20*len_S+15)) * max_S**24 * R(max(1,log(max_S, e))**(4*len_S - 2)) * k3 * k3.log()**2 * ((20*len_S - 19)*k3 + (e*k4).log()) + 2*R(2*b2.abs()+6).log() 

 

if verbose: 

print('k1,k2,k3,k4', k1, k2, k3, k4) 

sys.stdout.flush() 

#H_q -> [PZGH]:N_0 (due to consistency to integral_points()) 

H_q = R(((k1/2+k2)/lamda).sqrt()) 

 

#computation of logs 

mw_base_log = [(pts.elliptic_logarithm().abs())*(len_tors/w1) for pts in mw_base] 

mw_base_p_log = [] 

beta = [] 

mp=[] 

tmp = 0 

for p in S: 

Np = E.Np(p) 

cp = E.tamagawa_exponent(p) 

mp_temp = Z(len_tors).lcm(cp*Np) 

mp.append(mp_temp) #only necessary because of verbose below 

p_prec=30+E.discriminant().valuation(p) 

p_prec_ok=False 

while not p_prec_ok: 

if verbose: 

print("p=", p, ": trying with p_prec = ", p_prec) 

try: 

mw_base_p_log.append([mp_temp*(pts.padic_elliptic_logarithm(p,absprec=p_prec)) for pts in mw_base]) 

p_prec_ok=True 

except ValueError: 

p_prec *= 2 

#reorder mw_base_p: last value has minimal valuation at p 

mw_base_p_log_val = [mw_base_p_log[tmp][i].valuation() for i in range(r)] 

if verbose: 

print("mw_base_p_log_val = ",mw_base_p_log_val) 

min_index = mw_base_p_log_val.index(min(mw_base_p_log_val)) 

min_psi = mw_base_p_log[tmp][min_index] 

if verbose: 

print("min_psi = ", min_psi) 

mw_base_p_log[tmp].remove(min_psi) 

mw_base_p_log[tmp].append(min_psi) 

#beta needed for reduction at p later on 

try: 

beta.append([-mw_base_p_log[tmp][j]/min_psi for j in range(r)]) 

except ValueError: 

# e.g. mw_base_p_log[tmp]==[0]: can occur e.g. [?]'172c6, S=[2] 

beta.append([0] for j in range(r)) 

tmp +=1 

 

if verbose: 

print('mw_base', mw_base) 

print('mw_base_log', mw_base_log) 

print('mp', mp) 

print('mw_base_p_log', mw_base_p_log) 

sys.stdout.flush() 

 

#constants in reduction (not needed to be computed every reduction step) 

k5 = R((2*len_tors)/(3*w1)) 

k6 = R((k2/len_S).exp()) 

k7 = R(lamda/len_S) 

 

if verbose: 

print('k5,k6,k7', k5, k6, k7) 

sys.stdout.flush() 

 

break_cond = 0 

M = matrix.MatrixSpace(Z,n) 

#Reduction of initial bound 

if verbose: 

print('initial bound', H_q) 

sys.stdout.flush() 

 

while break_cond < 0.9: 

#reduction at infinity 

bound_list=[] 

c = R((H_q**n)*100) 

m = copy(M.identity_matrix()) 

for i in range(r): 

m[i, r] = R(c*mw_base_log[i]).round() 

m[r,r] = max(Z(1), R(c*w1).round()) 

#LLL - implemented in sage - operates on rows not on columns 

m_LLL = m.LLL() 

m_gram = m_LLL.gram_schmidt()[0] 

b1_norm = R(m_LLL.row(0).norm()) 

 

#compute constant c1_LLL (cf. integral_points()) 

c1_LLL = -R.one() 

for i in range(n): 

tmp = R(b1_norm/(m_gram.row(i).norm())) 

if tmp > c1_LLL: 

c1_LLL = tmp 

if c1_LLL < 0: 

raise RuntimeError('Unexpected intermediate result. Please try another Mordell-Weil base') 

d_L_0 = R(b1_norm**2 / c1_LLL) 

 

#Reducing of upper bound 

Q = r * H_q**2 

T = (1 + (Z(3)/2*r*H_q))/2 

if d_L_0 < R(T**2+Q): 

d_L_0 = 10*(T**2*Q) 

low_bound = (R(d_L_0 - Q).sqrt() - T) / c 

 

##new bound according to low_bound and upper bound 

##[k5*k6 exp(-k7**H_q^2)] 

if low_bound != 0: 

H_q_infinity = R(((low_bound/(k5*k6)).log()/(-k7)).abs().sqrt()) 

bound_list.append(H_q_infinity.ceil()) 

else: 

bound_list.append(H_q) 

 

##reduction for finite places in S 

for p in S: 

bound_list.append(reduction_at(p)) 

 

if verbose: 

print('bound_list', bound_list) 

sys.stdout.flush() 

 

H_q_new = max(bound_list) 

if (H_q_new > H_q): #no improvement 

break_cond = 1 #stop reduction 

elif (H_q_new == 1): #best possible H_q 

H_q = H_q_new 

break_cond = 1 #stop 

else: 

break_cond = R(H_q_new/H_q) 

H_q = H_q_new 

#end of reductions 

 

#search of S-integral points 

#step1: via linear combination and H_q 

x_S_int_points = set() 

if verbose: 

print('starting search of points using coefficient bound ', H_q) 

sys.stdout.flush() 

x_S_int_points1 = S_integral_points_with_bounded_mw_coeffs() 

x_S_int_points = x_S_int_points.union(x_S_int_points1) 

if verbose: 

print('x-coords of S-integral points via linear combination of mw_base and torsion:') 

L = sorted(x_S_int_points1) 

print(L) 

sys.stdout.flush() 

 

#step 2: Extra search 

if e3 < 0: 

M = R( max((27*c4).abs().sqrt(), R((54*c6).abs()**(1/3)) / R(2**(1/3))-1) ) 

else: 

M = R(0) 

e0 = max(e1+e2, 2*e3) + M 

abs_bound = R((max(0,e0)+6*b2.abs())/36) 

 

if proof: 

if verbose: 

print('starting search of extra S-integer points with absolute value bounded by', abs_bound) 

sys.stdout.flush() 

if abs_bound != 0: 

x_S_int_points2 = S_integral_x_coords_with_abs_bounded_by(abs_bound) 

x_S_int_points = x_S_int_points.union(x_S_int_points2) 

if verbose: 

print('x-coords of points with bounded absolute value') 

L = sorted(x_S_int_points2) 

print(L) 

sys.stdout.flush() 

 

if len(tors_points)>1: 

x_S_int_points_t = set() 

for x in x_S_int_points: 

P = E.lift_x(x) 

for T in tors_points: 

Q = P+T 

if not Q.is_zero() and Q[0].is_S_integral(S): 

x_S_int_points_t = x_S_int_points_t.union([Q[0]]) 

x_S_int_points = x_S_int_points.union(x_S_int_points_t) 

 

# All x values collected, now considering "both_signs" 

if both_signs: 

S_int_points = sum([self.lift_x(x,all=True) for x in x_S_int_points],[]) 

else: 

S_int_points = [self.lift_x(x) for x in x_S_int_points] 

S_int_points.sort() 

if verbose: 

print('Total number of S-integral points:', len(S_int_points)) 

return S_int_points 

 

 

def cremona_curves(conductors): 

""" 

Return iterator over all known curves (in database) with conductor 

in the list of conductors. 

 

EXAMPLES:: 

 

sage: [(E.label(), E.rank()) for E in cremona_curves(srange(35,40))] 

[('35a1', 0), 

('35a2', 0), 

('35a3', 0), 

('36a1', 0), 

('36a2', 0), 

('36a3', 0), 

('36a4', 0), 

('37a1', 1), 

('37b1', 0), 

('37b2', 0), 

('37b3', 0), 

('38a1', 0), 

('38a2', 0), 

('38a3', 0), 

('38b1', 0), 

('38b2', 0), 

('39a1', 0), 

('39a2', 0), 

('39a3', 0), 

('39a4', 0)] 

""" 

if isinstance(conductors, integer_types + (rings.RingElement,)): 

conductors = [conductors] 

return sage.databases.cremona.CremonaDatabase().iter(conductors) 

 

def cremona_optimal_curves(conductors): 

""" 

Return iterator over all known optimal curves (in database) with 

conductor in the list of conductors. 

 

EXAMPLES:: 

 

sage: [(E.label(), E.rank()) for E in cremona_optimal_curves(srange(35,40))] 

[('35a1', 0), 

('36a1', 0), 

('37a1', 1), 

('37b1', 0), 

('38a1', 0), 

('38b1', 0), 

('39a1', 0)] 

 

There is one case -- 990h3 -- when the optimal curve isn't labeled with a 1:: 

 

sage: [e.cremona_label() for e in cremona_optimal_curves([990])] 

['990a1', '990b1', '990c1', '990d1', '990e1', '990f1', '990g1', '990h3', '990i1', '990j1', '990k1', '990l1'] 

 

""" 

if isinstance(conductors, integer_types + (rings.RingElement,)): 

conductors = [conductors] 

return sage.databases.cremona.CremonaDatabase().iter_optimal(conductors) 

 

def integral_points_with_bounded_mw_coeffs(E, mw_base, N, x_bound): 

r""" 

Return the set of integers `x` which are 

`x`-coordinates of points on the curve `E` which 

are linear combinations of the generators (basis and torsion 

points) with coefficients bounded by `N`. 

 

INPUT: 

 

- ``E`` - an elliptic curve 

- ``mw_base`` - a list of points on `E` (generators) 

- ``N`` - a positive integer (bound on coefficients) 

- ``x_bound`` - a positive real number (upper bound on size of x-coordinates) 

 

OUTPUT: 

 

(list) list of integral points on `E` which are linear combinations 

of the given points with coefficients bounded by `N` in absolute 

value. 

 

TESTS: 

 

We check that some large integral points in a paper of Zagier are found:: 

 

sage: def t(a,b,x): # indirect doctest 

....: E = EllipticCurve([0,0,0,a,b]) 

....: xs = [P[0] for P in E.integral_points()] 

....: return x in xs 

sage: all([t(a,b,x) for a,b,x in [ (-2,5, 1318), (4,-1, 4321), 

....: (0,17, 5234), (11,4, 16833), (-13,37, 60721), (-12,-10, 80327), 

....: (-7,22, 484961), (-9,28, 764396), (-13,4, 1056517), (-19,-51, 

....: 2955980), (-24,124, 4435710), (-30,133, 5143326), (-37,60, 

....: 11975623), (-23,-33, 17454557), (-16,49, 19103002), (27,-62, 

....: 28844402), (37,18, 64039202), (2,97, 90086608), (49,-64, 

....: 482042404), (-59,74, 7257247018), (94,689, 30841587841), 

....: (469,1594, 6327540232326), (1785,0, 275702503440)] ]) 

True 

""" 

from sage.groups.generic import multiples 

xs=set() 

tors_points = E.torsion_points() 

r = len(mw_base) 

 

def use(P): 

""" 

Helper function to record x-coord of a point if integral. 

""" 

if P: 

xP = P[0] 

if xP.is_integral(): 

xs.add(xP) 

 

def use_t(R): 

""" 

Helper function to record x-coords of a point +torsion if 

integral. 

""" 

for T in tors_points: 

use(R+T) 

 

# We use a naive method when the number of possibilities is small: 

 

if r==1 and N<=10: 

for P in multiples(mw_base[0],N+1): 

use_t(P) 

return xs 

 

# Otherwise it is very very much faster to first compute the 

# linear combinations over RR, and only compute them as rational 

# points if they are approximately integral. We will use a bit 

# precision prec such that 2**prec is greater than the upper bound 

# on the x- and y-coordinates. 

 

def is_approx_integral(rx): 

r""" Local function. Return P if the real number `rx` is approximately 

integral and rounds to a valid integral x-coordinate of an 

integral point P on E, else 0. 

""" 

try: 

return E.lift_x(rx.round()) 

except ValueError: 

return 0 

 

prec = (2 * RealField()(x_bound).log(2)).ceil() 

#print("coeff bound={}, x_bound = {}, using {} bits precision".format(N,x_bound,prec)) 

RR = RealField(prec) 

ER = E.change_ring(RR) 

ER0 = ER(0) 

 

# Note: doing [ER(P) for P in mw_base] sometimes fails. The 

# following way is harder, since we have to make sure we don't use 

# -P instead of P, but is safer. 

 

Rgens = [ER.lift_x(P[0]) for P in mw_base] 

for i in range(r): 

if abs(Rgens[i][1]-mw_base[i][1])>abs((-Rgens[i])[1]-mw_base[i][1]): 

Rgens[i] = -Rgens[i] 

 

# the ni loop through all tuples (a1,a2,...,ar) with 

# |ai|<=N, but we stop immediately after using the tuple 

# (0,0,...,0). 

 

# Initialization: 

ni = [-N for i in range(r)] 

RgensN = [-N*P for P in Rgens] 

# RPi[i] = -N*(Rgens[0]+...+Rgens[i]) 

RPi = [0 for j in range(r)] 

RPi[0] = RgensN[0] 

for i in range(1,r): 

RPi[i] = RPi[i-1] + RgensN[i] 

 

tors_points_R = [ER(_) for _ in tors_points] 

while True: 

if all([n==0 for n in ni]): 

use_t(E(0)) 

break 

 

# test the ni-combination which is RPi[r-1] 

RP = RPi[r-1] 

 

for T, TR in zip(tors_points, tors_points_R): 

use(is_approx_integral((RP + TR)[0])) 

 

# increment indices and stored points 

i0 = r-1 

while ni[i0]==N: 

ni[i0] = -N 

i0 -= 1 

ni[i0] += 1 

# The next lines are to prevent rounding error: (-P)+P behaves 

# badly for real points! 

if all([n==0 for n in ni[0:i0+1]]): 

RPi[i0] = ER0 

else: 

RPi[i0] += Rgens[i0] 

for i in range(i0+1,r): 

RPi[i] = RPi[i-1] + RgensN[i] 

 

return xs 

 

 

def elliptic_curve_congruence_graph(curves): 

r""" 

Return the congruence graph for this set of elliptic curves. 

 

INPUT: 

 

- ``curves`` -- a list of elliptic curves 

 

OUTPUT: 

 

The graph with each curve as a vertex (labelled by its Cremona 

label) and an edge from `E` to `F` labelled `p` if and only if `E` is 

congruent to `F` mod `p` 

 

EXAMPLES:: 

 

sage: from sage.schemes.elliptic_curves.ell_rational_field import elliptic_curve_congruence_graph 

sage: curves = list(cremona_optimal_curves([11..30])) 

sage: G = elliptic_curve_congruence_graph(curves) 

sage: G 

Graph on 12 vertices 

""" 

from sage.graphs.graph import Graph 

from sage.arith.all import lcm, prime_divisors 

from sage.rings.fast_arith import prime_range 

from sage.misc.all import prod 

G = Graph() 

G.add_vertices([curve.cremona_label() for curve in curves]) 

n = len(curves) 

for i in range(n): 

E = curves[i] 

M = E.conductor() 

for j in range(i): 

F = curves[j] 

N = F.conductor() 

MN = lcm(M, N) 

lim = prod([(p - 1) * p ** (e - 1) for p, e in MN.factor()]) 

a_E = E.anlist(lim) 

a_F = F.anlist(lim) 

l_list = [p for p in prime_range(lim) if not p.divides(MN)] 

p_edges = l_list 

for l in l_list: 

n = a_E[l] - a_F[l] 

if n != 0: 

p_edges = [p for p in p_edges if p.divides(n)] 

if len(p_edges): 

G.add_edge(E.cremona_label(), F.cremona_label(), 

p_edges) 

return G