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

r""" 

Wehler K3 Surfaces 

 

AUTHORS: 

 

- Ben Hutz (11-2012) 

- Joao Alberto de Faria (10-2013) 

 

.. TODO:: 

 

Hasse-Weil Zeta Function 

 

Picard Number 

 

Number Fields 

 

REFERENCES: [FH2015]_, [CS1996]_, [Weh1998]_, [Hutz2007] 

 

""" 

 

#***************************************************************************** 

# This program is free software: you can redistribute it and/or modify 

# it under the terms of the GNU General Public License as published by 

# the Free Software Foundation, either version 2 of the License, or 

# (at your option) any later version. 

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

#***************************************************************************** 

 

from sage.calculus.functions import jacobian 

from sage.categories.fields import Fields 

from sage.categories.number_fields import NumberFields 

from sage.functions.all import sqrt 

from sage.misc.cachefunc import cached_method 

from sage.misc.mrange import xmrange 

from sage.rings.all import CommutativeRing 

from sage.rings.finite_rings.finite_field_constructor import GF 

from sage.rings.finite_rings.finite_field_base import is_FiniteField 

from sage.rings.fraction_field import FractionField 

from sage.rings.integer_ring import ZZ 

from sage.rings.number_field.order import is_NumberFieldOrder 

from sage.rings.padics.factory import Qp 

from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing 

from sage.rings.rational_field import QQ 

from sage.rings.real_mpfr import RealField 

from sage.schemes.generic.algebraic_scheme import AlgebraicScheme_subscheme 

from sage.schemes.product_projective.subscheme import AlgebraicScheme_subscheme_product_projective 

from sage.schemes.product_projective.space import ProductProjectiveSpaces 

from copy import copy 

 

_NumberFields = NumberFields() 

_Fields = Fields() 

 

 

def WehlerK3Surface(polys): 

r""" 

Defines a K3 Surface over `\mathbb{P}^2 \times \mathbb{P}^2` defined as 

the intersection of a bilinear and biquadratic form. [Weh1998]_ 

 

INPUT: Bilinear and biquadratic polynomials as a tuple or list 

 

OUTPUT: :class:`WehlerK3Surface_ring` 

 

EXAMPLES:: 

 

sage: PP.<x0,x1, x2, y0, y1, y2> = ProductProjectiveSpaces([2, 2],QQ) 

sage: L = x0*y0 + x1*y1 - x2*y2 

sage: Q = x0*x1*y1^2 + x2^2*y0*y2 

sage: WehlerK3Surface([L, Q]) 

Closed subscheme of Product of projective spaces P^2 x P^2 over Rational 

Field defined by: 

x0*y0 + x1*y1 - x2*y2, 

x0*x1*y1^2 + x2^2*y0*y2 

""" 

if not isinstance(polys, (list, tuple)): 

raise TypeError("polys must be a list or tuple of polynomials") 

 

R = polys[0].parent().base_ring() 

if R in _Fields: 

if is_FiniteField(R): 

return WehlerK3Surface_finite_field(polys) 

else: 

return WehlerK3Surface_field(polys) 

elif isinstance(R, CommutativeRing): 

return WehlerK3Surface_ring(polys) 

else: 

raise TypeError("R (= %s) must be a commutative ring"%R) 

 

def random_WehlerK3Surface(PP): 

r""" 

Produces a random K3 surface in `\mathbb{P}^2 \times \mathbb{P}^2` defined as the 

intersection of a bilinear and biquadratic form. [Weh1998]_ 

 

INPUT: Projective space cartesian product 

 

OUTPUT: :class:`WehlerK3Surface_ring` 

 

EXAMPLES:: 

 

sage: PP.<x0, x1, x2, y0, y1, y2> = ProductProjectiveSpaces([2, 2], GF(3)) 

sage: random_WehlerK3Surface(PP) 

Closed subscheme of Product of projective spaces P^2 x P^2 over Finite Field of size 3 defined by: 

x0*y0 + x1*y1 + x2*y2, 

-x1^2*y0^2 - x2^2*y0^2 + x0^2*y0*y1 - x0*x1*y0*y1 - x1^2*y0*y1 

+ x1*x2*y0*y1 + x0^2*y1^2 + x0*x1*y1^2 - x1^2*y1^2 + x0*x2*y1^2 

- x0^2*y0*y2 - x0*x1*y0*y2 + x0*x2*y0*y2 + x1*x2*y0*y2 + x0*x1*y1*y2 

- x1^2*y1*y2 - x1*x2*y1*y2 - x0^2*y2^2 + x0*x1*y2^2 - x1^2*y2^2 - x0*x2*y2^2 

""" 

 

CR = PP.coordinate_ring() 

BR = PP.base_ring() 

Q = 0 

for a in xmrange([3,3]): 

for b in xmrange([3,3]): 

Q += BR.random_element() * CR.gen(a[0]) * CR.gen(a[1]) * CR.gen(3+b[0]) * CR.gen(3+b[1]) 

#We can always change coordinates to make L diagonal 

L = CR.gen(0) * CR.gen(3) + CR.gen(1) * CR.gen(4) + CR.gen(2) * CR.gen(5) 

return(WehlerK3Surface([L,Q])) 

 

class WehlerK3Surface_ring(AlgebraicScheme_subscheme_product_projective): 

r""" 

 

A K3 surface in `\mathbb{P}^2 \times \mathbb{P}^2` defined as the 

intersection of a bilinear and biquadratic form. [Weh1998]_ 

 

EXAMPLES:: 

 

sage: R.<x,y,z,u,v,w> = PolynomialRing(QQ, 6) 

sage: L = x*u - y*v 

sage: Q = x*y*v^2 + z^2*u*w 

sage: WehlerK3Surface([L, Q]) 

Closed subscheme of Product of projective spaces P^2 x P^2 over Rational 

Field defined by: 

x*u - y*v, 

x*y*v^2 + z^2*u*w 

""" 

def __init__(self, polys): 

if not isinstance(polys, (list,tuple)): 

raise TypeError("polys must be a list or tuple of polynomials") 

R = polys[0].parent() 

vars = R.variable_names() 

A = ProductProjectiveSpaces([2, 2],R.base_ring(),vars) 

CR = A.coordinate_ring() 

#Check for following: 

# Is the user calling in 2 polynomials from a list or tuple? 

# Is there one biquadratic and one bilinear polynomial? 

if len(polys) != 2: 

raise AttributeError("there must be 2 polynomials") 

 

if (all(((e[0] + e[1] + e[2]) == 1 and (e[3] + e[4] + e[5]) == 1) for e in polys[0].exponents())): 

self.L = CR(polys[0]) 

elif (all(((e[0] + e[1] + e[2]) == 1 and (e[3] + e[4] + e[5]) == 1) for e in polys[1].exponents())): 

self.L = CR(polys[1]) 

else: 

raise AttributeError("there must be one bilinear polynomial") 

 

if (all(((e[0] + e[1] + e[2]) == 2 and (e[3] + e[4] + e[5]) == 2) for e in polys[0].exponents())): 

self.Q = CR(polys[0]) 

elif (all(((e[0] + e[1] + e[2]) == 2 and (e[3] + e[4] + e[5]) == 2) for e in polys[1].exponents())): 

self.Q = CR(polys[1]) 

else: 

raise AttributeError("there must be one biquadratic polynomial") 

AlgebraicScheme_subscheme.__init__(self, A, polys) 

 

def change_ring(self, R): 

r""" 

Changes the base ring on which the Wehler K3 Surface is defined. 

 

INPUT: ``R`` - ring 

 

OUTPUT: K3 Surface defined over input ring 

 

EXAMPLES:: 

 

sage: PP.<x0,x1,x2,y0,y1,y2> = ProductProjectiveSpaces([2, 2], GF(3)) 

sage: L = x0*y0 + x1*y1 - x2*y2 

sage: Q = x0*x1*y1^2 + x2^2*y0*y2 

sage: W = WehlerK3Surface([L, Q]) 

sage: W.base_ring() 

Finite Field of size 3 

sage: T = W.change_ring(GF(7)) 

sage: T.base_ring() 

Finite Field of size 7 

""" 

 

LR = self.L.change_ring(R) 

LQ = self.Q.change_ring(R) 

return (WehlerK3Surface( [LR,LQ])) 

 

def _check_satisfies_equations(self, P): 

r""" 

Function checks to see if point ``P`` lies on the K3 Surface. 

 

INPUT: ``P`` - point in `\mathbb{P}^2 \times \mathbb{P}^2` 

 

OUTPUT: AttributeError True if the point is not on the surface 

 

EXAMPLES:: 

 

sage: P.<x0,x1,x2,y0,y1,y2> = ProductProjectiveSpaces([2, 2], QQ) 

sage: Z = x0^2*y0^2 + 3*x0*x1*y0^2 + x1^2*y0^2 \ 

+ 4*x0^2*y0*y1 + 3*x0*x1*y0*y1 - \ 

2*x2^2*y0*y1 - x0^2*y1^2 + 2*x1^2*y1^2 - x0*x2*y1^2 \ 

- 4*x1*x2*y1^2 + 5*x0*x2*y0*y2 - \ 

4*x1*x2*y0*y2 + 7*x0^2*y1*y2 + 4*x1^2*y1*y2 \ 

+ x0*x1*y2^2 + 3*x2^2*y2^2 

sage: Y = x0 * y0 + x1 * y1 + x2 * y2 

sage: X = WehlerK3Surface([Z, Y]) 

sage: X._check_satisfies_equations([0, 0, 1, 1, 0, 0]) 

True 

 

:: 

 

sage: P.<x0,x1,x2,y0,y1,y2> = ProductProjectiveSpaces([2, 2], QQ) 

sage: Z = x0^2*y0^2 + 3*x0*x1*y0^2 + x1^2*y0^2 \ 

+ 4*x0^2*y0*y1 + 3*x0*x1*y0*y1 - \ 

2*x2^2*y0*y1 - x0^2*y1^2 + 2*x1^2*y1^2 - x0*x2*y1^2 \ 

- 4*x1*x2*y1^2 + 5*x0*x2*y0*y2 - \ 

4*x1*x2*y0*y2 + 7*x0^2*y1*y2 + 4*x1^2*y1*y2 \ 

+ x0*x1*y2^2 + 3*x2^2*y2^2 

sage: Y = x0*y0 + x1*y1 + x2*y2 

sage: X = WehlerK3Surface([Z, Y]) 

sage: X._check_satisfies_equations([0, 1, 1, 1, 0, 0]) 

Traceback (most recent call last): 

... 

AttributeError: point not on surface 

""" 

Point = list(P) 

if self.L(*Point) == 0 and self.Q(*Point) == 0: 

return True 

else: 

raise AttributeError("point not on surface") 

 

def _Lcoeff(self, component, i): 

r""" 

Returns the polynomials `L^x_i` or `L^y_i`. 

 

These polynomials are defined as: 

 

`L^x_i` = the coefficients of `y_i` in `L(x, y)` (Component = 0) 

 

`L^y_i` = the coefficients of `x_i` in `L(x, y)` (Component = 1) 

 

Definition and Notation from: [CS1996]_ 

 

INPUT: 

 

- ``component`` - Integer: 0 or 1 

 

- ``i`` - Integer: 0, 1 or 2 

 

OUTPUT: polynomial in terms of either y (Component = 0) or x (Component = 1) 

 

EXAMPLES:: 

 

sage: R.<x0,x1,x2,y0,y1,y2> = PolynomialRing(ZZ, 6) 

sage: Y = x0*y0 + x1*y1 - x2*y2 

sage: Z = x0^2*y0*y1 + x0^2*y2^2 - x0*x1*y1*y2 + x1^2*y2*y1 \ 

+ x2^2*y2^2 + x2^2*y1^2 + x1^2*y2^2 

sage: X = WehlerK3Surface([Z, Y]) 

sage: X._Lcoeff(0, 0) 

y0 

 

:: 

 

sage: R.<x0,x1,x2,y0,y1,y2> = PolynomialRing(ZZ, 6) 

sage: Y = x0*y0 + x1*y1 - x2*y2 

sage: Z =x0^2*y0*y1 + x0^2*y2^2 - x0*x1*y1*y2 + x1^2*y2*y1 \ 

+ x2^2*y2^2 + x2^2*y1^2 + x1^2*y2^2 

sage: X = WehlerK3Surface([Z, Y]) 

sage: X._Lcoeff(1, 0) 

x0 

""" 

#Error Checks for Passed in Values 

if not component in [0,1]: 

raise ValueError("component can only be 1 or 0") 

if not i in [0,1,2]: 

raise ValueError("index must be 0, 1, or 2") 

R = self.ambient_space().coordinate_ring() 

return self.L.coefficient(R.gen(component*3 + i)) 

 

def _Qcoeff(self, component, i, j): 

r""" 

Returns the polynomials `Q^x_{ij}` or `Q^y_{ij}`. 

 

These polynomials are defined as: 

 

`Q^x_{ij}` = the coefficients of `y_{i}y_{j}` in `Q(x, y)` (Component = 0). 

 

`Q^y_{ij}` = the coefficients of `x_{i}x_{j}` in `Q(x, y)` (Component = 1). 

 

Definition and Notation from: [CS1996]_. 

 

INPUT: 

 

- ``component`` - Integer: 0 or 1 

 

- ``i`` - Integer: 0, 1 or 2 

 

- ``j`` - Integer: 0, 1 or 2 

 

OUTPUT: polynomial in terms of either y (Component = 0) or x (Component = 1) 

 

EXAMPLES:: 

 

sage: R.<x0,x1,x2,y0,y1,y2> = PolynomialRing(ZZ, 6) 

sage: Y = x0*y0 + x1*y1 - x2*y2 

sage: Z = x0^2*y0*y1 + x0^2*y2^2 - x0*x1*y1*y2 + x1^2*y2*y1 \ 

+ x2^2*y2^2 + x2^2*y1^2 + x1^2*y2^2 

sage: X = WehlerK3Surface([Z, Y]) 

sage: X._Qcoeff(0, 0, 0) 

y0*y1 + y2^2 

 

:: 

 

sage: R.<x0,x1,x2,y0,y1,y2> = PolynomialRing(ZZ, 6) 

sage: Y = x0*y0 + x1*y1 - x2*y2 

sage: Z = x0^2*y0*y1 + x0^2*y2^2 - x0*x1*y1*y2 + x1^2*y2*y1 \ 

+ x2^2*y2^2 + x2^2*y1^2 + x1^2*y2^2 

sage: X = WehlerK3Surface([Z, Y]) 

sage: X._Qcoeff(1, 1, 0) 

x0^2 

""" 

#Check Errors in Passed in Values 

if not component in [0,1]: 

raise ValueError("component can only be 1 or 0") 

 

if not (i in [0,1,2]) and not (j in [0,1,2]): 

raise ValueError("the two indexes must be either 0, 1, or 2") 

 

R = self.ambient_space().coordinate_ring() 

return self.Q.coefficient(R.gen(component * 3 + i) * R.gen(component * 3 + j)) 

 

@cached_method 

def Gpoly(self, component, k): 

r""" 

Returns the G polynomials `G^*_k`. 

 

They are defined as: 

`G^*_k = \left(L^*_j\right)^2Q^*_{ii}-L^*_iL^*_jQ^*_{ij}+\left(L^*_i\right)^2Q^*_{jj}`\ 

where {i, j, k} is some permutation of (0, 1, 2) and * is either 

x (Component = 1) or y (Component = 0). 

 

INPUT: 

 

- ``component`` - Integer: 0 or 1 

 

- ``k`` - Integer: 0, 1 or 2 

 

OUTPUT: polynomial in terms of either y (Component = 0) or x (Component = 1) 

 

EXAMPLES:: 

 

sage: R.<x0,x1,x2,y0,y1,y2> = PolynomialRing(ZZ, 6) 

sage: Y = x0*y0 + x1*y1 - x2*y2 

sage: Z = x0^2*y0*y1 + x0^2*y2^2 - x0*x1*y1*y2 + x1^2*y2*y1 \ 

+ x2^2*y2^2 + x2^2*y1^2 + x1^2*y2^2 

sage: X = WehlerK3Surface([Z, Y]) 

sage: X.Gpoly(1, 0) 

x0^2*x1^2 + x1^4 - x0*x1^2*x2 + x1^3*x2 + x1^2*x2^2 + x2^4 

""" 

