Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

166

167

168

169

170

171

172

173

174

175

176

177

178

179

180

181

182

183

184

185

186

187

188

189

190

191

192

193

194

195

196

197

198

199

200

201

202

203

204

205

206

207

208

209

210

211

212

213

214

215

216

217

218

219

220

221

222

223

224

225

226

227

228

229

230

231

232

233

234

235

236

237

238

239

240

241

242

243

244

245

246

247

248

249

250

251

252

253

254

255

256

257

258

259

260

261

262

263

264

265

266

267

268

269

270

271

272

273

274

275

276

277

278

279

280

281

282

283

284

285

286

287

288

289

290

291

292

293

294

295

296

297

298

299

300

301

302

303

304

305

306

307

308

309

310

311

312

313

314

315

316

317

318

319

320

321

322

323

324

325

326

327

328

329

330

331

332

333

334

335

336

337

338

339

340

341

342

343

344

345

346

347

348

349

350

351

352

353

354

355

356

357

358

359

360

361

362

363

364

365

366

367

368

369

370

371

372

373

374

375

376

377

378

379

380

381

382

383

384

385

386

387

388

389

390

391

392

393

394

395

396

397

398

399

400

401

402

403

404

405

406

407

408

409

410

411

412

413

414

415

416

417

418

419

420

421

422

423

424

425

426

427

428

429

430

431

432

433

434

435

436

437

438

439

440

441

442

443

444

445

446

447

448

449

450

451

452

453

454

455

456

457

458

459

460

461

462

463

464

465

466

467

468

469

470

471

472

473

474

475

476

477

478

479

480

481

482

483

484

485

486

487

488

489

490

491

492

493

494

495

496

497

498

499

500

501

502

503

504

505

506

507

508

509

510

511

512

513

514

515

516

517

518

519

520

521

522

523

524

525

526

527

528

529

530

531

532

533

534

535

536

537

538

539

540

541

542

543

544

545

546

547

548

549

550

551

552

553

554

555

556

557

558

559

560

561

562

563

564

565

566

567

568

569

570

571

572

573

574

575

576

577

578

579

580

581

582

583

584

585

586

587

588

589

590

591

592

593

594

595

596

597

598

599

600

601

602

603

604

605

606

607

608

609

610

611

612

613

614

615

616

617

618

619

620

621

622

623

624

625

626

627

628

629

630

631

632

633

634

635

636

637

638

639

640

641

642

643

644

645

646

647

648

649

650

651

652

653

654

655

656

657

658

659

660

661

662

663

664

665

666

667

668

669

670

671

672

673

674

675

676

677

678

679

680

681

682

683

684

685

686

687

688

689

690

691

692

693

694

695

696

697

698

699

700

701

702

703

704

705

706

707

708

709

710

711

712

713

714

715

716

717

718

719

720

721

722

723

724

725

726

727

728

729

730

731

732

733

734

735

736

737

738

739

740

741

742

743

744

745

746

747

748

749

750

751

752

753

754

755

756

757

758

759

760

761

762

763

764

765

766

767

768

769

770

771

772

773

774

775

776

777

778

779

780

781

782

783

784

785

786

787

788

789

790

791

792

793

794

795

796

797

798

799

800

801

802

803

804

805

806

807

808

809

810

811

812

813

814

815

816

817

818

819

820

821

822

823

824

825

826

827

828

829

830

831

832

833

834

835

836

837

838

839

840

841

842

843

844

845

846

847

848

849

850

851

852

853

854

855

856

857

858

859

860

861

862

863

864

865

866

867

868

869

870

871

872

873

874

875

876

877

878

879

880

881

882

883

884

885

886

887

888

889

890

891

892

893

894

895

896

897

898

899

900

901

902

903

904

905

906

907

908

909

910

911

912

913

914

915

916

917

918

919

920

921

922

923

924

925

926

927

928

929

930

931

932

933

934

935

936

937

938

939

940

941

942

943

944

945

946

947

948

949

950

951

952

953

954

955

956

957

958

959

960

961

962

963

964

965

966

967

968

969

970

971

972

973

974

975

976

977

978

979

980

981

982

983

984

985

986

987

988

989

990

991

992

993

994

995

996

997

998

999

1000

1001

1002

1003

1004

1005

1006

1007

1008

1009

1010

1011

1012

1013

1014

1015

1016

1017

1018

1019

1020

1021

1022

1023

1024

1025

1026

1027

1028

1029

1030

1031

1032

1033

1034

1035

1036

1037

1038

1039

1040

1041

1042

1043

1044

1045

1046

1047

1048

1049

1050

1051

1052

1053

1054

1055

1056

1057

1058

1059

1060

1061

1062

1063

1064

1065

1066

1067

1068

1069

1070

1071

1072

1073

1074

1075

1076

1077

1078

1079

1080

1081

1082

1083

1084

1085

1086

1087

1088

1089

1090

1091

1092

1093

1094

1095

1096

1097

1098

1099

1100

1101

1102

1103

1104

1105

1106

1107

1108

1109

1110

1111

1112

1113

1114

1115

1116

1117

1118

1119

1120

1121

1122

1123

1124

1125

1126

1127

1128

1129

1130

1131

1132

1133

1134

1135

1136

1137

1138

1139

1140

1141

1142

1143

1144

1145

1146

1147

1148

1149

1150

1151

1152

1153

1154

1155

1156

1157

1158

1159

1160

1161

1162

1163

1164

1165

1166

1167

1168

1169

1170

1171

1172

1173

1174

1175

1176

1177

1178

1179

1180

1181

1182

1183

1184

1185

1186

1187

1188

1189

1190

1191

1192

1193

1194

1195

1196

1197

1198

1199

1200

1201

1202

1203

1204

1205

1206

1207

1208

1209

1210

1211

1212

1213

1214

1215

1216

1217

1218

1219

1220

1221

1222

1223

1224

1225

1226

1227

1228

1229

1230

1231

1232

1233

1234

1235

1236

1237

1238

1239

1240

1241

1242

1243

1244

1245

1246

1247

1248

1249

1250

1251

1252

1253

1254

1255

1256

1257

1258

1259

1260

1261

1262

1263

1264

1265

1266

1267

1268

1269

1270

1271

1272

1273

1274

1275

1276

1277

1278

1279

1280

1281

1282

1283

1284

1285

1286

1287

1288

1289

1290

1291

1292

1293

1294

1295

1296

1297

1298

1299

1300

1301

1302

1303

1304

1305

1306

1307

1308

1309

1310

1311

1312

1313

1314

1315

1316

1317

1318

1319

1320

1321

1322

1323

1324

1325

1326

1327

1328

1329

1330

1331

1332

1333

1334

1335

1336

1337

1338

1339

1340

1341

1342

1343

1344

1345

1346

1347

1348

1349

1350

1351

1352

1353

1354

1355

1356

1357

1358

1359

1360

1361

1362

1363

1364

1365

1366

1367

1368

1369

1370

1371

1372

1373

1374

1375

1376

1377

1378

1379

1380

1381

1382

1383

1384

1385

1386

1387

1388

1389

1390

1391

1392

1393

1394

1395

1396

1397

1398

1399

1400

1401

1402

1403

1404

1405

1406

1407

1408

1409

1410

1411

1412

1413

1414

1415

1416

1417

1418

1419

1420

1421

1422

1423

1424

1425

1426

1427

1428

1429

1430

1431

1432

1433

1434

1435

1436

1437

1438

1439

1440

1441

1442

1443

1444

1445

1446

1447

1448

1449

1450

1451

1452

1453

1454

1455

1456

1457

1458

1459

1460

1461

1462

1463

1464

1465

1466

1467

1468

1469

1470

1471

1472

1473

1474

1475

1476

1477

1478

1479

1480

1481

1482

1483

1484

1485

1486

1487

1488

1489

1490

1491

1492

1493

1494

1495

1496

1497

1498

1499

1500

1501

1502

1503

1504

1505

1506

1507

1508

1509

1510

1511

1512

1513

1514

1515

1516

1517

1518

1519

1520

1521

1522

1523

1524

1525

1526

1527

1528

1529

1530

1531

1532

1533

1534

1535

1536

1537

1538

1539

1540

1541

1542

1543

1544

1545

1546

1547

1548

1549

1550

1551

1552

1553

1554

1555

1556

1557

1558

1559

1560

1561

1562

1563

1564

1565

1566

1567

1568

1569

1570

1571

1572

1573

1574

1575

1576

1577

1578

1579

1580

1581

1582

1583

1584

1585

1586

1587

1588

1589

1590

1591

1592

1593

1594

1595

1596

1597

1598

1599

1600

1601

1602

1603

1604

1605

1606

1607

1608

1609

1610

1611

1612

1613

1614

1615

1616

1617

1618

1619

1620

1621

1622

1623

1624

1625

1626

1627

1628

1629

1630

1631

1632

1633

1634

1635

1636

1637

1638

1639

1640

1641

1642

1643

1644

1645

1646

1647

1648

1649

1650

1651

1652

1653

1654

1655

1656

1657

1658

1659

1660

1661

1662

1663

1664

1665

1666

1667

1668

1669

1670

1671

1672

1673

1674

1675

1676

1677

1678

1679

1680

1681

1682

1683

1684

1685

1686

1687

1688

1689

1690

1691

1692

1693

1694

1695

1696

1697

1698

1699

1700

1701

1702

1703

1704

1705

1706

1707

1708

1709

1710

1711

1712

1713

1714

1715

1716

1717

1718

1719

1720

1721

1722

1723

1724

1725

1726

1727

1728

1729

1730

1731

1732

1733

1734

1735

1736

1737

1738

1739

1740

1741

1742

1743

1744

1745

1746

1747

1748

1749

1750

1751

1752

1753

1754

1755

1756

1757

1758

1759

1760

1761

1762

1763

1764

1765

1766

1767

1768

1769

1770

1771

1772

1773

1774

1775

1776

1777

1778

1779

1780

1781

1782

1783

1784

1785

1786

1787

1788

1789

1790

1791

1792

1793

1794

1795

1796

1797

1798

1799

1800

1801

1802

1803

1804

1805

1806

1807

1808

1809

1810

1811

1812

1813

1814

1815

1816

1817

1818

1819

1820

1821

1822

1823

1824

1825

1826

1827

1828

1829

1830

1831

1832

1833

1834

1835

1836

1837

1838

1839

1840

1841

1842

1843

1844

1845

1846

1847

1848

1849

1850

1851

1852

1853

1854

1855

1856

1857

1858

1859

1860

1861

1862

1863

1864

1865

1866

1867

1868

1869

1870

1871

1872

1873

1874

1875

1876

1877

1878

1879

1880

1881

1882

1883

1884

1885

1886

1887

1888

1889

1890

1891

1892

1893

1894

1895

1896

1897

1898

1899

1900

1901

1902

1903

1904

1905

1906

1907

1908

1909

1910

1911

1912

1913

1914

1915

1916

1917

1918

1919

1920

1921

1922

1923

1924

1925

1926

1927

1928

1929

1930

1931

1932

1933

1934

1935

1936

1937

1938

1939

1940

1941

1942

1943

1944

1945

1946

1947

1948

1949

1950

1951

1952

1953

1954

1955

1956

1957

1958

1959

1960

1961

1962

1963

1964

1965

1966

1967

1968

1969

1970

1971

1972

1973

1974

1975

1976

1977

1978

1979

1980

1981

1982

1983

1984

1985

1986

1987

1988

1989

1990

1991

1992

1993

1994

1995

1996

1997

1998

1999

2000

2001

2002

2003

2004

2005

2006

2007

2008

2009

2010

2011

2012

2013

2014

2015

2016

2017

2018

2019

2020

2021

2022

2023

2024

2025

2026

2027

2028

2029

2030

2031

2032

2033

2034

2035

2036

2037

2038

2039

2040

2041

2042

2043

2044

2045

2046

2047

2048

2049

2050

2051

2052

2053

2054

2055

2056

2057

2058

2059

2060

2061

2062

2063

2064

2065

2066

2067

2068

2069

2070

2071

2072

2073

2074

2075

2076

2077

2078

2079

2080

2081

2082

2083

2084

2085

2086

2087

2088

2089

2090

2091

2092

2093

2094

2095

2096

2097

2098

2099

2100

2101

2102

2103

2104

2105

2106

2107

2108

2109

2110

2111

2112

2113

2114

2115

2116

2117

2118

2119

2120

2121

2122

2123

2124

2125

2126

2127

2128

2129

2130

2131

2132

2133

2134

2135

2136

2137

2138

2139

2140

2141

2142

2143

2144

2145

2146

2147

2148

2149

2150

2151

2152

2153

2154

2155

2156

2157

2158

2159

2160

2161

2162

2163

2164

2165

2166

2167

2168

2169

2170

2171

2172

2173

2174

2175

2176

2177

2178

2179

2180

2181

2182

2183

2184

2185

2186

2187

2188

2189

2190

2191

2192

2193

2194

2195

2196

2197

2198

2199

2200

2201

2202

2203

2204

2205

2206

2207

2208

2209

2210

2211

2212

2213

2214

2215

2216

2217

2218

2219

2220

2221

2222

2223

2224

2225

2226

2227

2228

2229

2230

2231

2232

2233

2234

2235

2236

2237

2238

2239

2240

2241

2242

2243

2244

2245

2246

2247

2248

2249

2250

2251

2252

2253

2254

2255

2256

2257

2258

2259

2260

2261

2262

2263

2264

2265

2266

2267

2268

2269

2270

2271

2272

2273

2274

2275

2276

2277

2278

2279

2280

2281

2282

2283

2284

2285

2286

2287

2288

2289

2290

2291

2292

2293

2294

2295

2296

2297

2298

2299

2300

2301

2302

2303

2304

2305

2306

2307

2308

2309

2310

2311

2312

2313

2314

2315

2316

2317

2318

2319

2320

2321

2322

2323

2324

2325

2326

2327

2328

2329

2330

2331

2332

2333

2334

2335

2336

2337

2338

2339

2340

2341

2342

2343

2344

2345

2346

2347

2348

2349

2350

2351

2352

2353

2354

2355

2356

2357

2358

2359

2360

2361

2362

2363

2364

2365

2366

2367

2368

2369

2370

2371

2372

2373

2374

2375

2376

2377

2378

2379

2380

2381

2382

2383

2384

2385

2386

2387

2388

2389

2390

2391

2392

2393

2394

2395

2396

2397

2398

2399

2400

2401

2402

2403

2404

2405

2406

2407

2408

2409

2410

2411

2412

2413

2414

2415

2416

2417

2418

2419

2420

2421

2422

2423

2424

2425

2426

2427

2428

2429

2430

2431

2432

2433

2434

2435

2436

2437

2438

2439

2440

2441

2442

2443

2444

2445

2446

2447

2448

2449

2450

2451

2452

2453

2454

2455

2456

2457

2458

2459

2460

2461

2462

2463

2464

2465

2466

2467

2468

2469

2470

2471

2472

2473

2474

2475

2476

2477

2478

2479

2480

2481

2482

2483

2484

2485

2486

2487

2488

2489

2490

2491

2492

2493

2494

2495

2496

2497

2498

2499

2500

2501

2502

2503

2504

2505

2506

2507

2508

2509

2510

2511

2512

2513

2514

2515

2516

2517

2518

2519

2520

2521

2522

2523

2524

2525

2526

2527

2528

2529

2530

2531

2532

2533

2534

2535

2536

2537

2538

2539

2540

2541

2542

2543

2544

2545

2546

2547

2548

2549

2550

2551

2552

2553

2554

2555

2556

2557

2558

2559

2560

2561

2562

2563

2564

2565

2566

2567

2568

2569

2570

2571

2572

2573

2574

2575

2576

2577

2578

2579

2580

2581

2582

2583

2584

2585

2586

2587

2588

2589

2590

2591

2592

2593

2594

2595

2596

2597

2598

2599

2600

2601

2602

2603

2604

2605

2606

2607

2608

2609

2610

2611

2612

2613

2614

2615

2616

2617

2618

2619

2620

2621

2622

2623

2624

2625

2626

2627

2628

2629

2630

2631

2632

2633

2634

2635

2636

2637

2638

2639

2640

2641

2642

2643

2644

2645

2646

2647

2648

2649

2650

2651

2652

2653

2654

2655

2656

2657

2658

2659

2660

2661

2662

2663

2664

2665

2666

2667

2668

2669

2670

2671

2672

2673

2674

2675

2676

2677

2678

2679

2680

2681

2682

2683

2684

2685

2686

2687

2688

2689

2690

2691

2692

2693

2694

2695

2696

2697

2698

2699

2700

2701

2702

2703

2704

2705

2706

2707

2708

2709

2710

2711

2712

2713

2714

2715

2716

2717

2718

2719

2720

2721

2722

2723

2724

2725

2726

2727

2728

2729

2730

2731

2732

2733

2734

2735

2736

2737

2738

2739

2740

2741

2742

2743

2744

2745

2746

2747

2748

2749

2750

2751

2752

2753

2754

2755

2756

2757

2758

2759

2760

2761

2762

2763

2764

2765

2766

2767

2768

2769

2770

2771

2772

2773

2774

2775

2776

2777

2778

2779

2780

2781

2782

2783

2784

2785

2786

2787

2788

2789

2790

2791

2792

2793

2794

2795

2796

2797

2798

2799

2800

2801

2802

2803

2804

2805

2806

2807

2808

2809

2810

2811

2812

2813

2814

2815

2816

2817

2818

2819

2820

2821

2822

2823

2824

2825

2826

2827

2828

2829

2830

2831

2832

2833

2834

2835

2836

2837

2838

2839

2840

2841

2842

2843

2844

2845

2846

2847

2848

2849

2850

2851

2852

2853

2854

2855

2856

2857

2858

2859

2860

2861

2862

2863

2864

2865

2866

2867

2868

2869

2870

2871

2872

2873

2874

2875

2876

2877

2878

2879

2880

2881

2882

2883

2884

2885

2886

2887

2888

2889

2890

2891

2892

2893

2894

2895

2896

2897

2898

2899

2900

2901

2902

2903

2904

2905

2906

2907

2908

2909

2910

2911

2912

2913

2914

2915

2916

2917

2918

2919

2920

2921

2922

2923

2924

2925

2926

2927

2928

2929

2930

2931

2932

2933

2934

2935

2936

2937

2938

2939

2940

2941

2942

2943

2944

2945

2946

2947

2948

2949

2950

2951

2952

2953

2954

2955

2956

2957

2958

2959

2960

2961

2962

2963

2964

2965

2966

2967

2968

2969

2970

2971

2972

2973

2974

2975

2976

2977

2978

2979

2980

2981

2982

2983

2984

2985

2986

2987

2988

2989

2990

2991

2992

2993

2994

2995

2996

2997

2998

2999

3000

3001

3002

3003

3004

3005

3006

3007

3008

3009

3010

3011

3012

3013

3014

3015

3016

3017

3018

3019

3020

3021

3022

3023

3024

3025

3026

3027

3028

3029

3030

3031

3032

3033

3034

3035

3036

3037

3038

3039

3040

3041

3042

3043

3044

3045

3046

3047

3048

3049

3050

3051

3052

3053

3054

3055

3056

3057

3058

3059

3060

3061

3062

3063

3064

3065

3066

3067

3068

3069

3070

3071

3072

3073

3074

3075

3076

3077

3078

3079

3080

3081

3082

3083

3084

3085

3086

3087

3088

3089

3090

3091

3092

3093

3094

3095

3096

3097

3098

3099

3100

3101

3102

3103

3104

3105

3106

3107

3108

3109

3110

3111

3112

3113

3114

3115

3116

3117

3118

3119

3120

3121

3122

3123

3124

3125

3126

3127

3128

3129

3130

3131

3132

3133

3134

3135

3136

3137

3138

3139

3140

3141

3142

3143

3144

3145

3146

3147

3148

3149

3150

3151

3152

3153

3154

3155

3156

3157

3158

3159

3160

3161

3162

3163

3164

3165

3166

3167

3168

3169

3170

3171

3172

3173

3174

3175

3176

3177

3178

3179

3180

3181

3182

3183

3184

3185

3186

3187

3188

3189

3190

3191

3192

3193

3194

3195

3196

3197

3198

3199

3200

3201

3202

3203

3204

3205

3206

3207

3208

3209

3210

3211

3212

3213

3214

3215

3216

3217

3218

3219

3220

3221

3222

3223

3224

3225

3226

3227

3228

3229

3230

3231

3232

3233

3234

3235

3236

3237

3238

3239

3240

3241

3242

3243

3244

3245

3246

3247

3248

3249

3250

3251

3252

3253

3254

3255

3256

3257

3258

3259

3260

3261

3262

3263

3264

3265

3266

3267

3268

3269

3270

3271

3272

3273

3274

3275

3276

3277

3278

3279

3280

3281

3282

3283

3284

3285

3286

3287

3288

3289

3290

3291

3292

3293

3294

3295

3296

3297

3298

3299

3300

3301

3302

3303

3304

3305

3306

3307

3308

3309

3310

3311

3312

3313

3314

3315

3316

3317

3318

3319

3320

3321

3322

3323

3324

3325

3326

3327

3328

3329

3330

3331

3332

3333

3334

3335

3336

3337

3338

3339

3340

3341

3342

3343

3344

3345

3346

3347

3348

3349

3350

3351

3352

3353

3354

3355

3356

3357

3358

3359

3360

3361

3362

3363

3364

3365

3366

3367

3368

3369

3370

3371

3372

3373

3374

3375

3376

3377

3378

3379

3380

3381

3382

3383

3384

3385

3386

3387

3388

3389

3390

3391

3392

3393

3394

3395

3396

3397

3398

3399

3400

3401

3402

3403

3404

3405

3406

3407

3408

3409

3410

3411

3412

3413

3414

3415

3416

3417

3418

3419

3420

3421

3422

3423

3424

3425

3426

3427

3428

3429

3430

3431

3432

3433

3434

3435

3436

3437

3438

3439

3440

3441

3442

3443

3444

3445

3446

3447

3448

3449

3450

3451

3452

3453

3454

3455

3456

3457

3458

3459

3460

3461

3462

3463

3464

3465

3466

3467

3468

3469

3470

3471

3472

3473

3474

3475

3476

3477

3478

3479

3480

3481

3482

3483

3484

3485

3486

3487

3488

3489

3490

3491

3492

3493

3494

3495

3496

3497

3498

3499

3500

3501

3502

3503

3504

3505

3506

3507

3508

3509

3510

3511

3512

3513

3514

3515

3516

3517

3518

3519

3520

3521

3522

3523

3524

3525

3526

3527

3528

3529

3530

3531

3532

3533

3534

3535

3536

3537

3538

3539

3540

3541

3542

3543

3544

3545

3546

3547

3548

3549

3550

3551

3552

3553

3554

3555

3556

3557

3558

3559

3560

3561

3562

3563

3564

3565

3566

3567

3568

3569

3570

3571

3572

3573

3574

3575

3576

3577

3578

3579

3580

3581

3582

3583

3584

3585

3586

3587

3588

3589

3590

3591

3592

3593

3594

3595

3596

3597

3598

3599

3600

3601

3602

3603

3604

3605

3606

3607

3608

3609

3610

3611

3612

3613

3614

3615

3616

3617

3618

3619

3620

3621

3622

3623

3624

3625

3626

3627

3628

3629

3630

3631

3632

3633

3634

3635

3636

3637

3638

3639

3640

3641

3642

3643

3644

3645

3646

3647

3648

3649

3650

3651

3652

3653

3654

3655

3656

3657

3658

3659

3660

3661

3662

3663

3664

3665

3666

3667

3668

3669

3670

3671

3672

3673

3674

3675

3676

3677

3678

3679

3680

3681

3682

3683

3684

3685

3686

3687

3688

3689

3690

3691

3692

3693

3694

3695

3696

3697

3698

3699

3700

3701

3702

3703

3704

3705

3706

3707

3708

3709

3710

3711

3712

3713

3714

3715

3716

3717

3718

3719

3720

3721

3722

3723

3724

3725

3726

3727

3728

3729

3730

3731

3732

3733

3734

3735

3736

3737

3738

3739

3740

3741

3742

3743

3744

3745

3746

3747

3748

3749

3750

3751

3752

3753

3754

3755

3756

3757

3758

3759

3760

3761

3762

3763

3764

3765

3766

3767

3768

3769

3770

3771

3772

3773

3774

3775

3776

3777

3778

3779

3780

3781

3782

3783

3784

3785

3786

3787

3788

3789

3790

3791

3792

3793

3794

3795

3796

3797

3798

3799

3800

3801

3802

3803

3804

3805

3806

3807

3808

3809

3810

3811

3812

3813

3814

3815

3816

3817

3818

3819

3820

3821

3822

3823

3824

3825

3826

3827

3828

3829

3830

3831

3832

3833

3834

3835

3836

3837

3838

3839

3840

3841

3842

3843

3844

3845

3846

3847

3848

3849

3850

3851

3852

3853

3854

3855

3856

3857

3858

3859

3860

3861

3862

3863

3864

3865

3866

3867

3868

3869

3870

3871

3872

3873

3874

3875

3876

3877

3878

3879

3880

3881

3882

3883

3884

3885

3886

3887

3888

3889

3890

3891

3892

3893

3894

3895

3896

3897

3898

3899

3900

3901

3902

3903

3904

3905

3906

3907

3908

3909

3910

3911

3912

3913

3914

3915

3916

3917

3918

3919

3920

3921

3922

3923

3924

3925

3926

3927

3928

3929

3930

3931

3932

3933

3934

3935

3936

3937

3938

3939

3940

3941

3942

3943

3944

3945

3946

3947

3948

3949

3950

3951

3952

3953

3954

3955

3956

3957

3958

3959

3960

3961

3962

3963

3964

3965

3966

3967

3968

3969

3970

3971

3972

3973

3974

3975

3976

3977

3978

3979

3980

3981

3982

3983

3984

3985

3986

3987

3988

3989

3990

3991

3992

3993

3994

3995

3996

3997

3998

3999

4000

4001

4002

4003

4004

4005

4006

4007

4008

4009

4010

4011

4012

4013

4014

4015

4016

4017

4018

4019

4020

4021

4022

4023

4024

4025

4026

4027

4028

4029

4030

4031

4032

4033

4034

4035

4036

4037

4038

4039

4040

4041

4042

4043

4044

4045

4046

4047

4048

4049

4050

4051

4052

4053

4054

4055

4056

4057

4058

4059

4060

4061

4062

4063

4064

4065

4066

4067

4068

4069

4070

4071

4072

4073

4074

4075

4076

4077

4078

4079

4080

4081

4082

4083

4084

4085

4086

4087

4088

4089

4090

4091

4092

4093

4094

4095

4096

4097

4098

4099

4100

4101

4102

4103

4104

4105

4106

4107

4108

4109

4110

4111

4112

4113

4114

4115

4116

4117

4118

4119

4120

4121

4122

4123

4124

4125

4126

4127

4128

4129

4130

4131

4132

4133

4134

4135

4136

4137

4138

4139

4140

4141

4142

4143

4144

4145

4146

4147

4148

4149

4150

4151

4152

4153

4154

4155

4156

4157

4158

4159

4160

4161

4162

4163

4164

4165

4166

4167

4168

4169

4170

4171

4172

4173

4174

4175

4176

4177

4178

4179

4180

4181

4182

4183

4184

4185

4186

4187

4188

4189

4190

4191

4192

4193

4194

4195

4196

4197

4198

4199

4200

4201

4202

4203

4204

4205

4206

4207

4208

4209

4210

4211

4212

4213

4214

4215

4216

4217

4218

4219

4220

4221

4222

4223

4224

4225

4226

4227

4228

4229

4230

4231

4232

4233

4234

4235

4236

4237

4238

4239

4240

4241

4242

4243

4244

4245

4246

4247

4248

4249

4250

4251

4252

4253

4254

4255

4256

4257

4258

4259

4260

4261

4262

4263

4264

4265

4266

4267

4268

4269

4270

4271

4272

4273

4274

4275

4276

4277

4278

4279

4280

4281

4282

4283

4284

4285

4286

4287

4288

4289

4290

4291

4292

4293

4294

4295

4296

4297

4298

4299

4300

4301

4302

4303

4304

4305

4306

4307

4308

4309

4310

4311

4312

4313

4314

4315

4316

4317

4318

4319

4320

4321

4322

4323

4324

4325

4326

4327

4328

4329

4330

4331

4332

4333

4334

4335

4336

4337

4338

4339

4340

4341

4342

4343

4344

4345

4346

4347

4348

4349

4350

4351

4352

4353

4354

4355

4356

4357

4358

4359

4360

4361

4362

4363

4364

4365

4366

4367

4368

4369

4370

4371

4372

4373

4374

4375

4376

4377

4378

4379

4380

4381

4382

4383

4384

4385

4386

4387

4388

4389

4390

4391

4392

4393

4394

4395

4396

4397

4398

4399

4400

4401

4402

4403

4404

4405

4406

4407

4408

4409

4410

4411

4412

4413

4414

4415

4416

4417

4418

4419

4420

4421

4422

4423

4424

4425

4426

4427

4428

4429

4430

4431

4432

4433

4434

4435

4436

4437

4438

4439

4440

4441

4442

4443

4444

4445

4446

4447

4448

4449

4450

4451

4452

4453

4454

4455

4456

4457

4458

4459

4460

4461

4462

4463

4464

4465

4466

4467

4468

4469

4470

4471

4472

4473

4474

4475

4476

4477

4478

4479

4480

4481

4482

4483

4484

4485

4486

4487

4488

4489

4490

4491

4492

4493

4494

4495

4496

4497

4498

4499

4500

4501

4502

4503

4504

4505

4506

4507

4508

4509

4510

4511

4512

4513

4514

4515

4516

4517

4518

4519

4520

4521

4522

4523

4524

4525

4526

4527

4528

4529

4530

4531

4532

4533

4534

4535

4536

4537

4538

4539

4540

4541

4542

4543

4544

4545

4546

4547

4548

4549

4550

4551

4552

4553

4554

4555

4556

4557

4558

4559

4560

4561

4562

4563

4564

4565

4566

4567

4568

4569

4570

4571

4572

4573

4574

4575

4576

4577

4578

4579

4580

4581

4582

4583

4584

4585

4586

4587

4588

4589

4590

4591

4592

4593

4594

4595

4596

4597

4598

4599

4600

4601

4602

4603

4604

4605

4606

4607

4608

4609

4610

4611

4612

4613

4614

4615

4616

4617

4618

4619

4620

4621

4622

4623

4624

4625

4626

4627

4628

4629

4630

4631

4632

4633

4634

4635

4636

4637

4638

4639

4640

4641

4642

4643

4644

4645

4646

4647

4648

4649

4650

4651

4652

4653

4654

4655

4656

4657

4658

4659

4660

4661

4662

4663

4664

4665

4666

4667

4668

4669

4670

4671

4672

4673

4674

4675