#Check Errors in passed in values 

if not component in [0, 1]: 

raise ValueError("component can only be 1 or 0") 

 

if not k in [0,1,2]: 

raise ValueError("index must be either 0, 1, or 2") 

 

Indices = [0, 1, 2] 

Indices.remove( k) 

i = Indices[0] 

j = Indices[1] 

 

return (self._Lcoeff(component, j)**2) * (self._Qcoeff(component, i, i)) - (self._Lcoeff(component, i))* \ 

(self._Lcoeff(component, j)) * (self._Qcoeff(component, i, j)) + (self._Lcoeff( component, i)**2)* \ 

(self._Qcoeff( component, j, j)) 

 

@cached_method 

def Hpoly(self, component, i, j): 

r""" 

Returns the H polynomials defined as `H^*_{ij}`. 

 

This polynomial is defined by: 

 

`H^*_{ij} = 2L^*_iL^*_jQ^*_{kk}-L^*_iL^*_kQ^*_{jk} - L^*_jL^*_kQ^*_{ik}+\left(L^*_k\right)^2Q^*_{ij}` 

where {i, j, k} is some permutation of (0, 1, 2) and * is either y (Component = 0) or x (Component = 1). 

 

INPUT: 

 

- ``component`` - Integer: 0 or 1 

 

- ``i`` - Integer: 0, 1 or 2 

 

- ``j`` - Integer: 0, 1 or 2 

 

OUTPUT: polynomial in terms of either y (Component = 0) or x (Component = 1) 

 

EXAMPLES:: 

 

sage: R.<x0,x1,x2,y0,y1,y2> = PolynomialRing(ZZ, 6) 

sage: Y = x0*y0 + x1*y1 - x2*y2 

sage: Z = x0^2*y0*y1 + x0^2*y2^2 - x0*x1*y1*y2 + x1^2*y2*y1 \ 

+ x2^2*y2^2 + x2^2*y1^2 + x1^2*y2^2 

sage: X = WehlerK3Surface([Z, Y]) 

sage: X.Hpoly(0, 1, 0) 

2*y0*y1^3 + 2*y0*y1*y2^2 - y1*y2^3 

""" 

#Check Errors in Passed in Values 

if component not in [0, 1]: 

raise ValueError("component can only be 1 or 0") 

 

if (i not in [0, 1, 2]) or (j not in [0, 1, 2]): 

raise ValueError("the two indexes must be either 0, 1, or 2") 

 

Indices = [0, 1, 2] 

Indices.remove(i) 

Indices.remove(j) 

 

k = Indices[0] 

 

return 2*(self._Lcoeff(component, i)) * (self._Lcoeff(component, j)) * (self._Qcoeff(component, k, k)) -\ 

(self._Lcoeff(component, i)) * (self._Lcoeff( component, k)) * (self._Qcoeff(component, j, k)) -\ 

(self._Lcoeff(component, j)) * (self._Lcoeff(component, k)) * (self._Qcoeff( component, i, k)) +\ 

(self._Lcoeff(component, k)**2) * (self._Qcoeff(component, i, j)) 

 

def Lxa(self, a): 

r""" 

Function will return the L polynomial defining the fiber, given by `L^{x}_{a}`. 

 

This polynomial is defined as: 

 

`L^{x}_{a} = \{(a, y) \in \mathbb{P}^{2} \times \mathbb{P}^{2} \colon L(a, y) = 0\}`. 

 

Notation and definition from: [CS1996]_ 

 

INPUT: ``a`` - Point in `\mathbb{P}^2` 

 

OUTPUT: A polynomial representing the fiber 

 

EXAMPLES:: 

 

sage: PP.<x0,x1,x2,y0,y1,y2> = ProductProjectiveSpaces([2, 2], QQ) 

sage: Z = x0^2*y0^2 + 3*x0*x1*y0^2 + x1^2*y0^2 + 4*x0^2*y0*y1 \ 

+ 3*x0*x1*y0*y1 - 2*x2^2*y0*y1 - \ 

x0^2*y1^2 + 2*x1^2*y1^2 - x0*x2*y1^2 - 4*x1*x2*y1^2 \ 

+ 5*x0*x2*y0*y2 - 4*x1*x2*y0*y2 + 7*x0^2*y1*y2 \ 

+ 4*x1^2*y1*y2 + x0*x1*y2^2 + 3*x2^2*y2^2 

sage: Y = x0*y0 + x1*y1 + x2*y2 

sage: X = WehlerK3Surface([Z, Y]) 

sage: T = PP(1, 1, 0, 1, 0, 0); 

sage: X.Lxa(T[0]) 

y0 + y1 

""" 

if not a in self.ambient_space()[0]: 

raise TypeError("point must be in projective space of dimension 2") 

AS = self.ambient_space() 

ASC = AS.coordinate_ring() 

PSY = AS[1] 

PSYC = PSY.coordinate_ring() 

#Define projection homomorphism 

p = ASC.hom([a[0],a[1],a[2]] + list(PSY.gens()), PSYC) 

return((p(self.L))) 

 

def Qxa(self, a): 

r""" 

Function will return the Q polynomial defining a fiber given by `Q^{x}_{a}`. 

 

This polynomial is defined as: 

 

`Q^{x}_{a} = \{(a,y) \in \mathbb{P}^{2} \times \mathbb{P}^{2} \colon Q(a,y) = 0\}`. 

 

Notation and definition from: [CS1996]_ 

 

INPUT: ``a`` - Point in `\mathbb{P}^2` 

 

OUTPUT: A polynomial representing the fiber 

 

EXAMPLES:: 

 

sage: PP.<x0,x1,x2,y0,y1,y2> = ProductProjectiveSpaces([2, 2], QQ) 

sage: Z = x0^2*y0^2 + 3*x0*x1*y0^2 + x1^2*y0^2 + 4*x0^2*y0*y1 + 3*x0*x1*y0*y1 \ 

- 2*x2^2*y0*y1 - x0^2*y1^2 + 2*x1^2*y1^2 - x0*x2*y1^2 - 4*x1*x2*y1^2 \ 

+ 5*x0*x2*y0*y2 \ 

- 4*x1*x2*y0*y2 + 7*x0^2*y1*y2 + 4*x1^2*y1*y2 + x0*x1*y2^2 + 3*x2^2*y2^2 \ 

sage: Y = x0*y0 + x1*y1 + x2*y2 

sage: X = WehlerK3Surface([Z, Y]) 

sage: T = PP(1, 1, 0, 1, 0, 0); 

sage: X.Qxa(T[0]) 

5*y0^2 + 7*y0*y1 + y1^2 + 11*y1*y2 + y2^2 

""" 

if not a in self.ambient_space()[0]: 

raise TypeError("point must be in Projective Space of dimension 2") 

AS = self.ambient_space() 

ASC = AS.coordinate_ring() 

PSY = AS[1] 

PSYC = PSY.coordinate_ring() 

#Define projection homomorphism 

p = ASC.hom([a[0], a[1], a[2]] + list(PSY.gens()), PSYC) 

return(p(self.Q)) 

 

def Sxa(self, a): 

r""" 

Function will return fiber by `S^{x}_{a}`. 

 

This function is defined as: 

 

`S^{x}_{a} = L^{x}_{a} \cap Q^{x}_{a}`. 

 

Notation and definition from: [CS1996]_ 

 

INPUT: ``a`` - Point in `\mathbb{P}^2` 

 

OUTPUT: A subscheme representing the fiber 

 

EXAMPLES:: 

 

sage: PP.<x0,x1,x2,y0,y1,y2> = ProductProjectiveSpaces([2, 2], QQ) 

sage: Z = x0^2*y0^2 + 3*x0*x1*y0^2 + x1^2*y0^2 + 4*x0^2*y0*y1 \ 

+ 3*x0*x1*y0*y1 \ 

- 2*x2^2*y0*y1 - x0^2*y1^2 + 2*x1^2*y1^2 - x0*x2*y1^2 - 4*x1*x2*y1^2 \ 

+ 5*x0*x2*y0*y2 \ 

- 4*x1*x2*y0*y2 + 7*x0^2*y1*y2 + 4*x1^2*y1*y2 + x0*x1*y2^2 + 3*x2^2*y2^2 

sage: Y = x0*y0 + x1*y1 + x2*y2 

sage: Y = x0*y0 + x1*y1 + x2*y2 

sage: X = WehlerK3Surface([Z, Y]) 

sage: T = PP(1, 1, 0, 1, 0, 0); 

sage: X.Sxa(T[0]) 

Closed subscheme of Projective Space of dimension 2 over Rational Field defined by: 

y0 + y1, 

5*y0^2 + 7*y0*y1 + y1^2 + 11*y1*y2 + y2^2 

""" 

if not a in self.ambient_space()[0]: 

raise TypeError("point must be in projective space of dimension 2") 

PSY = self.ambient_space()[1] 

return PSY.subscheme([self.Lxa(a),self.Qxa(a)]) 

 

def Lyb(self, b): 

r""" 

Function will return a fiber by `L^{y}_{b}`. 

 

This polynomial is defined as: 

 

`L^{y}_{b} = \{(x,b) \in \mathbb{P}^{2} \times \mathbb{P}^{2} \colon L(x,b) = 0\}`. 

 

Notation and definition from: [CS1996]_ 

 

INPUT: ``b`` - Point in projective space 

 

OUTPUT: A polynomial representing the fiber 

 

EXAMPLES:: 

 

sage: PP.<x0,x1,x2,y0,y1,y2> = ProductProjectiveSpaces([2, 2], QQ) 

sage: Z =x0^2*y0^2 + 3*x0*x1*y0^2 + x1^2*y0^2 + 4*x0^2*y0*y1 \ 

+ 3*x0*x1*y0*y1 \ 

- 2*x2^2*y0*y1 - x0^2*y1^2 + 2*x1^2*y1^2 - x0*x2*y1^2 - 4*x1*x2*y1^2 \ 

+ 5*x0*x2*y0*y2 \ 

- 4*x1*x2*y0*y2 + 7*x0^2*y1*y2 + 4*x1^2*y1*y2 + x0*x1*y2^2 + 3*x2^2*y2^2 

sage: Y = x0*y0 + x1*y1 + x2*y2 

sage: Y = x0*y0 + x1*y1 + x2*y2 

sage: X = WehlerK3Surface([Z, Y]) 

sage: T = PP(1, 1, 0, 1, 0, 0); 

sage: X.Lyb(T[1]) 

x0 

""" 

if not b in self.ambient_space()[1]: 

raise TypeError("point must be in projective space of dimension 2") 

AS = self.ambient_space() 

ASC = AS.coordinate_ring() 

PSY = AS[0]; 

PSYC = PSY.coordinate_ring() 

p = ASC.hom(list(PSY.gens()) + [b[0], b[1], b[2]], PSYC) 

return (p(self.L)) 

 

def Qyb(self, b): 

r""" 

 

Function will return a fiber by `Q^{y}_{b}`. 

 

This polynomial is defined as: 

 

`Q^{y}_{b} = \{(x,b) \in \mathbb{P}^{2} \times \mathbb{P}^{2} \colon Q(x,b) = 0\}`. 

 

Notation and definition from: [CS1996]_ 

 

INPUT: ``b`` - Point in projective space 

 

OUTPUT: A polynomial representing the fiber 

 

EXAMPLES:: 

 

sage: PP.<x0,x1,x2,y0,y1,y2> = ProductProjectiveSpaces([2, 2], QQ) 

sage: Z = x0^2*y0^2 + 3*x0*x1*y0^2 + x1^2*y0^2 + 4*x0^2*y0*y1 \ 

+ 3*x0*x1*y0*y1 - 2*x2^2*y0*y1 - x0^2*y1^2 + 2*x1^2*y1^2 - x0*x2*y1^2 \ 

- 4*x1*x2*y1^2 + 5*x0*x2*y0*y2 - 4*x1*x2*y0*y2 + 7*x0^2*y1*y2 \ 

+ 4*x1^2*y1*y2 + x0*x1*y2^2 + 3*x2^2*y2^2 

sage: Y = x0*y0 + x1*y1 + x2*y2 

sage: X = WehlerK3Surface([Z, Y]) 

sage: T = PP(1, 1, 0, 1, 0, 0); 

sage: X.Qyb(T[1]) 

x0^2 + 3*x0*x1 + x1^2 

""" 

if not b in self.ambient_space()[1]: 

raise TypeError("point must be in projective space of dimension 2") 

AS = self.ambient_space() 

ASC = AS.coordinate_ring() 

PSY = AS[0] 

PSYC = PSY.coordinate_ring() 

p = ASC.hom(list(PSY.gens()) + [b[0], b[1], b[2]], PSYC) 

return (p(self.Q)) 

 

def Syb(self, b): 

r""" 

Function will return fiber by `S^{y}_{b}`. 

 

This function is defined by: 

 

`S^{y}_{b} = L^{y}_{b} \cap Q^{y}_{b}`. 

 

Notation and definition from: [CS1996]_ 

 

INPUT: ``b`` - Point in `\mathbb{P}^2` 

 

OUTPUT: A subscheme representing the fiber 

 

EXAMPLES:: 

 

sage: PP.<x0,x1,x2,y0,y1,y2> = ProductProjectiveSpaces([2, 2], QQ) 

sage: Z = x0^2*y0^2 + 3*x0*x1*y0^2 + x1^2*y0^2 + 4*x0^2*y0*y1 + \ 

3*x0*x1*y0*y1 - 2*x2^2*y0*y1 - x0^2*y1^2 + 2*x1^2*y1^2 - x0*x2*y1^2 \ 

- 4*x1*x2*y1^2 + 5*x0*x2*y0*y2 - 4*x1*x2*y0*y2 + 7*x0^2*y1*y2 \ 

+ 4*x1^2*y1*y2 + x0*x1*y2^2 + 3*x2^2*y2^2 

sage: Y = x0 * y0 + x1 * y1 + x2 * y2 

sage: X = WehlerK3Surface([Z, Y]) 

sage: T = PP(1, 1, 0, 1, 0, 0); 

sage: X.Syb(T[1]) 

Closed subscheme of Projective Space of dimension 2 over Rational Field defined by: 

x0, 

x0^2 + 3*x0*x1 + x1^2 

 

""" 

if not b in self.ambient_space()[1]: 

raise TypeError("point must be in projective space of dimension 2") 

AS = self.ambient_space() 

PSY = AS[0] 

return PSY.subscheme([self.Lyb(b), self.Qyb(b)]) 

 

def Ramification_poly(self, i): 

r""" 

Function will return the Ramification polynomial `g^*`. 

 

This polynomial is defined by: 

 

`g^* = \frac{\left(H^*_{ij}\right)^2 - 4G^*_iG^*_j}{\left(L^*_k\right)^2}`. 

 

The roots of this polynomial will either be degenerate fibers or fixed points 

of the involutions `\sigma_x` or `\sigma_y` for more information, see [CS1996]_. 

 

INPUT: ``i`` - Integer, either 0 (polynomial in y) or 1 (polynomial in x) 

 

OUTPUT: Polynomial in the coordinate ring of the ambient space 

 

EXAMPLES:: 

 

sage: PP.<x0,x1,x2,y0,y1,y2> = ProductProjectiveSpaces([2, 2], QQ) 

sage: Z = x0^2*y0^2 + 3*x0*x1*y0^2 + x1^2*y0^2 + 4*x0^2*y0*y1 + 3*x0*x1*y0*y1\ 

- 2*x2^2*y0*y1 - x0^2*y1^2 + 2*x1^2*y1^2 - x0*x2*y1^2 - 4*x1*x2*y1^2 + 5*x0*x2*y0*y2\ 

- 4*x1*x2*y0*y2 + 7*x0^2*y1*y2 + 4*x1^2*y1*y2 + x0*x1*y2^2 + 3*x2^2*y2^2 

sage: Y = x0*y0 + x1*y1 + x2*y2 

sage: X = WehlerK3Surface([Z, Y]) 

sage: X.Ramification_poly(0) 

8*y0^5*y1 - 24*y0^4*y1^2 + 48*y0^2*y1^4 - 16*y0*y1^5 + y1^6 + 84*y0^3*y1^2*y2 

+ 46*y0^2*y1^3*y2 - 20*y0*y1^4*y2 + 16*y1^5*y2 + 53*y0^4*y2^2 + 56*y0^3*y1*y2^2 

- 32*y0^2*y1^2*y2^2 - 80*y0*y1^3*y2^2 - 92*y1^4*y2^2 - 12*y0^2*y1*y2^3 

- 168*y0*y1^2*y2^3 - 122*y1^3*y2^3 + 14*y0^2*y2^4 + 8*y0*y1*y2^4 - 112*y1^2*y2^4 + y2^6 

""" 

return ((self._Lcoeff(i, 0))**2)*(self._Qcoeff(i, 1, 2))**2 + \ 

((self._Lcoeff(i, 1))**2)*(self._Qcoeff(i, 0, 2)**2)+ \ 

((self._Lcoeff(i, 2))**2)*(self._Qcoeff(i, 0, 1)**2)- \ 

2*(self._Lcoeff(i, 0))*(self._Lcoeff(i, 1))*(self._Qcoeff(i, 0, 2))*(self._Qcoeff(i, 1, 2))\ 

-2*(self._Lcoeff(i, 0))*(self._Lcoeff(i, 2))*(self._Qcoeff(i, 0, 1))*(self._Qcoeff(i, 1, 2))\ 

-2*(self._Lcoeff(i, 1))*(self._Lcoeff(i, 2))*(self._Qcoeff(i, 0, 1))*(self._Qcoeff(i, 0, 2)) + \ 

4*(self._Lcoeff(i, 0))*(self._Lcoeff(i, 1))*(self._Qcoeff(i, 0, 1))*(self._Qcoeff(i, 2, 2)) + \ 

4*(self._Lcoeff(i, 0))*(self._Lcoeff(i, 2))*(self._Qcoeff(i, 0, 2))*(self._Qcoeff(i, 1, 1)) + \ 

4*(self._Lcoeff(i, 1))*(self._Lcoeff(i, 2))*(self._Qcoeff(i, 1, 2))*(self._Qcoeff(i, 0, 0)) - \ 

4*((self._Lcoeff(i, 0))**2)*(self._Qcoeff(i, 1, 1))*(self._Qcoeff(i, 2, 2)) - \ 

4*((self._Lcoeff(i, 1))**2)*(self._Qcoeff(i, 0, 0))*(self._Qcoeff(i, 2, 2)) - \ 

4*((self._Lcoeff(i, 2))**2)*(self._Qcoeff(i, 1, 1))*(self._Qcoeff(i, 0, 0)) 

 

@cached_method 

def is_degenerate(self): 

r""" 

Function will return True if there is a fiber (over the algebraic closure of the 

base ring) of dimension greater than 0 and False otherwise. 

 

OUTPUT: boolean 

 

EXAMPLES:: 

 

sage: R.<x0,x1,x2,y0,y1,y2> = PolynomialRing(ZZ, 6) 

sage: Y = x0*y0 + x1*y1 - x2*y2 

sage: Z = x0^2*y0*y1 + x0^2*y2^2 - x0*x1*y1*y2 + x1^2*y2*y1 + x2^2*y2^2 + \ 

x2^2*y1^2 + x1^2*y2^2 

sage: X = WehlerK3Surface([Z, Y]) 

sage: X.is_degenerate() 

True 

 

:: 

 

sage: PP.<x0,x1,x2,y0,y1,y2> = ProductProjectiveSpaces([2, 2], QQ) 

sage: Z = x0^2*y0^2 + 3*x0*x1*y0^2 + x1^2*y0^2 + 4*x0^2*y0*y1 + 3*x0*x1*y0*y1 - \ 

2*x2^2*y0*y1 - x0^2*y1^2 + 2*x1^2*y1^2 - x0*x2*y1^2 -4*x1*x2*y1^2 + 5*x0*x2*y0*y2 - \ 

4*x1*x2*y0*y2 + 7*x0^2*y1*y2 + 4*x1^2*y1*y2 + x0*x1*y2^2 + 3*x2^2*y2^2 

sage: Y = x0*y0 + x1*y1 + x2*y2 

sage: X = WehlerK3Surface([Z, Y]) 

sage: X.is_degenerate() 

False 

 

:: 

 

sage: PP.<x0,x1,x2,y0,y1,y2> = ProductProjectiveSpaces([2, 2], GF(3)) 

sage: Z = x0^2*y0^2 + 3*x0*x1*y0^2 + x1^2*y0^2 + 4*x0^2*y0*y1 + 3*x0*x1*y0*y1 - \ 

2*x2^2*y0*y1 - x0^2*y1^2 + 2*x1^2*y1^2 - x0*x2*y1^2 -4*x1*x2*y1^2 + 5*x0*x2*y0*y2 - \ 

4*x1*x2*y0*y2 + 7*x0^2*y1*y2 + 4*x1^2*y1*y2 + x0*x1*y2^2 + 3*x2^2*y2^2 

sage: Y = x0*y0 + x1*y1 + x2*y2 

sage: X = WehlerK3Surface([Z, Y]) 

sage: X.is_degenerate() 

True 

""" 

PP = self.ambient_space() 

K = FractionField(PP[0].base_ring()) 

R = PP.coordinate_ring() 

PS = PP[0] #check for x fibers 

vars = list(PS.gens()) 

R0 = PolynomialRing(K, 3, vars) #for dimension calculation to work, 

#must be done with Polynomial ring over a field 

#Degenerate is equivalent to a common zero, see Prop 1.4 in [CS1996]_ 

I = R.ideal(self.Gpoly(1, 0), self.Gpoly(1, 1), self.Gpoly(1, 2), self.Hpoly(1, 0, 1), 

self.Hpoly(1, 0, 2), self.Hpoly(1, 1, 2)) 

phi = R.hom(vars + [0, 0, 0], R0) 

I = phi(I) 

if I.dimension() != 0: 

return True 

 

PS = PP[1] #check for y fibers 

vars = list(PS.gens()) 

R0 = PolynomialRing(K,3,vars) #for dimension calculation to work, 

#must be done with Polynomial ring over a field 

#Degenerate is equivalent to a common zero, see Prop 1.4 in [CS1996]_ 

I = R.ideal(self.Gpoly(0, 0), self.Gpoly(0, 1), self.Gpoly(0, 2), self.Hpoly(0, 0, 1), 

self.Hpoly(0, 0, 2), self.Hpoly(0, 1, 2)) 

phi = R.hom([0, 0, 0] + vars, R0) 

I = phi(I) 

if I.dimension() != 0: 

return True 

return False 

 

 

def degenerate_fibers(self): 

r""" 

Function will return the (rational) degenerate fibers of the surface 

defined over the base ring, or the fraction field of the base ring if it is not a field. 

 

ALGORITHM: 

 

The criteria for degeneracy by the common vanishing of the polynomials 

``self.Gpoly(1, 0)``, ``self.Gpoly(1, 1)``, ``self.Gpoly(1, 2)``, 

``self.Hpoly(1, 0, 1)``,``self.Hpoly(1, 0, 2)``, 

``self.Hpoly(1, 1, 2)`` (for the first component), is from Proposition 1.4 

in the following article: [CS1996]_. 

 

This function finds the common solution through elimination via Groebner bases 

by using the .variety() function on the three affine charts in each component. 

 

OUTPUT: The output is a list of lists where the elements of lists are 

points in the appropriate projective space. 

The first list is the points whose pullback by the projection to the 

first component (projective space) is dimension greater than 0. 

The second list is points in the second component 

 

EXAMPLES:: 

 

sage: R.<x0,x1,x2,y0,y1,y2> = PolynomialRing(ZZ, 6) 

sage: Y = x0*y0 + x1*y1 - x2*y2 

sage: Z = x0^2*y0*y1 + x0^2*y2^2 - x0*x1*y1*y2 + x1^2*y2*y1 + x2^2*y2^2\ 

+ x2^2*y1^2 + x1^2*y2^2 

sage: X = WehlerK3Surface([Z, Y]) 

sage: X.degenerate_fibers() 

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

 

:: 

 

sage: PP.<x0,x1,x2,y0,y1,y2> = ProductProjectiveSpaces([2, 2], QQ) 

sage: Z = x0^2*y0^2 + 3*x0*x1*y0^2 + x1^2*y0^2 + 4*x0^2*y0*y1 + 3*x0*x1*y0*y1\ 

- 2*x2^2*y0*y1 - x0^2*y1^2 + 2*x1^2*y1^2 - x0*x2*y1^2 - 4*x1*x2*y1^2 + 5*x0*x2*y0*y2\ 

- 4*x1*x2*y0*y2 + 7*x0^2*y1*y2 + 4*x1^2*y1*y2 + x0*x1*y2^2 + 3*x2^2*y2^2 

sage: Y = x0*y0 + x1*y1 + x2*y2 

sage: X = WehlerK3Surface([Z, Y]) 

sage: X.degenerate_fibers() 

[[], []] 

 

:: 

 

sage: PP.<x0,x1,x2,y0,y1,y2> = ProductProjectiveSpaces([2, 2], QQ) 

sage: R = PP.coordinate_ring() 

sage: l = y0*x0 + y1*x1 + (y0 - y1)*x2 

sage: q = (y1*y0 + y2^2)*x0^2 + ((y0^2 - y2*y1)*x1 + (y0^2 + (y1^2 - y2^2))*x2)*x0 \ 

+ (y2*y0 + y1^2)*x1^2 + (y0^2 + (-y1^2 + y2^2))*x2*x1 

sage: X = WehlerK3Surface([l,q]) 

sage: X.degenerate_fibers() 

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

""" 

PP = self.ambient_space() 

R = PP.coordinate_ring() 

PSX = PP[0]; 

vars = list(PSX.gens()) 

K = FractionField(PSX.base_ring()) 

R0 = PolynomialRing(K, 3, vars) 

I = R.ideal(self.Gpoly(1, 0), self.Gpoly(1, 1), self.Gpoly(1, 2), self.Hpoly(1, 0,1 ), \ 

self.Hpoly(1, 0, 2), self.Hpoly(1, 1, 2)) 

phi = R.hom(vars + [0, 0, 0], R0) 

I = phi(I) 

xFibers = [] 

#check affine charts 

for n in range(3): 

affvars = list(R0.gens()) 

del affvars[n] 

R1 = PolynomialRing(K, 2, affvars, order = 'lex') 

mapvars = list(R1.gens()) 

mapvars.insert(n,1) 

phi1 = R0.hom(mapvars, R1) 

J = phi1(I) 

if (J.dimension() == 0): 

Var = J.variety() 

if Var != [{}]: 

for d in Var: #iterate through dictionaries 

P = [] #new point 

for z in mapvars: #assign coordinate values 

if (z == 1): 

P.append(1) 

else: 

P.append(d[z]) 

MP = PSX(P) #make projective point 

if MP not in xFibers: 

xFibers.append(MP) 

PSY = PP[1] 

vars = list(PSY.gens()) 

K = FractionField(PSY.base_ring()) 

R0 = PolynomialRing(K, 3, vars) 

I = R.ideal(self.Gpoly(0, 0), self.Gpoly(0, 1), self.Gpoly(0, 2), self.Hpoly(0, 0, 1), \ 

self.Hpoly(0, 0, 2), self.Hpoly(0, 1, 2)) 

phi = PP.coordinate_ring().hom([0, 0, 0] + vars, R0) 

I = phi(I) 

yFibers = [] 

#check affine charts 

for n in range(3): 

affvars = list(R0.gens()) 

del affvars[n] 

R1 = PolynomialRing(K, 2, affvars, order = 'lex') 

mapvars = list(R1.gens()) 

mapvars.insert(n, 1) 

phi1 = R0.hom(mapvars,R1) 

J = phi1(I) 

if (J.dimension() == 0): 

Var = J.variety() 

if Var != [{}]: 

for d in Var: #iterate through dictionaries 

P = [] #new point 

for z in mapvars: #assign coordinate values 

if (z == 1): 

P.append(1) 

else: 

P.append(d[z]) 

MP = PSY(P) #make projective point 

if MP not in yFibers: 

yFibers.append(MP) 

return [xFibers,yFibers] 

 

@cached_method 

def degenerate_primes(self,check = True): 

r""" 

Determine which primes `p` self has degenerate fibers over `GF(p)`. 

 

If check is False, then may return primes that do not have degenerate fibers. 

Raises an error if the surface is degenerate. 

Works only for ``ZZ`` or ``QQ``. 

 

INPUT: ``check`` -- (default: True) boolean, whether the primes are verified 

 

ALGORITHM: 

 

`p` is a prime of bad reduction if and only if the defining 

polynomials of self plus the G and H polynomials have a common 

zero. Or stated another way, `p` is a prime of bad reduction if 

and only if the radical of the ideal defined by the defining 

polynomials of self plus the G and H polynomials is not 

`(x_0,x_1,\ldots,x_N)`. This happens if and only if some 

power of each `x_i` is not in the ideal defined by the 

defining polynomials of self (with G and H). This last condition 

is what is checked. The lcm of the coefficients of the monomials `x_i` in 

a groebner basis is computed. This may return extra primes. 

 

OUTPUT: List of primes. 

 

EXAMPLES:: 

 

sage: R.<x0,x1,x2,y0,y1,y2> = PolynomialRing(QQ, 6) 

sage: L = y0*x0 + (y1*x1 + y2*x2) 

sage: Q = (2*y0^2 + y2*y0 + (2*y1^2 + y2^2))*x0^2 + ((y0^2 + y1*y0 + \ 

(y1^2 + 2*y2*y1 + y2^2))*x1 + (2*y1^2 + y2*y1 + y2^2)*x2)*x0 + ((2*y0^2\ 

+ (y1 + 2*y2)*y0 + (2*y1^2 + y2*y1))*x1^2 + ((2*y1 + 2*y2)*y0 + (y1^2 + \ 

y2*y1 + 2*y2^2))*x2*x1 + (2*y0^2 + y1*y0 + (2*y1^2 + y2^2))*x2^2) 

sage: X = WehlerK3Surface([L, Q]) 

sage: X.degenerate_primes() 

[2, 3, 5, 11, 23, 47, 48747691, 111301831] 

""" 

PP = self.ambient_space() 

if PP.base_ring() in _NumberFields or is_NumberFieldOrder(PP.base_ring()): 

if PP.base_ring() != ZZ and PP.base_ring() != QQ: 

raise NotImplementedError("must be ZZ or QQ") 

else: 

raise TypeError("must be over a number field") 

if self.is_degenerate(): 

raise TypeError("surface is degenerate at all primes") 

RR = PP.coordinate_ring() 

 

#x-fibers 

PSX = PP[0] 

vars = list(PSX.gens()) 

K = PSX.base_ring() 

R = PolynomialRing(K, 3, vars) 

I = RR.ideal(self.Gpoly(1, 0), self.Gpoly(1, 1), self.Gpoly(1, 2), self.Hpoly(1, 0, 1), 

self.Hpoly(1, 0, 2), self.Hpoly(1, 1, 2)) 

phi = PP.coordinate_ring().hom(vars + [0, 0, 0], R) 

I = phi(I) 

bad_primes = [] 

 

#move the ideal to the ring of integers 

if R.base_ring().is_field(): 

S = PolynomialRing(R.base_ring().ring_of_integers(),R.gens(),R.ngens()) 

I = S.ideal(I.gens()) 

GB = I.groebner_basis() 