4676

4677

4678

4679

4680

4681

4682

4683

4684

4685

4686

4687

4688

4689

4690

4691

4692

4693

4694

4695

4696

4697

4698

4699

4700

4701

4702

4703

4704

4705

4706

4707

4708

4709

4710

4711

4712

4713

4714

4715

4716

4717

4718

4719

4720

4721

4722

4723

4724

4725

4726

4727

4728

4729

4730

4731

4732

4733

4734

4735

4736

4737

4738

4739

4740

4741

4742

4743

4744

4745

4746

4747

4748

4749

4750

4751

4752

4753

4754

4755

4756

4757

4758

4759

4760

4761

4762

4763

4764

4765

4766

4767

4768

4769

4770

4771

4772

4773

4774

4775

4776

4777

4778

4779

4780

4781

4782

4783

4784

4785

4786

4787

4788

4789

4790

4791

4792

4793

4794

4795

4796

4797

4798

4799

4800

4801

4802

4803

4804

4805

4806

4807

4808

4809

4810

4811

4812

4813

4814

4815

4816

4817

4818

4819

4820

4821

4822

4823

4824

4825

4826

4827

4828

4829

4830

4831

4832

4833

4834

4835

4836

4837

4838

4839

4840

4841

4842

4843

4844

4845

4846

4847

4848

4849

4850

4851

4852

4853

4854

4855

4856

4857

4858

4859

4860

4861

4862

4863

4864

4865

4866

4867

4868

4869

4870

4871

4872

4873

4874

4875

4876

4877

4878

4879

4880

4881

4882

4883

4884

4885

4886

4887

4888

4889

4890

4891

4892

4893

4894

4895

4896

4897

4898

4899

4900

4901

4902

4903

4904

4905

4906

4907

4908

4909

4910

4911

4912

4913

4914

4915

4916

4917

4918

4919

4920

4921

4922

4923

4924

4925

4926

4927

4928

4929

4930

4931

4932

4933

4934

4935

4936

4937

4938

4939

4940

4941

4942

4943

4944

4945

4946

4947

4948

4949

4950

4951

4952

4953

4954

4955

4956

4957

4958

4959

4960

4961

4962

4963

4964

4965

4966

4967

4968

4969

4970

4971

4972

4973

4974

4975

4976

4977

4978

4979

4980

4981

4982

4983

4984

4985

4986

4987

4988

4989

4990

4991

4992

4993

4994

4995

4996

4997

4998

4999

5000

5001

5002

5003

5004

5005

5006

5007

5008

5009

5010

5011

5012

5013

5014

5015

5016

5017

5018

5019

5020

5021

5022

5023

5024

5025

5026

5027

5028

5029

5030

5031

5032

5033

5034

5035

5036

5037

5038

5039

5040

5041

5042

5043

5044

5045

5046

5047

5048

5049

5050

5051

5052

5053

5054

5055

5056

5057

5058

5059

5060

5061

5062

5063

5064

5065

5066

5067

5068

5069

5070

5071

5072

5073

5074

5075

5076

5077

5078

5079

5080

5081

5082

5083

5084

5085

5086

5087

5088

5089

5090

5091

5092

5093

5094

5095

5096

5097

5098

5099

5100

5101

5102

5103

5104

5105

5106

5107

5108

5109

5110

5111

5112

5113

5114

5115

5116

5117

5118

5119

5120

5121

5122

5123

5124

5125

5126

5127

5128

5129

5130

5131

5132

5133

5134

5135

5136

5137

5138

5139

5140

5141

5142

5143

5144

5145

5146

5147

5148

5149

5150

5151

5152

5153

5154

5155

5156

5157

5158

5159

5160

5161

5162

5163

5164

5165

5166

5167

5168

5169

5170

5171

5172

5173

5174

5175

5176

5177

5178

5179

5180

5181

5182

5183

5184

5185

5186

5187

5188

5189

5190

5191

5192

5193

5194

5195

5196

5197

5198

5199

5200

5201

5202

5203

5204

5205

5206

5207

5208

5209

5210

5211

5212

5213

5214

5215

5216

5217

5218

5219

5220

5221

5222

5223

5224

5225

5226

5227

5228

5229

5230

5231

5232

5233

5234

5235

5236

5237

5238

5239

5240

5241

5242

5243

5244

5245

5246

5247

5248

5249

5250

5251

5252

5253

5254

5255

5256

5257

5258

5259

5260

5261

5262

5263

5264

5265

5266

5267

5268

5269

5270

5271

5272

5273

5274

5275

5276

5277

5278

5279

5280

5281

5282

5283

5284

5285

5286

5287

5288

5289

5290

5291

5292

5293

5294

5295

5296

5297

5298

5299

5300

5301

5302

5303

5304

5305

5306

5307

5308

5309

5310

5311

5312

5313

5314

5315

5316

5317

5318

5319

5320

5321

5322

5323

5324

5325

5326

5327

5328

5329

5330

5331

5332

5333

5334

5335

5336

5337

5338

5339

5340

5341

5342

5343

5344

5345

5346

5347

5348

5349

5350

5351

5352

5353

5354

5355

5356

5357

5358

5359

5360

5361

5362

5363

5364

5365

5366

5367

5368

5369

5370

5371

5372

5373

5374

5375

5376

5377

5378

5379

5380

5381

5382

5383

5384

5385

5386

5387

5388

5389

5390

5391

5392

5393

5394

5395

5396

5397

5398

5399

5400

5401

5402

5403

5404

5405

5406

5407

5408

5409

5410

5411

5412

5413

5414

5415

5416

5417

5418

5419

5420

5421

5422

5423

5424

5425

5426

5427

5428

5429

5430

5431

5432

5433

5434

5435

5436

5437

5438

5439

5440

5441

5442

5443

5444

5445

5446

5447

5448

5449

5450

5451

5452

5453

5454

5455

5456

5457

5458

5459

5460

5461

5462

5463

5464

5465

5466

5467

5468

5469

5470

5471

5472

5473

5474

5475

5476

5477

5478

5479

5480

5481

5482

5483

5484

5485

5486

5487

5488

5489

5490

5491

5492

5493

5494

5495

5496

5497

5498

5499

5500

5501

5502

5503

5504

5505

5506

5507

5508

5509

5510

5511

5512

5513

5514

5515

5516

5517

5518

5519

5520

5521

5522

5523

5524

5525

5526

5527

5528

5529

5530

5531

5532

5533

5534

5535

5536

5537

5538

5539

5540

5541

5542

5543

5544

5545

5546

5547

5548

5549

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

r""" 

Dynamical systems on projective schemes 

 

A dynamical system of projective schemes determined by homogeneous 

polynomials functions that define what the morphism does on points 

in the ambient projective space. 

 

The main constructor functions are given by :class:`DynamicalSystem` and 

:class:`DynamicalSystem_projective`. The constructors function can take either 

polynomials or a morphism from which to construct a dynamical system. 

If the domain is not specified, it is constructed. However, if you plan on 

working with points or subvarieties in the domain, it recommended to specify 

the domain. 

 

The initialization checks are always performed by the constructor functions. 

It is possible, but not recommended, to skip these checks by calling the 

class initialization directly. 

 

AUTHORS: 

 

- David Kohel, William Stein 

 

- William Stein (2006-02-11): fixed bug where P(0,0,0) was allowed as 

a projective point. 

 

- Volker Braun (2011-08-08): Renamed classes, more documentation, misc 

cleanups. 

 

- Ben Hutz (2013-03) iteration functionality and new directory structure 

for affine/projective, height functionality 

 

- Brian Stout, Ben Hutz (Nov 2013) - added minimal model functionality 

 

- Dillon Rose (2014-01): Speed enhancements 

 

- Ben Hutz (2015-11): iteration of subschemes 

 

- Ben Hutz (2017-7): relocate code and create class 

 

""" 

 

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

# Copyright (C) 2011 Volker Braun <vbraun.name@gmail.com> 

# Copyright (C) 2006 David Kohel <kohel@maths.usyd.edu.au> 

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

# 

# 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 __future__ import print_function 

from __future__ import absolute_import 

 

from sage.arith.misc import is_prime 

from sage.categories.fields import Fields 

from sage.categories.function_fields import FunctionFields 

from sage.categories.number_fields import NumberFields 

from sage.categories.homset import End 

from sage.dynamics.arithmetic_dynamics.generic_ds import DynamicalSystem 

from sage.functions.all import sqrt 

from sage.functions.other import ceil 

from sage.libs.pari.all import PariError 

from sage.matrix.constructor import matrix, identity_matrix 

from sage.misc.cachefunc import cached_method 

from sage.misc.classcall_metaclass import typecall 

from sage.misc.mrange import xmrange 

from sage.modules.free_module_element import vector 

from sage.rings.all import Integer, CIF 

from sage.arith.all import gcd, lcm, next_prime, binomial, primes, moebius 

from sage.categories.finite_fields import FiniteFields 

from sage.rings.finite_rings.finite_field_constructor import (is_FiniteField, GF, 

is_PrimeFiniteField) 

from sage.rings.finite_rings.integer_mod_ring import Zmod 

from sage.rings.fraction_field import (FractionField, is_FractionField) 

from sage.rings.fraction_field_element import is_FractionFieldElement, FractionFieldElement 

from sage.rings.integer_ring import ZZ 

from sage.rings.morphism import RingHomomorphism_im_gens 

from sage.rings.number_field.number_field_ideal import NumberFieldFractionalIdeal 

from sage.rings.padics.all import Qp 

from sage.rings.polynomial.multi_polynomial_ring_generic import is_MPolynomialRing 

from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing 

from sage.rings.polynomial.polynomial_ring import is_PolynomialRing 

from sage.rings.qqbar import QQbar 

from sage.rings.quotient_ring import QuotientRing_generic 

from sage.rings.rational_field import QQ 

from sage.rings.real_double import RDF 

from sage.rings.real_mpfr import (RealField, is_RealField) 

from sage.schemes.generic.morphism import SchemeMorphism_polynomial 

from sage.schemes.projective.projective_subscheme import AlgebraicScheme_subscheme_projective 

from sage.schemes.projective.projective_morphism import ( 

SchemeMorphism_polynomial_projective_space, 

SchemeMorphism_polynomial_projective_space_field, 

SchemeMorphism_polynomial_projective_space_finite_field) 

from sage.schemes.projective.projective_space import (ProjectiveSpace, 

is_ProjectiveSpace) 

from sage.schemes.product_projective.space import is_ProductProjectiveSpaces 

from sage.symbolic.constants import e 

from copy import copy 

from sage.parallel.ncpus import ncpus 

from sage.parallel.use_fork import p_iter_fork 

from sage.dynamics.arithmetic_dynamics.projective_ds_helper import _fast_possible_periods 

from sage.sets.set import Set 

from sage.combinat.permutation import Arrangements 

from sage.combinat.subset import Subsets 

from sage.symbolic.ring import SR 

 

class DynamicalSystem_projective(SchemeMorphism_polynomial_projective_space, 

DynamicalSystem): 

r"""A dynamical system of projective schemes determined by homogeneous 

polynomials that define what the morphism does on points in the 

ambient projective space. 

 

.. WARNING:: 

 

You should not create objects of this class directly because 

no type or consistency checking is performed. The preferred 

method to construct such dynamical systems is to use 

:func:`~sage.dynamics.arithmetic_dynamics.generic_ds.DynamicalSystem_projective` 

function 

 

INPUT: 

 

- ``morphism_or_polys`` -- a SchemeMorphism, a polynomial, a 

rational function, or a list or tuple of homogeneous polynomials. 

 

- ``domain`` -- optional projective space or projective subscheme. 

 

- ``names`` -- optional tuple of strings to be used as coordinate 

names for a projective space that is constructed; defaults to ``'X','Y'``. 

 

The following combinations of ``morphism_or_polys`` and 

``domain`` are meaningful: 

 

* ``morphism_or_polys`` is a SchemeMorphism; ``domain`` is 

ignored in this case. 

 

* ``morphism_or_polys`` is a list of homogeneous polynomials 

that define a rational endomorphism of ``domain``. 

 

* ``morphism_or_polys`` is a list of homogeneous polynomials and 

``domain`` is unspecified; ``domain`` is then taken to be the 

projective space of appropriate dimension over the base ring of 

the first element of ``morphism_or_polys``. 

 

* ``morphism_or_polys`` is a single polynomial or rational 

function; ``domain`` is ignored and taken to be a 

1-dimensional projective space over the base ring of 

``morphism_or_polys`` with coordinate names given by ``names``. 

 

OUTPUT: :class:`DynamicalSystem_projectve`. 

 

EXAMPLES:: 

 

sage: P1.<x,y> = ProjectiveSpace(QQ,1) 

sage: DynamicalSystem_projective([y, 2*x]) 

Dynamical System of Projective Space of dimension 1 over Rational Field 

Defn: Defined on coordinates by sending (x : y) to 

(y : 2*x) 

 

We can define dynamical systems on `P^1` by giving a polynomial or 

rational function:: 

 

sage: R.<t> = QQ[] 

sage: DynamicalSystem_projective(t^2 - 3) 

Dynamical System of Projective Space of dimension 1 over Rational Field 

Defn: Defined on coordinates by sending (X : Y) to 

(X^2 - 3*Y^2 : Y^2) 

sage: DynamicalSystem_projective(1/t^2) 

Dynamical System of Projective Space of dimension 1 over Rational Field 

Defn: Defined on coordinates by sending (X : Y) to 

(Y^2 : X^2) 

 

:: 

 

sage: R.<x> = PolynomialRing(QQ,1) 

sage: DynamicalSystem_projective(x^2, names=['a','b']) 

Dynamical System of Projective Space of dimension 1 over Rational Field 

Defn: Defined on coordinates by sending (a : b) to 

(a^2 : b^2) 

 

Symbolic Ring elements are not allows:: 

 

sage: x,y = var('x,y') 

sage: DynamicalSystem_projective([x^2,y^2]) 

Traceback (most recent call last): 

... 

ValueError: [x^2, y^2] must be elements of a polynomial ring 

 

:: 

 

sage: R.<x> = PolynomialRing(QQ,1) 

sage: DynamicalSystem_projective(x^2) 

Dynamical System of Projective Space of dimension 1 over Rational Field 

Defn: Defined on coordinates by sending (X : Y) to 

(X^2 : Y^2) 

 

:: 

 

sage: R.<t> = PolynomialRing(QQ) 

sage: P.<x,y,z> = ProjectiveSpace(R, 2) 

sage: X = P.subscheme([x]) 

sage: DynamicalSystem_projective([x^2, t*y^2, x*z], domain=X) 

Dynamical System of Closed subscheme of Projective Space of dimension 

2 over Univariate Polynomial Ring in t over Rational Field defined by: 

x 

Defn: Defined on coordinates by sending (x : y : z) to 

(x^2 : t*y^2 : x*z) 

 

When elements of the quotient ring are used, they are reduced:: 

 

sage: P.<x,y,z> = ProjectiveSpace(CC, 2) 

sage: X = P.subscheme([x-y]) 

sage: u,v,w = X.coordinate_ring().gens() 

sage: DynamicalSystem_projective([u^2, v^2, w*u], domain=X) 

Dynamical System of Closed subscheme of Projective Space of dimension 

2 over Complex Field with 53 bits of precision defined by: 

x - y 

Defn: Defined on coordinates by sending (x : y : z) to 

(y^2 : y^2 : y*z) 

 

We can also compute the forward image of subschemes through 

elimination. In particular, let `X = V(h_1,\ldots, h_t)` and define the ideal 

`I = (h_1,\ldots,h_t,y_0-f_0(\bar{x}), \ldots, y_n-f_n(\bar{x}))`. 

Then the elimination ideal `I_{n+1} = I \cap K[y_0,\ldots,y_n]` is a homogeneous 

ideal and `f(X) = V(I_{n+1})`:: 

 

sage: P.<x,y,z> = ProjectiveSpace(QQ, 2) 

sage: f = DynamicalSystem_projective([(x-2*y)^2, (x-2*z)^2, x^2]) 

sage: X = P.subscheme(y-z) 

sage: f(f(f(X))) 

Closed subscheme of Projective Space of dimension 2 over Rational Field 

defined by: 

y - z 

 

:: 

 

sage: P.<x,y,z,w> = ProjectiveSpace(QQ, 3) 

sage: f = DynamicalSystem_projective([(x-2*y)^2, (x-2*z)^2, (x-2*w)^2, x^2]) 

sage: f(P.subscheme([x,y,z])) 

Closed subscheme of Projective Space of dimension 3 over Rational Field 

defined by: 

w, 

y, 

x 

 

:: 

 

sage: T.<x,y,z,w,u> = ProductProjectiveSpaces([2, 1], QQ) 

sage: DynamicalSystem_projective([x^2*u, y^2*w, z^2*u, w^2, u^2], domain=T) 

Dynamical System of Product of projective spaces P^2 x P^1 over Rational Field 

Defn: Defined by sending (x : y : z , w : u) to 

(x^2*u : y^2*w : z^2*u , w^2 : u^2). 

""" 

 

@staticmethod 

def __classcall_private__(cls, morphism_or_polys, domain=None, names=None): 

r""" 

Return the appropriate dynamical system on a projective scheme. 

 

TESTS:: 

 

sage: R.<x,y> = QQ[] 

sage: P1 = ProjectiveSpace(R) 

sage: f = DynamicalSystem_projective([x-y, x*y]) 

Traceback (most recent call last): 

... 

ValueError: polys (=[x - y, x*y]) must be of the same degree 

sage: DynamicalSystem_projective([x-1, x*y+x]) 

Traceback (most recent call last): 

... 

ValueError: polys (=[x - 1, x*y + x]) must be homogeneous 

 

:: 

 

sage: DynamicalSystem_projective([exp(x),exp(y)]) 

Traceback (most recent call last): 

... 

ValueError: [e^x, e^y] must be elements of a polynomial ring 

 

:: 

 

sage: T.<x,y,z,w,u> = ProductProjectiveSpaces([2, 1], QQ) 

sage: DynamicalSystem_projective([x^2*u, y^2*w, z^2*u, w^2, u*z], domain=T) 

Traceback (most recent call last): 

... 

TypeError: polys (=[x^2*u, y^2*w, z^2*u, w^2, z*u]) must be 

multi-homogeneous of the same degrees (by component) 

 

:: 

 

sage: A.<x,y> = AffineSpace(ZZ, 2) 

sage: DynamicalSystem_projective([x^2,y^2], A) 

Traceback (most recent call last): 

... 

ValueError: "domain" must be a projective scheme 

sage: H = End(A) 

sage: f = H([x,y]) 

sage: DynamicalSystem_projective(f) 

Traceback (most recent call last): 

... 

ValueError: "domain" must be a projective scheme 

 

:: 

 

sage: R.<x> = PolynomialRing(QQ,1) 

sage: DynamicalSystem_projective(x^2, names='t') 

Traceback (most recent call last): 

... 

ValueError: specify 2 variable names 

 

:: 

 

sage: P1.<x,y> = ProjectiveSpace(QQ,1) 

sage: DynamicalSystem_projective([y, x, y], domain=P1) 

Traceback (most recent call last): 

... 

ValueError: polys (=[y, x, y]) do not define a rational endomorphism of the domain 

 

:: 

 

sage: A.<x,y> = AffineSpace(QQ,2) 

sage: DynamicalSystem_projective([y,x], domain=A) 

Traceback (most recent call last): 

... 

ValueError: "domain" must be a projective scheme 

 

:: 

 

sage: R.<x> = QQ[] 

sage: DynamicalSystem([x^2]) 

Traceback (most recent call last): 

... 

ValueError: list/tuple must have at least 2 polynomials 

""" 

from sage.dynamics.arithmetic_dynamics.product_projective_ds import DynamicalSystem_product_projective 

 

if isinstance(morphism_or_polys, SchemeMorphism_polynomial): 

R = morphism_or_polys.base_ring() 

domain = morphism_or_polys.domain() 

polys = list(morphism_or_polys) 

if domain != morphism_or_polys.codomain(): 

raise ValueError('domain and codomain do not agree') 

if not is_ProjectiveSpace(domain) and not isinstance(domain, AlgebraicScheme_subscheme_projective): 

raise ValueError('"domain" must be a projective scheme') 

if R not in Fields(): 

return typecall(cls, polys, domain) 

if is_FiniteField(R): 

return DynamicalSystem_projective_finite_field(polys, domain) 

return DynamicalSystem_projective_field(polys, domain) 

 

if isinstance(morphism_or_polys, (list, tuple)): 

polys = list(morphism_or_polys) 

if len(polys) == 1: 

raise ValueError("list/tuple must have at least 2 polynomials") 

test = lambda x: is_PolynomialRing(x) or is_MPolynomialRing(x) 

if not all(test(poly.parent()) for poly in polys): 

try: 

polys = [poly.lift() for poly in polys] 

except AttributeError: 

raise ValueError('{} must be elements of a polynomial ring'.format(morphism_or_polys)) 

else: 

# homogenize! 

f = morphism_or_polys 

aff_CR = f.parent() 

if (not is_PolynomialRing(aff_CR) and not is_FractionField(aff_CR) 

and not (is_MPolynomialRing(aff_CR) and aff_CR.ngens() == 1)): 

msg = '{} is not a single variable polynomial or rational function' 

raise ValueError(msg.format(f)) 

if is_FractionField(aff_CR): 

polys = [f.numerator(),f.denominator()] 

else: 

polys = [f, aff_CR(1)] 

d = max(poly.degree() for poly in polys) 

if names is None: 

names = ('X','Y') 

elif len(names) != 2: 

raise ValueError('specify 2 variable names') 

proj_CR = PolynomialRing(aff_CR.base_ring(), names=names) 

X,Y = proj_CR.gens() 

polys = [proj_CR(Y**d * poly(X/Y)) for poly in polys] 

if domain is None: 

f = polys[0] 

proj_CR = f.parent() 

domain = ProjectiveSpace(proj_CR) 

R = domain.base_ring() 

if R is SR: 

raise TypeError("Symbolic Ring cannot be the base ring") 

 

if len(polys) != domain.ambient_space().coordinate_ring().ngens(): 

msg = 'polys (={}) do not define a rational endomorphism of the domain' 

raise ValueError(msg.format(polys)) 

 

if is_ProductProjectiveSpaces(domain): 

splitpolys = domain._factors(polys) 

for split_poly in splitpolys: 

split_d = domain._degree(split_poly[0]) 

if not all(split_d == domain._degree(f) for f in split_poly): 

msg = 'polys (={}) must be multi-homogeneous of the same degrees (by component)' 

raise TypeError(msg.format(polys)) 

return DynamicalSystem_product_projective(polys, domain) 

 

# Now polys define an endomorphism of a scheme in P^n 

if not all(poly.is_homogeneous() for poly in polys): 

msg = 'polys (={}) must be homogeneous' 

raise ValueError(msg.format(polys)) 

d = polys[0].degree() 

if not all(poly.degree() == d for poly in polys): 

msg = 'polys (={}) must be of the same degree' 

raise ValueError(msg.format(polys)) 

 

if not is_ProjectiveSpace(domain) and not isinstance(domain, AlgebraicScheme_subscheme_projective): 

raise ValueError('"domain" must be a projective scheme') 

if R not in Fields(): 

return typecall(cls, polys, domain) 

if is_FiniteField(R): 

return DynamicalSystem_projective_finite_field(polys, domain) 

return DynamicalSystem_projective_field(polys, domain) 

 

def __init__(self, polys, domain): 

r""" 

The Python constructor. 

 

See :class:`DynamicalSystem` for details. 

 

EXAMPLES:: 

 

sage: P.<x,y> = ProjectiveSpace(QQ, 1) 

sage: DynamicalSystem_projective([3/5*x^2, y^2], domain=P) 

Dynamical System of Projective Space of dimension 1 over Rational Field 

Defn: Defined on coordinates by sending (x : y) to 

(3/5*x^2 : y^2) 

""" 

# Next attribute needed for _fast_eval and _fastpolys 

self._is_prime_finite_field = is_PrimeFiniteField(polys[0].base_ring()) 

DynamicalSystem.__init__(self,polys,domain) 

 

def __copy__(self): 

r""" 

Return a copy of this dynamical system. 

 

OUTPUT: :class:`DynamicalSystem_projective` 

 

EXAMPLES:: 

 

sage: P.<x,y> = ProjectiveSpace(QQ,1) 

sage: f = DynamicalSystem_projective([3/5*x^2,6*y^2]) 

sage: g = copy(f) 

sage: f == g 

True 

sage: f is g 

False 

""" 

return DynamicalSystem_projective(self._polys, self.domain()) 

 

def dehomogenize(self, n): 

r""" 

Return the standard dehomogenization at the ``n[0]`` coordinate 

for the domain and the ``n[1]`` coordinate for the codomain. 

 

Note that the new function is defined over the fraction field 

of the base ring of this map. 

 

INPUT: 

 

- ``n`` -- a tuple of nonnegative integers; if ``n`` is an integer, 

then the two values of the tuple are assumed to be the same 

 

OUTPUT: 

 

:class:`DynamicalSystem_affine` given by dehomogenizing the 

source and target of `self` with respect to the given indices. 

 

EXAMPLES:: 

 

sage: P.<x,y> = ProjectiveSpace(ZZ,1) 

sage: f = DynamicalSystem_projective([x^2+y^2, y^2]) 

sage: f.dehomogenize(0) 

Dynamical System of Affine Space of dimension 1 over Integer Ring 

Defn: Defined on coordinates by sending (x) to 

(x^2/(x^2 + 1)) 

""" 

F = self.as_scheme_morphism().dehomogenize(n) 

return F.as_dynamical_system() 

 

def dynatomic_polynomial(self, period): 