#get the primes dividing the coefficients of the monomials x_i^k_i 

for i in range(len(GB)): 

LT = GB[i].lt().degrees() 

power = 0 

for j in range(R.ngens()): 

if LT[j] != 0: 

power += 1 

if power == 1: 

bad_primes = bad_primes+GB[i].lt().coefficients()[0].support() 

 

#y-fibers 

PSY = PP[1] 

vars = list(PSY.gens()) 

K = PSY.base_ring() 

R = PolynomialRing(K, 3, vars) 

I = RR.ideal(self.Gpoly(0, 0), self.Gpoly(0, 1), self.Gpoly(0, 2), self.Hpoly(0, 0, 1), 

self.Hpoly(0, 0, 2), self.Hpoly(0, 1, 2)) 

phi = PP.coordinate_ring().hom([0, 0, 0] + vars, R) 

I = phi(I) 

#move the ideal to the ring of integers 

if R.base_ring().is_field(): 

S = PolynomialRing(R.base_ring().ring_of_integers(),R.gens(),R.ngens()) 

I = S.ideal(I.gens()) 

GB = I.groebner_basis() 

#get the primes dividing the coefficients of the monomials x_i^k_i 

for i in range(len(GB)): 

LT = GB[i].lt().degrees() 

power = 0 

for j in range(R.ngens()): 

if LT[j] != 0: 

power += 1 

if power == 1: 

bad_primes = bad_primes+GB[i].lt().coefficients()[0].support() 

bad_primes = sorted(set(bad_primes)) 

#check to return only the truly bad primes 

if check: 

for p in bad_primes: 

X = self.change_ring(GF(p)) 

if not X.is_degenerate(): 

bad_primes.remove(p) 

return(bad_primes) 

 

def is_smooth(self): 

r""" 

Function will return the status of the smoothness of the surface. 

 

ALGORITHM: 

 

Checks to confirm that all of the 2x2 minors of the Jacobian generated from 

the biquadratic and bilinear forms have no common vanishing points. 

 

OUTPUT: Boolean 

 

EXAMPLES:: 

 

sage: R.<x0,x1,x2,y0,y1,y2> = PolynomialRing(ZZ, 6) 

sage: Y = x0*y0 + x1*y1 - x2*y2 

sage: Z = x0^2*y0*y1 + x0^2*y2^2 - x0*x1*y1*y2 + x1^2*y2*y1 +\ 

x2^2*y2^2 + x2^2*y1^2 + x1^2*y2^2 

sage: X = WehlerK3Surface([Z, Y]) 

sage: X.is_smooth() 

False 

 

:: 

 

sage: PP.<x0,x1,x2,y0,y1,y2> = ProductProjectiveSpaces([2, 2], QQ) 

sage: Z = x0^2*y0^2 + 3*x0*x1*y0^2 + x1^2*y0^2 + 4*x0^2*y0*y1 + \ 

3*x0*x1*y0*y1 - 2*x2^2*y0*y1 - x0^2*y1^2 + 2*x1^2*y1^2 - x0*x2*y1^2 \ 

- 4*x1*x2*y1^2 + 5*x0*x2*y0*y2 - 4*x1*x2*y0*y2 + 7*x0^2*y1*y2 + 4*x1^2*y1*y2 \ 

+ x0*x1*y2^2 + 3*x2^2*y2^2 

sage: Y = x0*y0 + x1*y1 + x2*y2 

sage: X = WehlerK3Surface([Z, Y]) 

sage: X.is_smooth() 

True 

""" 

vars = list(self.ambient_space().gens()) 

M = jacobian([self.L, self.Q], vars) 

R = self.ambient_space().coordinate_ring() 

I = R.ideal(M.minors(2) + [self.L,self.Q]) 

T = PolynomialRing(self.ambient_space().base_ring().fraction_field(), 4, 'h') 

#check the 9 affine charts for a singular point 

for l in xmrange([3, 3]): 

vars = list(T.gens()) 

vars.insert(l[0], 1) 

vars.insert(3 + l[1], 1) 

phi = R.hom(vars, T) 

J = phi(I) 

if J.dimension() != -1: 

return False 

return True 

 

def sigmaX(self, P, **kwds): 

r""" 

Function returns the involution on the Wehler K3 surface induced by the double covers. 

 

In particular, it fixes the projection to the first coordinate and swaps the 

two points in the fiber, i.e. `(x, y) \to (x, y')`. 

Note that in the degenerate case, while we can split fiber into pairs of points, 

it is not always possibleto distinguish them, using this algorithm. 

 

ALGORITHM: 

 

Refer to Section 6: "An algorithm to compute `\sigma_x`, `\sigma_y`, `\phi`, 

and `\psi`" in [CS1996FH2015. 

For the degenerate case refer to [FH2015]_. 

 

INPUT: 

 

- ``P`` - a point in `\mathbb{P}^2 \times \mathbb{P}^2` 

 

kwds: 

 

- ``check`` - (default: ``True``) boolean checks to see if point is on the surface 

 

- ``normalize`` -- (default: ``True``) boolean normalizes the point 

 

OUTPUT: A point on the K3 surface 

 

EXAMPLES:: 

 

sage: PP.<x0,x1,x2,y0,y1,y2> = ProductProjectiveSpaces([2, 2], QQ) 

sage: Z = x0^2*y0^2 + 3*x0*x1*y0^2 + x1^2*y0^2 + 4*x0^2*y0*y1 +\ 

3*x0*x1*y0*y1 -2*x2^2*y0*y1 - x0^2*y1^2 + 2*x1^2*y1^2 - x0*x2*y1^2 -\ 

4*x1*x2*y1^2 + 5*x0*x2*y0*y2 -4*x1*x2*y0*y2 + 7*x0^2*y1*y2 +\ 

4*x1^2*y1*y2 + x0*x1*y2^2 + 3*x2^2*y2^2 

sage: Y = x0*y0 + x1*y1 + x2*y2 

sage: X = WehlerK3Surface([Z, Y]) 

sage: T = PP(0, 0, 1, 1, 0, 0) 

sage: X.sigmaX(T) 

(0 : 0 : 1 , 0 : 1 : 0) 

 

degenerate examples:: 

 

sage: PP.<x0,x1,x2,y0,y1,y2> = ProductProjectiveSpaces([2, 2], QQ) 

sage: l = y0*x0 + y1*x1 + (y0 - y1)*x2 

sage: q = (y1*y0)*x0^2 + ((y0^2)*x1 + (y0^2 + (y1^2 - y2^2))*x2)*x0\ 

+ (y2*y0 + y1^2)*x1^2 + (y0^2 + (-y1^2 + y2^2))*x2*x1 

sage: X = WehlerK3Surface([l, q]) 

sage: X.sigmaX(X([1, 0, 0, 0, 1, -2])) 

(1 : 0 : 0 , 0 : 1/2 : 1) 

sage: X.sigmaX(X([1, 0, 0, 0, 0, 1])) 

(1 : 0 : 0 , 0 : 0 : 1) 

sage: X.sigmaX(X([-1, 1, 1, -1, -1, 1])) 

(-1 : 1 : 1 , 2 : 2 : 1) 

sage: X.sigmaX(X([0, 0, 1, 1, 1, 0])) 

(0 : 0 : 1 , 1 : 1 : 0) 

sage: X.sigmaX(X([0, 0, 1, 1, 1, 1])) 

(0 : 0 : 1 , -1 : -1 : 1) 

 

Case where we cannot distinguish the two points:: 

 

sage: PP.<y0,y1,y2,x0,x1,x2>=ProductProjectiveSpaces([2, 2], GF(3)) 

sage: l = x0*y0 + x1*y1 + x2*y2 

sage: q=-3*x0^2*y0^2 + 4*x0*x1*y0^2 - 3*x0*x2*y0^2 - 5*x0^2*y0*y1 - \ 

190*x0*x1*y0*y1- 5*x1^2*y0*y1 + 5*x0*x2*y0*y1 + 14*x1*x2*y0*y1 + \ 

5*x2^2*y0*y1 - x0^2*y1^2 - 6*x0*x1*y1^2- 2*x1^2*y1^2 + 2*x0*x2*y1^2 - \ 

4*x2^2*y1^2 + 4*x0^2*y0*y2 - x1^2*y0*y2 + 3*x0*x2*y0*y2+ 6*x1*x2*y0*y2 - \ 

6*x0^2*y1*y2 - 4*x0*x1*y1*y2 - x1^2*y1*y2 + 51*x0*x2*y1*y2 - 7*x1*x2*y1*y2 - \ 

9*x2^2*y1*y2 - x0^2*y2^2 - 4*x0*x1*y2^2 + 4*x1^2*y2^2 - x0*x2*y2^2 + 13*x1*x2*y2^2 - x2^2*y2^2 

sage: X = WehlerK3Surface([l, q]) 

sage: P = X([1, 0, 0, 0, 1, 1]) 

sage: X.sigmaX(X.sigmaX(P)) 

Traceback (most recent call last): 

... 

ValueError: cannot distinguish points in the degenerate fiber 

""" 

check = kwds.get("check", True) 

normalize = kwds.get("normalize", True) 

 

if check: 

if self != P.codomain(): 

try: 

P = self(list(P)) 

except (TypeError, NotImplementedError, AttributeError): 

raise TypeError("%s fails to convert into the map's domain %s, but a `pushforward` method is not properly implemented"%(P, self)) 

pt = list(P[0]) + [0, 0, 0] 

if(P[1][0] != 0): 

[a,b,c] = [P[1][0]*self.Gpoly(1, 0)(*pt),\ 

-1*P[1][0]*self.Hpoly(1, 0, 1)(*pt) - P[1][1]*self.Gpoly(1, 0)(*pt),\ 

-P[1][0]*self.Hpoly(1, 0, 2)(*pt) - P[1][2]*self.Gpoly(1, 0)(*pt)] 

elif(P[1][1] != 0): 

[a,b,c] = [-1*P[1][1]*self.Hpoly(1, 0, 1)(*pt)-P[1][0]*self.Gpoly(1, 1)(*pt),\ 

P[1][1]*self.Gpoly(1, 1)(*pt),\ 

-P[1][1]*self.Hpoly(1, 1, 2)(*pt)-P[1][2]*self.Gpoly(1, 1)(*pt)] 

else: 

[a,b,c] = [-1*P[1][2]*self.Hpoly(1, 0, 2)(*pt) - P[1][0]*self.Gpoly(1, 2)(*pt),\ 

-P[1][2]*self.Hpoly(1, 1, 2)(*pt) - P[1][1]*self.Gpoly(1, 2)(*pt),\ 

P[1][2]*self.Gpoly(1, 2)(*pt)] 

Point = [P[0][0], P[0][1], P[0][2], a, b, c] 

 

if [a,b,c] != [0,0,0]: 

if normalize: 

Point = self.point(Point,False) 

Point.normalize_coordinates() 

return Point 

return self.point(Point,False) 

#Start of the degenerate case 

R = self.ambient_space().coordinate_ring() 

BR = self.ambient_space().base_ring() 

S = PolynomialRing(BR, 6, 's0, s1, w1, z0, z1, z2') 

s0,s1,w1,z0,z1,z2 = S.gens() 

#Define the blow-up map with (s0,s1) the new `\mathbb{P}^1` coordinates 

#so that the points on the fiber come in pairs on the lines defined by `(s0,s1)` 

#this allows us to extend the involution to degenerate fibers 

if P[0][0]!= 0: 

t1 = BR(P[0][1]/P[0][0]) 

t = w1 - t1 

phi = R.hom([s0, s0*w1, s1*t + s0*P[0][2]/P[0][0], z0, z1, z2], S) 

elif P[0][1]!= 0: 

t1 = BR(P[0][0]/P[0][1]) 

t = w1 - t1 

phi = R.hom([s0*w1, s0, s1*t + s0*P[0][2]/P[0][1], z0, z1, z2], S) 

else: 

t1 = BR(P[0][1]/P[0][2]) 

t = w1 - t1 

phi = R.hom([s1*(t) + s0*P[0][0]/P[0][2], s0*w1, s0, z0, z1, z2], S) 

 

#Blow-up the fiber 

T = [phi(self.L),phi(self.Q),\ 

phi(self.Gpoly(1, 0)),\ 

phi(self.Gpoly(1, 1)),\ 

phi(self.Gpoly(1, 2)),\ 

-phi(self.Hpoly(1, 0, 1)),\ 

-phi(self.Hpoly(1, 0, 2)),\ 

-phi(self.Hpoly(1, 1, 2))] 

maxexp = [] 

 

#Find highest exponent that we can divide out by to get a non zero answer 

for i in range(2,len(T)): 

e = 0 

while (T[i]/t**e).subs({w1:t1}) == 0: 

e += 1 

maxexp.append(e) 

 

e = min(maxexp) 

 

#Fix L and Q 

for i in range(0,2): 

while T[i].subs({w1:t1}) == 0: 

T[i] = T[i]/t 

T[i] = T[i].subs({w1:t1}) 

 

#Fix G and H polys 

for i in range(2,len(T)): 

T[i] = T[i]/t**e 

T[i] = T[i].subs({w1:t1}) 

 

#Defines the ideal whose solution gives `(s0, s1)` and the two points 

#on the fiber 

RR = PolynomialRing(BR, 5,'s0, s1, z0, z1, z2',order = 'lex') 

s0, s1, z0, z1, z2 = RR.gens() 

I = RR.ideal([RR(T[0]), \ 

RR(T[1]), \ 

RR(T[2]) - P[1][0]*z0, RR(T[3]) - P[1][1]*z1, RR(T[4])-P[1][2]*z2, \ 

RR(T[5]) - (P[1][0]*z1 + P[1][1]*z0), \ 

RR(T[6]) - (P[1][0]*z2 + P[1][2]*z0), \ 

RR(T[7]) - (P[1][1]*z2 + P[1][2]*z1)]) 

 

#Find the points 

SS = PolynomialRing(BR, 4,'s, z0, z1, z2', order = 'lex') 

s, z0, z1, z2 = SS.gens() 

phi = RR.hom([s, 1, z0, z1, z2], SS) 

J = phi(I) 

if J.dimension() > 0: 

raise ValueError("cannot distinguish points in the degenerate fiber") 

V = J.variety() 

#Our blow-up point has more than one line passing through it, thus we cannot find 

#the corresponding point on the surface 

if len(V) > 2: 

raise ValueError("cannot distinguish points in the degenerate fiber") 

#We always expect to have the trivial solution (0, 0, 0) 

if len(V) == 2: 

for D in V: 

if D[s] != 0: 

[a,b,c] = [D[z0], D[z1], D[z2]] 

else: 

newT = [phi(tee) for tee in T] 

for i in range(2): 

while newT[i] != 0 and s.divides(newT[i]): 

newT[i] = SS(newT[i]/s) 

maxexp = [] 

 

for i in range(2, len(T)): 

e = 0 

if newT[i] != 0: 

while (newT[i]/s**e).subs({s:0})==0: 

e += 1 

maxexp.append(e) 

e = min(maxexp) 

 

#Cancel the powers of s 

for i in range(2,len(T)): 

newT[i] = newT[i]/s**e 

#Create the new ideal 

II = SS.ideal([SS(newT[0]), \ 

SS(newT[1]), \ 

SS(newT[2]) - P[1][0]*z0, \ 

SS(newT[3]) - P[1][1]*z1, \ 

SS(newT[4]) - P[1][2]*z2, \ 

SS(newT[5]) - (P[1][0]*z1 + P[1][1]*z0), \ 

SS(newT[6]) - (P[1][0]*z2 + P[1][2]*z0), \ 

SS(newT[7]) - (P[1][1]*z2 + P[1][2]*z1)]) 

 

#Find the points 

SSS = PolynomialRing(BR, 3, 'z0, z1, z2', order = 'lex') 

z0,z1,z2 = SSS.gens() 

phi = SS.hom([0, z0, z1, z2], SSS) 

J2 = phi(II) 

if J2.dimension() > 0: 

raise ValueError("cannot distinguish points in the degenerate fiber") 

V = J2.variety() 

if len(V) > 1: 

raise ValueError("cannot distinguish points in the degenerate fiber") 

 

if len(V) == 1: 

[a, b, c] = [V[0][z0], V[0][z1], V[0][z2]] 

 

if len(V) == 0 or [a,b,c] == [0, 0, 0]: 

SS = PolynomialRing(BR, 3, 'z0, z1, z2', order = 'lex') 

z0,z1,z2 = SS.gens() 

phi = RR.hom([1, 0, z0, z1, z2], SS) 

J = phi(I) 

if J.dimension() > 0: 

raise ValueError( "cannot distinguish points in the degenerate fiber") 

V = phi(I).variety() 

if len(V) > 1: 

raise ValueError( "cannot distinguish points in the degenerate fiber") 

[a,b,c] = [V[0][z0], V[0][z1], V[0][z2]] 

 

Point = [P[0][0], P[0][1], P[0][2], a, b, c] 

if normalize: 

Point = self.point(Point, False) 

Point.normalize_coordinates() 

return Point 

return self.point(Point, False) 

 

def sigmaY(self,P, **kwds): 

r""" 

Function returns the involution on the Wehler K3 surfaces induced by the double covers. 

 

In particular,it fixes the projection to the second coordinate and swaps 

the two points in the fiber, i.e. `(x,y) \to (x',y)`. 

Note that in the degenerate case, while we can split the fiber into two points, 

it is not always possibleto distinguish them, using this algorithm. 

 

ALGORITHM: 

 

Refer to Section 6: "An algorithm to compute `\sigma_x`, `\sigma_y`, `\phi`, 

and `\psi`" in [CS1996]_. 

For the degenerate case refer to [FH2015]_. 

 

INPUT: 

 

- ``P`` - a point in `\mathbb{P}^2 \times \mathbb{P}^2` 

 

kwds: 

 

- ``check`` - (default: ``True``) boolean checks to see if point is on the surface 

 

- ``normalize`` -- (default: ``True``) boolean normalizes the point 

 

OUTPUT: A point on the K3 surface 

 

EXAMPLES:: 

 

sage: PP.<x0,x1,x2,y0,y1,y2> = ProductProjectiveSpaces([2, 2], QQ) 

sage: Z = x0^2*y0^2 + 3*x0*x1*y0^2 + x1^2*y0^2 + 4*x0^2*y0*y1 + \ 

3*x0*x1*y0*y1 -2*x2^2*y0*y1 - x0^2*y1^2 + 2*x1^2*y1^2 - x0*x2*y1^2 \ 

- 4*x1*x2*y1^2 + 5*x0*x2*y0*y2 - 4*x1*x2*y0*y2 + 7*x0^2*y1*y2 + 4*x1^2*y1*y2 \ 

+ x0*x1*y2^2 + 3*x2^2*y2^2 

sage: Y = x0*y0 + x1*y1 + x2*y2 

sage: X = WehlerK3Surface([Z, Y]) 

sage: T = PP(0, 0, 1, 1, 0, 0) 

sage: X.sigmaY(T) 

(0 : 0 : 1 , 1 : 0 : 0) 

 

degenerate examples:: 

 

sage: PP.<x0,x1,x2,y0,y1,y2> = ProductProjectiveSpaces([2, 2], QQ) 

sage: l = y0*x0 + y1*x1 + (y0 - y1)*x2 

sage: q = (y1*y0)*x0^2 + ((y0^2)*x1 + (y0^2 + (y1^2 - y2^2))*x2)*x0 +\ 

(y2*y0 + y1^2)*x1^2 + (y0^2 + (-y1^2 + y2^2))*x2*x1 

sage: X = WehlerK3Surface([l, q]) 

sage: X.sigmaY(X([1, -1, 0 ,-1, -1, 1])) 

(1/10 : -1/10 : 1 , -1 : -1 : 1) 

sage: X.sigmaY(X([0, 0, 1, -1, -1, 1])) 

(-4 : 4 : 1 , -1 : -1 : 1) 

sage: X.sigmaY(X([1, 2, 0, 0, 0, 1])) 

(-3 : -3 : 1 , 0 : 0 : 1) 

sage: X.sigmaY(X([1, 1, 1, 0, 0, 1])) 

(1 : 0 : 0 , 0 : 0 : 1) 

 

Case where we cannot distinguish the two points:: 

 

sage: PP.<x0,x1,x2,y0,y1,y2>=ProductProjectiveSpaces([2, 2], GF(3)) 

sage: l = x0*y0 + x1*y1 + x2*y2 

sage: q=-3*x0^2*y0^2 + 4*x0*x1*y0^2 - 3*x0*x2*y0^2 - 5*x0^2*y0*y1 - 190*x0*x1*y0*y1 \ 

- 5*x1^2*y0*y1 + 5*x0*x2*y0*y1 + 14*x1*x2*y0*y1 + 5*x2^2*y0*y1 - x0^2*y1^2 - 6*x0*x1*y1^2 \ 

- 2*x1^2*y1^2 + 2*x0*x2*y1^2 - 4*x2^2*y1^2 + 4*x0^2*y0*y2 - x1^2*y0*y2 + 3*x0*x2*y0*y2 \ 

+ 6*x1*x2*y0*y2 - 6*x0^2*y1*y2 - 4*x0*x1*y1*y2 - x1^2*y1*y2 + 51*x0*x2*y1*y2 - 7*x1*x2*y1*y2 \ 

- 9*x2^2*y1*y2 - x0^2*y2^2 - 4*x0*x1*y2^2 + 4*x1^2*y2^2 - x0*x2*y2^2 + 13*x1*x2*y2^2 - x2^2*y2^2 

sage: X = WehlerK3Surface([l ,q]) 

sage: P = X([0, 1, 1, 1, 0, 0]) 

sage: X.sigmaY(X.sigmaY(P)) 

Traceback (most recent call last): 

... 

ValueError: cannot distinguish points in the degenerate fiber 

""" 

check = kwds.get("check", True) 

normalize = kwds.get("normalize", True) 

 

if check: 

if self != P.codomain(): 

try: 

P = self(list(P)) 

except (TypeError, NotImplementedError, AttributeError): 

raise TypeError("%s fails to convert into the map's domain %s, but a `pushforward` method is not properly implemented"%(P, self)) 

pt = [0, 0, 0] + list(P[1]) 

if(P[0][0] != 0): 

[a, b, c] = [P[0][0]*self.Gpoly(0, 0)(*pt), \ 

-1*P[0][0]*self.Hpoly(0, 0, 1)(*pt) - P[0][1]*self.Gpoly(0, 0)(*pt), \ 

-P[0][0]*self.Hpoly(0, 0, 2)(*pt) - P[0][2]*self.Gpoly(0, 0)(*pt)] 

elif(P[0][1] != 0): 

[a, b, c] = [-1*P[0][1]*self.Hpoly(0, 0, 1)(*pt) - P[0][0]*self.Gpoly(0, 1)(*pt),\ 

P[0][1]*self.Gpoly(0, 1)(*pt), \ 

-P[0][1]*self.Hpoly(0, 1, 2)(*pt) - P[0][2]*self.Gpoly(0, 1)(*pt)] 

else: 

[a, b, c] = [-1*P[0][2]*self.Hpoly(0, 0, 2)(*pt) - P[0][0]*self.Gpoly(0, 2)(*pt), \ 

- P[0][2]*self.Hpoly(0, 1, 2)(*pt) - P[0][1]*self.Gpoly(0, 2)(*pt), \ 

P[0][2]*self.Gpoly(0, 2)(*pt)] 

Point = [a, b, c, P[1][0], P[1][1], P[1][2]] 

if [a, b, c] != [0, 0, 0]: 

if normalize: 

Point = self.point(Point, False) 

Point.normalize_coordinates() 

return Point 

return self.point(Point, False) 

 

#Start of the degenerate case 

R = self.ambient_space().coordinate_ring() 

BR = self.ambient_space().base_ring() 

S = PolynomialRing(BR, 6, 'z0, z1, z2, s0, s1, w1') 

z0, z1, z2, s0, s1, w1 = S.gens() 

#Define the blow-up map with (s0,s1) the new `\mathbb{P}^1` coordinates 

#so that the points on the fiber come in pairs on the lines defined by `(s0,s1)` 

#this allows us to extend the involution to degenerate fibers 

if P[1][0] != 0: 

t1 = BR(P[1][1]/P[1][0]) 

t = w1 - t1 

phi = R.hom([z0, z1, z2, s0, s0*w1, s1*t + s0*P[1][2]/P[1][0]], S) 

elif P[1][1]!= 0: 

t1 = BR(P[1][0]/P[1][1]) 

t = w1 - t1 

phi = R.hom([z0, z1, z2, s0*w1, s0, s1*t + s0*P[1][2]/P[1][1]], S) 

else: 

t1 = BR(P[1][1]/P[1][2]) 

t = w1 - t1 

phi = R.hom([z0, z1, z2, s1*(t) + s0*P[1][0]/P[1][2], s0*w1, s0], S) 

 

#Blow-up the fiber 

T = [phi(self.L),\ 

phi(self.Q),\ 

phi(self.Gpoly(0, 0)), \ 

phi(self.Gpoly(0, 1)), \ 

phi(self.Gpoly(0, 2)), \ 

-phi(self.Hpoly(0, 0, 1)), \ 

-phi(self.Hpoly(0, 0, 2)), \ 

-phi(self.Hpoly(0, 1, 2))] 

maxexp = [] 

 

#Find highest exponent that we can divide out by to get a non zero answer 

for i in range(2, len(T)): 

e = 0 

while (T[i]/t**e).subs({w1:t1}) == 0: 

e += 1 

maxexp.append(e) 

 

e = min(maxexp) 

 

for i in range(0, 2): 

while T[i].subs({w1:t1}) == 0: 

T[i] = T[i]/t 

T[i] = T[i].subs({w1:t1}) 

for i in range(2, len(T)): 

T[i] = T[i]/t**e 

T[i] = T[i].subs({w1:t1}) 

 

#Defines the ideal whose solution gives `(s0,s1)` and the two points 

#on the fiber 

RR = PolynomialRing(BR ,5, 's0, s1, z0, z1, z2', order = 'lex') 

s0,s1,z0,z1,z2 = RR.gens() 

I = RR.ideal([RR(T[0]), \ 

RR(T[1]), \ 

RR(T[2]) - P[0][0]*z0, \ 

RR(T[3]) - P[0][1]*z1, \ 

RR(T[4]) - P[0][2]*z2, \ 

RR(T[5]) - (P[0][0]*z1 + P[0][1]*z0), \ 

RR(T[6]) - (P[0][0]*z2 + P[0][2]*z0), \ 

RR(T[7]) - (P[0][1]*z2 + P[0][2]*z1)]) 

#Find the points 

SS = PolynomialRing(BR, 4, 's, z0, z1, z2', order = 'lex') 

s, z0, z1, z2 = SS.gens() 

phi = RR.hom([s, 1, z0, z1, z2], SS) 

J = phi(I) 

if J.dimension() > 0: 

raise ValueError("cannot distinguish points in the degenerate fiber") 

V = J.variety() 

 

#Our blow-up point has more than one line passing through it, thus we cannot find 

#the corresponding point on the surface 

if len(V) > 2: 

raise ValueError("cannot distinguish points in the degenerate fiber") 

#We always expect to have the trivial solution (0, 0, 0) 

if len(V) == 2: 

for D in V: 

if D[s] != 0: 

[a, b, c] = [D[z0], D[z1], D[z2]] 

else: 

newT = [phi(tee) for tee in T] 

for i in range(2): 

while newT[i] != 0 and s.divides(newT[i]): 

newT[i] = SS(newT[i]/s) 

maxexp = [] 

for i in range(2, len(T)): 

e = 0 

if newT[i] != 0: 

while (newT[i]/s**e).subs({s:0}) == 0: 

e += 1 

maxexp.append(e) 

e = min(maxexp) 

#Cancel out the powers of s 

for i in range(2,len(T)): 

newT[i] = newT[i]/s**e 

#Create the new ideal 

II = SS.ideal([SS(newT[0]), \ 

SS(newT[1]), \ 

SS(newT[2]) - P[0][0]*z0, \ 

SS(newT[3]) - P[0][1]*z1, \ 

SS(newT[4]) - P[0][2]*z2, \ 

SS(newT[5]) - (P[0][0]*z1 + P[0][1]*z0), \ 

SS(newT[6]) - (P[0][0]*z2 + P[0][2]*z0), \ 

SS(newT[7]) - (P[0][1]*z2 + P[0][2]*z1)]) 

#Find the points 

SSS = PolynomialRing(BR, 3, 'z0, z1, z2',order = 'lex') 

z0,z1,z2 = SSS.gens() 

phi = SS.hom([0, z0, z1 ,z2], SSS) 

J2 = phi(II) 

if J2.dimension() > 0: 

raise ValueError("cannot distinguish points in the degenerate fiber") 

V = J2.variety() 

 

if len(V) > 1: 

raise ValueError("cannot distinguish points in the degenerate fiber") 

if len(V) == 1: 

[a, b, c] = [V[0][z0], V[0][z1], V[0][z2]] 

if len(V) == 0 or [a,b,c] == [0, 0, 0]: 

SS = PolynomialRing(BR, 3, 'z0, z1, z2', order = 'lex') 

z0,z1,z2 = SS.gens() 

phi = RR.hom([1, 0, z0, z1, z2], SS) 

J = phi(I) 

if J.dimension() > 0: 

raise ValueError("cannot distinguish points in the degenerate fiber") 

V = phi(I).variety() 

if len(V) > 1: 

raise ValueError("cannot distinguish points in the degenerate fiber") 

[a,b,c] = [V[0][z0], V[0][z1], V[0][z2]] 

 

Point = [a, b, c, P[1][0], P[1][1], P[1][2]] 

if normalize: 

Point = self.point(Point, False) 

Point.normalize_coordinates() 

return Point 

return self.point(Point, False) 

 

def phi(self, a, **kwds): 

r""" 

Evaluates the function `\phi = \sigma_y \circ \sigma_x`. 

 

ALGORITHM: 

 

Refer to Section 6: "An algorithm to compute `\sigma_x`, `\sigma_y`, 

`\phi`, and `\psi`" in [CS1996]_. 

 

For the degenerate case refer to [FH2015]_. 

 

INPUT: 

 

- ``a`` - Point in `\mathbb{P}^2 \times \mathbb{P}^2` 

 

kwds: 

 

- ``check`` - (default: ``True``) boolean checks to see if point is on the surface 

 

- ``normalize`` -- (default: ``True``) boolean normalizes the point 

 

OUTPUT: A point on this surface 

 

EXAMPLES:: 

 

sage: PP.<x0,x1,x2,y0,y1,y2> = ProductProjectiveSpaces([2, 2], QQ) 

sage: Z = x0^2*y0^2 + 3*x0*x1*y0^2 + x1^2*y0^2 + 4*x0^2*y0*y1 + \ 

3*x0*x1*y0*y1 -2*x2^2*y0*y1 - x0^2*y1^2 + 2*x1^2*y1^2 - x0*x2*y1^2 \ 

- 4*x1*x2*y1^2 + 5*x0*x2*y0*y2 -4*x1*x2*y0*y2 + 7*x0^2*y1*y2 + 4*x1^2*y1*y2 \ 

+ x0*x1*y2^2 + 3*x2^2*y2^2 

sage: Y = x0*y0 + x1*y1 + x2*y2 

sage: X = WehlerK3Surface([Z, Y]) 

sage: T = PP([0, 0, 1, 1 ,0, 0]) 

sage: X.phi(T) 

(-1 : 0 : 1 , 0 : 1 : 0) 

""" 

A = self.sigmaX(a, **kwds) 

kwds.update({"check":False}) 

return self.sigmaY(A, **kwds) 

 

def psi(self,a, **kwds): 