r""" 

For a dynamical system of `\mathbb{P}^1` compute the dynatomic 

polynomial. 

 

The dynatomic polynomial is the analog of the cyclotomic 

polynomial and its roots are the points of formal period `period`. 

If possible the division is done in the coordinate ring of this 

map and a polynomial is returned. In rings where that is not 

possible, a :class:`FractionField` element will be returned. 

In certain cases, when the conversion back to a polynomial fails, 

a :class:`SymbolRing` element will be returned. 

 

ALGORITHM: 

 

For a positive integer `n`, let `[F_n,G_n]` be the coordinates of the `nth` 

iterate of `f`. Then construct 

 

.. MATH:: 

 

\Phi^{\ast}_n(f)(x,y) = \sum_{d \mid n} 

(yF_d(x,y) - xG_d(x,y))^{\mu(n/d)}, 

 

where `\mu` is the Möbius function. 

 

For a pair `[m,n]`, let `f^m = [F_m,G_m]`. Compute 

 

.. MATH:: 

 

\Phi^{\ast}_{m,n}(f)(x,y) = \Phi^{\ast}_n(f)(F_m,G_m) / 

\Phi^{\ast}_n(f)(F_{m-1},G_{m-1}) 

 

REFERENCES: 

 

- [Hutz2015]_ 

- [MoPa1994]_ 

 

INPUT: 

 

- ``period`` -- a positive integer or a list/tuple `[m,n]` where 

`m` is the preperiod and `n` is the period 

 

OUTPUT: 

 

If possible, a two variable polynomial in the coordinate ring 

of this map. Otherwise a fraction field element of the coordinate 

ring of this map. Or, a :class:`SymbolicRing` element. 

 

.. TODO:: 

 

- Do the division when the base ring is `p`-adic so that 

the output is a polynomial. 

 

- Convert back to a polynomial when the base ring is a 

function field (not over `\QQ` or `F_p`). 

 

EXAMPLES:: 

 

sage: P.<x,y> = ProjectiveSpace(QQ,1) 

sage: f = DynamicalSystem_projective([x^2 + y^2, y^2]) 

sage: f.dynatomic_polynomial(2) 

x^2 + x*y + 2*y^2 

 

:: 

 

sage: P.<x,y> = ProjectiveSpace(ZZ,1) 

sage: f = DynamicalSystem_projective([x^2 + y^2, x*y]) 

sage: f.dynatomic_polynomial(4) 

2*x^12 + 18*x^10*y^2 + 57*x^8*y^4 + 79*x^6*y^6 + 48*x^4*y^8 + 12*x^2*y^10 + y^12 

 

:: 

 

sage: P.<x,y> = ProjectiveSpace(CC,1) 

sage: f = DynamicalSystem_projective([x^2 + y^2, 3*x*y]) 

sage: f.dynatomic_polynomial(3) 

13.0000000000000*x^6 + 117.000000000000*x^4*y^2 + 

78.0000000000000*x^2*y^4 + y^6 

 

:: 

 

sage: P.<x,y> = ProjectiveSpace(QQ,1) 

sage: f = DynamicalSystem_projective([x^2 - 10/9*y^2, y^2]) 

sage: f.dynatomic_polynomial([2,1]) 

x^4*y^2 - 11/9*x^2*y^4 - 80/81*y^6 

 

:: 

 

sage: P.<x,y> = ProjectiveSpace(QQ,1) 

sage: f = DynamicalSystem_projective([x^2 - 29/16*y^2, y^2]) 

sage: f.dynatomic_polynomial([2,3]) 

x^12 - 95/8*x^10*y^2 + 13799/256*x^8*y^4 - 119953/1024*x^6*y^6 + 

8198847/65536*x^4*y^8 - 31492431/524288*x^2*y^10 + 

172692729/16777216*y^12 

 

:: 

 

sage: P.<x,y> = ProjectiveSpace(ZZ,1) 

sage: f = DynamicalSystem_projective([x^2 - y^2, y^2]) 

sage: f.dynatomic_polynomial([1,2]) 

x^2 - x*y 

 

:: 

 

sage: P.<x,y> = ProjectiveSpace(QQ,1) 

sage: f = DynamicalSystem_projective([x^3 - y^3, 3*x*y^2]) 

sage: f.dynatomic_polynomial([0,4])==f.dynatomic_polynomial(4) 

True 

 

:: 

 

sage: P.<x,y,z> = ProjectiveSpace(QQ,2) 

sage: f = DynamicalSystem_projective([x^2 + y^2, x*y, z^2]) 

sage: f.dynatomic_polynomial(2) 

Traceback (most recent call last): 

... 

TypeError: does not make sense in dimension >1 

 

:: 

 

sage: P.<x,y> = ProjectiveSpace(Qp(5),1) 

sage: f = DynamicalSystem_projective([x^2 + y^2, y^2]) 

sage: f.dynatomic_polynomial(2) 

(x^4*y + (2 + O(5^20))*x^2*y^3 - x*y^4 + (2 + O(5^20))*y^5)/(x^2*y - 

x*y^2 + y^3) 

 

:: 

 

sage: L.<t> = PolynomialRing(QQ) 

sage: P.<x,y> = ProjectiveSpace(L,1) 

sage: f = DynamicalSystem_projective([x^2 + t*y^2, y^2]) 

sage: f.dynatomic_polynomial(2) 

x^2 + x*y + (t + 1)*y^2 

 

:: 

 

sage: K.<c> = PolynomialRing(ZZ) 

sage: P.<x,y> = ProjectiveSpace(K,1) 

sage: f = DynamicalSystem_projective([x^2 + c*y^2, y^2]) 

sage: f.dynatomic_polynomial([1, 2]) 

x^2 - x*y + (c + 1)*y^2 

 

:: 

 

sage: P.<x,y> = ProjectiveSpace(QQ,1) 

sage: f = DynamicalSystem_projective([x^2 + y^2, y^2]) 

sage: f.dynatomic_polynomial(2) 

x^2 + x*y + 2*y^2 

sage: R.<X> = PolynomialRing(QQ) 

sage: K.<c> = NumberField(X^2 + X + 2) 

sage: PP = P.change_ring(K) 

sage: ff = f.change_ring(K) 

sage: p = PP((c, 1)) 

sage: ff(ff(p)) == p 

True 

 

:: 

 

sage: P.<x,y> = ProjectiveSpace(QQ,1) 

sage: f = DynamicalSystem_projective([x^2 + y^2, x*y]) 

sage: f.dynatomic_polynomial([2, 2]) 

x^4 + 4*x^2*y^2 + y^4 

sage: R.<X> = PolynomialRing(QQ) 

sage: K.<c> = NumberField(X^4 + 4*X^2 + 1) 

sage: PP = P.change_ring(K) 

sage: ff = f.change_ring(K) 

sage: p = PP((c, 1)) 

sage: ff.nth_iterate(p, 4) == ff.nth_iterate(p, 2) 

True 

 

:: 

 

sage: P.<x,y> = ProjectiveSpace(CC, 1) 

sage: f = DynamicalSystem_projective([x^2 - CC.0/3*y^2, y^2]) 

sage: f.dynatomic_polynomial(2) 

(x^4*y + (-0.666666666666667*I)*x^2*y^3 - x*y^4 + (-0.111111111111111 - 0.333333333333333*I)*y^5)/(x^2*y - x*y^2 + (-0.333333333333333*I)*y^3) 

 

:: 

 

sage: P.<x,y> = ProjectiveSpace(CC, 1) 

sage: f = DynamicalSystem_projective([x^2-CC.0/5*y^2, y^2]) 

sage: f.dynatomic_polynomial(2) 

x^2 + x*y + (1.00000000000000 - 0.200000000000000*I)*y^2 

 

:: 

 

sage: L.<t> = PolynomialRing(QuadraticField(2).maximal_order()) 

sage: P.<x, y> = ProjectiveSpace(L.fraction_field() , 1) 

sage: f = DynamicalSystem_projective([x^2 + (t^2 + 1)*y^2 , y^2]) 

sage: f.dynatomic_polynomial(2) 

x^2 + x*y + (t^2 + 2)*y^2 

 

:: 

 

sage: P.<x,y> = ProjectiveSpace(ZZ, 1) 

sage: f = DynamicalSystem_projective([x^2 - 5*y^2, y^2]) 

sage: f.dynatomic_polynomial([3,0 ]) 

0 

 

TESTS: 

 

We check that the dynatomic polynomial has the right 

parent (see :trac:`18409`):: 

 

sage: P.<x,y> = ProjectiveSpace(QQbar,1) 

sage: f = DynamicalSystem_projective([x^2 - 1/3*y^2, y^2]) 

sage: f.dynatomic_polynomial(2).parent() 

Multivariate Polynomial Ring in x, y over Algebraic Field 

 

:: 

 

sage: T.<v> = QuadraticField(33) 

sage: S.<t> = PolynomialRing(T) 

sage: P.<x,y> = ProjectiveSpace(FractionField(S),1) 

sage: f = DynamicalSystem_projective([t*x^2 - 1/t*y^2, y^2]) 

sage: f.dynatomic_polynomial([1, 2]).parent() 

Multivariate Polynomial Ring in x, y over Fraction Field of Univariate Polynomial 

Ring in t over Number Field in v with defining polynomial x^2 - 33 

 

:: 

 

sage: P.<x, y> = ProjectiveSpace(QQ, 1) 

sage: f = DynamicalSystem_projective([x^3 - y^3*2, y^3]) 

sage: f.dynatomic_polynomial(1).parent() 

Multivariate Polynomial Ring in x, y over Rational Field 

 

:: 

 

sage: R.<c> = QQ[] 

sage: P.<x,y> = ProjectiveSpace(R,1) 

sage: f = DynamicalSystem_projective([x^2 + c*y^2, y^2]) 

sage: f.dynatomic_polynomial([1,2]).parent() 

Multivariate Polynomial Ring in x, y over Univariate 

Polynomial Ring in c over Rational Field 

 

:: 

 

sage: R.<c> = QQ[] 

sage: P.<x,y> = ProjectiveSpace(ZZ,1) 

sage: f = DynamicalSystem_projective([x^2 + y^2, (1)*y^2 + (1)*x*y]) 

sage: f.dynatomic_polynomial([1,2]).parent() 

Multivariate Polynomial Ring in x, y over Integer Ring 

 

:: 

 

sage: P.<x, y> = ProjectiveSpace(QQ, 1) 

sage: f = DynamicalSystem_projective([x^2 + y^2, y^2]) 

sage: f.dynatomic_polynomial(0) 

0 

sage: f.dynatomic_polynomial([0,0]) 

0 

sage: f.dynatomic_polynomial(-1) 

Traceback (most recent call last): 

... 

TypeError: period must be a positive integer 

 

:: 

 

sage: R.<c> = QQ[] 

sage: P.<x,y> = ProjectiveSpace(R,1) 

sage: f = DynamicalSystem_projective([x^2 + c*y^2,y^2]) 

sage: f.dynatomic_polynomial([1,2]).parent() 

Multivariate Polynomial Ring in x, y over Univariate Polynomial Ring in 

c over Rational Field 

 

Some rings still return :class:`SymoblicRing` elements:: 

 

sage: S.<t> = FunctionField(CC) 

sage: P.<x,y> = ProjectiveSpace(S,1) 

sage: f = DynamicalSystem_projective([t*x^2-1*y^2, t*y^2]) 

sage: f.dynatomic_polynomial([1, 2]).parent() 

Symbolic Ring 

 

:: 

 

sage: R.<x,y> = PolynomialRing(QQ) 

sage: S = R.quo(R.ideal(y^2-x+1)) 

sage: P.<u,v> = ProjectiveSpace(FractionField(S),1) 

sage: f = DynamicalSystem_projective([u^2 + S(x^2)*v^2, v^2]) 

sage: dyn = f.dynatomic_polynomial([1,1]); dyn 

v^3*xbar^2 + u^2*v + u*v^2 

sage: dyn.parent() 

Symbolic Ring 

""" 

if self.domain().ngens() > 2: 

raise TypeError("does not make sense in dimension >1") 

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

period = [0, period] 

x = self.domain().gen(0) 

y = self.domain().gen(1) 

f0, f1 = F0, F1 = self._polys 

PHI = self.base_ring().one() 

m = period[0] 

n = int(period[1]) 

if n < 0: 

raise TypeError("period must be a positive integer") 

if n == 0: 

return self[0].parent().zero() 

if m == 0 and n == 1: 

return y*F0 - x*F1 

for d in range(1, n): 

if n % d == 0: 