r""" 

Evaluates the function `\psi = \sigma_x \circ \sigma_y`. 

 

ALGORITHM: 

 

Refer to Section 6: "An algorithm to compute `\sigma_x`, `\sigma_y`, 

`\phi`, and `\psi`" in [CS1996]_. 

 

For the degenerate case refer to [FH2015]_. 

 

INPUT: 

 

- ``a`` - Point in `\mathbb{P}^2 \times \mathbb{P}^2` 

 

kwds: 

 

- ``check`` - (default: ``True``) boolean checks to see if point is on the surface 

 

- ``normalize`` -- (default: ``True``) boolean normalizes the point 

 

OUTPUT: A point on this surface 

 

EXAMPLES:: 

 

sage: PP.<x0,x1,x2,y0,y1,y2> = ProductProjectiveSpaces([2, 2], QQ) 

sage: Z = x0^2*y0^2 + 3*x0*x1*y0^2 + x1^2*y0^2 + 4*x0^2*y0*y1 + \ 

3*x0*x1*y0*y1 -2*x2^2*y0*y1 - x0^2*y1^2 + 2*x1^2*y1^2 - x0*x2*y1^2 \ 

- 4*x1*x2*y1^2 + 5*x0*x2*y0*y2 - 4*x1*x2*y0*y2 + 7*x0^2*y1*y2 + 4*x1^2*y1*y2 \ 

+ x0*x1*y2^2 + 3*x2^2*y2^2 

sage: Y = x0*y0 + x1*y1 + x2*y2 

sage: X = WehlerK3Surface([Z, Y]) 

sage: T = PP([0, 0, 1, 1, 0, 0]) 

sage: X.psi(T) 

(0 : 0 : 1 , 0 : 1 : 0) 

""" 

A = self.sigmaY(a, **kwds) 

kwds.update({"check":False}) 

return self.sigmaX(A, **kwds) 

 

def lambda_plus(self, P, v, N, m, n, prec = 100): 

r""" 

Evaluates the local canonical height plus function of Call-Silverman at 

the place ``v`` for ``P`` with ``N`` terms of the series. 

 

Use ``v = 0`` for the archimedean place. Must be over `\ZZ` or `\QQ`. 

 

ALGORITHM: 

 

Sum over local heights using convergent series, for more details, 

see section 4 of [CS1996]_. 

 

INPUT: 

 

- ``P`` -- a surface point 

 

- ``N`` -- positive integer. number of terms of the series to use 

 

- ``v`` -- non-negative integer. a place, use v = 0 for the Archimedean place 

 

- ``m,n`` -- positive integers, We compute the local height for the divisor `E_{mn}^{+}`. 

These must be indices of non-zero coordinates of the point ``P``. 

 

- ``prec`` -- (default: 100) float point or p-adic precision 

 

OUTPUT: A real number 

 

EXAMPLES:: 

 

sage: PP.<x0,x1,x2,y0,y1,y2> = ProductProjectiveSpaces([2, 2], QQ) 

sage: Z = x0^2*y0^2 + 3*x0*x1*y0^2 + x1^2*y0^2 + 4*x0^2*y0*y1 + 3*x0*x1*y0*y1\ 

- 2*x2^2*y0*y1 - x0^2*y1^2 + 2*x1^2*y1^2 - x0*x2*y1^2 -4*x1*x2*y1^2 + 5*x0*x2*y0*y2\ 

- 4*x1*x2*y0*y2 + 7*x0^2*y1*y2 + 4*x1^2*y1*y2 + x0*x1*y2^2 + 3*x2^2*y2^2 

sage: Y = x0*y0 + x1*y1 + x2*y2 

sage: X = WehlerK3Surface([Z, Y]) 

sage: P = X([0, 0, 1, 1, 0, 0]) 

sage: X.lambda_plus(P, 0, 10, 2, 0) 

0.89230705169161608922595928129 

""" 

if not (v == 0 or v.is_prime()): 

raise ValueError("invalid valuation (= %s) entered"%v) 

R = RealField(prec) 

if v == 0: 

K = R 

else: 

K = Qp(v, prec) 

PK = P.change_ring(K) 

W = self.change_ring(K) 

Rx = W.ambient_space().coordinate_ring().hom(\ 

list(W.ambient_space()[0].coordinate_ring().gens())+[0, 0, 0], \ 

W.ambient_space()[0].coordinate_ring()) 

Ry = W.ambient_space().coordinate_ring().hom(\ 

[0, 0, 0] + list(W.ambient_space()[1].coordinate_ring().gens()), \ 

W.ambient_space()[1].coordinate_ring()) 

beta = R(2 + sqrt(3)) 

L = [x.abs() for x in list(PK[0])] 

i = L.index(max(L)) 

L = [y.abs() for y in list(PK[1])] 

j = L.index(max(L)) 

 

#Compute the local height wrt the divisor E_{mn}^{+} 

local_height = beta*R((PK[0][i]/PK[0][m]).abs()).log() - R((PK[1][j]/PK[1][n]).abs()).log() 

 

for e in range(N): 

#Take next iterate 

Q = W.phi(PK, check=False) 

L = [x.abs() for x in list(Q[0])] 

k = L.index(max(L)) 

L = [y.abs() for y in list(Q[1])] 

l = L.index(max(L)) 

newP = copy(PK) 

#normalize PK 

newP.scale_by([1/PK[0][i],1]) 

 

#Find B and A, helper values for the local height 

if PK[1][j].abs() <= PK[1][l].abs(): 

B = Rx(W.Gpoly(1, l))(tuple(newP[0]))*PK[1][j]/PK[1][l] 

else: 

B = -Rx(W.Gpoly(1, j))(tuple(newP[0]))*PK[1][l]/PK[1][j] 

B = B - Rx(W.Hpoly(1, j, l))(tuple(newP[0])) 

 

#Normalize Q 

newQ = copy(Q) 

newQ.scale_by([1,1/Q[1][l]]) 

 

if PK[0][i].abs() <= PK[0][k].abs(): 

A = Ry(W.Gpoly(0, k))(tuple(newQ[1]))*PK[0][i]/PK[0][k] 

else: 

A = -Ry(W.Gpoly(0, i))(tuple(newQ[1]))*PK[0][k]/PK[0][i] 

A = A - Ry(W.Hpoly(0, i, k))(tuple(newQ[1])) 

#Compute the new local height 

local_height += beta**(-2*R(e)-1)*R(A.abs()).log() + beta**(-2*R(e))*R(B.abs()).log() 

 

i = k 

j = l 

newQ.scale_by([1/Q[0][k], 1]) 

PK = newQ 

return local_height 

 

def lambda_minus(self, P, v, N, m, n, prec=100): 

r""" 

Evaluates the local canonical height minus function of Call-Silverman 

at the place ``v`` for ``P`` with ``N`` terms of the series. 

 

Use ``v = 0`` for the Archimedean place. Must be over `\ZZ` or `\QQ`. 

 

ALGORITHM: 

 

Sum over local heights using convergent series, for more details, 

see section 4 of [CS1996]_. 

 

INPUT: 

 

- ``P`` -- a projective point 

 

- ``N`` -- positive integer. number of terms of the series to use 

 

- ``v`` -- non-negative integer. a place, use v = 0 for the Archimedean place 

 

- ``m,n`` -- positive integers, We compute the local height for the divisor `E_{mn}^{+}`. 

These must be indices of non-zero coordinates of the point ``P``. 

 

- ``prec`` -- (default: 100) float point or p-adic precision 

 

OUTPUT: A real number 

 

EXAMPLES:: 

 

sage: PP.<x0,x1,x2,y0,y1,y2> = ProductProjectiveSpaces([2, 2], QQ) 

sage: Z = x0^2*y0^2 + 3*x0*x1*y0^2 + x1^2*y0^2 + 4*x0^2*y0*y1 + 3*x0*x1*y0*y1 \ 

- 2*x2^2*y0*y1 - x0^2*y1^2 + 2*x1^2*y1^2 - x0*x2*y1^2 -4*x1*x2*y1^2 + 5*x0*x2*y0*y2\ 

- 4*x1*x2*y0*y2 + 7*x0^2*y1*y2 + 4*x1^2*y1*y2 + x0*x1*y2^2 + 3*x2^2*y2^2 

sage: Y = x0*y0 + x1*y1 + x2*y2 

sage: X = WehlerK3Surface([Z, Y]) 

sage: P = X([0, 0, 1, 1, 0, 0]) 

sage: X.lambda_minus(P, 2, 20, 2, 0, 200) 

-0.18573351672047135037172805779671791488351056677474271893705 

""" 

R = RealField(prec) 

if v == 0: 

K = R 

else: 

K = Qp(v, prec) 

PK = P.change_ring(K) 

W = self.change_ring(K) 

Rx = W.ambient_space().coordinate_ring().hom(list(W.ambient_space()[0].coordinate_ring().gens())\ 

+[0, 0, 0],W.ambient_space()[0].coordinate_ring()) 

Ry = W.ambient_space().coordinate_ring().hom([0, 0, 0] + \ 

list(W.ambient_space()[1].coordinate_ring().gens()), \ 

W.ambient_space()[1].coordinate_ring()) 

beta = R(2 + sqrt(3)) 

L = [x.abs() for x in list(PK[0])] 

j = L.index(max(L)) 

L = [y.abs() for y in list(PK[1])] 

i = L.index(max(L)) 

 

##Compute the local height wrt the divisor E_{mn}^{-} 

local_height = beta*R((PK[1][i]/PK[1][n]).abs()).log() - R((PK[0][j]/PK[0][m]).abs()).log() 

for e in range(N): 

#Take the next iterate 

Q = W.psi(PK, check = False) 

L = [x.abs() for x in list(Q[0])] 

l = L.index(max(L)) 

L = [y.abs() for y in list(Q[1])] 

k = L.index(max(L)) 

#Normalize the point 

newP = copy(PK) 

newP.scale_by([1, 1/PK[1][i]]) 

#Find A and B, helper functions for computing local height 

if PK[0][j].abs() <= PK[0][l].abs(): 

B = Ry(W.Gpoly(0, l))(tuple(newP[1]))*PK[0][j]/PK[0][l] 

else: 

B = -Ry(W.Gpoly(0, j))(tuple(newP[1]))*PK[0][l]/PK[0][j] 

B = B - Ry(W.Hpoly(0, j, l))(tuple(newP[1])) 

 

#Normalize Q 

newQ = copy(Q) 

newQ.scale_by([1/Q[0][l], 1]) 

 

if PK[1][i].abs()<= PK[1][k].abs(): 

A = Rx(W.Gpoly(1, k))(tuple(newQ[0]))*PK[1][i]/PK[1][k] 

else: 

A = -Rx(W.Gpoly(1, i))(tuple(newQ[0]))*PK[1][k]/PK[1][i] 

A = A-Rx(W.Hpoly(1, i, k))(tuple(newQ[0])) 

 

#Compute the local height 

local_height += beta**(-2*R(e)-1)*R(A.abs()).log() + beta**(-2*R(e))*R(B.abs()).log() 

i = k 

j = l 

newQ.scale_by([1, 1/Q[1][k]]) 

PK = newQ 

return local_height 

 

def canonical_height_plus(self, P, N, badprimes=None, prec=100): 

r""" 

Evaluates the canonical height plus function of Call-Silverman 

for ``P`` with ``N`` terms of the series of the local heights. 

 

Must be over `\ZZ` or `\QQ`. 

 

ALGORITHM: 

 

Sum over the lambda plus heights (local heights) in a convergent series, 

for more detail see section 7 of [CS1996]_. 

 

INPUT: 

 

- ``P`` -- a surface point 

 

- ``N`` -- positive integer. Number of terms of the series to use 

 

- ``badprimes`` -- (optional) list of integer primes (where the surface is degenerate) 

 

- ``prec`` -- (default: 100) float point or p-adic precision 

 

OUTPUT: A real number 

 

EXAMPLES:: 

 

sage: set_verbose(None) 

sage: R.<x0,x1,x2,y0,y1,y2> = PolynomialRing(QQ, 6) 

sage: L = (-y0 - y1)*x0 + (-y0*x1 - y2*x2) 

sage: Q = (-y2*y0 - y1^2)*x0^2 + ((-y0^2 - y2*y0 + (-y2*y1 - y2^2))*x1 + \ 

(-y0^2 - y2*y1)*x2)*x0 + ((-y0^2 - y2*y0 - y2^2)*x1^2 + (-y2*y0 - y1^2)*x2*x1 \ 

+ (-y0^2 + (-y1 - y2)*y0)*x2^2) 

sage: X = WehlerK3Surface([L, Q]) 

sage: P = X([1, 0, -1, 1, -1, 0]) #order 16 

sage: X.canonical_height_plus(P, 5) # long time 

0.00000000000000000000000000000 

 

Call-Silverman Example:: 

 

sage: set_verbose(None) 

sage: PP.<x0,x1,x2,y0,y1,y2> = ProductProjectiveSpaces([2, 2], QQ) 

sage: Z = x0^2*y0^2 + 3*x0*x1*y0^2 + x1^2*y0^2 + 4*x0^2*y0*y1 + \ 

3*x0*x1*y0*y1 - 2*x2^2*y0*y1 - x0^2*y1^2 + 2*x1^2*y1^2 - x0*x2*y1^2 \ 

- 4*x1*x2*y1^2 + 5*x0*x2*y0*y2 -4*x1*x2*y0*y2 + 7*x0^2*y1*y2 + 4*x1^2*y1*y2 \ 

+ x0*x1*y2^2 + 3*x2^2*y2^2 

sage: Y = x0*y0 + x1*y1 + x2*y2 

sage: X = WehlerK3Surface([Z, Y]) 

sage: P = X([0, 1, 0, 0, 0, 1]) 

sage: X.canonical_height_plus(P, 4) # long time 

0.14752753298983071394400412161 

""" 

if badprimes is None: 

badprimes = self.degenerate_primes() 

m = 2 

while P[0][m] == 0: 

m = m - 1 

n = 2 

while P[1][n] == 0: 

n = n-1 

h = self.lambda_plus(P, 0, N, m, n, prec) 

for p in badprimes: 

h += self.lambda_plus(P, p, N, m, n, prec) 

return(h) 

 

def canonical_height_minus(self, P, N, badprimes=None, prec=100): 

r""" 

Evaluates the canonical height minus function of Call-Silverman 

for ``P`` with ``N`` terms of the series of the local heights. 

 

Must be over `\ZZ` or `\QQ`. 

 

ALGORITHM: 

 

Sum over the lambda minus heights (local heights) in a convergent series, 

for more detail see section 7 of [CS1996]_. 

 

INPUT: 

 

- ``P`` -- a surface point 

 

- ``N`` -- positive integer (number of terms of the series to use) 

 

- ``badprimes`` -- (optional) list of integer primes (where the surface is degenerate) 

 

- ``prec`` -- (default: 100) float point or p-adic precision 

 

OUTPUT: A real number 

 

EXAMPLES:: 

 

sage: set_verbose(None) 

sage: R.<x0,x1,x2,y0,y1,y2> = PolynomialRing(QQ, 6) 

sage: L = (-y0 - y1)*x0 + (-y0*x1 - y2*x2) 

sage: Q = (-y2*y0 - y1^2)*x0^2 + ((-y0^2 - y2*y0 + (-y2*y1 - y2^2))*x1\ 

+ (-y0^2 - y2*y1)*x2)*x0 + ((-y0^2 - y2*y0 - y2^2)*x1^2 + (-y2*y0 - y1^2)*x2*x1\ 

+ (-y0^2 + (-y1 - y2)*y0)*x2^2) 

sage: X = WehlerK3Surface([L, Q]) 

sage: P = X([1, 0, -1, 1, -1, 0]) #order 16 

sage: X.canonical_height_minus(P, 5) # long time 

0.00000000000000000000000000000 

 

Call-Silverman example:: 

 

sage: set_verbose(None) 

sage: PP.<x0,x1,x2,y0,y1,y2> = ProductProjectiveSpaces([2, 2], QQ) 

sage: Z = x0^2*y0^2 + 3*x0*x1*y0^2 + x1^2*y0^2 + 4*x0^2*y0*y1 +\ 

3*x0*x1*y0*y1 - 2*x2^2*y0*y1 - x0^2*y1^2 + 2*x1^2*y1^2 - x0*x2*y1^2 - \ 

4*x1*x2*y1^2 + 5*x0*x2*y0*y2 - 4*x1*x2*y0*y2 + 7*x0^2*y1*y2 + 4*x1^2*y1*y2 + \ 

x0*x1*y2^2 + 3*x2^2*y2^2 

sage: Y = x0*y0 + x1*y1 + x2*y2 

sage: X = WehlerK3Surface([Z, Y]) 

sage: P = X([0, 1, 0, 0, 0, 1]) 

sage: X.canonical_height_minus(P, 4) # long time 

0.55073705369676788175590206734 

""" 

if badprimes is None: 

badprimes = self.degenerate_primes() 

m = 2 

while P[0][m] == 0: 

m = m - 1 

n = 2 

while P[1][n] == 0: 

n = n-1 

h = self.lambda_minus(P, 0, N, m, n, prec) 

for p in badprimes: 

h += self.lambda_minus(P, p, N, m, n, prec) 

return(h) 

 

def canonical_height(self, P, N, badprimes=None, prec=100): 

r""" 

Evaluates the canonical height for ``P`` with ``N`` terms of the series of the local 

heights. 

 

ALGORITHM: 

 

The sum of the canonical height minus and canonical height plus, 

for more info see section 4 of [CS1996]_. 

 

INPUT: 

 

- ``P`` -- a surface point 

 

- ``N`` -- positive integer (number of terms of the series to use) 

 

- ``badprimes`` -- (optional) list of integer primes (where the surface is degenerate) 

 

- ``prec`` -- (default: 100) float point or p-adic precision 

 

OUTPUT: A real number 

 

EXAMPLES:: 

 

sage: set_verbose(None) 

sage: R.<x0,x1,x2,y0,y1,y2> = PolynomialRing(QQ, 6) 

sage: L = (-y0 - y1)*x0 + (-y0*x1 - y2*x2) 

sage: Q = (-y2*y0 - y1^2)*x0^2 + ((-y0^2 - y2*y0 + (-y2*y1 - y2^2))*x1 + \ 

(-y0^2 - y2*y1)*x2)*x0 + ((-y0^2 - y2*y0 - y2^2)*x1^2 + (-y2*y0 - y1^2)*x2*x1 \ 

+ (-y0^2 + (-y1 - y2)*y0)*x2^2) 

sage: X = WehlerK3Surface([L, Q]) 

sage: P = X([1, 0, -1, 1,- 1, 0]) #order 16 

sage: X.canonical_height(P, 5) # long time 

0.00000000000000000000000000000 

 

Call-Silverman example:: 

 

sage: set_verbose(None) 

sage: PP.<x0,x1,x2,y0,y1,y2> = ProductProjectiveSpaces([2, 2], QQ) 

sage: Z = x0^2*y0^2 + 3*x0*x1*y0^2 + x1^2*y0^2 + 4*x0^2*y0*y1 + 3*x0*x1*y0*y1 - \ 

2*x2^2*y0*y1 - x0^2*y1^2 + 2*x1^2*y1^2 - x0*x2*y1^2 - 4*x1*x2*y1^2 + 5*x0*x2*y0*y2 \ 

-4*x1*x2*y0*y2 + 7*x0^2*y1*y2 + 4*x1^2*y1*y2 + x0*x1*y2^2 + 3*x2^2*y2^2 

sage: Y = x0*y0 + x1*y1 + x2*y2 

sage: X = WehlerK3Surface([Z, Y]) 

sage: P = X(0, 1, 0, 0, 0, 1) 

sage: X.canonical_height(P, 4) 

0.69826458668659859569990618895 

""" 

if badprimes is None: 

badprimes = self.degenerate_primes() 

return(self.canonical_height_plus(P, N,badprimes,prec) + 

self.canonical_height_minus(P, N,badprimes,prec)) 

 

def fiber(self, p, component): 

r""" 

Returns the fibers [y (component = 1) or x (Component = 0)] of a point on a 

K3 Surface, will work for nondegenerate fibers only. 

 

For algorithm, see [Hutz2007]_. 

 

INPUT: 

 

-``p`` - a point in `\mathbb{P}^2` 

 

OUTPUT: The corresponding fiber (as a list) 

 

EXAMPLES:: 

 

sage: R.<x0,x1,x2,y0,y1,y2> = PolynomialRing(ZZ, 6) 

sage: Y = x0*y0 + x1*y1 - x2*y2 

sage: Z = y0^2*x0*x1 + y0^2*x2^2 - y0*y1*x1*x2 + y1^2*x2*x1 + y2^2*x2^2 +\ 

y2^2*x1^2 + y1^2*x2^2 

sage: X = WehlerK3Surface([Z, Y]) 

sage: Proj = ProjectiveSpace(QQ, 2) 

sage: P = Proj([1, 0, 0]) 

sage: X.fiber(P, 1) 

Traceback (most recent call last): 

... 

TypeError: fiber is degenerate 

 

:: 

 

sage: P.<x0,x1,x2,y0,y1,y2> = ProductProjectiveSpaces([2, 2], QQ) 

sage: Z = x0^2*y0^2 + 3*x0*x1*y0^2 + x1^2*y0^2 + 4*x0^2*y0*y1 + 3*x0*x1*y0*y1 - \ 

2*x2^2*y0*y1 - x0^2*y1^2 + 2*x1^2*y1^2 - x0*x2*y1^2 -4*x1*x2*y1^2 + 5*x0*x2*y0*y2 - \ 

4*x1*x2*y0*y2 + 7*x0^2*y1*y2 + 4*x1^2*y1*y2 + x0*x1*y2^2 + 3*x2^2*y2^2 

sage: Y = x0*y0 + x1*y1 + x2*y2 

sage: X = WehlerK3Surface([Z, Y]) 

sage: Proj = P[0] 

sage: T = Proj([0, 0, 1]) 

sage: X.fiber(T, 1) 

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

 

:: 

 

sage: PP.<x0,x1,x2,y0,y1,y2> = ProductProjectiveSpaces([2, 2], GF(7)) 

sage: L = x0*y0 + x1*y1 - 1*x2*y2 

sage: Q=(2*x0^2 + x2*x0 + (2*x1^2 + x2^2))*y0^2 + ((x0^2 + x1*x0 +(x1^2 + 2*x2*x1 + x2^2))*y1 + \ 

(2*x1^2 + x2*x1 + x2^2)*y2)*y0 + ((2*x0^2+ (x1 + 2*x2)*x0 + (2*x1^2 + x2*x1))*y1^2 + ((2*x1 + 2*x2)*x0 + \ 

(x1^2 +x2*x1 + 2*x2^2))*y2*y1 + (2*x0^2 + x1*x0 + (2*x1^2 + x2^2))*y2^2) 

sage: W = WehlerK3Surface([L, Q]) 

sage: W.fiber([4, 0, 1], 0) 

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

""" 

R = self.base_ring() 

Zero = R(0) 

One = R(1) 

P = [] 

for i in list(p): 

j = R(i) 

P.append(j) 

if component == 1: 

P0 = P + [Zero, Zero, Zero] 

else: 

P0 = [Zero, Zero, Zero] + P 

Points = [] 

 

if (self.Gpoly(component,0)(P0)!= 0): 

#We are using the quadratic formula, we need this check to ensure that the points 

#will be rational 

T0 = (self.Hpoly(component, 0, 1)(P0)**2 -4*self.Gpoly(component, 0)(P0)*self.Gpoly(component, 1)(P0)) 

T1 = (self.Hpoly(component, 0, 2)(P0)**2 -4*self.Gpoly(component, 0)(P0)*self.Gpoly(component, 2)(P0)) 

if (T0.is_square() and T1.is_square()): 

T0 = T0.sqrt() 

T1 = T1.sqrt() 

B1 = (-self.Hpoly(component, 0, 1)(P0)+T0)/(2*self.Gpoly(component, 0)(P0)) 

B2 = (-self.Hpoly(component, 0, 1)(P0)-T0)/(2*self.Gpoly(component, 0)(P0)) 

C1 = (-self.Hpoly(component, 0, 2)(P0)+T1)/(2*self.Gpoly(component, 0)(P0)) 

C2 = (-self.Hpoly(component, 0, 2)(P0)-T1)/(2*self.Gpoly(component, 0)(P0)) 

if component == 1: 

Points.append(P+[One, B1, C1]) 

Points.append(P+[One, B2, C1]) 

Points.append(P+[One, B1, C2]) 

Points.append(P+[One, B2, C2]) 

else: 

Points.append([One, B1, C1]+P) 

Points.append([One, B2, C1]+P) 

Points.append([One, B1, C2]+P) 

Points.append([One, B2, C2]+P) 

else: 

return [] 

elif (self.Gpoly(component, 1)(P0) != 0): 

T0 = (self.Hpoly(component, 0, 1)(P0)**2 - 4*self.Gpoly(component, 0)(P0)*self.Gpoly(component, 1)(P0)) 

T1 = (self.Hpoly(component, 1, 2)(P0)**2 - 4*self.Gpoly(component, 1)(P0)*self.Gpoly(component, 2)(P0)) 

if (T0.is_square() and T1.is_square()): 

T0 = T0.sqrt() 

T1 = T1.sqrt() 

A1 = (-self.Hpoly(component, 0, 1)(P0)+T0)/(2*self.Gpoly(component, 1)(P0)) 

A2 = (-self.Hpoly(component, 0, 1)(P0)-T0)/(2*self.Gpoly(component, 1)(P0)) 

C1 = (-self.Hpoly(component, 1, 2)(P0)+T1)/(2*self.Gpoly(component, 1)(P0)) 

C2 = (-self.Hpoly(component, 1, 2)(P0)-T1)/(2*self.Gpoly(component, 1)(P0)) 

if component == 1: 

Points.append(P + [A1, One, C1]) 

Points.append(P + [A1, One, C2]) 

Points.append(P + [A2, One, C1]) 

Points.append(P + [A2, One, C2]) 

else: 

Points.append([A1, One, C1] + P) 

Points.append([A1, One, C2] + P) 

Points.append([A2, One, C1] + P) 

Points.append([A2, One, C2] + P) 

else: 

return [] 

elif(self.Gpoly(component, 2)(P0) != 0): 

T0 = (self.Hpoly(component, 0, 2)(P0)**2 - 4*self.Gpoly(component, 0)(P0)*self.Gpoly(component, 2)(P0)) 

T1 = (self.Hpoly(component, 1, 2)(P0)**2 - 4*self.Gpoly(component, 1)(P0)*self.Gpoly(component, 2)(P0)) 

if (T0.is_square() and T1.is_square()): 

T0 = T0.sqrt() 

T1 = T1.sqrt() 

A1 = (-self.Hpoly(component, 0, 2)(P0)+T0)/(2*self.Gpoly(component, 2)(P0)) 

A2 = (-self.Hpoly(component, 0, 2)(P0)-T0)/(2*self.Gpoly(component, 2)(P0)) 

B1 = (-self.Hpoly(component, 1, 2)(P0)+T1)/(2*self.Gpoly(component, 2)(P0)) 

B2 = (-self.Hpoly(component, 1, 2)(P0)-T1)/(2*self.Gpoly(component, 2)(P0)) 

if component == 1: 

Points.append(P + [A1, B1, One]) 

Points.append(P + [A1, B2, One]) 

Points.append(P + [A2, B1, One]) 

Points.append(P + [A2, B2, One]) 

else: 

Points.append([A1, B1, One] + P) 

Points.append([A1, B2, One] + P) 

Points.append([A2, B1, One] + P) 

Points.append([A2, B2, One] + P) 

else: 

return [] 

elif(self.Hpoly(component, 0, 1)(P0) != 0): 

if component == 1: 

Points.append(P+[Zero, One, Zero]) 

Points.append(P+[-self.Hpoly(component, 0, 1)(P0),Zero,-self.Hpoly(component, 1, 2)(P0)]) 

Points.append(P+[One,Zero,Zero]) 

Points.append(P+[Zero,-self.Hpoly(component, 0, 1)(P0),-self.Hpoly(component, 0, 2)(P0)]) 

else: 

Points.append([Zero,One,Zero]+P) 

Points.append([-self.Hpoly(component, 0, 1)(P0),Zero,-self.Hpoly(component, 1, 2)(P0)] + P) 

Points.append([One,Zero,Zero]+P) 

Points.append([Zero,-self.Hpoly(component, 0, 1)(P0),-self.Hpoly(component, 0, 2)(P0)] + P) 

elif(self.Hpoly(component, 0, 2)(P0) != 0): 

if component == 1: 

Points.append(P+[Zero, Zero, One]) 

Points.append(P+[-self.Hpoly(component, 0, 2)(P0),-self.Hpoly(component, 1, 2)(P0), Zero]) 

else: 

Points.append([Zero, Zero, One]+P) 

Points.append([-self.Hpoly(component, 0, 2)(P0),-self.Hpoly(component, 1, 2)(P0), Zero]+ P) 

elif(self.Hpoly(component, 1, 2)(P0) != 0): 

if component == 1: 

Points.append(P + [Zero, Zero, One]) 

Points.append(P + [Zero, One, Zero]) 

else: 

Points.append([Zero, Zero, One] + P) 

Points.append([Zero, One, Zero] + P) 

else: 

raise TypeError("fiber is degenerate") 

 

fiber = [] 

for x in Points: 

if (self.L(x) == 0) and (self.Q(x) == 0): 

Y = self.point(x, False) 

if not Y in fiber: 

fiber.append(Y) 

return(fiber) 

 

def nth_iterate_phi(self, P, n, **kwds): 

r""" 

Computes the nth iterate for the phi function. 

 

INPUT: 

 

- ``P`` -- - a point in `\mathbb{P}^2 \times \mathbb{P}^2` 

 

- ``n`` -- an integer 

 

kwds: 

 

- ``check`` - (default: ``True``) boolean checks to see if point is on the surface 

 

- ``normalize`` -- (default: ``False``) boolean normalizes the point 

 

OUTPUT: The nth iterate of the point given the phi function (if ``n`` is positive), or the 

psi function (if ``n`` is negative) 

 

EXAMPLES:: 

 

sage: PP.<x0,x1,x2,y0,y1,y2> = ProductProjectiveSpaces([2, 2], QQ) 

sage: L = x0*y0 + x1*y1 + x2*y2 

sage: Q = x1^2*y0^2 + 2*x2^2*y0*y1 + x0^2*y1^2 - x0*x1*y2^2 

sage: W = WehlerK3Surface([L ,Q]) 

sage: T = W([-1, -1, 1, 1, 0, 1]) 

sage: W.nth_iterate_phi(T, 7) 

(-1 : 0 : 1 , 1 : -2 : 1) 

 

:: 

 

sage: PP.<x0,x1,x2,y0,y1,y2> = ProductProjectiveSpaces([2, 2], QQ) 

sage: L = x0*y0 + x1*y1 + x2*y2 

sage: Q = x1^2*y0^2 + 2*x2^2*y0*y1 + x0^2*y1^2 - x0*x1*y2^2 

sage: W = WehlerK3Surface([L, Q]) 

sage: T = W([-1, -1, 1, 1, 0, 1]) 

sage: W.nth_iterate_phi(T, -7) 

(1 : 0 : 1 , -1 : 2 : 1) 

 

:: 

 

sage: R.<x0,x1,x2,y0,y1,y2>=PolynomialRing(QQ, 6) 

sage: L = (-y0 - y1)*x0 + (-y0*x1 - y2*x2) 

sage: Q = (-y2*y0 - y1^2)*x0^2 + ((-y0^2 - y2*y0 + (-y2*y1 - y2^2))*x1 + (-y0^2 - y2*y1)*x2)*x0 \ 

+ ((-y0^2 - y2*y0 - y2^2)*x1^2 + (-y2*y0 - y1^2)*x2*x1 + (-y0^2 + (-y1 - y2)*y0)*x2^2) 

sage: X = WehlerK3Surface([L, Q]) 

sage: P = X([1, 0, -1, 1, -1, 0]) 

sage: X.nth_iterate_phi(P, 8) == X.nth_iterate_psi(P, 8) 

True 

""" 