PHI = PHI * ((y*F0 - x*F1)**moebius(n//d)) 

F0, F1 = f0(F0, F1), f1(F0, F1) 

PHI = PHI * (y*F0 - x*F1) 

if m != 0: 

fm = self.nth_iterate_map(m) 

fm1 = self.nth_iterate_map(m - 1) 

try: 

QR = PHI.numerator().quo_rem(PHI.denominator()) 

if not QR[1]: 

PHI = QR[0] 

if m != 0: 

PHI = PHI(fm._polys)/(PHI(fm1._polys)) 

QR = PHI.numerator().quo_rem(PHI.denominator()) 

if QR[1] == 0: 

PHI = QR[0] 

return PHI 

except (TypeError, NotImplementedError): # something Singular can't handle 

if m != 0: 

PHI = PHI(fm._polys) / PHI(fm1._polys) 

#even when the ring can be passed to singular in quo_rem, 

#it can't always do the division, so we call Maxima 

from sage.rings.padics.generic_nodes import is_pAdicField, is_pAdicRing 

if period != [0,1]: #period==[0,1] we don't need to do any division 

BR = self.domain().base_ring().base_ring() 

if not (is_pAdicRing(BR) or is_pAdicField(BR)): 

try: 

QR2 = PHI.numerator()._maxima_().divide(PHI.denominator()) 

if not QR2[1].sage(): 

# do it again to divide out by denominators of coefficients 

PHI = QR2[0].sage() 

PHI = PHI.numerator()._maxima_().divide(PHI.denominator())[0].sage() 

if not is_FractionFieldElement(PHI): 

from sage.symbolic.expression_conversions import polynomial 

PHI = polynomial(PHI, ring=self.coordinate_ring()) 

except (TypeError, NotImplementedError): #something Maxima, or the conversion, can't handle 

pass 

return PHI 

 

def nth_iterate_map(self, n, normalize=False): 

r""" 

Return the ``n``-th iterate of this dynamical system. 

 

ALGORITHM: 

 

Uses a form of successive squaring to reducing computations. 

 

.. TODO:: This could be improved. 

 

INPUT: 

 

- ``n`` -- positive integer 

 

- ``normalize`` -- boolean; remove gcd's during iteration 

 

OUTPUT: a projective dynamical system 

 

EXAMPLES:: 

 

sage: P.<x,y> = ProjectiveSpace(QQ,1) 

sage: f = DynamicalSystem_projective([x^2+y^2, y^2]) 

sage: f.nth_iterate_map(2) 

Dynamical System of Projective Space of dimension 1 over Rational 

Field 

Defn: Defined on coordinates by sending (x : y) to 

(x^4 + 2*x^2*y^2 + 2*y^4 : y^4) 

 

:: 

 

sage: P.<x,y> = ProjectiveSpace(CC,1) 

sage: f = DynamicalSystem_projective([x^2-y^2, x*y]) 

sage: f.nth_iterate_map(3) 

Dynamical System of Projective Space of dimension 1 over Complex 

Field with 53 bits of precision 

Defn: Defined on coordinates by sending (x : y) to 

(x^8 + (-7.00000000000000)*x^6*y^2 + 13.0000000000000*x^4*y^4 + 

(-7.00000000000000)*x^2*y^6 + y^8 : x^7*y + (-4.00000000000000)*x^5*y^3 

+ 4.00000000000000*x^3*y^5 - x*y^7) 

 

:: 

 

sage: P.<x,y,z> = ProjectiveSpace(ZZ,2) 

sage: f = DynamicalSystem_projective([x^2-y^2, x*y, z^2+x^2]) 

sage: f.nth_iterate_map(2) 

Dynamical System of Projective Space of dimension 2 over Integer Ring 

Defn: Defined on coordinates by sending (x : y : z) to 

(x^4 - 3*x^2*y^2 + y^4 : x^3*y - x*y^3 : 2*x^4 - 2*x^2*y^2 + y^4 

+ 2*x^2*z^2 + z^4) 

 

:: 

 

sage: P.<x,y,z> = ProjectiveSpace(QQ,2) 

sage: X = P.subscheme(x*z-y^2) 

sage: f = DynamicalSystem_projective([x^2, x*z, z^2], domain=X) 

sage: f.nth_iterate_map(2) 

Dynamical System of Closed subscheme of Projective Space of dimension 

2 over Rational Field defined by: 

-y^2 + x*z 

Defn: Defined on coordinates by sending (x : y : z) to 

(x^4 : x^2*z^2 : z^4) 

 

:: 

 

sage: P.<x,y,z> = ProjectiveSpace(QQ, 2) 

sage: f = DynamicalSystem_projective([y^2 * z^3, y^3 * z^2, x^5]) 

sage: f.nth_iterate_map( 5, normalize=True) 

Dynamical System of Projective Space of dimension 2 over Rational 

Field 

Defn: Defined on coordinates by sending (x : y : z) to 

(y^202*z^443 : x^140*y^163*z^342 : x^645) 

""" 

D = int(n) 

if D < 0: 

raise TypeError("iterate number must be a positive integer") 

if D == 1: 

return self 

H = End(self.domain()) 

N = self.codomain().ambient_space().dimension_relative() + 1 

F = copy(self) 

Coord_ring = self.codomain().coordinate_ring() 

if isinstance(Coord_ring, QuotientRing_generic): 

PHI = H([Coord_ring.gen(i).lift() for i in range(N)])#makes a mapping 

else: 

PHI = H([Coord_ring.gen(i) for i in range(N)]) 

while D: 

if D&1: 

PHI = PHI*F 

if normalize: 

PHI.normalize_coordinates() 

if D > 1: #avoid extra iterate 

F = F*F 

if normalize: 

F.normalize_coordinates() 

D >>= 1 

return PHI.as_dynamical_system() 

 

def nth_iterate(self, P, n, **kwds): 

r""" 

Return the ``n``-th iterate of the point ``P`` by this 

dynamical system. 

 

If ``normalize`` is ``True``, then the coordinates are 

automatically normalized. 

 

.. TODO:: Is there a more efficient way to do this? 

 

INPUT: 

 

- ``P`` -- a point in this map's domain 

 

- ``n`` -- a positive integer 

 

kwds: 

 

- ``normalize`` -- (default: ``False``) boolean 

 

OUTPUT: a point in this map's codomain 

 

EXAMPLES:: 

 

sage: P.<x,y> = ProjectiveSpace(ZZ,1) 

sage: f = DynamicalSystem_projective([x^2+y^2, 2*y^2]) 

sage: Q = P(1,1) 

sage: f.nth_iterate(Q,4) 

(32768 : 32768) 

 

:: 

 

sage: P.<x,y> = ProjectiveSpace(ZZ,1) 

sage: f = DynamicalSystem_projective([x^2+y^2, 2*y^2]) 

sage: Q = P(1,1) 

sage: f.nth_iterate(Q, 4, normalize=True) 

(1 : 1) 

 

:: 

 

sage: P.<x,y,z> = ProjectiveSpace(QQ,2) 

sage: f = DynamicalSystem_projective([x^2, 2*y^2, z^2-x^2]) 

sage: Q = P(2,7,1) 

sage: f.nth_iterate(Q,2) 

(-16/7 : -2744 : 1) 

 

:: 

 

sage: R.<t> = PolynomialRing(QQ) 

sage: P.<x,y,z> = ProjectiveSpace(R,2) 

sage: f = DynamicalSystem_projective([x^2+t*y^2, (2-t)*y^2, z^2]) 

sage: Q = P(2+t,7,t) 

sage: f.nth_iterate(Q,2) 

(t^4 + 2507*t^3 - 6787*t^2 + 10028*t + 16 : -2401*t^3 + 14406*t^2 - 

28812*t + 19208 : t^4) 

 

:: 

 

sage: P.<x,y,z> = ProjectiveSpace(ZZ,2) 

sage: X = P.subscheme(x^2-y^2) 

sage: f = DynamicalSystem_projective([x^2, y^2, z^2], domain=X) 

sage: f.nth_iterate(X(2,2,3), 3) 

(256 : 256 : 6561) 

 

:: 

 

sage: K.<c> = FunctionField(QQ) 

sage: P.<x,y> = ProjectiveSpace(K,1) 

sage: f = DynamicalSystem_projective([x^3 - 2*x*y^2 - c*y^3, x*y^2]) 

sage: f.nth_iterate(P(c,1), 2) 

((c^6 - 9*c^4 + 25*c^2 - c - 21)/(c^2 - 3) : 1) 

 

sage: P.<x,y,z> = ProjectiveSpace(QQ,2) 

sage: H = Hom(P,P) 

sage: f = H([x^2+3*y^2, 2*y^2,z^2]) 

sage: P(2, 7, 1).nth_iterate(f, -2) 

Traceback (most recent call last): 

... 

TypeError: must be a forward orbit 

 

:: 

 

sage: P.<x,y> = ProjectiveSpace(QQ, 1) 

sage: f = DynamicalSystem_projective([x^3, x*y^2], domain=P) 

sage: f.nth_iterate(P(0, 1), 3, check=False) 

(0 : 0) 

sage: f.nth_iterate(P(0, 1), 3) 

Traceback (most recent call last): 

... 

ValueError: [0, 0] does not define a valid point since all entries are 0 

 

:: 

 

sage: P.<x,y> = ProjectiveSpace(ZZ, 1) 

sage: f = DynamicalSystem_projective([x^3, x*y^2], domain=P) 

sage: f.nth_iterate(P(2,1), 3, normalize=False) 

(134217728 : 524288) 

sage: f.nth_iterate(P(2,1), 3, normalize=True) 

(256 : 1) 

""" 

n = ZZ(n) 

if n < 0: 

raise TypeError("must be a forward orbit") 

return self.orbit(P, [n,n+1], **kwds)[0] 

 

def degree_sequence(self, iterates=2): 

r""" 

Return sequence of degrees of normalized iterates starting with 

the degree of this dynamical system. 

 

INPUT: ``iterates`` -- (default: 2) positive integer 

 

OUTPUT: list of integers 

 

EXAMPLES:: 

 

sage: P2.<X,Y,Z> = ProjectiveSpace(QQ, 2) 

sage: f = DynamicalSystem_projective([Z^2, X*Y, Y^2]) 

sage: f.degree_sequence(15) 

[2, 3, 5, 8, 11, 17, 24, 31, 45, 56, 68, 91, 93, 184, 275] 

 

:: 

 

sage: F.<t> = PolynomialRing(QQ) 

sage: P2.<X,Y,Z> = ProjectiveSpace(F, 2) 

sage: f = DynamicalSystem_projective([Y*Z, X*Y, Y^2 + t*X*Z]) 

sage: f.degree_sequence(5) 

[2, 3, 5, 8, 13] 

 

:: 

 

sage: P2.<X,Y,Z> = ProjectiveSpace(QQ, 2) 

sage: f = DynamicalSystem_projective([X^2, Y^2, Z^2]) 

sage: f.degree_sequence(10) 

[2, 4, 8, 16, 32, 64, 128, 256, 512, 1024] 

 

:: 

 

sage: P2.<X,Y,Z> = ProjectiveSpace(ZZ, 2) 

sage: f = DynamicalSystem_projective([X*Y, Y*Z+Z^2, Z^2]) 

sage: f.degree_sequence(10) 

[2, 3, 4, 5, 6, 7, 8, 9, 10, 11] 

""" 

if int(iterates) < 1: 

raise TypeError("number of iterates must be a positive integer") 

 

if self.is_morphism(): 

d = self.degree() 

D = [d**t for t in range(1, iterates+1)] 

else: 

F = self 

F.normalize_coordinates() 

D = [F.degree()] 

for n in range(2, iterates+1): 

F = F*self 

F.normalize_coordinates() 

D.append(F.degree()) 

return D 

 

def dynamical_degree(self, N=3, prec=53): 

r""" 

Return an approximation to the dynamical degree of this dynamical 

system. The dynamical degree is defined as 

`\lim_{n \to \infty} \sqrt[n]{\deg(f^n)}`. 

 

INPUT: 

 

- ``N`` -- (default: 3) positive integer, iterate to use 

for approximation 

 

- ``prec`` -- (default: 53) positive integer, real precision 

to use when computing root 

 

OUTPUT: real number 

 

EXAMPLES:: 

 

sage: P.<x,y> = ProjectiveSpace(QQ, 1) 

sage: f = DynamicalSystem_projective([x^2 + (x*y), y^2]) 

sage: f.dynamical_degree() 

2.00000000000000 

 

:: 

 

sage: P2.<X,Y,Z> = ProjectiveSpace(ZZ, 2) 

sage: f = DynamicalSystem_projective([X*Y, Y*Z+Z^2, Z^2]) 

sage: f.dynamical_degree(N=5, prec=100) 

1.4309690811052555010452244131 

""" 

if int(N) < 1: 

raise TypeError("number of iterates must be a positive integer") 

 

R = RealField(prec=prec) 

if self.is_morphism(): 

return R(self.degree()) 

else: 

D = self.nth_iterate_map(N, normalize=True).degree() 

return R(D).nth_root(N) 

 

def orbit(self, P, N, **kwds): 

r""" 

Return the orbit of the point ``P`` by this dynamical system. 

 

Let `F` be this dynamical system. If ``N`` is an integer return 

`[P,F(P),\ldots,F^N(P)]`. If ``N`` is a list or tuple `N=[m,k]` 

return `[F^m(P),\ldots,F^k(P)]`. 

Automatically normalize the points if ``normalize=True``. Perform 

the checks on point initialization if ``check=True``. 

 

INPUT: 

 

- ``P`` -- a point in this dynamical system's domain 

 

- ``n`` -- a non-negative integer or list or tuple of two 

non-negative integers 

 

kwds: 

 

- ``check`` -- (default: ``True``) boolean 

 

- ``normalize`` -- (default: ``False``) boolean 

 

OUTPUT: a list of points in this dynamical system's codomain 

 

EXAMPLES:: 

 

sage: P.<x,y,z> = ProjectiveSpace(ZZ,2) 

sage: f = DynamicalSystem_projective([x^2+y^2, y^2-z^2, 2*z^2]) 

sage: f.orbit(P(1,2,1), 3) 

[(1 : 2 : 1), (5 : 3 : 2), (34 : 5 : 8), (1181 : -39 : 128)] 

 

:: 

 

sage: P.<x,y,z> = ProjectiveSpace(ZZ,2) 

sage: f = DynamicalSystem_projective([x^2+y^2, y^2-z^2, 2*z^2]) 

sage: f.orbit(P(1,2,1), [2,4]) 

[(34 : 5 : 8), (1181 : -39 : 128), (1396282 : -14863 : 32768)] 

 

:: 

 

sage: P.<x,y,z> = ProjectiveSpace(ZZ,2) 

sage: X = P.subscheme(x^2-y^2) 

sage: f = DynamicalSystem_projective([x^2, y^2, x*z], domain=X) 

sage: f.orbit(X(2,2,3), 3, normalize=True) 

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

 

:: 

 

sage: P.<x,y> = ProjectiveSpace(QQ,1) 

sage: f = DynamicalSystem_projective([x^2+y^2, y^2]) 

sage: f.orbit(P.point([1,2],False), 4, check=False) 

[(1 : 2), (5 : 4), (41 : 16), (1937 : 256), (3817505 : 65536)] 

 

:: 

 

sage: K.<c> = FunctionField(QQ) 

sage: P.<x,y> = ProjectiveSpace(K,1) 

sage: f = DynamicalSystem_projective([x^2+c*y^2, y^2]) 

sage: f.orbit(P(0,1), 3) 

[(0 : 1), (c : 1), (c^2 + c : 1), (c^4 + 2*c^3 + c^2 + c : 1)] 

 

:: 

 

sage: P.<x,y> = ProjectiveSpace(QQ,1) 

sage: f = DynamicalSystem_projective([x^2+y^2,y^2], domain=P) 

sage: f.orbit(P.point([1, 2], False), 4, check=False) 

[(1 : 2), (5 : 4), (41 : 16), (1937 : 256), (3817505 : 65536)] 

 

:: 

 

sage: P.<x,y> = ProjectiveSpace(QQ,1) 

sage: f = DynamicalSystem_projective([x^2, 2*y^2], domain=P) 

sage: P(2, 1).orbit(f,[-1, 4]) 

Traceback (most recent call last): 

... 

TypeError: orbit bounds must be non-negative 

sage: P(2, 1).orbit(f, 0.1) 

Traceback (most recent call last): 

... 

TypeError: Attempt to coerce non-integral RealNumber to Integer 

 

:: 

 

sage: P.<x,y> = ProjectiveSpace(QQ,1) 

sage: f = DynamicalSystem_projective([x^3, x*y^2], domain=P) 

sage: P(0, 1).orbit(f, 3) 

Traceback (most recent call last): 

... 

ValueError: [0, 0] does not define a valid point since all entries are 0 

sage: P(0, 1).orbit(f, 3, check=False) 

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

 

:: 

 

sage: P.<x,y> = ProjectiveSpace(ZZ, 1) 

sage: f = DynamicalSystem_projective([x^3, x*y^2], domain=P) 

sage: P(2,1).orbit(f, 3, normalize=False) 

[(2 : 1), (8 : 2), (512 : 32), (134217728 : 524288)] 

sage: P(2, 1).orbit(f, 3, normalize=True) 

[(2 : 1), (4 : 1), (16 : 1), (256 : 1)] 

""" 

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

N = [0,N] 

N[0] = ZZ(N[0]) 

N[1] = ZZ(N[1]) 

if N[0] < 0 or N[1] < 0: 

raise TypeError("orbit bounds must be non-negative") 

if N[0] > N[1]: 

return([]) 

 

Q = P 

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

normalize = kwds.pop("normalize",False) 

 

if normalize: 

Q.normalize_coordinates() 

for i in range(1, N[0]+1): 

Q = self(Q, check) 

if normalize: 

Q.normalize_coordinates() 

orb = [Q] 

for i in range(N[0]+1, N[1]+1): 

Q = self(Q, check) 

if normalize: 

Q.normalize_coordinates() 

orb.append(Q) 

return(orb) 

 

def resultant(self, normalize=False): 

r""" 

Computes the resultant of the defining polynomials of 

this dynamical system. 

 

If ``normalize`` is ``True``, then first normalize the coordinate 

functions with :meth:`normalize_coordinates`. 

 

INPUT: 

 

- ``normalize`` -- (default: ``False``) boolean 

 

OUTPUT: an element of the base ring of this map 

 

EXAMPLES:: 

 

sage: P.<x,y> = ProjectiveSpace(QQ,1) 

sage: f = DynamicalSystem_projective([x^2+y^2, 6*y^2]) 

sage: f.resultant() 

36 

 

:: 

 

sage: R.<t> = PolynomialRing(GF(17)) 

sage: P.<x,y> = ProjectiveSpace(R,1) 

sage: f = DynamicalSystem_projective([t*x^2+t*y^2, 6*y^2]) 

sage: f.resultant() 

2*t^2 

 

:: 

 

sage: R.<t> = PolynomialRing(GF(17)) 

sage: P.<x,y,z> = ProjectiveSpace(R,2) 

sage: f = DynamicalSystem_projective([t*x^2+t*y^2, 6*y^2, 2*t*z^2]) 

sage: f.resultant() 

13*t^8 

 

:: 

 

sage: P.<x,y,z> = ProjectiveSpace(QQ,2) 

sage: F = DynamicalSystem_projective([x^2+y^2,6*y^2,10*x*z+z^2+y^2]) 

sage: F.resultant() 

1296 

 

:: 

 

sage: R.<t>=PolynomialRing(QQ) 

sage: s = (t^3+t+1).roots(QQbar)[0][0] 

sage: P.<x,y>=ProjectiveSpace(QQbar,1) 

sage: f = DynamicalSystem_projective([s*x^3-13*y^3, y^3-15*y^3]) 

sage: f.resultant() 

871.6925062959149? 

""" 

if normalize: 

F = copy(self) 

F.normalize_coordinates() 

else: 

F = self 

 

if self.domain().dimension_relative() == 1: 

x = self.domain().gen(0) 

y = self.domain().gen(1) 

d = self.degree() 

f = F[0].substitute({y:1}) 

g = F[1].substitute({y:1}) 

#Try to use pari first, as it is faster for one dimensional case 

#however the coercion from a Pari object to a sage object breaks 

#in the case of QQbar, so we just pass it into the macaulay resultant 

try: 

res = (f.lc() ** (d - g.degree()) * g.lc() ** (d - f.degree()) 

* f.__pari__().polresultant(g, x)) 

return(self.domain().base_ring()(res)) 

except (TypeError, PariError): 

pass 

#Otherwise, use Macaulay 

R = F[0].parent() 

res = R.macaulay_resultant(list(F._polys)) 

return res #Coercion here is not necessary as it is already done in Macaulay Resultant 

 

@cached_method 

def primes_of_bad_reduction(self, check=True): 

r""" 

Determine the primes of bad reduction for this dynamical system. 

 

Must be defined over a number field. 

 

If ``check`` is ``True``, each prime is verified to be of 

bad reduction. 

 

ALGORITHM: 

 

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

polynomials of self 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 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. 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. 

 

INPUT: 

 

- ``check`` -- (default: ``True``) boolean 

 

OUTPUT: a list of primes 

 

EXAMPLES:: 

 

sage: P.<x,y> = ProjectiveSpace(QQ,1) 

sage: f = DynamicalSystem_projective([1/3*x^2+1/2*y^2, y^2]) 

sage: f.primes_of_bad_reduction() 

[2, 3] 

 

:: 

 

sage: P.<x,y,z,w> = ProjectiveSpace(QQ,3) 

sage: f = DynamicalSystem_projective([12*x*z-7*y^2, 31*x^2-y^2, 26*z^2, 3*w^2-z*w]) 

sage: f.primes_of_bad_reduction() 

[2, 3, 7, 13, 31] 

 

A number field example:: 

 

sage: R.<z> = QQ[] 

sage: K.<a> = NumberField(z^2 - 2) 

sage: P.<x,y> = ProjectiveSpace(K,1) 

sage: f = DynamicalSystem_projective([1/3*x^2+1/a*y^2, y^2]) 

sage: f.primes_of_bad_reduction() 

[Fractional ideal (a), Fractional ideal (3)] 

 

This is an example where check = False returns extra primes:: 

 

sage: P.<x,y,z> = ProjectiveSpace(ZZ,2) 

sage: f = DynamicalSystem_projective([3*x*y^2 + 7*y^3 - 4*y^2*z + 5*z^3, 

....: -5*x^3 + x^2*y + y^3 + 2*x^2*z, 

....: -2*x^2*y + x*y^2 + y^3 - 4*y^2*z + x*z^2]) 

sage: f.primes_of_bad_reduction(False) 

[2, 5, 37, 2239, 304432717] 

sage: f.primes_of_bad_reduction() 

[5, 37, 2239, 304432717] 

""" 

if (not is_ProjectiveSpace(self.domain())) or (not is_ProjectiveSpace(self.codomain())): 

raise NotImplementedError("not implemented for subschemes") 

K = FractionField(self.codomain().base_ring()) 

#The primes of bad reduction are the support of the resultant for number fields 

 

if K in NumberFields(): 

if K != QQ: 

F = copy(self) 

F.normalize_coordinates() 

return (K(F.resultant()).support()) 

else: 

#For the rationals, we can use groebner basis, as it is quicker in practice 

R = self.coordinate_ring() 

F = self._polys 

 

if R.base_ring().is_field(): 

J = R.ideal(F) 

else: 

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

J = S.ideal([S.coerce(F[i]) for i in range(R.ngens())]) 

if J.dimension() > 0: 

raise TypeError("not a morphism") 

#normalize to coefficients in the ring not the fraction field. 

F = [F[i] * lcm([F[j].denominator() for j in range(len(F))]) for i in range(len(F))] 

 

#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()) 

F = [F[i].change_ring(R.base_ring().ring_of_integers()) for i in range(len(F))] 

J = S.ideal(F) 

else: 

J = R.ideal(F) 

GB = J.groebner_basis() 

badprimes = [] 

 

#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: 

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

badprimes = sorted(set(badprimes)) 

 

#check to return only the truly bad primes 

if check: 

index = 0 

while index < len(badprimes): #figure out which primes are really bad primes... 

S = PolynomialRing(GF(badprimes[index]), R.gens(), R.ngens()) 

J = S.ideal([S.coerce(F[j]) for j in range(R.ngens())]) 

if J.dimension() == 0: 

badprimes.pop(index) 

else: 

index += 1 

return(badprimes) 

else: 

raise TypeError("base ring must be number field or number field ring") 

 

def conjugate(self, M): 

r""" 

Conjugate this dynamical system by ``M``, i.e. `M^{-1} \circ f \circ M`. 

 

If possible the new map will be defined over the same space. 

Otherwise, will try to coerce to the base ring of ``M``. 

 

INPUT: 

 

- ``M`` -- a square invertible matrix 

 

OUTPUT: a dynamical system 

 

EXAMPLES:: 

 

sage: P.<x,y> = ProjectiveSpace(ZZ,1) 

sage: f = DynamicalSystem_projective([x^2+y^2, y^2]) 

sage: f.conjugate(matrix([[1,2], [0,1]])) 

Dynamical System of Projective Space of dimension 1 over Integer Ring 

Defn: Defined on coordinates by sending (x : y) to 

(x^2 + 4*x*y + 3*y^2 : y^2) 

 

:: 

 

sage: R.<x> = PolynomialRing(QQ) 

sage: K.<i> = NumberField(x^2+1) 

sage: P.<x,y> = ProjectiveSpace(ZZ,1) 

sage: f = DynamicalSystem_projective([x^3+y^3, y^3]) 

sage: f.conjugate(matrix([[i,0], [0,-i]])) 

Dynamical System of Projective Space of dimension 1 over Integer Ring 

Defn: Defined on coordinates by sending (x : y) to 

(-x^3 + y^3 : -y^3) 

 

:: 

 

sage: P.<x,y,z> = ProjectiveSpace(ZZ,2) 

sage: f = DynamicalSystem_projective([x^2+y^2 ,y^2, y*z]) 

sage: f.conjugate(matrix([[1,2,3], [0,1,2], [0,0,1]])) 

Dynamical System of Projective Space of dimension 2 over Integer Ring 

Defn: Defined on coordinates by sending (x : y : z) to 

(x^2 + 4*x*y + 3*y^2 + 6*x*z + 9*y*z + 7*z^2 : y^2 + 2*y*z : y*z + 2*z^2) 

 

:: 

 

sage: P.<x,y> = ProjectiveSpace(ZZ,1) 

sage: f = DynamicalSystem_projective([x^2+y^2, y^2]) 

sage: f.conjugate(matrix([[2,0], [0,1/2]])) 

Dynamical System of Projective Space of dimension 1 over Rational Field 

Defn: Defined on coordinates by sending (x : y) to 

(2*x^2 + 1/8*y^2 : 1/2*y^2) 

 

:: 

 

sage: R.<x> = PolynomialRing(QQ) 

sage: K.<i> = NumberField(x^2+1) 

sage: P.<x,y> = ProjectiveSpace(QQ,1) 

sage: f = DynamicalSystem_projective([1/3*x^2+1/2*y^2, y^2]) 

sage: f.conjugate(matrix([[i,0], [0,-i]])) 

Dynamical System of Projective Space of dimension 1 over Number Field in i with defining polynomial x^2 + 1 

Defn: Defined on coordinates by sending (x : y) to 

((1/3*i)*x^2 + (1/2*i)*y^2 : (-i)*y^2) 

""" 

if not (M.is_square() == 1 and M.determinant() != 0 

and M.ncols() == self.domain().ambient_space().dimension_relative() + 1): 

raise TypeError("matrix must be invertible and size dimension + 1") 

X = M * vector(self[0].parent().gens()) 

F = vector(self._polys) 

F = F(list(X)) 

N = M.inverse() 

F = N * F 

R = self.codomain().ambient_space().coordinate_ring() 

try: 

F = [R(f) for f in F] 

PS = self.codomain() 

except TypeError: #no longer defined over same ring 

R = R.change_ring(M.base_ring()) 

F = [R(f) for f in F] 

PS = self.codomain().change_ring(M.base_ring()) 

return DynamicalSystem_projective(F, domain=PS) 

 

def green_function(self, P, v, **kwds): 

r""" 

Evaluate the local Green's function at the place ``v`` for ``P`` 

with ``N`` terms of the series or to within a given error bound. 

 

Must be over a number field or order of a number field. Note that 

this is the absolute local Green's function so is scaled by the 

degree of the base field. 

 

Use ``v=0`` for the archimedean place over `\QQ` or field embedding. 

Non-archimedean places are prime ideals for number fields or primes 

over `\QQ`. 

 

ALGORITHM: 

 

See Exercise 5.29 and Figure 5.6 of [Sil2007]_. 

 

INPUT: 

 

- ``P`` -- a projective point 

 

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

archimedean place 

 

kwds: 

 

- ``N`` -- (optional - default: 10) positive integer. number of 

terms of the series to use 

 

- ``prec`` -- (default: 100) positive integer, float point or 

`p`-adic precision 

 

- ``error_bound`` -- (optional) a positive real number 

 

OUTPUT: a real number 

 

EXAMPLES:: 

 

sage: P.<x,y> = ProjectiveSpace(QQ,1) 

sage: f = DynamicalSystem_projective([x^2+y^2, x*y]); 

sage: Q = P(5, 1) 

sage: f.green_function(Q, 0, N=30) 

1.6460930159932946233759277576 

 

:: 

 

sage: P.<x,y> = ProjectiveSpace(QQ,1) 

sage: f = DynamicalSystem_projective([x^2+y^2, x*y]); 

sage: Q = P(5, 1) 

sage: f.green_function(Q, 0, N=200, prec=200) 

1.6460930160038721802875250367738355497198064992657997569827 

 

:: 

 

sage: K.<w> = QuadraticField(3) 

sage: P.<x,y> = ProjectiveSpace(K,1) 

sage: f = DynamicalSystem_projective([17*x^2+1/7*y^2, 17*w*x*y]) 

sage: f.green_function(P.point([w, 2], False), K.places()[1]) 

1.7236334013785676107373093775 

sage: f.green_function(P([2, 1]), K.ideal(7), N=7) 

0.48647753726382832627633818586 

sage: f.green_function(P([w, 1]), K.ideal(17), error_bound=0.001) 

-0.70813041039490996737374178059 

 

:: 

 

sage: P.<x,y> = ProjectiveSpace(QQ,1) 

sage: f = DynamicalSystem_projective([x^2+y^2, x*y]) 

sage: f.green_function(P.point([5,2], False), 0, N=30) 

1.7315451844777407992085512000 

sage: f.green_function(P.point([2,1], False), 0, N=30) 

0.86577259223181088325226209926 

sage: f.green_function(P.point([1,1], False), 0, N=30) 

0.43288629610862338612700146098 

""" 

N = kwds.get('N', 10) #Get number of iterates (if entered) 

err = kwds.get('error_bound', None) #Get error bound (if entered) 

prec = kwds.get('prec', 100) #Get precision (if entered) 

R = RealField(prec) 

localht = R(0) 

BR = FractionField(P.codomain().base_ring()) 

GBR = self.change_ring(BR) #so the heights work 

 

if not BR in NumberFields(): 

raise NotImplementedError("must be over a number field or a number field order") 

if not BR.is_absolute(): 

raise TypeError("must be an absolute field") 

 

#For QQ the 'flip-trick' works better over RR or Qp 

if isinstance(v, (NumberFieldFractionalIdeal, RingHomomorphism_im_gens)): 

K = BR 

elif is_prime(v): 

K = Qp(v, prec) 

elif v == 0: 

K = R 

v = BR.places(prec=prec)[0] 

else: 

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

 

#Coerce all polynomials in F into polynomials with coefficients in K 

F = self.change_ring(K, check=False) 

d = F.degree() 

dim = F.codomain().ambient_space().dimension_relative() 

Q = P.change_ring(K, check=False) 

 

if err is not None: 

err = R(err) 

if not err > 0: 

raise ValueError("error bound (=%s) must be positive"%err) 

 

#if doing error estimates, compute needed number of iterates 

D = (dim + 1) * (d - 1) + 1 

#compute upper bound 

if isinstance(v, RingHomomorphism_im_gens): #archimedean 

vindex = BR.places(prec=prec).index(v) 

U = GBR.local_height_arch(vindex, prec=prec) + R(binomial(dim + d, d)).log() 

else: #non-archimedean 

U = GBR.local_height(v, prec=prec) 

 

#compute lower bound - from explicit polynomials of Nullstellensatz 

CR = GBR.codomain().ambient_space().coordinate_ring() #.lift() only works over fields 

I = CR.ideal(GBR.defining_polynomials()) 

maxh = 0 

Res = 1 

for k in range(dim + 1): 

CoeffPolys = (CR.gen(k) ** D).lift(I) 

h = 1 

for poly in CoeffPolys: 

if poly != 0: 

for c in poly.coefficients(): 

Res = lcm(Res, c.denominator()) 

for poly in CoeffPolys: 

if poly != 0: 

if isinstance(v, RingHomomorphism_im_gens): #archimedean 

if BR == QQ: 

h = max([(Res*c).local_height_arch(prec=prec) for c in poly.coefficients()]) 

else: 

h = max([(Res*c).local_height_arch(vindex, prec=prec) for c in poly.coefficients()]) 

else: #non-archimedean 

h = max([c.local_height(v, prec=prec) for c in poly.coefficients()]) 

if h > maxh: 

maxh=h 

if maxh == 0: 

maxh = 1 #avoid division by 0 

if isinstance(v, RingHomomorphism_im_gens): #archimedean 

L = R(Res / ((dim + 1) * binomial(dim + D - d, D - d) * maxh)).log().abs() 

else: #non-archimedean 

L = R(Res / maxh).log().abs() 

C = max([U, L]) 

if C != 0: 

N = R(C / (err*(d-1))).log(d).abs().ceil() 

else: #we just need log||P||_v 

N=1 

 

#START GREEN FUNCTION CALCULATION 

if isinstance(v, RingHomomorphism_im_gens): #embedding for archimedean local height 

for i in range(N+1): 

Qv = [ (v(t).abs()) for t in Q ] 

m = -1 

#compute the maximum absolute value of entries of a, and where it occurs 

for n in range(dim + 1): 

if Qv[n] > m: 

j = n 

m = Qv[n] 

# add to sum for the Green's function 

localht += ((1/R(d))**R(i)) * (R(m).log()) 

#get the next iterate 

if i < N: 

Q.scale_by(1/Q[j]) 

Q = F(Q, False) 

return (1/BR.absolute_degree()) * localht 

 

#else - prime or prime ideal for non-archimedean 

for i in range(N + 1): 

if BR == QQ: 

Qv = [ R(K(t).abs()) for t in Q ] 

else: 

Qv = [ R(t.abs_non_arch(v)) for t in Q ] 

m = -1 

#compute the maximum absolute value of entries of a, and where it occurs 

for n in range(dim + 1): 

if Qv[n] > m: 

j = n 

m = Qv[n] 

# add to sum for the Green's function 

localht += (1/R(d))**R(i) * (R(m).log()) 

#get the next iterate 

if i < N: 

Q.scale_by(1 / Q[j]) 

Q = F(Q, False) 

return (1 / BR.absolute_degree()) * localht 

 

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

r""" 

Evaluate the (absolute) canonical height of ``P`` with respect to 

this dynamical system. 

 

Must be over number field or order of a number field. Specify 

either the number of terms of the series to evaluate or the 

error bound required. 

 

ALGORITHM: 

 

The sum of the Green's function at the archimedean places and 

the places of bad reduction. 

 

If function is defined over `\QQ` uses Wells' Algorithm, which 

allows us to not have to factor the resultant. 

 

INPUT: 

 

- ``P`` -- a projective point 

 

kwds: 

 

- ``badprimes`` -- (optional) a list of primes of bad reduction 

 

- ``N`` -- (default: 10) positive integer. number of 

terms of the series to use in the local green functions 

 

- ``prec`` -- (default: 100) positive integer, float point or 

`p`-adic precision 

 

- ``error_bound`` -- (optional) a positive real number 

 

OUTPUT: a real number 

 

EXAMPLES:: 

 

sage: P.<x,y> = ProjectiveSpace(ZZ,1) 

sage: f = DynamicalSystem_projective([x^2+y^2, 2*x*y]); 

sage: f.canonical_height(P.point([5,4]), error_bound=0.001) 

2.1970553519503404898926835324 

sage: f.canonical_height(P.point([2,1]), error_bound=0.001) 

1.0984430632822307984974382955 

 

Notice that preperiodic points may not return exactly 0:: 

 

sage: R.<X> = PolynomialRing(QQ) 

sage: K.<a> = NumberField(X^2 + X - 1) 

sage: P.<x,y> = ProjectiveSpace(K,1) 

sage: f = DynamicalSystem_projective([x^2-2*y^2, y^2]) 

sage: Q = P.point([a,1]) 

sage: f.canonical_height(Q, error_bound=0.000001) # Answer only within error_bound of 0 

5.7364919788790160119266380480e-8 

sage: f.nth_iterate(Q,2) == Q # but it is indeed preperiodic 

True 

 

:: 

 

sage: P.<x,y,z> = ProjectiveSpace(QQ,2) 

sage: X = P.subscheme(x^2-y^2); 

sage: f = DynamicalSystem_projective([x^2,y^2, 4*z^2], domain=X); 

sage: Q = X([4,4,1]) 

sage: f.canonical_height(Q, badprimes=[2]) 

0.0013538030870311431824555314882 

 

:: 

 

sage: P.<x,y,z> = ProjectiveSpace(QQ,2) 

sage: X = P.subscheme(x^2-y^2); 

sage: f = DynamicalSystem_projective([x^2,y^2, 30*z^2], domain=X) 

sage: Q = X([4, 4, 1]) 

sage: f.canonical_height(Q, badprimes=[2,3,5], prec=200) 

2.7054056208276961889784303469356774912979228770208655455481 

 

:: 

 

sage: P.<x,y> = ProjectiveSpace(QQ, 1) 

sage: f = DynamicalSystem_projective([1000*x^2-29*y^2, 1000*y^2]) 

sage: Q = P(-1/4, 1) 

sage: f.canonical_height(Q, error_bound=0.01) 

3.7996079979254623065837411853 

 

:: 

 

sage: RSA768 = 123018668453011775513049495838496272077285356959533479219732245215\ 

....: 1726400507263657518745202199786469389956474942774063845925192557326303453731548\ 

....: 2685079170261221429134616704292143116022212404792747377940806653514195974598569\ 

....: 02143413 

sage: P.<x,y> = ProjectiveSpace(QQ,1) 

sage: f = DynamicalSystem_projective([RSA768*x^2 + y^2, x*y]) 

sage: Q = P(RSA768,1) 

sage: f.canonical_height(Q, error_bound=0.00000000000000001) 

931.18256422718241278672729195 

""" 

bad_primes = kwds.get("badprimes", None) 

prec = kwds.get("prec", 100) 

error_bound = kwds.get("error_bound", None) 

K = FractionField(self.codomain().base_ring()) 

 

if not K in NumberFields(): 

if not K is QQbar: 

raise NotImplementedError("must be over a number field or a number field order or QQbar") 

else: 

#since this an absolute height, we can compute the height of a QQbar point 

#by choosing any number field it is defined over. 

Q = P._number_field_from_algebraics() 

K = Q.codomain().base_ring() 

f = self._number_field_from_algebraics().as_dynamical_system() 

if K == QQ: 

K = f.base_ring() 

Q = Q.change_ring(K) 

elif f.base_ring() == QQ: 

f = f.change_ring(K) 

else: 

K, phi, psi, b = K.composite_fields(f.base_ring(), both_maps=True)[0] 

Q = Q.change_ring(K, embedding=phi) 

f = f.change_ring(K, embedding=psi) 

else: 

if not K.is_absolute(): 

raise TypeError("must be an absolute field") 

Q = P 

f = self 

 

# After moving from QQbar to K being something like QQ, we need 

# to renormalize f, especially to match the normalized resultant. 

f.normalize_coordinates() 

 

# If our map and point are defined on P^1(QQ), use Wells' Algorithm 

# instead of the usual algorithm using local Green's functions: 

if K is QQ and self.codomain().ambient_space().dimension_relative() == 1: 

# write our point with coordinates whose gcd is 1 

Q.normalize_coordinates() 

if Q.parent().value_ring() is QQ: 

Q.clear_denominators() 

#assures integer coeffcients 

coeffs = f[0].coefficients() + f[1].coefficients() 

t = 1 

for c in coeffs: 

t = lcm(t, c.denominator()) 

A = t * f[0] 

B = t * f[1] 

Res = f.resultant(normalize=True) 

H = 0 

x_i = Q[0] 

y_i = Q[1] 

d = self.degree() 

R = RealField(prec) 

N = kwds.get('N', 10) 

err = kwds.get('error_bound', None) 

#computes the error bound as defined in Algorithm 3.1 of [WELLS] 

if Res > 1: 

if not err is None: 

err = err / 2 

N = ceil((R(Res.abs()).log().log() - R(d-1).log() - R(err).log())/(R(d).log())) 

if N < 1: 

N = 1 

kwds.update({'error_bound': err}) 

kwds.update({'N': N}) 

for n in range(N): 

x = A(x_i,y_i) % Res**(N-n) 

y = B(x_i,y_i) % Res**(N-n) 

g = gcd([x, y, Res]) 

H = H + R(g).abs().log() / (d**(n+1)) 

x_i = x / g 

y_i = y / g 

# this looks different than Wells' Algorithm because of the difference 

# between what Wells' calls H_infty, 

# and what Green's Function returns for the infinite place 

h = f.green_function(Q, 0 , **kwds) - H + R(t).log() 

# The value returned by Well's algorithm may be negative. As the canonical height 

# is always nonnegative, so if this value is within -err of 0, return 0. 

if h < 0: 

assert h > -err, "A negative height less than -error_bound was computed. " + \ 

"This should be impossible, please report bug on trac.sagemath.org." 

# This should be impossible. The error bound for Wells' is rigorous 

# and the actual height is always >= 0. If we see something less than -err, 

# something has g one very wrong. 

h = R(0) 

return h 

 

if bad_primes is None: 

bad_primes = [] 

for b in Q: 

if K == QQ: 

bad_primes += b.denominator().prime_factors() 

else: 

bad_primes += b.denominator_ideal().prime_factors() 

bad_primes += K(f.resultant(normalize=True)).support() 

bad_primes = list(set(bad_primes)) 

 

emb = K.places(prec=prec) 

num_places = len(emb) + len(bad_primes) 

if not error_bound is None: 

error_bound /= num_places 

R = RealField(prec) 

h = R.zero() 

 

##update the keyword dictionary for use in green_function 

kwds.update({"badprimes": bad_primes}) 

kwds.update({"error_bound": error_bound}) 

 

# Archimedean local heights 

# :: WARNING: If places is fed the default Sage precision of 53 bits, 

# it uses Real or Complex Double Field in place of RealField(prec) or ComplexField(prec) 

# the function is_RealField does not identify RDF as real, so we test for that ourselves. 

for v in emb: 

if is_RealField(v.codomain()) or v.codomain() is RDF: 

dv = R.one() 

else: 

dv = R(2) 

h += dv * f.green_function(Q, v, **kwds) #arch Green function 

 

# Non-Archimedean local heights 

for v in bad_primes: 

if K == QQ: 

dv = R.one() 

else: 

dv = R(v.residue_class_degree() * v.absolute_ramification_index()) 

h += dv * f.green_function(Q, v, **kwds) #non-arch Green functions 

return h 

 

def height_difference_bound(self, prec=None): 

r""" 

Return an upper bound on the different between the canonical 

height of a point with respect to this dynamical system and the 

absolute height of the point. 

 

This map must be a morphism. 

 

ALGORITHM: 

 

Uses a Nullstellensatz argument to compute the constant. 

For details: see [Hutz2015]_. 

 

INPUT: 

 

- ``prec`` -- (default: :class:`RealField` default) 

positive integer, float point precision 

 

OUTPUT: a real number 

 

EXAMPLES:: 

 

sage: P.<x,y> = ProjectiveSpace(QQ,1) 

sage: f = DynamicalSystem_projective([x^2+y^2, x*y]) 

sage: f.height_difference_bound() 

1.38629436111989 

 

This function does not automatically normalize. :: 

 

sage: P.<x,y,z> = ProjectiveSpace(ZZ,2) 

sage: f = DynamicalSystem_projective([4*x^2+100*y^2, 210*x*y, 10000*z^2]) 

sage: f.height_difference_bound() 

11.0020998412042 

sage: f.normalize_coordinates() 

sage: f.height_difference_bound() 

10.3089526606443 

 

A number field example:: 

 

sage: R.<x> = QQ[] 

sage: K.<c> = NumberField(x^3 - 2) 

sage: P.<x,y,z> = ProjectiveSpace(K,2) 

sage: f = DynamicalSystem_projective([1/(c+1)*x^2+c*y^2, 210*x*y, 10000*z^2]) 

sage: f.height_difference_bound() 

11.0020998412042 

 

:: 

 

sage: P.<x,y,z> = ProjectiveSpace(QQbar,2) 

sage: f = DynamicalSystem_projective([x^2, QQbar(sqrt(-1))*y^2, QQbar(sqrt(3))*z^2]) 

sage: f.height_difference_bound() 

3.43967790223022 

""" 

FF = FractionField(self.domain().base_ring()) #lift will only work over fields, so coercing into FF 

if not FF in NumberFields(): 

if FF == QQbar: 

#since this is absolute height, we can choose any number field over which the 

#function is defined. 

f = self._number_field_from_algebraics() 

else: 

raise NotImplementedError("fraction field of the base ring must be a number field or QQbar") 

else: 

f = self.change_ring(FF) 

if prec is None: 

R = RealField() 

else: 

R = RealField(prec) 

N = f.domain().dimension_relative() 

d = f.degree() 

D = (N + 1) * (d - 1) + 1 

#compute upper bound 

U = f.global_height(prec) + R(binomial(N + d, d)).log() 

#compute lower bound - from explicit polynomials of Nullstellensatz 

CR = f.domain().coordinate_ring() 

I = CR.ideal(f.defining_polynomials()) 

MCP = [] 

for k in range(N + 1): 

CoeffPolys = (CR.gen(k) ** D).lift(I) 

Res = lcm([1] + [abs(coeff.denominator()) for val in CoeffPolys 

for coeff in val.coefficients()]) 

h = max([c.global_height() for g in CoeffPolys for c in (Res*g).coefficients()]) 

MCP.append([Res, h]) #since we need to clear denominators 

maxh = 0 

gcdRes = 0 

for val in MCP: 

gcdRes = gcd(gcdRes, val[0]) 

maxh = max(maxh, val[1]) 

L = abs(R(gcdRes).log() - R((N + 1) * binomial(N + D - d, D - d)).log() - maxh) 

C = max(U, L) #height difference dh(P) - L <= h(f(P)) <= dh(P) +U 

return(C / (d - 1)) 

 

def multiplier(self, P, n, check=True): 

r""" 

Return the multiplier of the point ``P`` of period ``n`` with 

respect to this dynamical system. 

 

INPUT: 

 

- ``P`` -- a point on domain of this map 

 

- ``n`` -- a positive integer, the period of ``P`` 

 

- ``check`` -- (default: ``True``) boolean; verify that ``P`` 

has period ``n`` 

 

OUTPUT: 

 

A square matrix of size ``self.codomain().dimension_relative()`` 

in the ``base_ring`` of this dynamical system. 

 

EXAMPLES:: 

 

sage: P.<x,y,z> = ProjectiveSpace(QQ,2) 

sage: f = DynamicalSystem_projective([x^2,y^2, 4*z^2]); 

sage: Q = P.point([4,4,1], False); 

sage: f.multiplier(Q,1) 

[2 0] 

[0 2] 

 

:: 

 

sage: P.<x,y> = ProjectiveSpace(QQ,1) 

sage: f = DynamicalSystem_projective([7*x^2 - 28*y^2, 24*x*y]) 

sage: f.multiplier(P(2,5), 4) 

[231361/20736] 

 

:: 

 

sage: P.<x,y> = ProjectiveSpace(CC,1) 

sage: f = DynamicalSystem_projective([x^3 - 25*x*y^2 + 12*y^3, 12*y^3]) 

sage: f.multiplier(P(1,1), 5) 

[0.389017489711935] 

 

:: 

 

sage: P.<x,y> = ProjectiveSpace(RR,1) 

sage: f = DynamicalSystem_projective([x^2-2*y^2, y^2]) 

sage: f.multiplier(P(2,1), 1) 

[4.00000000000000] 

 

:: 

 

sage: P.<x,y> = ProjectiveSpace(Qp(13),1) 

sage: f = DynamicalSystem_projective([x^2-29/16*y^2, y^2]) 

sage: f.multiplier(P(5,4), 3) 

[6 + 8*13 + 13^2 + 8*13^3 + 13^4 + 8*13^5 + 13^6 + 8*13^7 + 13^8 + 

8*13^9 + 13^10 + 8*13^11 + 13^12 + 8*13^13 + 13^14 + 8*13^15 + 13^16 + 

8*13^17 + 13^18 + 8*13^19 + O(13^20)] 

 

:: 

 

sage: P.<x,y> = ProjectiveSpace(QQ,1) 

sage: f = DynamicalSystem_projective([x^2-y^2, y^2]) 

sage: f.multiplier(P(0,1), 1) 

Traceback (most recent call last): 

... 

ValueError: (0 : 1) is not periodic of period 1 

""" 

if check: 

if self.nth_iterate(P, n) != P: 

raise ValueError("%s is not periodic of period %s"%(P, n)) 

if n < 1: 

raise ValueError("period must be a positive integer") 

N = self.domain().ambient_space().dimension_relative() 

l = identity_matrix(FractionField(self.codomain().base_ring()), N, N) 

Q = P 

Q.normalize_coordinates() 

index = N 

indexlist = [] #keep track of which dehomogenizations are needed 

while Q[index] == 0: 

index -= 1 

indexlist.append(index) 

for i in range(0, n): 

F = [] 

R = self(Q) 

R.normalize_coordinates() 

index = N 

while R[index] == 0: 

index -= 1 

indexlist.append(index) 

#dehomogenize and compute multiplier 

F = self.dehomogenize((indexlist[i],indexlist[i+1])) 

#get the correct order for chain rule matrix multiplication 

l = F.jacobian()(tuple(Q.dehomogenize(indexlist[i])))*l 

Q = R 

return l 

 

def _multipliermod(self, P, n, p, k): 

r""" 

Return the multiplier of the point ``P`` of period ``n`` with 

respect to this dynamical system modulo `p^k`. 

 

This map must be an endomorphism of projective space defined 

over `\QQ` or `\ZZ`. This function should not be used at the top 

level as it does not perform input checks. It is used primarily 

for the rational preperiodic and periodic point algorithms. 

 

INPUT: 

 

- ``P`` -- a point on domain of this map 

 

- ``n`` -- a positive integer, the period of ``P`` 

 

- ``p`` -- a positive integer 

 

- ``k`` -- a positive integer 

 

OUTPUT: 

 

A square matrix of size ``self.codomain().dimension_relative()`` 

in `\ZZ/(p^k)\ZZ`. 

 

EXAMPLES:: 

 

sage: P.<x,y> = ProjectiveSpace(QQ,1) 

sage: f = DynamicalSystem_projective([x^2-29/16*y^2, y^2]) 

sage: f._multipliermod(P(5,4), 3, 11, 1) 

[3] 

 

:: 

 

sage: P.<x,y> = ProjectiveSpace(QQ,1) 

sage: f = DynamicalSystem_projective([x^2-29/16*y^2, y^2]) 

sage: f._multipliermod(P(5,4), 3, 11, 2) 

[80] 

""" 

N = self.domain().dimension_relative() 

BR = FractionField(self.codomain().base_ring()) 

l = identity_matrix(BR, N, N) 

Q = copy(P) 

g = gcd(Q._coords) #we can't use normalize_coordinates since it can cause denominators 

Q.scale_by(1 / g) 

index = N 

indexlist = [] #keep track of which dehomogenizations are needed 

while Q[index] % p == 0: 

index -= 1 

indexlist.append(index) 

for i in range(0, n): 

F = [] 

R = self(Q, False) 

g = gcd(R._coords) 

R.scale_by(1 / g) 

R_list = list(R) 

for index in range(N + 1): 

R_list[index] = R_list[index] % (p ** k) 

R._coords = tuple(R_list) 

index = N 

while R[index] % p == 0: 

index -= 1 

indexlist.append(index) 

#dehomogenize and compute multiplier 

F = self.dehomogenize((indexlist[i],indexlist[i+1])) 

l = (F.jacobian()(tuple(Q.dehomogenize(indexlist[i])))*l) % (p ** k) 

Q = R 

return(l) 

 

def possible_periods(self, **kwds): 

r""" 

Return the set of possible periods for rational periodic points of 

this dynamical system. 

 

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

 

ALGORITHM: 

 

Calls ``self.possible_periods()`` modulo all primes of good reduction 

in range ``prime_bound``. Return the intersection of those lists. 

 

INPUT: 

 

kwds: 

 

- ``prime_bound`` -- (default: ``[1, 20]``) a list or tuple of 

two positive integers or an integer for the upper bound 

 

- ``bad_primes`` -- (optional) a list or tuple of integer primes, 

the primes of bad reduction 

 

- ``ncpus`` -- (default: all cpus) number of cpus to use in parallel 

 

OUTPUT: a list of positive integers 

 

EXAMPLES:: 

 

sage: P.<x,y> = ProjectiveSpace(QQ,1) 

sage: f = DynamicalSystem_projective([x^2-29/16*y^2, y^2]) 

sage: f.possible_periods(ncpus=1) 

[1, 3] 

 

:: 

 

sage: PS.<x,y> = ProjectiveSpace(1,QQ) 

sage: f = DynamicalSystem_projective([5*x^3 - 53*x*y^2 + 24*y^3, 24*y^3]) 

sage: f.possible_periods(prime_bound=[1,5]) 

Traceback (most recent call last): 

... 

ValueError: no primes of good reduction in that range 

sage: f.possible_periods(prime_bound=[1,10]) 

[1, 4, 12] 

sage: f.possible_periods(prime_bound=[1,20]) 

[1, 4] 

 

:: 

 

sage: P.<x,y,z> = ProjectiveSpace(ZZ,2) 

sage: f = DynamicalSystem_projective([2*x^3 - 50*x*z^2 + 24*z^3, 

....: 5*y^3 - 53*y*z^2 + 24*z^3, 24*z^3]) 

sage: f.possible_periods(prime_bound=10) 

[1, 2, 6, 20, 42, 60, 140, 420] 

sage: f.possible_periods(prime_bound=20) # long time 

[1, 20] 

""" 

if self.domain().base_ring() not in [ZZ, QQ]: 

raise NotImplementedError("must be ZZ or QQ") 

 

primebound = kwds.pop("prime_bound", [1, 20]) 

badprimes = kwds.pop("bad_primes", None) 

num_cpus = kwds.pop("ncpus", ncpus()) 

 

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

try: 

primebound = [1, ZZ(primebound)] 

except TypeError: 

raise TypeError("prime bound must be an integer") 

else: 

try: 

primebound[0] = ZZ(primebound[0]) 

primebound[1] = ZZ(primebound[1]) 

except TypeError: 

raise TypeError("prime bounds must be integers") 

 

if badprimes is None: 

badprimes = self.primes_of_bad_reduction() 

 

firstgood = 0 

 

def parallel_function(morphism): 

return morphism.possible_periods() 

 

# Calling possible_periods for each prime in parallel 

parallel_data = [] 

for q in primes(primebound[0], primebound[1] + 1): 

if not (q in badprimes): 

F = self.change_ring(GF(q)) 

parallel_data.append(((F,), {})) 

 

parallel_iter = p_iter_fork(num_cpus, 0) 

parallel_results = list(parallel_iter(parallel_function, parallel_data)) 

 

for result in parallel_results: 

possible_periods = result[1] 

if firstgood == 0: 

periods = set(possible_periods) 

firstgood = 1 

else: 

periodsq = set(possible_periods) 

periods = periods.intersection(periodsq) 

 

if firstgood == 0: 

raise ValueError("no primes of good reduction in that range") 

else: 

return sorted(periods) 

 

def _preperiodic_points_to_cyclegraph(self, preper): 

r""" 

Given the complete set of periodic or preperiodic points return the 

digraph representing the orbit. 

 

If ``preper`` is not the complete set, this function will not fill 

in the gaps. 

 

INPUT: 

 

- ``preper`` -- a list or tuple of projective points; the complete 

set of rational periodic or preperiodic points 

 

OUTPUT: 

 

A digraph representing the orbit the rational preperiodic points 

``preper`` in projective space. 

 

EXAMPLES:: 

 

sage: P.<x,y> = ProjectiveSpace(QQ,1) 

sage: f = DynamicalSystem_projective([x^2-2*y^2, y^2]) 

sage: preper = [P(-2, 1), P(1, 0), P(0, 1), P(1, 1), P(2, 1), P(-1, 1)] 

sage: f._preperiodic_points_to_cyclegraph(preper) 

Looped digraph on 6 vertices 

""" 

V = [] 

E = [] 

#We store the points we encounter is a list, D. Each new point is checked to 

#see if it is in that list (which uses ==) so that equal points with different 

#representations only appear once in the graph. 

D = [] 

for val in preper: 

try: 

V.append(D[D.index(val)]) 

except ValueError: 

D.append(val) 

V.append(val) 

Q = self(val) 

Q.normalize_coordinates() 

try: 

E.append([D[D.index(Q)]]) 

except ValueError: 

D.append(Q) 

E.append([Q]) 

from sage.graphs.digraph import DiGraph 

g = DiGraph(dict(zip(V, E)), loops=True) 

return(g) 

 

def is_PGL_minimal(self, prime_list=None): 

r""" 

Check if this dynamical system is a minimal model in 

its conjugacy class. 

 

See [BM2012]_ and [Mol2015]_ for a description of the algorithm. 

 

INPUT: 

 

- ``prime_list`` -- (optional) list of primes to check minimality 

 

OUTPUT: boolean 

 

EXAMPLES:: 

 

sage: PS.<X,Y> = ProjectiveSpace(QQ,1) 

sage: f = DynamicalSystem_projective([X^2+3*Y^2, X*Y]) 

sage: f.is_PGL_minimal() 

True 

 

:: 

 

sage: PS.<x,y> = ProjectiveSpace(QQ,1) 

sage: f = DynamicalSystem_projective([6*x^2+12*x*y+7*y^2, 12*x*y]) 

sage: f.is_PGL_minimal() 

False 

 

:: 

 

sage: PS.<x,y> = ProjectiveSpace(QQ,1) 

sage: f = DynamicalSystem_projective([6*x^2+12*x*y+7*y^2, y^2]) 

sage: f.is_PGL_minimal() 

Traceback (most recent call last): 

... 

TypeError: affine minimality is only considered for maps not of the form 

f or 1/f for a polynomial f 

""" 

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

raise NotImplementedError("minimal models only implemented over ZZ or QQ") 

if not self.is_morphism(): 

raise TypeError("the function is not a morphism") 

if self.degree() == 1: 

raise NotImplementedError("minimality is only for degree 2 or higher") 

 

from .endPN_minimal_model import affine_minimal 

return(affine_minimal(self, False , prime_list , True)) 

 

def minimal_model(self, return_transformation=False, prime_list=None): 

r""" 

Determine if this dynamical system is minimal. 

 

This dynamical system must be defined over the projective line 

over the rationals. In particular, determine if this map is affine 

minimal, which is enough to decide if it is minimal or not. 

See Proposition 2.10 in [BM2012]_. 

 

REFERENCES: 

 

- [BM2012]_ 

- [Mol2015]_ 

 

INPUT: 

 

- ``return_transformation`` -- (default: ``False``) boolean; this 

signals a return of the `PGL_2` transformation to conjugate 

this map to the calculated minimal model 

 

- ``prime_list`` -- (optional) a list of primes, in case one 

only wants to determine minimality at those specific primes 

 

OUTPUT: 

 

- a scheme morphism on the projective line which is a minimal model 

of this map 

 

- a `PGL(2,\QQ)` element which conjugates this map to a minimal model 

 

EXAMPLES:: 

 

sage: PS.<X,Y> = ProjectiveSpace(QQ,1) 

sage: f = DynamicalSystem_projective([X^2+3*Y^2, X*Y]) 

sage: f.minimal_model(return_transformation=True) 

( 

Dynamical System of Projective Space of dimension 1 over Rational 

Field 

Defn: Defined on coordinates by sending (X : Y) to 

(X^2 + 3*Y^2 : X*Y) 

, 

[1 0] 

[0 1] 

) 

 

:: 

 

sage: PS.<X,Y> = ProjectiveSpace(QQ,1) 

sage: f = DynamicalSystem_projective([7365/2*X^4 + 6282*X^3*Y + 4023*X^2*Y^2 + 1146*X*Y^3 + 245/2*Y^4, 

....: -12329/2*X^4 - 10506*X^3*Y - 6723*X^2*Y^2 - 1914*X*Y^3 - 409/2*Y^4]) 

sage: f.minimal_model(return_transformation=True) 

( 

Dynamical System of Projective Space of dimension 1 over Rational 

Field 

Defn: Defined on coordinates by sending (X : Y) to 

(22176*X^4 + 151956*X^3*Y + 390474*X^2*Y^2 + 445956*X*Y^3 + 190999*Y^4 

: -12329*X^4 - 84480*X^3*Y - 217080*X^2*Y^2 - 247920*X*Y^3 - 106180*Y^4), 

[2 3] 

[0 1] 

) 

 

:: 

 

sage: PS.<x,y> = ProjectiveSpace(QQ,1) 

sage: f = DynamicalSystem_projective([6*x^2+12*x*y+7*y^2, 12*x*y]) 

sage: f.minimal_model() 

Dynamical System of Projective Space of dimension 1 over Rational 

Field 

Defn: Defined on coordinates by sending (x : y) to 

(x^2 + 12*x*y + 42*y^2 : 2*x*y) 

 

:: 

 

sage: PS.<x,y> = ProjectiveSpace(ZZ,1) 

sage: f = DynamicalSystem_projective([6*x^2+12*x*y+7*y^2, 12*x*y + 42*y^2]) 

sage: g,M=f.minimal_model(return_transformation=True) 

sage: f.conjugate(M) == g 

True 

 

:: 

 

sage: PS.<X,Y> = ProjectiveSpace(QQ,1) 

sage: f = DynamicalSystem_projective([X+Y, X-3*Y]) 

sage: f.minimal_model() 

Traceback (most recent call last): 

... 

NotImplementedError: minimality is only for degree 2 or higher 

 

:: 

 

sage: PS.<X,Y> = ProjectiveSpace(QQ,1) 

sage: f = DynamicalSystem_projective([X^2-Y^2, X^2+X*Y]) 

sage: f.minimal_model() 

Traceback (most recent call last): 

... 

TypeError: the function is not a morphism 

 

""" 

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

raise NotImplementedError("minimal models only implemented over ZZ or QQ") 

if not self.is_morphism(): 

raise TypeError("the function is not a morphism") 

if self.degree() == 1: 

raise NotImplementedError("minimality is only for degree 2 or higher") 

 

from .endPN_minimal_model import affine_minimal 

return(affine_minimal(self, return_transformation, prime_list, False)) 

 

def automorphism_group(self, **kwds): 

r""" 

Calculates the subgroup of `PGL2` that is the automorphism group 

of this dynamical system. 

 

The automorphism group is the set of `PGL(2)` elements that fixes 

this map under conjugation. 

 

INPUT: 

 

keywords: 

 

- ``starting_prime`` -- (default: 5) the first prime to use for CRT 

 

- ``algorithm``-- (optional) can be one of the following: 

 

* ``'CRT'`` - Chinese Remainder Theorem 

* ``'fixed_points'`` - fixed points algorithm 

 

- ``return_functions``-- (default: ``False``) boolean; ``True`` 

returns elements as linear fractional transformations and 

``False`` returns elements as `PGL2` matrices 

 

- ``iso_type`` -- (default: ``False``) boolean; ``True`` returns the 

isomorphism type of the automorphism group 

 

OUTPUT: a list of elements in the automorphism group 

 

AUTHORS: 

 

- Original algorithm written by Xander Faber, Michelle Manes, 

Bianca Viray 

 

- Modified by Joao Alberto de Faria, Ben Hutz, Bianca Thompson 

 

REFERENCES: 

 

- [FMV2014]_ 

 

EXAMPLES:: 

 

sage: R.<x,y> = ProjectiveSpace(QQ,1) 

sage: f = DynamicalSystem_projective([x^2-y^2, x*y]) 

sage: f.automorphism_group(return_functions=True) 

[x, -x] 

 

:: 

 

sage: R.<x,y> = ProjectiveSpace(QQ,1) 

sage: f = DynamicalSystem_projective([x^2 + 5*x*y + 5*y^2, 5*x^2 + 5*x*y + y^2]) 

sage: f.automorphism_group() 

[ 

[1 0] [0 2] 

[0 1], [2 0] 

] 

 

:: 

 

sage: R.<x,y> = ProjectiveSpace(QQ,1) 

sage: f = DynamicalSystem_projective([x^2-2*x*y-2*y^2, -2*x^2-2*x*y+y^2]) 

sage: f.automorphism_group(return_functions=True) 

[x, 2/(2*x), -x - 1, -2*x/(2*x + 2), (-x - 1)/x, -1/(x + 1)] 

 

:: 

 

sage: R.<x,y> = ProjectiveSpace(QQ,1) 

sage: f = DynamicalSystem_projective([3*x^2*y - y^3, x^3 - 3*x*y^2]) 

sage: f.automorphism_group(algorithm='CRT', return_functions=True, iso_type=True) 

([x, (x + 1)/(x - 1), (-x + 1)/(x + 1), -x, 1/x, -1/x, 

(x - 1)/(x + 1), (-x - 1)/(x - 1)], 'Dihedral of order 8') 

 

:: 

 

sage: A.<z> = AffineSpace(QQ,1) 

sage: f = DynamicalSystem_affine([1/z^3]) 

sage: F = f.homogenize(1) 

sage: F.automorphism_group() 

[ 

[1 0] [0 2] [-1 0] [ 0 -2] 

[0 1], [2 0], [ 0 1], [ 2 0] 

] 

 

:: 

 

sage: P.<x,y,z> = ProjectiveSpace(QQ,2) 

sage: f = DynamicalSystem_projective([x**2 + x*z, y**2, z**2]) 

sage: f.automorphism_group() # long time 

[ 

[1 0 0] 

[0 1 0] 

[0 0 1] 

] 

 

:: 

 

sage: K.<w> = CyclotomicField(3) 

sage: P.<x,y> = ProjectiveSpace(K, 1) 

sage: D6 = DynamicalSystem_projective([y^2,x^2]) 

sage: D6.automorphism_group() 

[ 

[1 0] [0 w] [0 1] [w 0] [-w - 1 0] [ 0 -w - 1] 

[0 1], [1 0], [1 0], [0 1], [ 0 1], [ 1 0] 

] 

""" 

alg = kwds.get('algorithm', None) 

p = kwds.get('starting_prime', 5) 

return_functions = kwds.get('return_functions', False) 

iso_type = kwds.get('iso_type', False) 

if self.domain().dimension_relative() != 1: 

return self.conjugating_set(self) 

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

return self.conjugating_set(self) 

f = self.dehomogenize(1) 

R = PolynomialRing(f.base_ring(),'x') 

if is_FractionFieldElement(f[0]): 

F = (f[0].numerator().univariate_polynomial(R))/f[0].denominator().univariate_polynomial(R) 

else: 

F = f[0].univariate_polynomial(R) 

from .endPN_automorphism_group import automorphism_group_QQ_CRT, automorphism_group_QQ_fixedpoints 

if alg is None: 

if self.degree() <= 12: 

return(automorphism_group_QQ_fixedpoints(F, return_functions, iso_type)) 

return(automorphism_group_QQ_CRT(F, p, return_functions, iso_type)) 

elif alg == 'CRT': 

return(automorphism_group_QQ_CRT(F, p, return_functions, iso_type)) 

return(automorphism_group_QQ_fixedpoints(F, return_functions, iso_type)) 

 

def critical_subscheme(self): 

r""" 

Return the critical subscheme of this dynamical system. 

 

OUTPUT: projective subscheme 

 

EXAMPLES:: 

 

sage: set_verbose(None) 

sage: P.<x,y> = ProjectiveSpace(QQ,1) 

sage: f = DynamicalSystem_projective([x^3-2*x*y^2 + 2*y^3, y^3]) 

sage: f.critical_subscheme() 

Closed subscheme of Projective Space of dimension 1 over Rational Field 

defined by: 

9*x^2*y^2 - 6*y^4 

 

:: 

 

sage: set_verbose(None) 

sage: P.<x,y> = ProjectiveSpace(QQ,1) 

sage: f = DynamicalSystem_projective([2*x^2-y^2, x*y]) 

sage: f.critical_subscheme() 

Closed subscheme of Projective Space of dimension 1 over Rational Field 

defined by: 

4*x^2 + 2*y^2 

 

:: 

 

sage: P.<x,y,z> = ProjectiveSpace(QQ,2) 

sage: f = DynamicalSystem_projective([2*x^2-y^2, x*y, z^2]) 

sage: f.critical_subscheme() 

Closed subscheme of Projective Space of dimension 2 over Rational Field 

defined by: 

8*x^2*z + 4*y^2*z 

 

:: 

 

sage: P.<x,y,z,w> = ProjectiveSpace(GF(81),3) 

sage: g = DynamicalSystem_projective([x^3+y^3, y^3+z^3, z^3+x^3, w^3]) 

sage: g.critical_subscheme() 

Closed subscheme of Projective Space of dimension 3 over Finite Field in 

z4 of size 3^4 defined by: 

0 

 

:: 

 

sage: P.<x,y> = ProjectiveSpace(QQ,1) 

sage: f = DynamicalSystem_projective([x^2,x*y]) 

sage: f.critical_subscheme() 

Traceback (most recent call last): 

... 

TypeError: the function is not a morphism 

""" 

PS = self.domain() 

if not is_ProjectiveSpace(PS): 

raise NotImplementedError("not implemented for subschemes") 

if not self.is_morphism(): 

raise TypeError("the function is not a morphism") 

wr = self.wronskian_ideal() 

crit_subscheme = self.codomain().subscheme(wr) 

return crit_subscheme 

 

def critical_points(self, R=None): 

r""" 

Return the critical points of this dynamical system defined over 

the ring ``R`` or the base ring of this map. 

 

Must be dimension 1. 

 

INPUT: 

 

- ``R`` -- (optional) a ring 

 

OUTPUT: a list of projective space points defined over ``R`` 

 

EXAMPLES:: 

 

sage: set_verbose(None) 

sage: P.<x,y> = ProjectiveSpace(QQ,1) 

sage: f = DynamicalSystem_projective([x^3-2*x*y^2 + 2*y^3, y^3]) 

sage: f.critical_points() 

[(1 : 0)] 

sage: K.<w> = QuadraticField(6) 

sage: f.critical_points(K) 

[(-1/3*w : 1), (1/3*w : 1), (1 : 0)] 

 

:: 

 

sage: set_verbose(None) 

sage: P.<x,y> = ProjectiveSpace(QQ,1) 

sage: f = DynamicalSystem_projective([2*x^2-y^2, x*y]) 

sage: f.critical_points(QQbar) 

[(-0.7071067811865475?*I : 1), (0.7071067811865475?*I : 1)] 

""" 

PS = self.domain() 

if PS.dimension_relative() > 1: 

raise NotImplementedError("use .wronskian_ideal() for dimension > 1") 

if R is None: 

F = self 

else: 

F = self.change_ring(R) 

P = F.codomain() 

X = F.critical_subscheme() 

crit_points = [P(Q) for Q in X.rational_points()] 

return crit_points 

 

def is_postcritically_finite(self, err=0.01, embedding=None): 

r""" 

Determine if this dynamical system is post-critically finite. 

 

Only for endomorphisms of `\mathbb{P}^1`. It checks if each critical 

point is preperiodic. The optional parameter ``err`` is passed into 

``is_preperiodic()`` as part of the preperiodic check. 

 

INPUT: 

 

- ``err`` -- (default: 0.01) positive real number 

 

- ``embedding`` -- embedding of base ring into `\QQbar` 

 

OUTPUT: boolean 

 

EXAMPLES:: 

 

sage: P.<x,y> = ProjectiveSpace(QQ,1) 

sage: f = DynamicalSystem_projective([x^2 - y^2, y^2]) 

sage: f.is_postcritically_finite() 

True 

 

:: 

 

sage: P.<x,y> = ProjectiveSpace(QQ,1) 

sage: f = DynamicalSystem_projective([x^3- y^3, y^3]) 

sage: f.is_postcritically_finite() 

False 

 

:: 

 

sage: R.<z> = QQ[] 

sage: K.<v> = NumberField(z^8 + 3*z^6 + 3*z^4 + z^2 + 1) 

sage: PS.<x,y> = ProjectiveSpace(K,1) 

sage: f = DynamicalSystem_projective([x^3+v*y^3, y^3]) 

sage: f.is_postcritically_finite(embedding=K.embeddings(QQbar)[0]) # long time 

True 

 

:: 

 

sage: P.<x,y> = ProjectiveSpace(QQ,1) 

sage: f = DynamicalSystem_projective([6*x^2+16*x*y+16*y^2, -3*x^2-4*x*y-4*y^2]) 

sage: f.is_postcritically_finite() 

True 

""" 

#iteration of subschemes not yet implemented 

if self.domain().dimension_relative() > 1: 

raise NotImplementedError("only implemented in dimension 1") 

 

#Since is_preperiodic uses heights we need to be over a numberfield 

K = FractionField(self.codomain().base_ring()) 

if not K in NumberFields() and not K is QQbar: 

raise NotImplementedError("must be over a number field or a number field order or QQbar") 

 

if embedding is None: 

F = self.change_ring(QQbar) 

else: 

F = self.change_ring(embedding) 

crit_points = F.critical_points() 

pcf = True 

i = 0 

while pcf and i < len(crit_points): 

if crit_points[i].is_preperiodic(F, err) == False: 

pcf = False 

i += 1 

return(pcf) 

 

def critical_point_portrait(self, check=True, embedding=None): 

r""" 

If this dynamical system is post-critically finite, return its 

critical point portrait. 

 

This is the directed graph of iterates starting with the critical 

points. Must be dimension 1. If ``check`` is ``True``, then the 

map is first checked to see if it is postcritically finite. 

 

INPUT: 

 

- ``check`` -- boolean 

 

- ``embedding`` -- embedding of base ring into `\QQbar` 

 

OUTPUT: a digraph 

 

EXAMPLES:: 

 

sage: R.<z> = QQ[] 

sage: K.<v> = NumberField(z^6 + 2*z^5 + 2*z^4 + 2*z^3 + z^2 + 1) 

sage: PS.<x,y> = ProjectiveSpace(K,1) 

sage: f = DynamicalSystem_projective([x^2+v*y^2, y^2]) 

sage: f.critical_point_portrait(check=False, embedding=K.embeddings(QQbar)[0]) # long time 

Looped digraph on 6 vertices 

 

:: 

 

sage: P.<x,y> = ProjectiveSpace(QQ,1) 

sage: f = DynamicalSystem_projective([x^5 + 5/4*x*y^4, y^5]) 

sage: f.critical_point_portrait(check=False) 

Looped digraph on 5 vertices 

 

:: 

 

sage: P.<x,y> = ProjectiveSpace(QQ,1) 

sage: f = DynamicalSystem_projective([x^2 + 2*y^2, y^2]) 

sage: f.critical_point_portrait() 

Traceback (most recent call last): 

... 

TypeError: map must be post-critically finite 

""" 

#input checking done in is_postcritically_finite 

if check: 

if not self.is_postcritically_finite(): 

raise TypeError("map must be post-critically finite") 

if embedding is None: 

F = self.change_ring(QQbar) 

else: 

F = self.change_ring(embedding) 

crit_points = F.critical_points() 

N = len(crit_points) 

for i in range(N): 

done = False 

Q= F(crit_points[i]) 

while not done: 

if Q in crit_points: 

done = True 

else: 

crit_points.append(Q) 

Q = F(Q) 

return(F._preperiodic_points_to_cyclegraph(crit_points)) 

 

def critical_height(self, **kwds): 

r""" 

Compute the critical height of this dynamical system. 

 

The critical height is defined by J. Silverman as 

the sum of the canonical heights of the critical points. 

This must be dimension 1 and defined over a number field 

or number field order. 

 

INPUT: 

 

kwds: 

 

- ``badprimes`` -- (optional) a list of primes of bad reduction 

 

- ``N`` -- (default: 10) positive integer; number of terms of 

the series to use in the local green functions 

 

- ``prec`` -- (default: 100) positive integer, float point 

or `p`-adic precision 

 

- ``error_bound`` -- (optional) a positive real number 

 

- ``embedding`` -- (optional) the embedding of the base field to `\QQbar` 

 

OUTPUT: real number 

 

EXAMPLES:: 

 

sage: P.<x,y> = ProjectiveSpace(QQ,1) 

sage: f = DynamicalSystem_projective([x^3+7*y^3, 11*y^3]) 

sage: f.critical_height() 

1.1989273321156851418802151128 

 

:: 

 

sage: K.<w> = QuadraticField(2) 

sage: P.<x,y> = ProjectiveSpace(K,1) 

sage: f = DynamicalSystem_projective([x^2+w*y^2, y^2]) 

sage: f.critical_height() 

0.16090842452312941163719755472 

 

Postcritically finite maps have critical height 0:: 

 

sage: P.<x,y> = ProjectiveSpace(QQ,1) 

sage: f = DynamicalSystem_projective([x^3-3/4*x*y^2 + 3/4*y^3, y^3]) 

sage: f.critical_height(error_bound=0.0001) 

0.00000000000000000000000000000 

""" 

PS = self.codomain() 

if PS.dimension_relative() > 1: 

raise NotImplementedError("only implemented in dimension 1") 

 

K = FractionField(PS.base_ring()) 

if not K in NumberFields() and not K is QQbar: 

raise NotImplementedError("must be over a number field or a number field order or QQbar") 

#doesn't really matter which we choose as Galois conjugates have the same height 

emb = kwds.get("embedding", K.embeddings(QQbar)[0]) 

F = self.change_ring(K).change_ring(emb) 

crit_points = F.critical_points() 

n = len(crit_points) 

err_bound = kwds.get("error_bound", None) 

if not err_bound is None: 

kwds["error_bound"] = err_bound / n 

ch = 0 

for P in crit_points: 

ch += F.canonical_height(P, **kwds) 

return ch 

 

def periodic_points(self, n, minimal=True, R=None, algorithm='variety', 

return_scheme=False): 

r""" 

Computes the periodic points of period ``n`` of this dynamical system 

defined over the ring ``R`` or the base ring of the map. 

 

This can be done either by finding the rational points on the variety 

defining the points of period ``n``, or, for finite fields, 

finding the cycle of appropriate length in the cyclegraph. For small 

cardinality fields, the cyclegraph algorithm is effective for any 

map and length cycle, but is slow when the cyclegraph is large. 

The variety algorithm is good for small period, degree, and dimension, 

but is slow as the defining equations of the variety get more 

complicated. 

 

For rational map, where there are potentially infinitely many peiodic 

points of a given period, you must use the ``return_scheme`` option. 

Note that this scheme will include the indeterminacy locus. 

 

INPUT: 

 

- ``n`` - a positive integer 

 

- ``minimal`` -- (default: ``True``) boolean; ``True`` specifies to 

find only the periodic points of minimal period ``n`` and ``False`` 

specifies to find all periodic points of period ``n`` 

 

- ``R`` a commutative ring 

 

- ``algorithm`` -- (default: ``'variety'``) must be one of 

the following: 

 

* ``'variety'`` - find the rational points on the appropriate variety 

* ``'cyclegraph'`` - find the cycles from the cycle graph 

 

- ``return_scheme`` -- return a subscheme of the ambient space 

that defines the ``n`` th periodic points 

 

OUTPUT: 

 

A list of periodic points of this map or the subscheme defining 

the periodic points. 

 

EXAMPLES:: 

 

sage: set_verbose(None) 

sage: P.<x,y> = ProjectiveSpace(QQbar,1) 

sage: f = DynamicalSystem_projective([x^2-x*y+y^2, x^2-y^2+x*y]) 

sage: f.periodic_points(1) 

[(-0.500000000000000? - 0.866025403784439?*I : 1), 

(-0.500000000000000? + 0.866025403784439?*I : 1), 

(1 : 1)] 

 

:: 

 

sage: P.<x,y,z> = ProjectiveSpace(QuadraticField(5,'t'),2) 

sage: f = DynamicalSystem_projective([x^2 - 21/16*z^2, y^2-z^2, z^2]) 

sage: f.periodic_points(2) 

[(-5/4 : -1 : 1), (-5/4 : -1/2*t + 1/2 : 1), (-5/4 : 0 : 1), 

(-5/4 : 1/2*t + 1/2 : 1), (-3/4 : -1 : 1), (-3/4 : 0 : 1), 

(1/4 : -1 : 1), (1/4 : -1/2*t + 1/2 : 1), (1/4 : 0 : 1), 

(1/4 : 1/2*t + 1/2 : 1), (7/4 : -1 : 1), (7/4 : 0 : 1)] 

 

:: 

 

sage: w = QQ['w'].0 

sage: K = NumberField(w^6 - 3*w^5 + 5*w^4 - 5*w^3 + 5*w^2 - 3*w + 1,'s') 

sage: P.<x,y,z> = ProjectiveSpace(K,2) 

sage: f = DynamicalSystem_projective([x^2+z^2, y^2+x^2, z^2+y^2]) 

sage: f.periodic_points(1) 

[(-s^5 + 3*s^4 - 5*s^3 + 4*s^2 - 3*s + 1 : s^5 - 2*s^4 + 3*s^3 - 3*s^2 + 4*s - 1 : 1), 

(-2*s^5 + 4*s^4 - 5*s^3 + 3*s^2 - 4*s : -2*s^5 + 5*s^4 - 7*s^3 + 6*s^2 - 7*s + 3 : 1), 

(-s^5 + 3*s^4 - 4*s^3 + 4*s^2 - 4*s + 2 : -s^5 + 2*s^4 - 2*s^3 + s^2 - s : 1), 

(s^5 - 2*s^4 + 3*s^3 - 3*s^2 + 3*s - 1 : -s^5 + 3*s^4 - 5*s^3 + 4*s^2 - 4*s + 2 : 1), 

(2*s^5 - 6*s^4 + 9*s^3 - 8*s^2 + 7*s - 4 : 2*s^5 - 5*s^4 + 7*s^3 - 5*s^2 + 6*s - 2 : 1), 

(1 : 1 : 1), 

(s^5 - 2*s^4 + 2*s^3 + s : s^5 - 3*s^4 + 4*s^3 - 3*s^2 + 2*s - 1 : 1)] 

 

:: 

 

sage: P.<x,y,z> = ProjectiveSpace(QQ,2) 

sage: f = DynamicalSystem_projective([x^2 - 21/16*z^2, y^2-2*z^2, z^2]) 

sage: f.periodic_points(2, False) 

[(-5/4 : -1 : 1), (-5/4 : 2 : 1), (-3/4 : -1 : 1), 

(-3/4 : 2 : 1), (0 : 1 : 0), (1/4 : -1 : 1), (1/4 : 2 : 1), 

(1 : 0 : 0), (1 : 1 : 0), (7/4 : -1 : 1), (7/4 : 2 : 1)] 

 

:: 

 

sage: P.<x,y,z> = ProjectiveSpace(QQ,2) 

sage: f = DynamicalSystem_projective([x^2 - 21/16*z^2, y^2-2*z^2, z^2]) 

sage: f.periodic_points(2) 

[(-5/4 : -1 : 1), (-5/4 : 2 : 1), (1/4 : -1 : 1), (1/4 : 2 : 1)] 

 

:: 

 

sage: set_verbose(None) 

sage: P.<x,y> = ProjectiveSpace(ZZ, 1) 

sage: f = DynamicalSystem_projective([x^2+y^2,y^2]) 

sage: f.periodic_points(2, R=QQbar, minimal=False) 

[(-0.500000000000000? - 1.322875655532296?*I : 1), 

(-0.500000000000000? + 1.322875655532296?*I : 1), 

(0.500000000000000? - 0.866025403784439?*I : 1), 

(0.500000000000000? + 0.866025403784439?*I : 1), 

(1 : 0)] 

 

:: 

 

sage: P.<x,y> = ProjectiveSpace(GF(307), 1) 

sage: f = DynamicalSystem_projective([x^10+y^10, y^10]) 

sage: f.periodic_points(16, minimal=True, algorithm='cyclegraph') 

[(69 : 1), (185 : 1), (120 : 1), (136 : 1), (97 : 1), (183 : 1), 

(170 : 1), (105 : 1), (274 : 1), (275 : 1), (154 : 1), (156 : 1), 

(87 : 1), (95 : 1), (161 : 1), (128 : 1)] 

 

:: 

 

sage: P.<x,y> = ProjectiveSpace(GF(13^2,'t'),1) 

sage: f = DynamicalSystem_projective([x^3 + 3*y^3, x^2*y]) 

sage: f.periodic_points(30, minimal=True, algorithm='cyclegraph') 

[(t + 3 : 1), (6*t + 6 : 1), (7*t + 1 : 1), (2*t + 8 : 1), 

(3*t + 4 : 1), (10*t + 12 : 1), (8*t + 10 : 1), (5*t + 11 : 1), 

(7*t + 4 : 1), (4*t + 8 : 1), (9*t + 1 : 1), (2*t + 2 : 1), 

(11*t + 9 : 1), (5*t + 7 : 1), (t + 10 : 1), (12*t + 4 : 1), 

(7*t + 12 : 1), (6*t + 8 : 1), (11*t + 10 : 1), (10*t + 7 : 1), 

(3*t + 9 : 1), (5*t + 5 : 1), (8*t + 3 : 1), (6*t + 11 : 1), 

(9*t + 12 : 1), (4*t + 10 : 1), (11*t + 4 : 1), (2*t + 7 : 1), 

(8*t + 12 : 1), (12*t + 11 : 1)] 

 

:: 

 

sage: P.<x,y> = ProjectiveSpace(QQ,1) 

sage: f = DynamicalSystem_projective([3*x^2+5*y^2,y^2]) 

sage: f.periodic_points(2, R=GF(3), minimal=False) 

[(2 : 1)] 

 

:: 

 

sage: P.<x,y,z> = ProjectiveSpace(QQ, 2) 

sage: f = DynamicalSystem_projective([x^2, x*y, z^2]) 

sage: f.periodic_points(1) 

Traceback (most recent call last): 

... 

TypeError: use return_scheme=True 

 

:: 

 

sage: R.<x> = QQ[] 

sage: K.<u> = NumberField(x^2 - x + 3) 

sage: P.<x,y,z> = ProjectiveSpace(K,2) 

sage: X = P.subscheme(2*x-y) 

sage: f = DynamicalSystem_projective([x^2-y^2, 2*(x^2-y^2), y^2-z^2], domain=X) 

sage: f.periodic_points(2) 

[(-1/5*u - 1/5 : -2/5*u - 2/5 : 1), (1/5*u - 2/5 : 2/5*u - 4/5 : 1)] 

 

:: 

 

sage: P.<x,y,z> = ProjectiveSpace(QQ,2) 

sage: f = DynamicalSystem_projective([x^2-y^2, x^2-z^2, y^2-z^2]) 

sage: f.periodic_points(1) 

[(-1 : 0 : 1)] 

sage: f.periodic_points(1, return_scheme=True) 

Closed subscheme of Projective Space of dimension 2 over Rational Field 

defined by: 

-x^3 + x^2*y - y^3 + x*z^2, 

-x*y^2 + x^2*z - y^2*z + x*z^2, 

-y^3 + x^2*z + y*z^2 - z^3 

sage: f.periodic_points(2, minimal=True, return_scheme=True) 

Traceback (most recent call last): 

... 

NotImplementedError: return_subscheme only implemented for minimal=False 

""" 

if n <= 0: 

raise ValueError("a positive integer period must be specified") 

if R is None: 

f = self 

R = self.base_ring() 

else: 

f = self.change_ring(R) 

CR = f.coordinate_ring() 

dom = f.domain() 

PS = f.codomain().ambient_space() 

N = PS.dimension_relative() + 1 

if algorithm == 'cyclegraph': 

if R in FiniteFields(): 

g = f.cyclegraph() 

points = [] 

for cycle in g.all_simple_cycles(): 

m = len(cycle)-1 

if minimal: 

if m == n: 

points = points + cycle[:-1] 

else: 

if n % m == 0: 

points = points + cycle[:-1] 

return(points) 

else: 

raise TypeError("ring must be finite to generate cyclegraph") 

elif algorithm == 'variety': 

F = f.nth_iterate_map(n) 

L = [F[i]*CR.gen(j) - F[j]*CR.gen(i) for i in range(0,N) 

for j in range(i+1, N)] 

L = [t for t in L if t != 0] 

X = PS.subscheme(L + list(dom.defining_polynomials())) 

if return_scheme: # this includes the indeterminacy locus points! 

if minimal and n != 1: 

raise NotImplementedError("return_subscheme only implemented for minimal=False") 

return X 

if X.dimension() == 0: 

if R in NumberFields() or R is QQbar or R in FiniteFields(): 

Z = f.indeterminacy_locus() 

points = [dom(Q) for Q in X.rational_points()] 

good_points = [] 

for Q in points: 

try: 

Z(list(Q)) 

except TypeError: 

good_points.append(Q) 

points = good_points 

 

if not minimal: 

return points 

else: 

#we want only the points with minimal period n 

#so we go through the list and remove any that 

#have smaller period by checking the iterates 

for i in range(len(points)-1,-1,-1): 

# iterate points to check if minimal 

P = points[i] 

for j in range(1,n): 

P = f(P) 

if P == points[i]: 

points.pop(i) 

break 

return points 

else: 

raise NotImplementedError("ring must a number field or finite field") 

else: #a higher dimensional scheme 

raise TypeError("use return_scheme=True") 

else: 

raise ValueError("algorithm must be either 'variety' or 'cyclegraph'") 

 

def multiplier_spectra(self, n, formal=False, embedding=None, type='point'): 

r""" 

Computes the ``n`` multiplier spectra of this dynamical system. 

 

This is the set of multipliers of the periodic points of formal 

period ``n`` included with the appropriate multiplicity. 

User can also specify to compute the ``n`` multiplier spectra 

instead which includes the multipliers of all periodic points 

of period ``n``. The map must be defined over 

projective space of dimension 1 over a number field. 

 

INPUT: 

 

- ``n`` -- a positive integer, the period 

 

- ``formal`` -- (default: ``False``) boolean; ``True`` specifies 

to find the formal ``n`` multiplier spectra of this map and 

``False`` specifies to find the ``n`` multiplier spectra 

 

- ``embedding`` -- embedding of the base field into `\QQbar` 

 

- ``type`` -- (default: ``'point'``) string; either ``'point'`` 

or ``'cycle'`` depending on whether you compute one multiplier 

per point or one per cycle 

 

OUTPUT: a list of `\QQbar` elements 

 

EXAMPLES:: 

 

sage: P.<x,y> = ProjectiveSpace(QQ,1) 

sage: f = DynamicalSystem_projective([4608*x^10 - 2910096*x^9*y + 325988068*x^8*y^2 + 31825198932*x^7*y^3 - 4139806626613*x^6*y^4\ 

- 44439736715486*x^5*y^5 + 2317935971590902*x^4*y^6 - 15344764859590852*x^3*y^7 + 2561851642765275*x^2*y^8\ 

+ 113578270285012470*x*y^9 - 150049940203963800*y^10, 4608*y^10]) 

sage: f.multiplier_spectra(1) 

[0, -7198147681176255644585/256, 848446157556848459363/19683, -3323781962860268721722583135/35184372088832, 

529278480109921/256, -4290991994944936653/2097152, 1061953534167447403/19683, -3086380435599991/9, 

82911372672808161930567/8192, -119820502365680843999, 3553497751559301575157261317/8192] 

 

:: 

 

sage: set_verbose(None) 

sage: z = QQ['z'].0 

sage: K.<w> = NumberField(z^4 - 4*z^2 + 1,'z') 

sage: P.<x,y> = ProjectiveSpace(K,1) 

sage: f = DynamicalSystem_projective([x^2 - w/4*y^2, y^2]) 

sage: f.multiplier_spectra(2, formal=False, embedding=K.embeddings(QQbar)[0], type='cycle') 

[0, 

5.931851652578137? + 0.?e-47*I, 

0.0681483474218635? - 1.930649271699173?*I, 

0.0681483474218635? + 1.930649271699173?*I] 

 

:: 

 

sage: P.<x,y> = ProjectiveSpace(QQ,1) 

sage: f = DynamicalSystem_projective([x^2 - 3/4*y^2, y^2]) 

sage: f.multiplier_spectra(2, formal=False, type='cycle') 

[0, 1, 1, 9] 

sage: f.multiplier_spectra(2, formal=False, type='point') 

[0, 1, 1, 1, 9] 

 

:: 

 

sage: P.<x,y> = ProjectiveSpace(QQ,1) 

sage: f = DynamicalSystem_projective([x^2 - 7/4*y^2, y^2]) 

sage: f.multiplier_spectra(3, formal=True, type='cycle') 

[1, 1] 

sage: f.multiplier_spectra(3, formal=True, type='point') 

[1, 1, 1, 1, 1, 1] 

 

:: 

 

sage: P.<x,y> = ProjectiveSpace(QQ,1) 

sage: f = DynamicalSystem_projective([x^2 + y^2, x*y]) 

sage: f.multiplier_spectra(1) 

[1, 1, 1] 

""" 

PS = self.domain() 

n = Integer(n) 

 

if (n < 1): 

raise ValueError("period must be a positive integer") 

if not is_ProjectiveSpace(PS): 

raise NotImplementedError("not implemented for subschemes") 

if (PS.dimension_relative() > 1): 

raise NotImplementedError("only implemented for dimension 1") 

if not PS.base_ring() in NumberFields() and not PS.base_ring() is QQbar: 

raise NotImplementedError("self must be a map over a number field") 

 

if embedding is None: 

f = self.change_ring(QQbar) 

else: 

f = self.change_ring(embedding) 

 

PS = f.domain() 

 

if not formal: 

G = f.nth_iterate_map(n) 

F = G[0]*PS.gens()[1] - G[1]*PS.gens()[0] 

else: 

# periodic points of formal period n are the roots of the nth dynatomic polynomial 

K = f._number_field_from_algebraics().as_dynamical_system() 

F = K.dynatomic_polynomial(n) 

if K.domain().base_ring() != QQ: # need to coerce F to poly over QQbar. This is only needed if base ring is not QQ 

abspoly = K.domain().base_ring().absolute_polynomial() 

phi = K.domain().base_ring().hom(QQbar.polynomial_root(abspoly,abspoly.any_root(CIF)),QQbar) 

Kx = K.coordinate_ring() 

QQbarx = QQbar[Kx.variable_names()] 

phix = Kx.hom(phi,QQbarx) 

F = phix(F) 

 

other_roots = F.parent()(F([(f.domain().gens()[0]),1])).univariate_polynomial().roots(ring=QQbar) 

 

points = [] 

 

minfty = min([e[1] for e in F.exponents()]) # include the point at infinity with the right multiplicity 

for i in range(minfty): 

points.append(PS([1,0])) 

 

for R in other_roots: 

for i in range(R[1]): 

points.append(PS([R[0],1])) # include copies of higher multiplicity roots 

 

if type == 'cycle': 

# should include one representative point per cycle, included with the right multiplicity 

newpoints = [] 

 

while points: 

P = points[0] 

newpoints.append(P) 

points.pop(0) 

Q = P 

for i in range(1,n): 

try: 

points.remove(f(Q)) 

except ValueError: 

pass 

Q = f(Q) 

points = newpoints 

 

multipliers = [f.multiplier(pt,n)[0,0] for pt in points] 

 

return multipliers 

 

def sigma_invariants(self, n, formal=False, embedding=None, type='point'): 

r""" 

Computes the values of the elementary symmetric polynomials of 

the ``n`` multiplier spectra of this dynamical system. 

 

Can specify to instead compute the values corresponding to the 

elementary symmetric polynomials of the formal ``n`` multiplier 

spectra. The map must be defined over projective space of dimension 

`1`. The base ring should be a number field, number field order, or 

a finite field or a polynomial ring or function field over a 

number field, number field order, or finite field. 

 

The parameter ``type`` determines if the sigma are computed from 

the multipliers calculated at one per cycle (with multiplicity) 

or one per point (with multiplicity). Note that in the ``cycle`` 

case, a map with a cycle which collapses into multiple smaller 

cycles, this is still considered one cycle. In other words, if a 

4-cycle collapses into a 2-cycle with multiplicity 2, there is only 

one multiplier used for the doubled 2-cycle when computing ``n=4``. 

 

ALGORITHM: 

 

We use the Poisson product of the resultant of two polynomials: 

 

.. MATH:: 

 

res(f,g) = \prod_{f(a)=0} g(a). 

 

Letting `f` be the polynomial defining the periodic or formal 

periodic points and `g` the polynomial `w - f'` for an auxilarly 

variable `w`. Note that if `f` is a rational function, we clear 

denominators for `g`. 

 

INPUT: 

 

- ``n`` -- a positive integer, the period 

 

- ``formal`` -- (default: ``False``) boolean; ``True`` specifies 

to find the values of the elementary symmetric polynomials 

corresponding to the formal ``n`` multiplier spectra and ``False`` 

specifies to instead find the values corresponding to the ``n`` 

multiplier spectra, which includes the multipliers of all 

periodic points of period ``n`` 

 

- ``embedding`` -- deprecated in :trac:`23333` 

 

- ``type`` -- (default: ``'point'``) string; either ``'point'`` 

or ``'cycle'`` depending on whether you compute with one 

multiplier per point or one per cycle 

 

OUTPUT: a list of elements in the base ring 

 

EXAMPLES:: 

 

sage: P.<x,y> = ProjectiveSpace(QQ,1) 

sage: f = DynamicalSystem_projective([512*x^5 - 378128*x^4*y + 76594292*x^3*y^2 - 4570550136*x^2*y^3 - 2630045017*x*y^4\ 

+ 28193217129*y^5, 512*y^5]) 

sage: f.sigma_invariants(1) 

[19575526074450617/1048576, -9078122048145044298567432325/2147483648, 

-2622661114909099878224381377917540931367/1099511627776, 

-2622661107937102104196133701280271632423/549755813888, 

338523204830161116503153209450763500631714178825448006778305/72057594037927936, 0] 

 

:: 

 

sage: set_verbose(None) 

sage: z = QQ['z'].0 

sage: K = NumberField(z^4 - 4*z^2 + 1, 'z') 

sage: P.<x,y> = ProjectiveSpace(K, 1) 

sage: f = DynamicalSystem_projective([x^2 - 5/4*y^2, y^2]) 

sage: f.sigma_invariants(2, formal=False, type='cycle') 

[13, 11, -25, 0] 

sage: f.sigma_invariants(2, formal=False, type='point') 

[12, -2, -36, 25, 0] 

 

check that infinity as part of a longer cycle is handled correctly:: 

 

sage: P.<x,y> = ProjectiveSpace(QQ, 1) 

sage: f = DynamicalSystem_projective([y^2, x^2]) 

sage: f.sigma_invariants(2, type='cycle') 

[12, 48, 64, 0] 

sage: f.sigma_invariants(2, type='point') 

[12, 48, 64, 0, 0] 

sage: f.sigma_invariants(2, type='cycle', formal=True) 

[0] 

sage: f.sigma_invariants(2, type='point', formal=True) 

[0, 0] 

 

:: 

 

sage: P.<x,y,z> = ProjectiveSpace(QQ, 2) 

sage: f = DynamicalSystem_projective([x^2, y^2, z^2]) 

sage: f.sigma_invariants(1) 

Traceback (most recent call last): 

... 

NotImplementedError: only implemented for dimension 1 

 

:: 

 

sage: K.<w> = QuadraticField(3) 

sage: P.<x,y> = ProjectiveSpace(K, 1) 

sage: f = DynamicalSystem_projective([x^2 - w*y^2, (1-w)*x*y]) 

sage: f.sigma_invariants(2, formal=False, type='cycle') 

[6*w + 21, 78*w + 159, 210*w + 367, 90*w + 156] 

sage: f.sigma_invariants(2, formal=False, type='point') 

[6*w + 24, 96*w + 222, 444*w + 844, 720*w + 1257, 270*w + 468] 

 

:: 

 

sage: P.<x,y> = ProjectiveSpace(QQ,1) 

sage: f = DynamicalSystem_projective([x^2 + x*y + y^2, y^2 + x*y]) 

sage: f.sigma_invariants(1) 

[3, 3, 1] 

 

:: 

 

sage: R.<c> = QQ[] 

sage: Pc.<x,y> = ProjectiveSpace(R, 1) 

sage: f = DynamicalSystem_projective([x^2 + c*y^2, y^2]) 

sage: f.sigma_invariants(1) 

[2, 4*c, 0] 

sage: f.sigma_invariants(2, formal=True, type='point') 

[8*c + 8, 16*c^2 + 32*c + 16] 

sage: f.sigma_invariants(2, formal=True, type='cycle') 

[4*c + 4] 

 

doubled fixed point:: 

 

sage: P.<x,y> = ProjectiveSpace(QQ, 1) 

sage: f = DynamicalSystem_projective([x^2 - 3/4*y^2, y^2]) 

sage: f.sigma_invariants(2, formal=True) 

[2, 1] 

 

doubled 2 cycle:: 

 

sage: P.<x,y> = ProjectiveSpace(QQ, 1) 

sage: f = DynamicalSystem_projective([x^2 - 5/4*y^2, y^2]) 

sage: f.sigma_invariants(4, formal=False, type='cycle') 

[170, 5195, 172700, 968615, 1439066, 638125, 0] 

""" 

n = ZZ(n) 

if n < 1: 

raise ValueError("period must be a positive integer") 

dom = self.domain() 

if not is_ProjectiveSpace(dom): 

raise NotImplementedError("not implemented for subschemes") 

if dom.dimension_relative() > 1: 

raise NotImplementedError("only implemented for dimension 1") 

if not embedding is None: 

from sage.misc.superseded import deprecation 

deprecation(23333, "embedding keyword no longer used") 

if self.degree() <= 1: 

raise TypeError("must have degree at least 2") 

if not type in ['point', 'cycle']: 

raise ValueError("type must be either point or cycle") 

 

base_ring = dom.base_ring() 

if is_FractionField(base_ring): 

base_ring = base_ring.ring() 

if (is_PolynomialRing(base_ring) or is_MPolynomialRing(base_ring) 

or base_ring in FunctionFields()): 

base_ring = base_ring.base_ring() 

from sage.rings.number_field.order import is_NumberFieldOrder 

if not (base_ring in NumberFields() or is_NumberFieldOrder(base_ring) 

or (base_ring in FiniteFields())): 

raise NotImplementedError("incompatible base field, see documentation") 

 

#now we find the two polynomials for the resultant 

Fn = self.nth_iterate_map(n) 

fn = Fn.dehomogenize(1) 

R = fn.domain().coordinate_ring() 

S = PolynomialRing(FractionField(self.base_ring()), 'z', 2) 

phi = R.hom([S.gen(0)], S) 

psi = dom.coordinate_ring().hom([S.gen(0), 1], S) #dehomogenize 

dfn = fn[0].derivative(R.gen()) 

 

#polynomial to be evaluated at the periodic points 

mult_poly = phi(dfn.denominator())*S.gen(1) - phi(dfn.numerator()) #w-f'(z) 

 

#polynomial defining the periodic points 

x,y = dom.gens() 

if formal: 

fix_poly = self.dynatomic_polynomial(n) #f(z)-z 

else: 

fix_poly = Fn[0]*y - Fn[1]*x #f(z) - z 

 

#check infinity 

inf = dom(1,0) 

inf_per = ZZ(1) 

Q = self(inf) 

while Q != inf and inf_per <= n: 

inf_per += 1 

Q = self(Q) 

#get multiplicity 

if inf_per <= n: 

e_inf = 0 

while (y**(e_inf + 1)).divides(fix_poly): 

e_inf += 1 

 

if type == 'cycle': 

#now we need to deal with having the correct number of factors 

#1 multiplier for each cycle. But we need to be careful about 

#the length of the cycle and the multiplicities 

good_res = 1 

if formal: 

#then we are working with the n-th dynatomic and just need 

#to take one multiplier per cycle 

 

#evaluate the resultant 

fix_poly = psi(fix_poly) 

res = fix_poly.resultant(mult_poly, S.gen(0)) 

#take infinity into consideration 

if inf_per.divides(n): 

res *= (S.gen(1) - self.multiplier(inf, n)[0,0])**e_inf 

res = res.univariate_polynomial() 

#adjust multiplicities 

L = res.factor() 

for p,e in L: 

good_res *= p**(e/n) 

else: 

#For each d-th dynatomic for d dividing n, take 

#one multiplier per cycle; e.g., this treats a double 2 

#cycle as a single 4 cycle for n=4 

for d in n.divisors(): 

fix_poly_d = self.dynatomic_polynomial(d) 

resd = mult_poly.resultant(psi(fix_poly_d), S.gen(0)) 

#check infinity 

if inf_per == d: 

e_inf_d = 0 

while (y**(e_inf_d + 1)).divides(fix_poly_d): 

e_inf_d += 1 

resd *= (S.gen(1) - self.multiplier(inf, n)[0,0])**e_inf 

resd = resd.univariate_polynomial() 

Ld = resd.factor() 

for pd,ed in Ld: 

good_res *= pd**(ed/d) 

res = good_res 

else: #type is 'point' 

#evaluate the resultant 

fix_poly = psi(fix_poly) 

res = fix_poly.resultant(mult_poly, S.gen(0)) 

#take infinity into consideration 

if inf_per.divides(n): 

res *= (S.gen(1) - self.multiplier(inf, n)[0,0])**e_inf 

res = res.univariate_polynomial() 

 

#the sigmas are the coeficients 

#need to fix the signs and the order 

sig = res.coefficients(sparse=False) 

den = sig.pop(-1) 

sig.reverse() 

sig = [sig[i] * (-1)**(i+1) / den for i in range(len(sig))] 

return sig 

 

def reduced_form(self, prec=300, return_conjugation=True, error_limit=0.000001): 

r""" 

Return reduced form of this dynamical system. 

 

The reduced form is the `SL(2, \ZZ)` equivalent morphism obtained 

by applying the binary form reduction algorithm from Stoll and 

Cremona [SC]_ to the homogeneous polynomial defining the periodic 

points (the dynatomic polynomial). The smallest period `n` with 

enough periodic points is used. 

 

This should also minimize the sum of the squares of the coefficients, 

but this is not always the case. 

 

See :meth:`sage.rings.polynomial.multi_polynomial.reduced_form` for 

the information on binary form reduction. 

 

Implemented by Rebecca Lauren Miller as part of GSOC 2016. 

 

INPUT: 

 

- ``prec`` -- (default: 300) integer, desired precision 

 

- ``return_conjuagtion`` -- (default: ``True``) boolean; return 

an element of `SL(2, \ZZ)` 

 

- ``error_limit`` -- (default: 0.000001) a real number, sets 

the error tolerance 

 

OUTPUT: 

 

- a projective morphism 

 

- a matrix 

 

EXAMPLES:: 

 

sage: PS.<x,y> = ProjectiveSpace(QQ, 1) 

sage: f = DynamicalSystem_projective([x^3 + x*y^2, y^3]) 

sage: m = matrix(QQ, 2, 2, [-221, -1, 1, 0]) 

sage: f = f.conjugate(m) 

sage: f.reduced_form(prec=100) #needs 2 periodic 

Traceback (most recent call last): 

... 

ValueError: not enough precision 

sage: f.reduced_form() 

( 

Dynamical System of Projective Space of dimension 1 over Rational Field 

Defn: Defined on coordinates by sending (x : y) to 

(x^3 + x*y^2 : y^3) 

, 

[ 0 -1] 

[ 1 221] 

) 

 

:: 

 

sage: PS.<x,y> = ProjectiveSpace(ZZ, 1) 

sage: f = DynamicalSystem_projective([x^2+ x*y, y^2]) #needs 3 periodic 

sage: m = matrix(QQ, 2, 2, [-221, -1, 1, 0]) 

sage: f = f.conjugate(m) 

sage: f.reduced_form(prec=200) 

( 

Dynamical System of Projective Space of dimension 1 over Integer Ring 

Defn: Defined on coordinates by sending (x : y) to 

(-x^2 + x*y - y^2 : -y^2) 

, 

[ 0 -1] 

[ 1 220] 

) 

 

:: 

 

sage: P.<x,y> = ProjectiveSpace(QQ, 1) 

sage: f = DynamicalSystem_projective([x^3, y^3]) 

sage: f.reduced_form() 

( 

Dynamical System of Projective Space of dimension 1 over Rational Field 

Defn: Defined on coordinates by sending (x : y) to 

(x^3 : y^3) 

, 

<BLANKLINE> 

[-1 0] 

[ 0 -1] 

) 

 

:: 

 

sage: PS.<X,Y> = ProjectiveSpace(QQ,1) 

sage: f = DynamicalSystem_projective([7365*X^4 + 12564*X^3*Y + 8046*X^2*Y^2 + 2292*X*Y^3 + 245*Y^4,\ 

-12329*X^4 - 21012*X^3*Y - 13446*X^2*Y^2 - 3828*X*Y^3 - 409*Y^4]) 

sage: f.reduced_form(prec=30) 

Traceback (most recent call last): 

... 

ValueError: accuracy of Newton's root not within tolerance(1.2519607 > 1e-06), increase precision 

sage: f.reduced_form() 

( 

Dynamical System of Projective Space of dimension 1 over Rational Field 

Defn: Defined on coordinates by sending (X : Y) to 

(-7*X^4 - 12*X^3*Y - 42*X^2*Y^2 - 12*X*Y^3 - 7*Y^4 : -X^4 - 4*X^3*Y - 6*X^2*Y^2 - 4*X*Y^3 - Y^4), 

<BLANKLINE> 

[-1 2] 

[ 2 -5] 

) 

 

:: 

 

sage: P.<x,y> = ProjectiveSpace(RR, 1) 

sage: f = DynamicalSystem_projective([x^4, RR(sqrt(2))*y^4]) 

sage: m = matrix(RR, 2, 2, [1,12,0,1]) 

sage: f = f.conjugate(m) 

sage: f.reduced_form() 

( 

Dynamical System of Projective Space of dimension 1 over Real Field with 53 bits of precision 

Defn: Defined on coordinates by sending (x : y) to 

(-x^4 + 2.86348722511320e-12*y^4 : -1.41421356237310*y^4) 

, 

<BLANKLINE> 

[-1 12] 

[ 0 -1] 

) 

 

:: 

 

sage: P.<x,y> = ProjectiveSpace(CC, 1) 

sage: f = DynamicalSystem_projective([x^4, CC(sqrt(-2))*y^4]) 

sage: m = matrix(CC, 2, 2, [1,12,0,1]) 

sage: f = f.conjugate(m) 

sage: f.reduced_form() 

( 

Dynamical System of Projective Space of dimension 1 over Complex Field with 53 bits of precision 

Defn: Defined on coordinates by sending (x : y) to 

(-x^4 + (-1.03914726748259e-15)*y^4 : (-8.65956056235493e-17 - 1.41421356237309*I)*y^4) , 

<BLANKLINE> 

[-1 12] 

[ 0 -1] 

) 

 

:: 

 

sage: K.<w> = QuadraticField(2) 

sage: P.<x,y> = ProjectiveSpace(K, 1) 

sage: f = DynamicalSystem_projective([x^3, w*y^3]) 

sage: m = matrix(K, 2, 2, [1,12,0,1]) 

sage: f = f.conjugate(m) 

sage: f.reduced_form() 

( 

Dynamical System of Projective Space of dimension 1 over Number Field in w with defining polynomial x^2 - 2 

Defn: Defined on coordinates by sending (x : y) to 

(x^3 : (w)*y^3) 

, 

<BLANKLINE> 

[-1 12] 

[ 0 -1] 

) 

 

:: 

 

sage: R.<x> = QQ[] 

sage: K.<w> = NumberField(x^5+x-3, embedding=(x^5+x-3).roots(ring=CC)[0][0]) 

sage: P.<x,y> = ProjectiveSpace(K, 1) 

sage: f = DynamicalSystem_projective([12*x^3, 2334*w*y^3]) 

sage: m = matrix(K, 2, 2, [-12,1,1,0]) 

sage: f = f.conjugate(m) 

sage: f.reduced_form() 

( 

Dynamical System of Projective Space of dimension 1 over Number Field 

in w with defining polynomial x^5 + x - 3 

Defn: Defined on coordinates by sending (x : y) to 

(12*x^3 : (2334*w)*y^3) 

, 

[ 0 -1] 

[ 1 -12] 

) 

""" 

R = self.coordinate_ring() 

F = R(self.dynatomic_polynomial(1)) 

x,y = R.gens() 

d = gcd(F, F.derivative(x)).degree() #counts multiple roots 

n = 2 

# Checks to make sure there are enough distinct, roots we need 3 

# if there are not it finds the nth periodic points until there are enough 

while F.degree() - d <= 2: 

F = self.dynatomic_polynomial(n) # finds n periodic points 

d = gcd(F, F.derivative(x)).degree() #counts multiple roots 

n += 1 

G,m = F.reduced_form(prec=prec, return_conjugation=return_conjugation) 

if return_conjugation: 

return (self.conjugate(m), m) 

return self.conjugate(m) 

 

def _is_preperiodic(self, P, err=0.1, return_period=False): 

r""" 

Determine if the point is preperiodic with respect to this 

dynamical system. 

 

.. NOTE:: 

 

This is only implemented for projective space (not subschemes). 

 

ALGORITHM: 

 

We know that a point is preperiodic if and only if it has 

canonical height zero. However, we can only compute the canonical 

height up to numerical precision. This function first computes 

the canonical height of the point to the given error bound. If 

it is larger than that error bound, then it must not be preperiodic. 

If it is less than the error bound, then we expect preperiodic. In 

this case we begin computing the orbit stopping if either we 

determine the orbit is finite, or the height of the point is large 

enough that it must be wandering. We can determine the height 

cutoff by computing the height difference constant, i.e., the bound 

between the height and the canonical height of a point (which 

depends only on the map and not the point itself). If the height 

of the point is larger than the difference bound, then the canonical 

height cannot be zero so the point cannot be preperiodic. 

 

INPUT: 

 

- ``P`` -- a point of this dynamical system's codomain 

 

kwds: 

 

- ``error_bound`` -- (default: 0.1) a positive real number; 

sets the error_bound used in the canonical height computation 

and ``return_period`` a boolean which 

 

- ``return_period`` -- (default: ``False``) boolean; controls if 

the period is returned if the point is preperiodic 

 

OUTPUT: 

 

- boolean -- ``True`` if preperiodic 

 

- if ``return_period`` is ``True``, then ``(0,0)`` if wandering, 

and ``(m,n)`` if preperiod ``m`` and period ``n`` 

 

EXAMPLES:: 

 

sage: P.<x,y> = ProjectiveSpace(QQ,1) 

sage: f = DynamicalSystem_projective([x^3-3*x*y^2, y^3], domain=P) 

sage: Q = P(-1, 1) 

sage: f._is_preperiodic(Q) 

True 

 

Check that :trac:`23814` is fixed (works even if domain is not specified):: 

 

sage: R.<X> = PolynomialRing(QQ) 

sage: K.<a> = NumberField(X^2 + X - 1) 

sage: P.<x,y> = ProjectiveSpace(K,1) 

sage: f = DynamicalSystem_projective([x^2-2*y^2, y^2]) 

sage: Q = P.point([a,1]) 

sage: Q.is_preperiodic(f) 

True 

""" 

if not is_ProjectiveSpace(self.codomain()): 

raise NotImplementedError("must be over projective space") 

if not self.is_morphism(): 

raise TypeError("must be a morphism") 

if not P.codomain() == self.domain(): 

raise TypeError("point must be in domain of map") 

 

K = FractionField(self.codomain().base_ring()) 

if not K in NumberFields() and not K is QQbar: 

raise NotImplementedError("must be over a number field or" 

" a number field order or QQbar") 

 

h = self.canonical_height(P, error_bound = err) 

# we know canonical height 0 if and only if preperiodic 

# however precision issues can occur so we can only tell *not* preperiodic 

# if the value is larger than the error 

if h <= err: 

# if the canonical height is less than than the 

# error, then we suspect preperiodic so check 

# either we can find the cycle or the height is 

# larger than the difference between the canonical height 

# and the height, so the canonical height cannot be 0 

B = self.height_difference_bound() 

orbit = [P] 

n = 1 # to compute period 

Q = self(P) 

H = Q.global_height() 

while Q not in orbit and H <= B: 

orbit.append(Q) 

Q = self(Q) 

H = Q.global_height() 

n += 1 

if H <= B: #it must have been in the cycle 

if return_period: 

m = orbit.index(Q) 

return((m, n-m)) 

else: 

return True 

if return_period: 

return (0,0) 

else: 

return False 

 

class DynamicalSystem_projective_field(DynamicalSystem_projective, 

SchemeMorphism_polynomial_projective_space_field): 

 

def lift_to_rational_periodic(self, points_modp, B=None): 

r""" 

Given a list of points in projective space over `\GF{p}`, 

determine if they lift to `\QQ`-rational periodic points. 

 

The map must be an endomorphism of projective space defined 

over `\QQ`. 

 

ALGORITHM: 

 

Use Hensel lifting to find a `p`-adic approximation for that 

rational point. The accuracy needed is determined by the height 

bound ``B``. Then apply the LLL algorithm to determine if the 

lift corresponds to a rational point. 

 

If the point is a point of high multiplicity (multiplier 1), the 

procedure can be very slow. 

 

INPUT: 

 

- ``points_modp`` -- a list or tuple of pairs containing a point 

in projective space over `\GF{p}` and the possible period 

 

- ``B`` -- (optional) a positive integer; the height bound for 

a rational preperiodic point 

 

OUTPUT: a list of projective points 

 

EXAMPLES:: 

 

sage: P.<x,y> = ProjectiveSpace(QQ,1) 

sage: f = DynamicalSystem_projective([x^2 - y^2, y^2]) 

sage: f.lift_to_rational_periodic([[P(0,1).change_ring(GF(7)), 4]]) 

[[(0 : 1), 2]] 

 

:: 

 

There may be multiple points in the lift. 

sage: P.<x,y> = ProjectiveSpace(QQ,1) 

sage: f = DynamicalSystem_projective([-5*x^2 + 4*y^2, 4*x*y]) 

sage: f.lift_to_rational_periodic([[P(1,0).change_ring(GF(3)), 1]]) # long time 

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

 

:: 

 

sage: P.<x,y> = ProjectiveSpace(QQ,1) 

sage: f = DynamicalSystem_projective([16*x^2 - 29*y^2, 16*y^2]) 

sage: f.lift_to_rational_periodic([[P(3,1).change_ring(GF(13)), 3]]) 

[[(-1/4 : 1), 3]] 

 

:: 

 

sage: P.<x,y,z> = ProjectiveSpace(QQ, 2) 

sage: f = DynamicalSystem_projective([76*x^2 - 180*x*y + 45*y^2 + 14*x*z + 45*y*z - 90*z^2, 67*x^2 - 180*x*y - 157*x*z + 90*y*z, -90*z^2]) 

sage: f.lift_to_rational_periodic([[P(14,19,1).change_ring(GF(23)), 9]]) # long time 

[[(-9 : -4 : 1), 9]] 

""" 

if not points_modp: 

return [] 

 

if B is None: 

B = e ** self.height_difference_bound() 

 

p = points_modp[0][0].codomain().base_ring().characteristic() 

if p == 0: 

raise TypeError("must be positive characteristic") 

PS = self.domain() 

N = PS.dimension_relative() 

R = RealField() 

#compute the maximum p-adic precision needed to conclusively determine 

#if the rational point exists 

L = R((R(2 ** (N/2 + 1) * sqrt(N+1) * B**2).log()) / R(p).log() + 1).trunc() 

 

points = [] 

for i in range(len(points_modp)): 

#[point mod p, period, current p-adic precision] 

points.append([points_modp[i][0].change_ring(QQ, check=False), points_modp[i][1], 1]) 

good_points = [] 

#shifts is used in non-Hensel lifting 

shifts = None 

#While there are still points to consider try to lift to next precision 

while points: 

q = points.pop() 

qindex = N 

#Find the last non-zero coordinate to use for normalizations 

while q[0][qindex] % p == 0: 

qindex -= 1 

T = q[0] 

n = q[1] 

k = q[2] 

T.scale_by(1 / T[qindex]) #normalize 

bad = 0 

#stop where we reach the needed precision or the point is bad 

while k < L and bad == 0: 

l = self._multipliermod(T, n, p, 2*k) 

l -= l.parent().one() #f^n(x) - x 

lp = l.change_ring(Zmod(p**k)) 

ldet = lp.determinant() 

# if the matrix is invertible then we can Hensel lift 

if ldet % p != 0: 

RQ = ZZ.quo(p**(2*k)) 

T.clear_denominators() 

newT = T.change_ring(RQ, check=False) 

fp = self.change_ring(RQ, check=False) 

S = fp.nth_iterate(newT, n, normalize=False).change_ring(QQ, check=False) 

T.scale_by(1 / T[qindex]) 

S.scale_by(1 / S[qindex]) 

newS = list(S) 

for i in range(N + 1): 

newS[i] = S[i] - T[i] 

if newS[i] % (p**k) != 0 and i != N: 

bad = 1 

break 

if bad == 1: 

break 

S = PS.point(newS, False) 

S.scale_by(-1 / p**k) 

vecs = [Zmod(p**k)(S._coords[iS]) for iS in range(N + 1)] 

vecs.pop(qindex) 

newvecs = list((lp.inverse()) * vector(vecs)) #l.inverse should be mod p^k!! 

newS = [] 

[newS.append(QQ(newvecs[i])) for i in range(qindex)] 

newS.append(0) 

[newS.append(QQ(newvecs[i])) for i in range(qindex, N)] 

for i in range(N + 1): 

newS[i] = newS[i] % (p**k) 

S = PS.point(newS, False) #don't check for [0,...,0] 

newT = list(T) 

for i in range(N + 1): 

newT[i] += S[i] * (p**k) 

T = PS.point(newT, False) 

T.normalize_coordinates() 

#Hensel gives us 2k for the newprecision 

k = min(2*k, L) 

else: 

#we are unable to Hensel Lift so must try all possible lifts 

#to the next precision (k+1) 

first = 0 

newq = [] 

RQ = Zmod(p**(k+1)) 

fp = self.change_ring(RQ, check=False) 

if shifts is None: 

shifts = xmrange([p for i in range(N)]) 

for shift in shifts: 

newT = [RQ(t) for t in T] #T.change_ring(RQ, check = False) 

shiftindex = 0 

for i in range(N + 1): 

if i != qindex: 

newT[i] = newT[i] + shift[shiftindex] * p**k 

shiftindex += 1 

newT = fp.domain().point(newT, check=False) 

TT = fp.nth_iterate(newT, n, normalize=False) 

if TT == newT: 

if first == 0: 

newq.append(newT.change_ring(QQ, check=False)) 

newq.append(n) 

newq.append(k + 1) 

first = 1 

else: 

points.append([newT.change_ring(QQ, check=False), n, k+1]) 

if not newq: 

bad = 1 

break 

else: 

T = newq[0] 

k += 1 

#given a p-adic lift of appropriate precision 

#perform LLL to find the "smallest" rational approximation 

#If this height is small enough, then it is a valid rational point 

if bad == 0: 

M = matrix(N + 2, N + 1) 

T.clear_denominators() 

for i in range(N + 1): 

M[0, i] = T[i] 

M[i+1, i] = p**L 

M[N+1, N] = p**L 

M = M.LLL() 

Q = [] 

[Q.append(M[1, i]) for i in range(N + 1)] 

g = gcd(Q) 

#remove gcds since this is a projective point 

newB = B * g 

for i in range(N + 1): 

if abs(Q[i]) > newB: 

#height too big, so not a valid point 

bad = 1 

break 

if bad == 0: 

P = PS.point(Q, False) 

#check that it is actually periodic 

newP = copy(P) 

k = 1 

done = False 

while not done and k <= n: 

newP = self(newP) 

if newP == P: 

if not ([P, k] in good_points): 

good_points.append([newP, k]) 

done = True 

k += 1 

 

return(good_points) 

 

def rational_periodic_points(self, **kwds): 

r""" 

Determine the set of rational periodic points 

for this dynamical system. 

 

The map must be defined over `\QQ` and be an endomorphism of 

projective space. If the map is a polynomial endomorphism of 

`\mathbb{P}^1`, i.e. has a totally ramified fixed point, then 

the base ring can be an absolute number field. 

This is done by passing to the Weil restriction. 

 

The default parameter values are typically good choices for 

`\mathbb{P}^1`. If you are having trouble getting a particular 

map to finish, try first computing the possible periods, then 

try various different ``lifting_prime`` values. 

 

ALGORITHM: 

 

Modulo each prime of good reduction `p` determine the set of 

periodic points modulo `p`. For each cycle modulo `p` compute 

the set of possible periods (`mrp^e`). Take the intersection 

of the list of possible periods modulo several primes of good 

reduction to get a possible list of minimal periods of rational 

periodic points. Take each point modulo `p` associated to each 

of these possible periods and try to lift it to a rational point 

with a combination of `p`-adic approximation and the LLL basis 

reduction algorithm. 

 

See [Hutz2015]_. 

 

INPUT: 

 

kwds: 

 

- ``prime_bound`` -- (default: ``[1,20]``) a pair (list or tuple) 

of positive integers that represent the limits of primes to use 

in the reduction step or an integer that represents the upper bound 

 

- ``lifting_prime`` -- (default: 23) a prime integer; argument that 

specifies modulo which prime to try and perform the lifting 

 

- ``periods`` -- (optional) a list of positive integers that is 

the list of possible periods 

 

- ``bad_primes`` -- (optional) a list or tuple of integer primes; 

the primes of bad reduction 

 

- ``ncpus`` -- (default: all cpus) number of cpus to use in parallel 

 

OUTPUT: a list of rational points in projective space 

 

EXAMPLES:: 

 

sage: P.<x,y> = ProjectiveSpace(QQ,1) 

sage: f = DynamicalSystem_projective([x^2-3/4*y^2, y^2]) 

sage: sorted(f.rational_periodic_points(prime_bound=20, lifting_prime=7)) # long time 

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

 

:: 

 

sage: P.<x,y,z> = ProjectiveSpace(QQ,2) 

sage: f = DynamicalSystem_projective([2*x^3 - 50*x*z^2 + 24*z^3, 

....: 5*y^3 - 53*y*z^2 + 24*z^3, 24*z^3]) 

sage: sorted(f.rational_periodic_points(prime_bound=[1,20])) # long time 

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

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

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

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

(5 : 1 : 1), (5 : 3 : 1)] 

 

:: 

 

sage: P.<x,y> = ProjectiveSpace(QQ,1) 

sage: f = DynamicalSystem_projective([-5*x^2 + 4*y^2, 4*x*y]) 

sage: sorted(f.rational_periodic_points()) # long time 

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

 

:: 

 

sage: R.<x> = QQ[] 

sage: K.<w> = NumberField(x^2-x+1) 

sage: P.<u,v> = ProjectiveSpace(K,1) 

sage: f = DynamicalSystem_projective([u^2 + v^2,v^2]) 

sage: f.rational_periodic_points() 

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

 

:: 

 

sage: R.<x> = QQ[] 

sage: K.<w> = NumberField(x^2-x+1) 

sage: P.<u,v> = ProjectiveSpace(K,1) 

sage: f = DynamicalSystem_projective([u^2+v^2,u*v]) 

sage: f.rational_periodic_points() 

Traceback (most recent call last): 

... 

NotImplementedError: rational periodic points for number fields only implemented for polynomials 

""" 

PS = self.domain() 

K = PS.base_ring() 

if K in NumberFields(): 

if not K.is_absolute(): 

raise TypeError("base field must be an absolute field") 

d = K.absolute_degree() 

#check that we are not over QQ 

if d > 1: 

if PS.dimension_relative() != 1: 

raise NotImplementedError("rational periodic points for number fields only implemented in dimension 1") 

w = K.absolute_generator() 

#we need to dehomogenize for the Weil restriction and will check that point at infty 

#separately. We also check here that we are working with a polynomial. If the map 

#is not a polynomial, the Weil restriction will not be a morphism and we cannot 

#apply this algorithm. 

g = self.dehomogenize(1) 

inf = PS([1,0]) 

k = 1 

if isinstance(g[0], FractionFieldElement): 

g = self.dehomogenize(0) 

inf = PS([0,1]) 

k = 0 

if isinstance(g[0], FractionFieldElement): 

raise NotImplementedError("rational periodic points for number fields only implemented for polynomials") 

#determine rational periodic points 

#infinity is a totally ramified fixed point for a polynomial 

periodic_points = set([inf]) 

#compute the weil restriction 

G = g.weil_restriction() 

F = G.homogenize(d) 

#find the QQ rational periodic points for the weil restriction 

Fper = F.rational_periodic_points(**kwds) 

for P in Fper: 

#take the 'good' points in the weil restriction and find the 

#associated number field points. 

if P[d] == 1: 

pt = [sum([P[i]*w**i for i in range(d)])] 

pt.insert(k,1) 

Q = PS(pt) 

#for each periodic point get the entire cycle 

if not Q in periodic_points: 

#check periodic not preperiodic and add all points in cycle 

orb = set([Q]) 

Q2 = self(Q) 

while Q2 not in orb: 

orb.add(Q2) 

Q2 = self(Q2) 

if Q2 == Q: 

periodic_points = periodic_points.union(orb) 

return list(periodic_points) 

else: 

primebound = kwds.pop("prime_bound", [1, 20]) 

p = kwds.pop("lifting_prime", 23) 

periods = kwds.pop("periods", None) 

badprimes = kwds.pop("bad_primes", None) 

num_cpus = kwds.pop("ncpus", ncpus()) 

 

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

try: 

primebound = [1, ZZ(primebound)] 

except TypeError: 

raise TypeError("bound on primes must be an integer") 

else: 

try: 

primebound[0] = ZZ(primebound[0]) 

primebound[1] = ZZ(primebound[1]) 

except TypeError: 

raise TypeError("prime bounds must be integers") 

 

if badprimes is None: 

badprimes = self.primes_of_bad_reduction() 

if periods is None: 

periods = self.possible_periods(prime_bound=primebound, bad_primes=badprimes, ncpus=num_cpus) 

PS = self.domain() 

periodic = set() 

while p in badprimes: 

p = next_prime(p + 1) 

B = e ** self.height_difference_bound() 

 

f = self.change_ring(GF(p)) 

all_points = f.possible_periods(True) #return the list of points and their periods. 

pos_points = [] 

for i in range(len(all_points)): 

if all_points[i][1] in periods and not (all_points[i] in pos_points): #check period, remove duplicates 

pos_points.append(all_points[i]) 

periodic_points = self.lift_to_rational_periodic(pos_points,B) 

for p,n in periodic_points: 

for k in range(n): 

p.normalize_coordinates() 

periodic.add(p) 

p = self(p) 

return list(periodic) 

else: 

raise TypeError("base field must be an absolute number field") 

 

def all_rational_preimages(self, points): 

r""" 

Given a set of rational points in the domain of this 

dynamical system, return all the rational preimages of those points. 

 

In others words, all the rational points which have some 

iterate in the set points. This function repeatedly calls 

``rational_preimages``. If the degree is at least two, 

by Northocott, this is always a finite set. The map must be 

defined over number fields and be an endomorphism. 

 

INPUT: 

 

- ``points`` -- a list of rational points in the domain of this map 

 

OUTPUT: a list of rational points in the domain of this map 

 

EXAMPLES:: 

 

sage: P.<x,y> = ProjectiveSpace(QQ,1) 

sage: f = DynamicalSystem_projective([16*x^2 - 29*y^2, 16*y^2]) 

sage: sorted(f.all_rational_preimages([P(-1,4)])) 

[(-7/4 : 1), (-5/4 : 1), (-3/4 : 1), (-1/4 : 1), (1/4 : 1), (3/4 : 1), 

(5/4 : 1), (7/4 : 1)] 

 

:: 

 

sage: P.<x,y,z> = ProjectiveSpace(QQ,2) 

sage: f = DynamicalSystem_projective([76*x^2 - 180*x*y + 45*y^2 + 14*x*z + 45*y*z - 90*z^2, 67*x^2 - 180*x*y - 157*x*z + 90*y*z, -90*z^2]) 

sage: sorted(f.all_rational_preimages([P(-9,-4,1)])) 

[(-9 : -4 : 1), (0 : -1 : 1), (0 : 0 : 1), (0 : 1 : 1), (0 : 4 : 1), 

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

 

A non-periodic example :: 

 

sage: P.<x,y> = ProjectiveSpace(QQ,1) 

sage: f = DynamicalSystem_projective([x^2 + y^2, 2*x*y]) 

sage: sorted(f.all_rational_preimages([P(17,15)])) 

[(1/3 : 1), (3/5 : 1), (5/3 : 1), (3 : 1)] 

 

A number field example:: 

 

sage: z = QQ['z'].0 

sage: K.<w> = NumberField(z^3 + (z^2)/4 - (41/16)*z + 23/64); 

sage: P.<x,y> = ProjectiveSpace(K,1) 

sage: f = DynamicalSystem_projective([16*x^2 - 29*y^2, 16*y^2]) 

sage: f.all_rational_preimages([P(16*w^2 - 29,16)]) 

[(-w^2 + 21/16 : 1), 

(w : 1), 

(w + 1/2 : 1), 

(w^2 + w - 33/16 : 1), 

(-w^2 - w + 25/16 : 1), 

(w^2 - 21/16 : 1), 

(-w^2 - w + 33/16 : 1), 

(-w : 1), 

(-w - 1/2 : 1), 

(-w^2 + 29/16 : 1), 

(w^2 - 29/16 : 1), 

(w^2 + w - 25/16 : 1)] 

 

:: 

 

sage: K.<w> = QuadraticField(3) 

sage: P.<u,v> = ProjectiveSpace(K,1) 

sage: f = DynamicalSystem_projective([u^2+v^2, v^2]) 

sage: f.all_rational_preimages(P(4)) 

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

""" 

if self.domain().base_ring() not in NumberFields(): 

raise TypeError("field won't return finite list of elements") 

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

points = [points] 

 

preperiodic = set() 

while points != []: 

P = points.pop() 

preimages = self.rational_preimages(P) 

for i in range(len(preimages)): 

if not preimages[i] in preperiodic: 

points.append(preimages[i]) 

preperiodic.add(preimages[i]) 

return list(preperiodic) 

 

def rational_preperiodic_points(self, **kwds): 

r""" 

Determine the set of rational preperiodic points for 

this dynamical system. 

 

The map must be defined over `\QQ` and be an endomorphism of 

projective space. If the map is a polynomial endomorphism of 

`\mathbb{P}^1`, i.e. has a totally ramified fixed point, then 

the base ring can be an absolute number field. 

This is done by passing to the Weil restriction. 

 

The default parameter values are typically good choices for 

`\mathbb{P}^1`. If you are having trouble getting a particular 

map to finish, try first computing the possible periods, then 

try various different values for ``lifting_prime``. 

 

ALGORITHM: 

 

- Determines the list of possible periods. 

 

- Determines the rational periodic points from the possible periods. 

 

- Determines the rational preperiodic points from the rational 

periodic points by determining rational preimages. 

 

INPUT: 

 

kwds: 

 

- ``prime_bound`` -- (default: ``[1, 20]``) a pair (list or tuple) 

of positive integers that represent the limits of primes to use 

in the reduction step or an integer that represents the upper bound 

 

- ``lifting_prime`` -- (default: 23) a prime integer; specifies 

modulo which prime to try and perform the lifting 

 

- ``periods`` -- (optional) a list of positive integers that is 

the list of possible periods 

 

- ``bad_primes`` -- (optional) a list or tuple of integer primes; 

the primes of bad reduction 

 

- ``ncpus`` -- (default: all cpus) number of cpus to use in parallel 

 

OUTPUT: a list of rational points in projective space 

 

EXAMPLES:: 

 

sage: PS.<x,y> = ProjectiveSpace(1,QQ) 

sage: f = DynamicalSystem_projective([x^2 -y^2, 3*x*y]) 

sage: sorted(f.rational_preperiodic_points()) 

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

(2 : 1)] 

 

:: 

 

sage: PS.<x,y> = ProjectiveSpace(1,QQ) 

sage: f = DynamicalSystem_projective([5*x^3 - 53*x*y^2 + 24*y^3, 24*y^3]) 

sage: sorted(f.rational_preperiodic_points(prime_bound=10)) 

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

 

:: 

 

sage: PS.<x,y,z> = ProjectiveSpace(2,QQ) 

sage: f = DynamicalSystem_projective([x^2 - 21/16*z^2, y^2-2*z^2, z^2]) 

sage: sorted(f.rational_preperiodic_points(prime_bound=[1,8], lifting_prime=7, periods=[2])) # long time 

[(-5/4 : -2 : 1), (-5/4 : -1 : 1), (-5/4 : 0 : 1), (-5/4 : 1 : 1), (-5/4 

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

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

: 1 : 1), (1/4 : 2 : 1), (5/4 : -2 : 1), (5/4 : -1 : 1), (5/4 : 0 : 1), 

(5/4 : 1 : 1), (5/4 : 2 : 1)] 

 

:: 

 

sage: K.<w> = QuadraticField(33) 

sage: PS.<x,y> = ProjectiveSpace(K,1) 

sage: f = DynamicalSystem_projective([x^2-71/48*y^2, y^2]) 

sage: sorted(f.rational_preperiodic_points()) # long time 

[(-1/12*w - 1 : 1), 

(-1/6*w - 1/4 : 1), 

(-1/12*w - 1/2 : 1), 

(-1/6*w + 1/4 : 1), 

(1/12*w - 1 : 1), 

(1/12*w - 1/2 : 1), 

(-1/12*w + 1/2 : 1), 

(-1/12*w + 1 : 1), 

(1/6*w - 1/4 : 1), 

(1/12*w + 1/2 : 1), 

(1 : 0), 

(1/6*w + 1/4 : 1), 

(1/12*w + 1 : 1)] 

""" 

PS = self.domain() 

K = PS.base_ring() 

if K not in NumberFields() or not K.is_absolute(): 

raise TypeError("base field must be an absolute field") 

d = K.absolute_degree() 

#check that we are not over QQ 

if d > 1: 

if PS.dimension_relative() != 1: 

raise NotImplementedError("rational preperiodic points for number fields only implemented in dimension 1") 

w = K.absolute_generator() 

#we need to dehomogenize for the Weil restriction and will check that point at infty 

#separately. We also check here that we are working with a polynomial. If the map 

#is not a polynomial, the Weil restriction will not be a morphism and we cannot 

#apply this algorithm. 

g = self.dehomogenize(1) 

inf = PS([1,0]) 

k = 1 

if isinstance(g[0], FractionFieldElement): 

g = self.dehomogenize(0) 

inf = PS([0,1]) 

k = 0 

if isinstance(g[0], FractionFieldElement): 

raise NotImplementedError("rational preperiodic points for number fields only implemented for polynomials") 

#determine rational preperiodic points 

#infinity is a totally ramified fixed point for a polynomial 

preper = set([inf]) 

#compute the weil restriction 

G = g.weil_restriction() 

F = G.homogenize(d) 

#find the QQ rational preperiodic points for the weil restriction 

Fpre = F.rational_preperiodic_points(**kwds) 

for P in Fpre: 

#take the 'good' points in the weil restriction and find the 

#associated number field points. 

if P[d] == 1: 

pt = [sum([P[i]*w**i for i in range(d)])] 

pt.insert(k,1) 

Q = PS(pt) 

#for each preperiodic point get the entire connected component 

if not Q in preper: 

for t in self.connected_rational_component(Q): 

preper.add(t) 

preper = list(preper) 

else: 

#input error checking done in possible_periods and rational_periodic_points 

badprimes = kwds.pop("bad_primes", None) 

periods = kwds.pop("periods", None) 

primebound = kwds.pop("prime_bound", [1, 20]) 

num_cpus = kwds.pop("ncpus", ncpus()) 

if badprimes is None: 

badprimes = self.primes_of_bad_reduction() 

if periods is None: 

#determine the set of possible periods 

periods = self.possible_periods(prime_bound=primebound, 

bad_primes=badprimes, ncpus=num_cpus) 

if periods == []: 

return([]) #no rational preperiodic points 

else: 

p = kwds.pop("lifting_prime", 23) 

#find the rational preperiodic points 

T = self.rational_periodic_points(prime_bound=primebound, lifting_prime=p, 

periods=periods, bad_primes=badprimes, 

ncpus=num_cpus) 

preper = self.all_rational_preimages(T) #find the preperiodic points 

preper = list(preper) 

return preper 

 

def rational_preperiodic_graph(self, **kwds): 

r""" 

Determine the directed graph of the rational preperiodic points 

for this dynamical system. 

 

The map must be defined over `\QQ` and be an endomorphism of 

projective space. If this map is a polynomial endomorphism of 

`\mathbb{P}^1`, i.e. has a totally ramified fixed point, then 

the base ring can be an absolute number field. 

This is done by passing to the Weil restriction. 

 

ALGORITHM: 

 

- Determines the list of possible periods. 

 

- Determines the rational periodic points from the possible periods. 

 

- Determines the rational preperiodic points from the rational 

periodic points by determining rational preimages. 

 

INPUT: 

 

kwds: 

 

- ``prime_bound`` -- (default: ``[1, 20]``) a pair (list or tuple) 

of positive integers that represent the limits of primes to use 

in the reduction step or an integer that represents the upper bound 

 

- ``lifting_prime`` -- (default: 23) a prime integer; specifies 

modulo which prime to try and perform the lifting 

 

- ``periods`` -- (optional) a list of positive integers that is 

the list of possible periods 

 

- ``bad_primes`` -- (optional) a list or tuple of integer primes; 

the primes of bad reduction 

 

- ``ncpus`` -- (default: all cpus) number of cpus to use in parallel 

 

OUTPUT: 

 

A digraph representing the orbits of the rational preperiodic 

points in projective space. 

 

EXAMPLES:: 

 

sage: PS.<x,y> = ProjectiveSpace(1,QQ) 

sage: f = DynamicalSystem_projective([7*x^2 - 28*y^2, 24*x*y]) 

sage: f.rational_preperiodic_graph() 

Looped digraph on 12 vertices 

 

:: 

 

sage: PS.<x,y> = ProjectiveSpace(1,QQ) 

sage: f = DynamicalSystem_projective([-3/2*x^3 +19/6*x*y^2, y^3]) 

sage: f.rational_preperiodic_graph(prime_bound=[1,8]) 

Looped digraph on 12 vertices 

 

:: 

 

sage: PS.<x,y,z> = ProjectiveSpace(2,QQ) 

sage: f = DynamicalSystem_projective([2*x^3 - 50*x*z^2 + 24*z^3, 

....: 5*y^3 - 53*y*z^2 + 24*z^3, 24*z^3]) 

sage: f.rational_preperiodic_graph(prime_bound=[1,11], lifting_prime=13) # long time 

Looped digraph on 30 vertices 

 

:: 

 

sage: K.<w> = QuadraticField(-3) 

sage: P.<x,y> = ProjectiveSpace(K,1) 

sage: f = DynamicalSystem_projective([x^2+y^2, y^2]) 

sage: f.rational_preperiodic_graph() # long time 

Looped digraph on 5 vertices 

""" 

#input checking done in .rational_preperiodic_points() 

preper = self.rational_preperiodic_points(**kwds) 

g = self._preperiodic_points_to_cyclegraph(preper) 

return g 

 

def connected_rational_component(self, P, n=0): 

r""" 

Computes the connected component of a rational preperiodic 

point ``P`` by this dynamical system. 

 

Will work for non-preperiodic points if ``n`` is positive. 

Otherwise this will not terminate. 

 

INPUT: 

 

- ``P`` -- a rational preperiodic point of this map 

 

- ``n`` -- (default: 0) integer; maximum distance from ``P`` to 

branch out; a value of 0 indicates no bound 

 

OUTPUT: 

 

A list of points connected to ``P`` up to the specified distance. 

 

EXAMPLES:: 

 

sage: R.<x> = PolynomialRing(QQ) 

sage: K.<w> = NumberField(x^3+1/4*x^2-41/16*x+23/64) 

sage: PS.<x,y> = ProjectiveSpace(1,K) 

sage: f = DynamicalSystem_projective([x^2 - 29/16*y^2, y^2]) 

sage: P = PS([w,1]) 

sage: f.connected_rational_component(P) 

[(w : 1), 

(w^2 - 29/16 : 1), 

(-w^2 - w + 25/16 : 1), 

(w^2 + w - 25/16 : 1), 

(-w : 1), 

(-w^2 + 29/16 : 1), 

(w + 1/2 : 1), 

(-w - 1/2 : 1), 

(-w^2 + 21/16 : 1), 

(w^2 - 21/16 : 1), 

(w^2 + w - 33/16 : 1), 

(-w^2 - w + 33/16 : 1)] 

 

:: 

 

sage: PS.<x,y,z> = ProjectiveSpace(2,QQ) 

sage: f = DynamicalSystem_projective([x^2 - 21/16*z^2, y^2-2*z^2, z^2]) 

sage: P = PS([17/16,7/4,1]) 

sage: f.connected_rational_component(P,3) 

[(17/16 : 7/4 : 1), 

(-47/256 : 17/16 : 1), 

(-83807/65536 : -223/256 : 1), 

(-17/16 : -7/4 : 1), 

(-17/16 : 7/4 : 1), 

(17/16 : -7/4 : 1), 

(1386468673/4294967296 : -81343/65536 : 1), 

(-47/256 : -17/16 : 1), 

(47/256 : -17/16 : 1), 

(47/256 : 17/16 : 1), 

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

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

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

(1/2 : 1/2 : 1)] 

 

""" 

points = [[],[]] # list of points and a list of their corresponding levels 

points[0].append(P) 

points[1].append(0) # P is treated as level 0 

 

nextpoints = [] 

nextpoints.append(P) 

 

level = 1 

foundall = False # whether done or not 

while not foundall: 

newpoints = [] 

for Q in nextpoints: 

# forward image 

newpoints.append(self(Q)) 

# preimages 

newpoints.extend(self.rational_preimages(Q)) 

del nextpoints[:] # empty list 

# add any points that are not already in the connected component 

for Q in newpoints: 

if (Q not in points[0]): 

points[0].append(Q) 

points[1].append(level) 

nextpoints.append(Q) 

# done if max level was achieved or if there were no more points to add 

if ((level + 1 > n and n != 0) or len(nextpoints) == 0): 

foundall = True 

level = level + 1 

 

return points[0] 

 

def conjugating_set(self, other): 

r""" 

Return the set of elements in PGL that conjugates one 

dynamical system to the other. 

 

Given two nonconstant rational functions of equal degree 

determine to see if there is an element of PGL that 

conjugates one rational function to another. It does this 

by taking the fixed points of one map and mapping 

them to all unique permutations of the fixed points of 

the other map. If there are not enough fixed points the 

function compares the mapping between rational preimages of 

fixed points and the rational preimages of the preimages of 

fixed points until there are enough points; such that there 

are `n+2` points with all `n+1` subsets linearly independent. 

 

ALGORITHM: 

 

Implementing invariant set algorithim from the paper [FMV2014]_. 

Given that the set of `n` th preimages of fixed points is 

invariant under conjugation find all elements of PGL that 

take one set to another. 

 

INPUT: 

 

- ``other`` -- a nonconstant rational function of same degree 

as ``self`` 

 

OUTPUT: 

 

Set of conjugating `n+1` by `n+1` matrices. 

 

AUTHORS: 

 

- Original algorithm written by Xander Faber, Michelle Manes, 

Bianca Viray [FMV2014]_. 

 

- Implimented by Rebecca Lauren Miller, as part of GSOC 2016. 

 

EXAMPLES:: 

 

sage: P.<x,y> = ProjectiveSpace(QQ,1) 

sage: f = DynamicalSystem_projective([x^2 - 2*y^2, y^2]) 

sage: m = matrix(QQbar, 2, 2, [-1, 3, 2, 1]) 

sage: g = f.conjugate(m) 

sage: f.conjugating_set(g) 

[ 

[-1 3] 

[ 2 1] 

] 

 

:: 

 

sage: K.<w> = QuadraticField(-1) 

sage: P.<x,y> = ProjectiveSpace(K,1) 

sage: f = DynamicalSystem_projective([x^2 + y^2, x*y]) 

sage: m = matrix(K, 2, 2, [1, 1, 2, 1]) 

sage: g = f.conjugate(m) 

sage: f.conjugating_set(g) # long time 

[ 

[1 1] [-1 -1] 

[2 1], [ 2 1] 

] 

 

:: 

 

sage: K.<i> = QuadraticField(-1) 

sage: P.<x,y> = ProjectiveSpace(K,1) 

sage: D8 = DynamicalSystem_projective([y^3, x^3]) 

sage: D8.conjugating_set(D8) # long time 

[ 

[1 0] [0 1] [ 0 -i] [i 0] [ 0 -1] [-1 0] [-i 0] [0 i] 

[0 1], [1 0], [ 1 0], [0 1], [ 1 0], [ 0 1], [ 0 1], [1 0] 

] 

 

:: 

 

sage: P.<x,y> = ProjectiveSpace(QQ,1) 

sage: D8 = DynamicalSystem_projective([y^2, x^2]) 

sage: D8.conjugating_set(D8) 

Traceback (most recent call last): 

... 

ValueError: not enough rational preimages 

 

:: 

 

sage: P.<x,y> = ProjectiveSpace(GF(7),1) 

sage: D6 = DynamicalSystem_projective([y^2, x^2]) 

sage: D6.conjugating_set(D6) 

[ 

[1 0] [0 1] [0 2] [4 0] [2 0] [0 4] 

[0 1], [1 0], [1 0], [0 1], [0 1], [1 0] 

] 

 

:: 

 

sage: P.<x,y,z> = ProjectiveSpace(QQ,2) 

sage: f = DynamicalSystem_projective([x^2 + x*z, y^2, z^2]) 

sage: f.conjugating_set(f) # long time 

[ 

[1 0 0] 

[0 1 0] 

[0 0 1] 

] 

""" 

f = copy(self) 

g = copy(other) 

try: 

f.normalize_coordinates() 

g.normalize_coordinates() 

except (ValueError): 

pass 

if f.degree() != g.degree():# checks that maps are of equal degree 

return [] 

n = f.domain().dimension_relative() 

L = Set(f.periodic_points(1)) 

K = Set(g.periodic_points(1)) 

if len(L) != len(K): # checks maps have the same number of fixed points 

return [] 

d = len(L) 

r = f.domain().base_ring() 

more = True 

if d >= n+2: # need at least n+2 points 

for i in Subsets(L, n+2): 

# make sure all n+1 subsets are linearly independent 

Ml = matrix(r, [list(s) for s in i]) 

if not any([j == 0 for j in Ml.minors(n+1)]): 

Tf = list(i) 

more= False 

break 

while more: 

# finds preimages of fixed points 

Tl = [Q for i in L for Q in f.rational_preimages(i)] 

Tk = [Q for i in K for Q in g.rational_preimages(i)] 

if len(Tl) != len(Tk): 

return [] 

L = L.union(Set(Tl)) 

K = K.union(Set(Tk)) 

if d == len(L): # if no new preimages then not enough points 

raise ValueError("not enough rational preimages") 

d = len(L) 

if d >= n + 2: # makes sure all n+1 subsets are linearly independent 

for i in Subsets(L, n+2): 

Ml = matrix(r, [list(s) for s in i]) 

if not any([j == 0 for j in Ml.minors(n+1)]): 

more = False 

Tf = list(i) 

break 

Conj = [] 

for i in Arrangements(K,(n+2)): 

# try all possible conjugations between invariant sets 

try: # need all n+1 subsets linearly independent 

s = f.domain().point_transformation_matrix(i,Tf)# finds elements of PGL that maps one map to another 

if self.conjugate(s) == other: 

Conj.append(s) 

except (ValueError): 

pass 

return Conj 

 

def is_conjugate(self, other): 

r""" 

Return whether or not two dynamical systems are conjugate. 

 

ALGORITHM: 

 

Implementing invariant set algorithim from the paper [FMV2014]_. 

Given that the set of `n` th preimages is invariant under 

conjugation this function finds whether two maps are conjugate. 

 

INPUT: 

 

- ``other`` -- a nonconstant rational function of same degree 

as ``self`` 

 

OUTPUT: boolean 

 

AUTHORS: 

 

- Original algorithm written by Xander Faber, Michelle Manes, 

Bianca Viray [FMV2014]_. 

 

- Implimented by Rebecca Lauren Miller as part of GSOC 2016. 

 

EXAMPLES:: 

 

sage: K.<w> = CyclotomicField(3) 

sage: P.<x,y> = ProjectiveSpace(K,1) 

sage: D8 = DynamicalSystem_projective([y^2, x^2]) 

sage: D8.is_conjugate(D8) 

True 

 

:: 

 

sage: set_verbose(None) 

sage: P.<x,y> = ProjectiveSpace(QQbar,1) 

sage: f = DynamicalSystem_projective([x^2 + x*y,y^2]) 

sage: m = matrix(QQbar, 2, 2, [1, 1, 2, 1]) 

sage: g = f.conjugate(m) 

sage: f.is_conjugate(g) # long time 

True 

 

:: 

 

sage: P.<x,y> = ProjectiveSpace(GF(5),1) 

sage: f = DynamicalSystem_projective([x^3 + x*y^2,y^3]) 

sage: m = matrix(GF(5), 2, 2, [1, 3, 2, 9]) 

sage: g = f.conjugate(m) 

sage: f.is_conjugate(g) 

True 

 

:: 

 

sage: P.<x,y> = ProjectiveSpace(QQ,1) 

sage: f = DynamicalSystem_projective([x^2 + x*y,y^2]) 

sage: g = DynamicalSystem_projective([x^3 + x^2*y, y^3]) 

sage: f.is_conjugate(g) 

False 

 

:: 

 

sage: P.<x,y> = ProjectiveSpace(QQ,1) 

sage: f = DynamicalSystem_projective([x^2 + x*y, y^2]) 

sage: g = DynamicalSystem_projective([x^2 - 2*y^2, y^2]) 

sage: f.is_conjugate(g) 

False 

""" 

f = copy(self) 

g = copy(other) 

try: 

f.normalize_coordinates() 

g.normalize_coordinates() 

except (ValueError): 

pass 

if f.degree() != g.degree(): # checks that maps are of equal degree 

return False 

n = f.domain().dimension_relative() 

L = Set(f.periodic_points(1)) 

K = Set(g.periodic_points(1)) 

if len(L) != len(K): # checks maps have the same number of fixed points 

return False 

d = len(L) 

r = f.domain().base_ring() 

more = True 

if d >= n+2: # need at least n+2 points 

for i in Subsets(L, n+2): # makes sure all n+1 subsets are linearly independent 

Ml = matrix(r, [list(s) for s in i]) 

if not any([j == 0 for j in Ml.minors(n+1)]): 

Tf = list(i) 

more = False 

break 

while more: 

# finds preimages of fixed points 

Tl = [Q for i in L for Q in f.rational_preimages(i)] 

Tk = [Q for i in K for Q in g.rational_preimages(i)] 

if len(Tl) != len(Tk): 

return False 

L = L.union(Set(Tl)) 

K = K.union(Set(Tk)) 

if d == len(L):# if no new preimages then not enough points 

raise ValueError("not enough rational preimages") 

d = len(L) 

if d >= n + 2: 

# make sure all n+1 subsets are linearly independent 

for i in Subsets(L, n+2): # checks at least n+1 are linearly independent 

Ml = matrix(r, [list(s) for s in i]) 

if not any([j == 0 for j in Ml.minors(n+1)]): 

more = False 

Tf = list(i) 

break 

for i in Arrangements(K, n+2): 

# try all possible conjugations between invariant sets 

try: # need all n+1 subsets linearly independent 

s = f.domain().point_transformation_matrix(i,Tf) # finds elements of PGL that maps one map to another 

if self.conjugate(s) == other: 

return True 

except (ValueError): 

pass 

return False 

 

def is_polynomial(self): 

r""" 

Check to see if the dynamical system has a totally ramified 

fixed point. 

 

The function must be defined over an absolute number field or a 

finite field. 

 

OUTPUT: boolean 

 

EXAMPLES:: 

 

sage: R.<x> = QQ[] 

sage: K.<w> = QuadraticField(7) 

sage: P.<x,y> = ProjectiveSpace(K, 1) 

sage: f = DynamicalSystem_projective([x**2 + 2*x*y - 5*y**2, 2*x*y]) 

sage: f.is_polynomial() 

False 

 

:: 

 

sage: R.<x> = QQ[] 

sage: K.<w> = QuadraticField(7) 

sage: P.<x,y> = ProjectiveSpace(K, 1) 

sage: f = DynamicalSystem_projective([x**2 - 7*x*y, 2*y**2]) 

sage: m = matrix(K, 2, 2, [w, 1, 0, 1]) 

sage: f = f.conjugate(m) 

sage: f.is_polynomial() 

True 

 

:: 

 

sage: K.<w> = QuadraticField(4/27) 

sage: P.<x,y> = ProjectiveSpace(K,1) 

sage: f = DynamicalSystem_projective([x**3 + w*y^3,x*y**2]) 

sage: f.is_polynomial() 

False 

 

:: 

 

sage: K = GF(3**2, prefix='w') 

sage: P.<x,y> = ProjectiveSpace(K,1) 

sage: f = DynamicalSystem_projective([x**2 + K.gen()*y**2, x*y]) 

sage: f.is_polynomial() 

False 

 

:: 

 

sage: PS.<x,y> = ProjectiveSpace(QQ, 1) 

sage: f = DynamicalSystem_projective([6*x^2+12*x*y+7*y^2, 12*x*y + 42*y^2]) 

sage: f.is_polynomial() 

False 

""" 

if self.codomain().dimension_relative() != 1: 

raise NotImplementedError("space must have dimension equal to 1") 

K = self.base_ring() 

if not K in FiniteFields() and (not K in NumberFields() or not K.is_absolute()): 

raise NotImplementedError("must be over an absolute number field or finite field") 

if K in FiniteFields(): 

q = K.characteristic() 

deg = K.degree() 

var = K.variable_name() 

g = self 

#get polynomial defining fixed points 

G = self.dehomogenize(1).dynatomic_polynomial(1) 

# see if infty = (1,0) is fixed 

if G.degree() <= g.degree(): 

#check if infty is totally ramified 

if len((g[1]).factor()) == 1: 

return True 

#otherwise we need to create the tower of extensions 

#which contain the fixed points. We do 

#this successively so we can exit early if 

#we find one and not go all the way to the splitting field 

i = 0 #field index 

if G.degree() != 0: 

G = G.polynomial(G.variable(0)) 

while G.degree() != 0: 

Y = G.factor() 

R = G.parent() 

u = G 

for p,e in Y: 

if p.degree() == 1: 

if len((g[0]*p[1] + g[1]*p[0]).factor()) == 1: 

return True 

G = R(G/p) # we already checked this root 

else: 

u = p #need to extend to get these roots 

if G.degree() != 0: 

#create the next extension 

if K == QQ: 

from sage.rings.number_field.number_field import NumberField 

L = NumberField(u, 't'+str(i)) 

i += 1 

phi = K.embeddings(L)[0] 

K = L 

elif K in FiniteFields(): 

deg = deg*G.degree() 

K = GF(q**(deg), prefix=var) 

else: 

L = K.extension(u, 't'+str(i)) 

i += 1 

phi1 = K.embeddings(L)[0] 

K = L 

L = K.absolute_field('t'+str(i)) 

i += 1 

phi = K.embeddings(L)[0]*phi1 

K = L 

if K in FiniteFields(): 

G = G.change_ring(K) 

g = g.change_ring(K) 

else: 

G = G.change_ring(phi) 

g = g.change_ring(phi) 

return False 

 

def normal_form(self, return_conjugation=False): 

r""" 

Return a normal form in the moduli space of dynamical systems. 

 

Currently implemented only for polynomials. The totally ramified 

fixed point is moved to infinity and the map is conjugated to the form 

`x^n + a_{n-2} x^{n-2} + \cdots + a_{0}`. Note that for finite fields 

we can only remove the `(n-1)`-st term when the characteristic 

does not divide `n`. 

 

INPUT: 

 

- ``return_conjugation`` -- (default: ``False``) boolean; if ``True``, 

then return the conjugation element of PGL along with the embedding 

into the new field 

 

OUTPUT: 

 

- :class:`SchemeMorphism_polynomial` 

 

- (optional) an element of PGL as a matrix 

 

- (optional) the field embedding 

 

EXAMPLES:: 

 

sage: P.<x,y> = ProjectiveSpace(QQ, 1) 

sage: f = DynamicalSystem_projective([x^2 + 2*x*y - 5*x^2, 2*x*y]) 

sage: f.normal_form() 

Traceback (most recent call last): 

... 

NotImplementedError: map is not a polynomial 

 

:: 

 

sage: R.<x> = QQ[] 

sage: K.<w> = NumberField(x^2 - 5) 

sage: P.<x,y> = ProjectiveSpace(K,1) 

sage: f = DynamicalSystem_projective([x^2 + w*x*y, y^2]) 

sage: g,m,psi = f.normal_form(return_conjugation = True);m 

[ 1 -1/2*w] 

[ 0 1] 

sage: f.change_ring(psi).conjugate(m) == g 

True 

 

:: 

 

sage: P.<x,y> = ProjectiveSpace(QQ,1) 

sage: f = DynamicalSystem_projective([13*x^2 + 4*x*y + 3*y^2, 5*y^2]) 

sage: f.normal_form() 

Dynamical System of Projective Space of dimension 1 over Rational Field 

Defn: Defined on coordinates by sending (x : y) to 

(5*x^2 + 9*y^2 : 5*y^2) 

 

:: 

 

sage: K = GF(3^3, prefix = 'w') 

sage: P.<x,y> = ProjectiveSpace(K,1) 

sage: f = DynamicalSystem_projective([x^3 + 2*x^2*y + 2*x*y^2 + K.gen()*y^3, y^3]) 

sage: f.normal_form() 

Dynamical System of Projective Space of dimension 1 over Finite Field in w3 of size 3^3 

Defn: Defined on coordinates by sending (x : y) to 

(x^3 + x^2*y + x*y^2 + (-w3)*y^3 : y^3) 

""" 

#defines the field of fixed points 

if self.codomain().dimension_relative() != 1: 

raise NotImplementedError("space must have dimension equal to 1") 

K = self.base_ring() 

if not K in FiniteFields() and (not K in NumberFields() or not K.is_absolute()): 

raise NotImplementedError("must be over an absolute number field or finite field") 

if K in FiniteFields(): 

q = K.characteristic() 

deg = K.degree() 

var = K.variable_name() 

else: 

psi = K.hom([K.gen()]) #identity hom for return_embedding 

g = self 

G = self.dehomogenize(1).dynatomic_polynomial(1) 

done = False 

bad = True 

#check infty = (1,0) is fixed 

if G.degree() <= g.degree(): 

#check infty totally ramified 

if len((g[1]).factor()) == 1: 

T = self.domain()(1,0) 

bad = False 

done = True 

m = matrix(K, 2, 2, [1,0,0,1]) 

#otherwise we need to create the tower of extensions 

#which contain the fixed points. We do 

#this successively so we can early exit if 

#we find one and not go all the way to the splitting field 

i = 0 

if G.degree() != 0: 

G = G.polynomial(G.variable(0)) 

else: 

#no other fixed points 

raise NotImplementedError("map is not a polynomial") 

#check other fixed points 

while not done: 

Y = G.factor() 

R = G.parent() 

done = True 

for p,e in Y: 

if p.degree() == 1: 

if len((g[0]*p[1] + g[1]*p[0]).factor()) == 1: 

T = self.domain()(-p[0], p[1]) 

bad = False 

done = True 

break # bc only 1 totally ramified fixed pt 

G = R(G/p) 

else: 

done = False 

u = p 

if not done: 

#extend 

if K == QQ: 

from sage.rings.number_field.number_field import NumberField 

L = NumberField(u, 't'+str(i)) 

i += 1 

phi = K.embeddings(L)[0] 

psi = phi * psi 

K = L 

elif K in FiniteFields(): 

deg = deg * G.degree() 

K = GF(q**(deg), prefix=var) 

else: 

L = K.extension(u, 't'+str(i)) 

i += 1 

phi1 = K.embeddings(L)[0] 

K = L 

L = K.absolute_field('t'+str(i)) 

i += 1 

phi = K.embeddings(L)[0]*phi1 

psi = phi * psi 

K = L 

#switch to the new field 

if K in FiniteFields(): 

G = G.change_ring(K) 

g = g.change_ring(K) 

else: 

G = G.change_ring(phi) 

g = g.change_ring(phi) 

if bad: 

raise NotImplementedError("map is not a polynomial") 

#conjugate to normal form 

Q = T.codomain() 

#moved totally ramified fixed point to infty 

target = [T, Q(T[0]+1, 1), Q(T[0]+2, 1)] 

source = [Q(1, 0), Q(0, 1), Q(1, 1)] 

m = Q.point_transformation_matrix(source, target) 

N = g.base_ring() 

d = g.degree() 

gc = g.conjugate(m) 

#make monic 

R = PolynomialRing(N, 'z') 

v = N(gc[1].coefficient([0,d])/gc[0].coefficient([d,0])) 

#need a (d-1)-st root to make monic 

u = R.gen(0)**(d-1) - v 

if d != 2 and u.is_irreducible(): 

#we need to extend again 

if N in FiniteFields(): 

deg = deg*(d-1) 

M = GF(q**(deg), prefix=var) 

else: 

L = N.extension(u,'t'+str(i)) 

i += 1 

phi1 = N.embeddings(L)[0] 

M = L.absolute_field('t'+str(i)) 

phi = L.embeddings(M)[0]*phi1 

psi = phi*psi 

if M in FiniteFields(): 

gc = gc.change_ring(M) 

else: 

gc = gc.change_ring(phi) 

m = matrix(M, 2, 2, [phi(s) for t in list(m) for s in t]) 

rv = phi(v).nth_root(d-1) 

else: #root is already in the field 

M = N 

rv = v.nth_root(d-1) 

mc = matrix(M, 2, 2, [rv,0,0,1]) 

gcc = gc.conjugate(mc) 

if not (M in FiniteFields() and q.divides(d)): 

#remove 2nd order term 

mc2 = matrix(M, 2, 2, [1, M((-gcc[0].coefficient([d-1, 1]) 

/ (d*gcc[1].coefficient([0, d]))).constant_coefficient()), 0, 1]) 

else: 

mc2 = mc.parent().one() 

gccc = gcc.conjugate(mc2) 

if return_conjugation: 

if M in FiniteFields(): 

return gccc, m * mc * mc2 

else: 

return gccc, m * mc * mc2, psi 

return gccc 

 

class DynamicalSystem_projective_finite_field(DynamicalSystem_projective_field, 

SchemeMorphism_polynomial_projective_space_finite_field): 

def orbit_structure(self, P): 

r""" 

Return the pair ``[m,n]``, where ``m`` is the preperiod and ``n`` 

is the period of the point ``P`` by this dynamical system. 

 

Every point is preperiodic over a finite field so every point 

will be preperiodic. 

 

INPUT: 

 

- ``P`` -- a point in the domain of this map 

 

OUTPUT: a list ``[m,n]`` of integers 

 

EXAMPLES:: 

 

sage: P.<x,y,z> = ProjectiveSpace(GF(5),2) 

sage: f = DynamicalSystem_projective([x^2 + y^2,y^2, z^2 + y*z], domain=P) 

sage: f.orbit_structure(P(2,1,2)) 

[0, 6] 

 

:: 

 

sage: P.<x,y,z> = ProjectiveSpace(GF(7),2) 

sage: X = P.subscheme(x^2-y^2) 

sage: f = DynamicalSystem_projective([x^2, y^2, z^2], domain=X) 

sage: f.orbit_structure(X(1,1,2)) 

[0, 2] 

 

:: 

 

sage: P.<x,y> = ProjectiveSpace(GF(13),1) 

sage: f = DynamicalSystem_projective([x^2 - y^2, y^2], domain=P) 

sage: f.orbit_structure(P(3,4)) 

[2, 3] 

 

:: 

 

sage: R.<t> = GF(13^3) 

sage: P.<x,y> = ProjectiveSpace(R,1) 

sage: f = DynamicalSystem_projective([x^2 - y^2, y^2], domain=P) 

sage: f.orbit_structure(P(t, 4)) 

[11, 6] 

""" 

orbit = [] 

index = 1 

Q = copy(P) 

Q.normalize_coordinates() 

F = copy(self) 

F.normalize_coordinates() 

while not Q in orbit: 

orbit.append(Q) 

Q = F(Q) 

Q.normalize_coordinates() 

index += 1 

I = orbit.index(Q) 

return([I, index-I-1]) 

 

def cyclegraph(self): 

r""" 

Return the digraph of all orbits of this dyanmical system. 

 

Over a finite field this is a finite graph. For subscheme domains, only points 

on the subscheme whose image are also on the subscheme are in the digraph. 

 

OUTPUT: a digraph 

 

EXAMPLES:: 

 

sage: P.<x,y> = ProjectiveSpace(GF(13),1) 

sage: f = DynamicalSystem_projective([x^2-y^2, y^2]) 

sage: f.cyclegraph() 

Looped digraph on 14 vertices 

 

:: 

 

sage: P.<x,y,z> = ProjectiveSpace(GF(3^2,'t'),2) 

sage: f = DynamicalSystem_projective([x^2+y^2, y^2, z^2+y*z]) 

sage: f.cyclegraph() 

Looped digraph on 91 vertices 

 

:: 

 

sage: P.<x,y,z> = ProjectiveSpace(GF(7),2) 

sage: X = P.subscheme(x^2-y^2) 

sage: f = DynamicalSystem_projective([x^2, y^2, z^2], domain=X) 

sage: f.cyclegraph() 

Looped digraph on 15 vertices 

 

:: 

 

sage: P.<x,y,z> = ProjectiveSpace(GF(3),2) 

sage: f = DynamicalSystem_projective([x*z-y^2, x^2-y^2, y^2-z^2]) 

sage: f.cyclegraph() 

Looped digraph on 13 vertices 

 

:: 

 

sage: P.<x,y,z> = ProjectiveSpace(GF(3),2) 

sage: X = P.subscheme([x-y]) 

sage: f = DynamicalSystem_projective([x^2-y^2, x^2-y^2, y^2-z^2], domain=X) 

sage: f.cyclegraph() 

Looped digraph on 4 vertices 

""" 

V = [] 

E = [] 

if is_ProjectiveSpace(self.domain()): 

for P in self.domain(): 

V.append(P) 

try: 

Q = self(P) 

Q.normalize_coordinates() 

E.append([Q]) 

except ValueError: #indeterminacy 

E.append([]) 

else: 

X = self.domain() 

for P in X.ambient_space(): 

try: 

XP = X.point(P) 

V.append(XP) 

try: 

Q = self(XP) 

Q.normalize_coordinates() 

E.append([Q]) 

except ValueError: #indeterminacy 

E.append([]) 

except TypeError: # not a point on the scheme 

pass 

from sage.graphs.digraph import DiGraph 

g = DiGraph(dict(zip(V, E)), loops=True) 

return g 

 

def possible_periods(self, return_points=False): 

r""" 

Return the list of possible minimal periods of a periodic point 

over `\QQ` and (optionally) a point in each cycle. 

 

ALGORITHM: 

 

See [Hutz2009]_. 

 

INPUT: 

 

- ``return_points`` -- (default: ``False``) boolean; if ``True``, 

then return the points as well as the possible periods 

 

OUTPUT: 

 

A list of positive integers, or a list of pairs of projective 

points and periods if ``return_points`` is ``True``. 

 

EXAMPLES:: 

 

sage: P.<x,y> = ProjectiveSpace(GF(23),1) 

sage: f = DynamicalSystem_projective([x^2-2*y^2, y^2]) 

sage: f.possible_periods() 

[1, 5, 11, 22, 110] 

 

:: 

 

sage: P.<x,y> = ProjectiveSpace(GF(13),1) 

sage: f = DynamicalSystem_projective([x^2-y^2, y^2]) 

sage: sorted(f.possible_periods(True)) 

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

 

:: 

 

sage: PS.<x,y,z> = ProjectiveSpace(2,GF(7)) 

sage: f = DynamicalSystem_projective([-360*x^3 + 760*x*z^2, 

....: y^3 - 604*y*z^2 + 240*z^3, 240*z^3]) 

sage: f.possible_periods() 

[1, 2, 4, 6, 12, 14, 28, 42, 84] 

 

.. TODO:: 

 

- do not return duplicate points 

 

- improve hash to reduce memory of point-table 

""" 

return _fast_possible_periods(self, return_points) 

 

def automorphism_group(self, absolute=False, iso_type=False, return_functions=False): 

r""" 

Return the subgroup of `PGL2` that is the automorphism group of this 

dynamical system. 

 

Only for dimension 1. The automorphism group is the set of `PGL2` 

elements that fixed the map under conjugation. See [FMV2014]_ 

for the algorithm. 

 

INPUT: 

 

- ``absolute``-- (default: ``False``) boolean; if ``True``, then 

return the absolute automorphism group and a field of definition 

 

- ``iso_type`` -- (default: ``False``) boolean; if ``True``, then 

return the isomorphism type of the automorphism group 

 

- ``return_functions`` -- (default: ``False``) boolean; ``True`` 

returns elements as linear fractional transformations and 

``False`` returns elements as `PGL2` matrices 

 

OUTPUT: a list of elements of the automorphism group 

 

AUTHORS: 

 

- Original algorithm written by Xander Faber, Michelle Manes, 

Bianca Viray 

 

- Modified by Joao Alberto de Faria, Ben Hutz, Bianca Thompson 

 

EXAMPLES:: 

 

sage: R.<x,y> = ProjectiveSpace(GF(7^3,'t'),1) 

sage: f = DynamicalSystem_projective([x^2-y^2, x*y]) 

sage: f.automorphism_group() 

[ 

[1 0] [6 0] 

[0 1], [0 1] 

] 

 

:: 

 

sage: R.<x,y> = ProjectiveSpace(GF(3^2,'t'),1) 

sage: f = DynamicalSystem_projective([x^3,y^3]) 

sage: f.automorphism_group(return_functions=True, iso_type=True) # long time 

([x, x/(x + 1), x/(2*x + 1), 2/(x + 2), (2*x + 1)/(2*x), (2*x + 2)/x, 

1/(2*x + 2), x + 1, x + 2, x/(x + 2), 2*x/(x + 1), 2*x, 1/x, 2*x + 1, 

2*x + 2, ((t + 2)*x + t + 2)/((2*t + 1)*x + t + 2), (t*x + 2*t)/(t*x + 

t), 2/x, (x + 1)/(x + 2), (2*t*x + t)/(t*x), (2*t + 1)/((2*t + 1)*x + 

2*t + 1), ((2*t + 1)*x + 2*t + 1)/((2*t + 1)*x), t/(t*x + 2*t), (2*x + 

1)/(x + 1)], 'PGL(2,3)') 

 

:: 

 

sage: R.<x,y> = ProjectiveSpace(GF(2^5,'t'),1) 

sage: f = DynamicalSystem_projective([x^5,y^5]) 

sage: f.automorphism_group(return_functions=True, iso_type=True) 

([x, 1/x], 'Cyclic of order 2') 

 

:: 

 

sage: R.<x,y> = ProjectiveSpace(GF(3^4,'t'),1) 

sage: f = DynamicalSystem_projective([x^2+25*x*y+y^2, x*y+3*y^2]) 

sage: f.automorphism_group(absolute=True) 

[Univariate Polynomial Ring in w over Finite Field in b of size 3^4, 

[ 

[1 0] 

[0 1] 

]] 

""" 

if self.domain().dimension_relative() != 1: 

raise NotImplementedError("must be dimension 1") 

else: 

f = self.dehomogenize(1) 

z = f[0].parent().gen() 

if f[0].denominator() != 1: 

F = f[0].numerator().polynomial(z) / f[0].denominator().polynomial(z) 

else: 

F = f[0].numerator().polynomial(z) 

from .endPN_automorphism_group import automorphism_group_FF 

return(automorphism_group_FF(F, absolute, iso_type, return_functions))