try: 

n = ZZ(n) 

except TypeError: 

raise TypeError("iterate number must be an integer") 

#Since phi and psi are inverses and automorphisms 

if n < 0: 

return(self.nth_iterate_psi(P, abs(n), **kwds)) 

if n == 0: 

return(self) 

else: 

Q = self.phi(P, **kwds) 

for i in range(2, n+1): 

Q = self.phi(Q, **kwds) 

return(Q) 

 

def nth_iterate_psi(self, P, n, **kwds): 

r""" 

Computes the nth iterate for the psi function. 

 

INPUT: 

 

- ``P`` -- - a point in `\mathbb{P}^2 \times \mathbb{P}^2` 

 

- ``n`` -- an integer 

 

kwds: 

 

- ``check`` -- (default: ``True``) boolean, checks to see if point is on the surface 

 

- ``normalize`` -- (default: ``False``) boolean, normalizes the point 

 

OUTPUT: The nth iterate of the point given the psi function (if ``n`` is positive), 

or the phi function (if ``n`` is negative) 

 

EXAMPLES:: 

 

sage: PP.<x0,x1,x2,y0,y1,y2> = ProductProjectiveSpaces([2, 2], QQ) 

sage: L = x0*y0 + x1*y1 + x2*y2 

sage: Q = x1^2*y0^2 + 2*x2^2*y0*y1 + x0^2*y1^2 - x0*x1*y2^2 

sage: W = WehlerK3Surface([L, Q]) 

sage: T = W([-1, -1, 1, 1, 0, 1]) 

sage: W.nth_iterate_psi(T, -7) 

(-1 : 0 : 1 , 1 : -2 : 1) 

 

:: 

 

sage: PP.<x0,x1,x2,y0,y1,y2> = ProductProjectiveSpaces([2, 2], QQ) 

sage: L = x0*y0 + x1*y1 + x2*y2 

sage: Q = x1^2*y0^2 + 2*x2^2*y0*y1 + x0^2*y1^2 - x0*x1*y2^2 

sage: W = WehlerK3Surface([L, Q]) 

sage: T = W([-1, -1, 1, 1, 0, 1]) 

sage: W.nth_iterate_psi(T, 7) 

(1 : 0 : 1 , -1 : 2 : 1) 

""" 

try: 

n = ZZ(n) 

except TypeError: 

raise TypeError("iterate number must be an integer") 

#Since phi and psi and inverses 

if n < 0: 

return(self.nth_iterate_phi(P, abs(n), **kwds)) 

if n == 0: 

return(self) 

else: 

Q = self.psi(P, **kwds) 

for i in range(2, n+1): 

Q = self.psi(Q, **kwds) 

return(Q) 

 

def orbit_phi(self,P,N, **kwds): 

r""" 

Returns the orbit of the `\phi` function defined by `\phi = \sigma_y \circ \sigma_x` 

Function is defined in [CS1996]_. 

 

INPUT: 

 

- ``P`` - Point on the K3 surface 

 

- ``N`` - a non-negative integer or list or tuple of two non-negative integers 

 

kwds: 

 

- ``check`` -- (default: ``True``) boolean, checks to see if point is on the surface 

 

- ``normalize`` -- (default: ``False``) boolean, normalizes the point 

 

OUTPUT: List of points in the orbit 

 

EXAMPLES:: 

 

sage: PP.<x0,x1,x2,y0,y1,y2> = ProductProjectiveSpaces([2, 2], QQ) 

sage: Z = x0^2*y0^2 + 3*x0*x1*y0^2 + x1^2*y0^2 + 4*x0^2*y0*y1 + \ 

3*x0*x1*y0*y1 -2*x2^2*y0*y1 - x0^2*y1^2 + 2*x1^2*y1^2 - x0*x2*y1^2 - \ 

4*x1*x2*y1^2 + 5*x0*x2*y0*y2 - 4*x1*x2*y0*y2 + 7*x0^2*y1*y2 + 4*x1^2*y1*y2 + \ 

x0*x1*y2^2 + 3*x2^2*y2^2 

sage: Y = x0*y0 + x1*y1 + x2*y2 

sage: X = WehlerK3Surface([Z, Y]) 

sage: T = PP(0, 0, 1, 1, 0, 0) 

sage: X.orbit_phi(T,2, normalize = True) 

[(0 : 0 : 1 , 1 : 0 : 0), (-1 : 0 : 1 , 0 : 1 : 0), (-12816/6659 : 55413/6659 : 1 , 1 : 1/9 : 1)] 

sage: X.orbit_phi(T,[2,3], normalize = True) 

[(-12816/6659 : 55413/6659 : 1 , 1 : 1/9 : 1), 

(7481279673854775690938629732119966552954626693713001783595660989241/18550615454277582153932951051931712107449915856862264913424670784695 

: 3992260691327218828582255586014718568398539828275296031491644987908/18550615454277582153932951051931712107449915856862264913424670784695 : 

1 , -117756062505511/54767410965117 : -23134047983794359/37466994368025041 : 1)] 

""" 

 

if not isinstance(N, (list, tuple)): 

N = [0, N] 

try: 

N[0] = ZZ(N[0]) 

N[1] = ZZ(N[1]) 

except TypeError: 

raise TypeError("orbit bounds must be integers") 

if N[0] < 0 or N[1] < 0: 

raise TypeError("orbit bounds must be non-negative") 

if N[0] > N[1]: 

return([]) 

Q = self(copy(P)) 

for i in range(1, N[0] + 1): 

Q = self.phi(Q, **kwds) 

Orb = [Q] 

for i in range(N[0] + 1, N[1] + 1): 

Q = self.phi(Q, **kwds) 

Orb.append(Q) 

return Orb 

 

def orbit_psi(self, P, N, **kwds): 

r""" 

Returns the orbit of the `\psi` function defined by `\psi = \sigma_x \circ \sigma_y`. 

 

Function is defined in [CS1996]_. 

 

INPUT: 

 

- ``P`` - a point on the K3 surface 

 

- ``N`` - a non-negative integer or list or tuple of two non-negative integers 

 

kwds: 

 

- ``check`` - (default: ``True``) boolean, checks to see if point is on the surface 

 

- ``normalize`` -- (default: ``False``) boolean, normalizes the point 

 

OUTPUT: a list of points in the orbit 

 

EXAMPLES:: 

 

sage: PP.<x0,x1,x2,y0,y1,y2> = ProductProjectiveSpaces([2, 2], QQ) 

sage: Z = x0^2*y0^2 + 3*x0*x1*y0^2 + x1^2*y0^2 + 4*x0^2*y0*y1 + \ 

3*x0*x1*y0*y1 -2*x2^2*y0*y1 - x0^2*y1^2 + 2*x1^2*y1^2 - x0*x2*y1^2 - \ 

4*x1*x2*y1^2 + 5*x0*x2*y0*y2 -4*x1*x2*y0*y2 + 7*x0^2*y1*y2 + 4*x1^2*y1*y2 + \ 

x0*x1*y2^2 + 3*x2^2*y2^2 

sage: Y = x0*y0 + x1*y1 + x2*y2 

sage: X = WehlerK3Surface([Z, Y]) 

sage: T = X(0, 0, 1, 1, 0, 0) 

sage: X.orbit_psi(T, 2, normalize = True) 

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

sage: X.orbit_psi(T,[2,3], normalize = True) 

[(-1 : 0 : 1 , 1 : 1/9 : 1), 

(-12816/6659 : 55413/6659 : 1 , -117756062505511/54767410965117 : -23134047983794359/37466994368025041 : 1)] 

""" 

if not isinstance(N, (list, tuple)): 

N = [0, N] 

try: 

N[0] = ZZ(N[0]) 

N[1] = ZZ(N[1]) 

except TypeError: 

raise TypeError("orbit bounds must be integers") 

if N[0] < 0 or N[1] < 0: 

raise TypeError("orbit bounds must be non-negative") 

if N[0] > N[1]: 

return([]) 

Q = self(copy(P)) 

for i in range(1, N[0] + 1): 

Q = self.psi(Q, **kwds) 

Orb = [Q] 

for i in range(N[0] + 1, N[1] + 1): 

Q = self.psi(Q, **kwds) 

Orb.append(Q) 

return Orb 

 

def is_isomorphic(self, right): 

r""" 

Checks to see if two K3 surfaces have the same defining ideal. 

 

INPUT: 

 

- ``right`` - the K3 surface to compare to the original 

 

OUTPUT: Boolean 

 

EXAMPLES:: 

 

sage: PP.<x0,x1,x2,y0,y1,y2> = ProductProjectiveSpaces([2, 2], QQ) 

sage: Z = x0^2*y0^2 + 3*x0*x1*y0^2 + x1^2*y0^2 + 4*x0^2*y0*y1 + \ 

3*x0*x1*y0*y1 -2*x2^2*y0*y1 - x0^2*y1^2 + 2*x1^2*y1^2 - x0*x2*y1^2 \ 

-4*x1*x2*y1^2 + 5*x0*x2*y0*y2 - 4*x1*x2*y0*y2 + 7*x0^2*y1*y2 + 4*x1^2*y1*y2 \ 

+ x0*x1*y2^2 + 3*x2^2*y2^2 

sage: Y = x0*y0 + x1*y1 + x2*y2 

sage: X = WehlerK3Surface([Z, Y]) 

sage: W = WehlerK3Surface([Z + Y^2, Y]) 

sage: X.is_isomorphic(W) 

True 

 

:: 

 

sage: R.<x,y,z,u,v,w> = PolynomialRing(QQ, 6) 

sage: L = x*u-y*v 

sage: Q = x*y*v^2 + z^2*u*w 

sage: W1 = WehlerK3Surface([L, Q]) 

sage: PP.<x0,x1,x2,y0,y1,y2> = ProductProjectiveSpaces([2, 2], QQ) 

sage: L = x0*y0 + x1*y1 + x2*y2 

sage: Q = x1^2*y0^2 + 2*x2^2*y0*y1 + x0^2*y1^2 -x0*x1*y2^2 

sage: W2 = WehlerK3Surface([L, Q]) 

sage: W1.is_isomorphic(W2) 

False 

""" 

return self.defining_ideal() == right.defining_ideal() 

 

def is_symmetric_orbit(self,orbit): 

r""" 

Checks to see if the orbit is symmetric (i.e. if one of the points on the 

orbit is fixed by '\sigma_x' or '\sigma_y'). 

 

INPUT: 

 

- ``orbit``- a periodic cycle of either psi or phi 

 

OUTPUT: Boolean 

 

EXAMPLES:: 

 

sage: PP.<x0,x1,x2,y0,y1,y2> = ProductProjectiveSpaces([2, 2], GF(7)) 

sage: Z = x0^2*y0^2 + 3*x0*x1*y0^2 + x1^2*y0^2 + 4*x0^2*y0*y1 + 3*x0*x1*y0*y1 \ 

-2*x2^2*y0*y1 - x0^2*y1^2 + 2*x1^2*y1^2 - x0*x2*y1^2 -4*x1*x2*y1^2 + 5*x0*x2*y0*y2 \ 

-4*x1*x2*y0*y2 + 7*x0^2*y1*y2 + 4*x1^2*y1*y2 + x0*x1*y2^2 + 3*x2^2*y2^2 

sage: Y = x0*y0 + x1*y1 + x2*y2 

sage: X = WehlerK3Surface([Z, Y]) 

sage: T = PP([0, 0, 1, 1, 0, 0]) 

sage: orbit = X.orbit_psi(T, 4) 

sage: X.is_symmetric_orbit(orbit) 

True 

 

:: 

 

sage: PP.<x0,x1,x2,y0,y1,y2> = ProductProjectiveSpaces([2, 2], QQ) 

sage: L = x0*y0 + x1*y1 + x2*y2 

sage: Q = x1^2*y0^2 + 2*x2^2*y0*y1 + x0^2*y1^2 - x0*x1*y2^2 

sage: W = WehlerK3Surface([L, Q]) 

sage: T = W([-1, -1, 1, 1, 0, 1]) 

sage: Orb = W.orbit_phi(T, 7) 

sage: W.is_symmetric_orbit(Orb) 

False 

""" 

N = len(orbit) 

if self.nth_iterate_phi(orbit[0], N) != orbit[0] and self.nth_iterate_psi(orbit[0], N) != orbit[0]: 

raise ValueError("must be an orbit of phi or psi functions") 

sym = False 

i = 0 

while i < len(orbit) - 1 and not sym: 

P = orbit[i] 

Q = orbit[i + 1] 

if P[0] == Q[0] or P[1] == Q[1]: 

sym = True 

i += 1 

return(sym) 

 

 

class WehlerK3Surface_field( WehlerK3Surface_ring): 

pass 

 

 

class WehlerK3Surface_finite_field( WehlerK3Surface_field): 

def cardinality( self): 

r""" 

Counts the total number of points on the K3 surface. 

 

ALGORITHM: 

 

Enumerate points over `\mathbb{P}^2`, and then count the points on the fiber of 

each of those points. 

 

OUTPUT: Integer - total number of points on the surface 

 

EXAMPLES:: 

 

sage: PP.<x0,x1,x2,y0,y1,y2> = ProductProjectiveSpaces([2, 2], GF(7)) 

sage: Z = x0^2*y0^2 + 3*x0*x1*y0^2 + x1^2*y0^2 + 4*x0^2*y0*y1 + \ 

3*x0*x1*y0*y1 -2*x2^2*y0*y1 - x0^2*y1^2 + 2*x1^2*y1^2 - x0*x2*y1^2 \ 

- 4*x1*x2*y1^2 + 5*x0*x2*y0*y2 -4*x1*x2*y0*y2 + 7*x0^2*y1*y2 + 4*x1^2*y1*y2 \ 

+ x0*x1*y2^2 + 3*x2^2*y2^2 

sage: Y = x0*y0 + x1*y1 + x2*y2 

sage: X = WehlerK3Surface([Z, Y]) 

sage: X.cardinality() 

55 

""" 

def getPx1(): 

return ([x, y, 1] for x in self.base_ring() for y in self.base_ring()) 

def getPx2(): 

return ([x, 1, 0] for x in self.base_ring()) 

Count = 0 

Xpoint = [1, 0, 0] 

Ypoint = [1, 0, 0] 

#Create all possible Px1 Values 

for i in getPx1(): 

for j in getPx1(): 

A = i + j 

if(self.L(A) == 0 and self.Q(A) == 0): 

Count += 1 

for k in getPx2(): 

A = i + k 

if(self.L(A) == 0 and self.Q(A) == 0): 

Count += 1 

B = i + Ypoint 

if(self.L(B) == 0 and self.Q(B) == 0): 

Count += 1 

#Create all possible Px2 Values 

for i in getPx2(): 

for j in getPx1(): 

A = i + j 

if (self.L(A) == 0 and self.Q(A) == 0): 

Count += 1 

for k in getPx2(): 

A = i + k 

if (self.L(A) == 0 and self.Q(A) == 0): 

Count += 1 

B = i + Ypoint 

if (self.L(B) == 0 and self.Q(B) == 0): 

Count += 1 

#Create all Xpoint values 

for j in getPx1(): 

A = Xpoint+j 

if (self.L(A) == 0 and self.Q(A) == 0): 

Count += 1 

for k in getPx2(): 

B = Xpoint + k 

if (self.L(B) == 0 and self.Q(B) == 0): 

Count += 1 

C = Xpoint + Ypoint 

if (self.L(C) == 0 and self.Q(C) == 0): 

Count += 1 

return Count