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

r""" 

Points on projective varieties 

 

Scheme morphism for points on projective varieties 

 

 

 

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 (June 2012) added support for projective ring; 

(March 2013) iteration functionality and new directory structure 

for affine/projective, height functionality 

""" 

 

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

# 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 sage.categories.integral_domains import IntegralDomains 

from sage.categories.number_fields import NumberFields 

_NumberFields = NumberFields() 

from sage.rings.integer_ring import ZZ 

from sage.rings.fraction_field import FractionField 

from sage.rings.morphism import RingHomomorphism_im_gens 

from sage.rings.number_field.order import is_NumberFieldOrder 

from sage.rings.number_field.number_field_ideal import NumberFieldFractionalIdeal 

from sage.rings.padics.all import Qp 

from sage.rings.qqbar import QQbar, number_field_elements_from_algebraics 

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.arith.all import gcd, lcm, is_prime, binomial 

from sage.functions.other import ceil 

 

from copy import copy 

from sage.schemes.generic.morphism import (SchemeMorphism, 

is_SchemeMorphism, 

SchemeMorphism_point) 

from sage.structure.element import AdditiveGroupElement 

from sage.structure.sequence import Sequence 

from sage.structure.richcmp import rich_to_bool, richcmp, op_EQ, op_NE 

 

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

# Projective varieties 

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

class SchemeMorphism_point_projective_ring(SchemeMorphism_point): 

""" 

A rational point of projective space over a ring. 

 

INPUT: 

 

- ``X`` -- a homset of a subscheme of an ambient projective space over a field `K`. 

 

- ``v`` -- a list or tuple of coordinates in `K`. 

 

- ``check`` -- boolean (optional, default:``True``). Whether to check the input for consistency. 

 

EXAMPLES:: 

 

sage: P = ProjectiveSpace(2, ZZ) 

sage: P(2,3,4) 

(2 : 3 : 4) 

 

""" 

 

def __init__(self, X, v, check=True): 

""" 

The Python constructor. 

 

EXAMPLES:: 

 

sage: P = ProjectiveSpace(2, QQ) 

sage: P(2, 3/5, 4) 

(1/2 : 3/20 : 1) 

 

:: 

 

sage: P = ProjectiveSpace(1, ZZ) 

sage: P([0, 1]) 

(0 : 1) 

 

:: 

 

sage: P = ProjectiveSpace(1, ZZ) 

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

Traceback (most recent call last): 

... 

TypeError: v (=[0, 0, 1]) must have 2 components 

 

:: 

 

sage: P = ProjectiveSpace(3, QQ) 

sage: P(0,0,0,0) 

Traceback (most recent call last): 

... 

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

 

It is possible to avoid the possibly time-consuming checks, but be careful!! :: 

 

sage: P = ProjectiveSpace(3, QQ) 

sage: P.point([0,0,0,0], check=False) 

(0 : 0 : 0 : 0) 

 

:: 

 

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

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

sage: X([2, 2, 2]) 

(2 : 2 : 2) 

 

:: 

 

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

sage: P = ProjectiveSpace(1, R.quo(t^2+1)) 

sage: P([2*t, 1]) 

(2*tbar : 1) 

 

:: 

 

sage: P = ProjectiveSpace(ZZ,1) 

sage: P.point(Infinity) 

(1 : 0) 

sage: P(infinity) 

(1 : 0) 

 

:: 

 

sage: P = ProjectiveSpace(ZZ,2) 

sage: P(Infinity) 

Traceback (most recent call last): 

... 

ValueError: +Infinity not well defined in dimension > 1 

sage: P.point(infinity) 

Traceback (most recent call last): 

... 

ValueError: +Infinity not well defined in dimension > 1 

""" 

SchemeMorphism.__init__(self, X) 

if check: 

from sage.schemes.elliptic_curves.ell_point import EllipticCurvePoint_field 

from sage.rings.ring import CommutativeRing 

d = X.codomain().ambient_space().ngens() 

 

if is_SchemeMorphism(v) or isinstance(v, EllipticCurvePoint_field): 

v = list(v) 

else: 

try: 

if isinstance(v.parent(), CommutativeRing): 

v = [v] 

except AttributeError: 

pass 

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

raise TypeError("argument v (= %s) must be a scheme point, list, or tuple"%str(v)) 

if len(v) != d and len(v) != d-1: 

raise TypeError("v (=%s) must have %s components"%(v, d)) 

 

R = X.value_ring() 

v = Sequence(v, R) 

if len(v) == d-1: # very common special case 

v.append(R(1)) 

 

n = len(v) 

all_zero = True 

for i in range(n): 

last = n-1-i 

if v[last]: 

all_zero = False 

break 

if all_zero: 

raise ValueError("%s does not define a valid point since all entries are 0"%repr(v)) 

 

X.extended_codomain()._check_satisfies_equations(v) 

 

self._coords = tuple(v) 

 

def _richcmp_(self, right, op): 

""" 

Tests the projective equality of two points. 

 

INPUT: 

 

- ``right`` -- a point on projective space. 

 

OUTPUT: 

 

- Boolean 

 

Examples:: 

 

sage: PS = ProjectiveSpace(ZZ, 1, 'x') 

sage: P = PS([1, 2]) 

sage: Q = PS([2, 4]) 

sage: P == Q 

True 

 

:: 

 

sage: PS = ProjectiveSpace(ZZ, 1, 'x') 

sage: P = PS([1, 2]) 

sage: Q = PS([1, 0]) 

sage: P == Q 

False 

 

:: 

 

sage: PS = ProjectiveSpace(Zp(5), 1, 'x') 

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

sage: P == PS(0) 

True 

 

:: 

 

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

sage: PS = ProjectiveSpace(R, 1, 'x') 

sage: P = PS([t, 1+t^2]) 

sage: Q = PS([t^2, t+t^3]) 

sage: P == Q 

True 

 

:: 

 

sage: PS = ProjectiveSpace(ZZ, 2, 'x') 

sage: P = PS([0, 1, 2]) 

sage: P == PS([0, 0]) 

False 

 

:: 

 

sage: PS = ProjectiveSpace(ZZ, 1, 'x') 

sage: P = PS([2, 1]) 

sage: PS2 = ProjectiveSpace(Zp(7), 1, 'x') 

sage: Q = PS2([2, 1]) 

sage: P == Q 

True 

 

:: 

 

sage: PS = ProjectiveSpace(ZZ.quo(6), 2, 'x') 

sage: P = PS([2, 4, 1]) 

sage: Q = PS([0, 1, 3]) 

sage: P == Q 

False 

 

Check that :trac:`17433` is fixed:: 

 

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

sage: p1 = P(1/3, 1) 

sage: p2 = P.point([1, 3], False) 

sage: p1 == p2 

True 

 

:: 

 

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

sage: K.<t> = NumberField(z^2+5) 

sage: OK = K.ring_of_integers() 

sage: t = OK.gen(1) 

sage: PS.<x,y> = ProjectiveSpace(OK,1) 

sage: P = PS(2, 1+t) 

sage: Q = PS(1-t, 3) 

sage: P == Q 

True 

 

Check that :trac:`17429` is fixed:: 

 

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

sage: r = (x^2-x-3).polynomial(x).roots(ComplexIntervalField(), multiplicities=False) 

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

sage: P1 = P(r[0], 1) 

sage: H = End(P) 

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

sage: Q1 = f(P1) 

sage: Q1 == P1 

False 

 

For inequality:: 

 

sage: PS = ProjectiveSpace(ZZ, 1, 'x') 

sage: P = PS([1, 2]) 

sage: Q = PS([2, 4]) 

sage: P != Q 

False 

 

:: 

 

sage: PS = ProjectiveSpace(ZZ, 1, 'x') 

sage: P = PS([1, 2]) 

sage: Q = PS([1, 0]) 

sage: P != Q 

True 

 

:: 

 

sage: PS = ProjectiveSpace(Zp(5), 1, 'x') 

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

sage: P != PS(0) 

False 

 

:: 

 

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

sage: PS = ProjectiveSpace(R, 1, 'x') 

sage: P = PS([t, 1+t^2]) 

sage: Q = PS([t^2, t+t^3]) 

sage: P != Q 

False 

 

:: 

 

sage: PS = ProjectiveSpace(ZZ, 2, 'x') 

sage: P = PS([0, 1, 2]) 

sage: P != PS([0, 0]) 

True 

 

:: 

 

sage: PS = ProjectiveSpace(ZZ, 1, 'x') 

sage: P = PS([2, 1]) 

sage: PS2 = ProjectiveSpace(Zp(7), 1, 'x') 

sage: Q = PS2([2, 1]) 

sage: P != Q 

False 

 

:: 

 

sage: PS = ProjectiveSpace(ZZ.quo(6), 2, 'x') 

sage: P = PS([2, 4, 1]) 

sage: Q = PS([0, 1, 3]) 

sage: P != Q 

True 

""" 

if not isinstance(right, SchemeMorphism_point): 

try: 

right = self.codomain()(right) 

except TypeError: 

return NotImplemented 

if self.codomain() != right.codomain(): 

return op == op_NE 

 

n = len(self._coords) 

if op in [op_EQ, op_NE]: 

b = all(self[i] * right[j] == self[j] * right[i] 

for i in range(n) for j in range(i + 1, n)) 

return b == (op == op_EQ) 

return richcmp(self._coords, right._coords, op) 

 

def __hash__(self): 

""" 

Computes the hash value of this point. 

 

If the base ring has a fraction field, normalize the point in 

the fraction field and then hash so that equal points have 

equal hash values. If the base ring is not an integral domain, 

return the hash of the parent. 

 

OUTPUT: Integer. 

 

EXAMPLES:: 

 

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

sage: hash(P([1, 1])) 

1300952125 # 32-bit 

3713081631935493181 # 64-bit 

sage: hash(P.point([2, 2], False)) 

1300952125 # 32-bit 

3713081631935493181 # 64-bit 

 

:: 

 

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

sage: K.<w> = NumberField(x^2 + 3) 

sage: O = K.maximal_order() 

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

sage: hash(P([1+w, 2])) 

-1562365407 # 32-bit 

1251212645657227809 # 64-bit 

sage: hash(P([2, 1-w])) 

-1562365407 # 32-bit 

1251212645657227809 # 64-bit 

 

:: 

 

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

sage: hash(P([2, 5])) 

-479010389 # 32-bit 

4677413289753502123 # 64-bit 

""" 

R = self.codomain().base_ring() 

#if there is a fraction field normalize the point so that 

#equal points have equal hash values 

if R in IntegralDomains(): 

P = self.change_ring(FractionField(R)) 

P.normalize_coordinates() 

return hash(tuple(P)) 

#if there is no good way to normalize return 

#a constant value 

return hash(self.codomain()) 

 

def scale_by(self,t): 

""" 

Scale the coordinates of the point by ``t``. 

 

A ``TypeError`` occurs if the point is not in the 

base_ring of the codomain after scaling. 

 

INPUT: 

 

- ``t`` -- a ring element. 

 

OUTPUT: None. 

 

EXAMPLES:: 

 

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

sage: P = ProjectiveSpace(R, 2, 'x') 

sage: p = P([3/5*t^3, 6*t, t]) 

sage: p.scale_by(1/t); p 

(3/5*t^2 : 6 : 1) 

 

:: 

 

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

sage: S = R.quo(R.ideal(t^3)) 

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

sage: Q = P(t, 1, 1) 

sage: Q.scale_by(t);Q 

(tbar^2 : tbar : tbar) 

 

:: 

 

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

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

sage: Q.scale_by(1/2);Q 

(1 : 1 : 1) 

""" 

if t == 0: #what if R(t) == 0 ? 

raise ValueError("Cannot scale by 0") 

R = self.codomain().base_ring() 

if isinstance(R, QuotientRing_generic): 

for i in range(self.codomain().ambient_space().dimension_relative()+1): 

new_coords = [R(u.lift()*t) for u in self] 

else: 

for i in range(self.codomain().ambient_space().dimension_relative()+1): 

new_coords = [R(u*t) for u in self] 

self._coords = tuple(new_coords) 

 

def normalize_coordinates(self): 

""" 

Removes the gcd from the coordinates of this point (including `-1`). 

 

.. WARNING:: The gcd will depend on the base ring. 

 

OUTPUT: None. 

 

EXAMPLES:: 

 

sage: P = ProjectiveSpace(ZZ,2,'x') 

sage: p = P([-5, -15, -20]) 

sage: p.normalize_coordinates(); p 

(1 : 3 : 4) 

 

:: 

 

sage: P = ProjectiveSpace(Zp(7),2,'x') 

sage: p = P([-5, -15, -2]) 

sage: p.normalize_coordinates(); p 

(5 + O(7^20) : 1 + 2*7 + O(7^20) : 2 + O(7^20)) 

 

:: 

 

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

sage: P = ProjectiveSpace(R,2,'x') 

sage: p = P([3/5*t^3, 6*t, t]) 

sage: p.normalize_coordinates(); p 

(3/5*t^2 : 6 : 1) 

 

:: 

 

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

sage: Q = P(3, 6) 

sage: Q.normalize_coordinates() 

sage: Q 

(1 : 2) 

 

Since the base ring is a polynomial ring over a field, only the 

gcd `c` is removed. :: 

 

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

sage: P = ProjectiveSpace(R,1) 

sage: Q = P(2*c, 4*c) 

sage: Q.normalize_coordinates();Q 

(2 : 4) 

 

A polynomial ring over a ring gives the more intuitive result. :: 

 

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

sage: P = ProjectiveSpace(R,1) 

sage: Q = P(2*c, 4*c) 

sage: Q.normalize_coordinates();Q 

(1 : 2) 

 

:: 

 

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

sage: S = R.quotient_ring(R.ideal(t^3)) 

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

sage: Q = P(t, t^2) 

sage: Q.normalize_coordinates() 

sage: Q 

(1 : tbar) 

""" 

R = self.codomain().base_ring() 

if isinstance(R,(QuotientRing_generic)): 

GCD = gcd(self[0].lift(),self[1].lift()) 

index = 2 

if self[0].lift() > 0 or self[1].lift() > 0: 

neg = 1 

else: 

neg = -1 

while GCD != 1 and index < len(self._coords): 

if self[index].lift() > 0: 

neg = 1 

GCD = gcd(GCD,self[index].lift()) 

index += 1 

else: 

GCD = R(gcd(self[0], self[1])) 

index = 2 

if self[0] > 0 or self[1] > 0: 

neg = R(1) 

else: 

neg = R(-1) 

while GCD != 1 and index < len(self._coords): 

if self[index] > 0: 

neg = R(1) 

GCD = R(gcd(GCD,self[index])) 

index += 1 

if GCD != 1: 

self.scale_by(neg/GCD) 

elif neg == -1: 

self.scale_by(neg) 

 

def dehomogenize(self,n): 

r""" 

Dehomogenizes at the nth coordinate. 

 

INPUT: 

 

- ``n`` -- non-negative integer. 

 

OUTPUT: 

 

- :class:`SchemeMorphism_point_affine`. 

 

EXAMPLES:: 

 

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

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

sage: Q = X(23, 23, 46) 

sage: Q.dehomogenize(2) 

(1/2, 1/2) 

 

:: 

 

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

sage: S = R.quo(R.ideal(t^3)) 

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

sage: Q = P(t, 1, 1) 

sage: Q.dehomogenize(1) 

(tbar, 1) 

 

:: 

 

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

sage: Q = P(1, 3, 1) 

sage: Q.dehomogenize(0) 

(3, 1) 

 

:: 

 

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

sage: Q = P(1, 3, 0) 

sage: Q.dehomogenize(2) 

Traceback (most recent call last): 

... 

ValueError: can't dehomogenize at 0 coordinate 

""" 

if self[n] == 0: 

raise ValueError("can't dehomogenize at 0 coordinate") 

PS = self.codomain() 

A = PS.affine_patch(n) 

Q = [] 

for i in range(0,PS.ambient_space().dimension_relative()+1): 

if i !=n: 

Q.append(self[i]/self[n]) 

return(A.point(Q)) 

 

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

r""" 

Return the ``n``-th iterate of this point for the map ``f``. 

 

If ``normalize==True``, then the coordinates are automatically 

normalized. If ``check==True``, then the initialization checks 

are performed on the new point. 

 

INPUT: 

 

- ``f`` -- a SchmemMorphism_polynomial with the points in its domain. 

 

- ``n`` -- a positive integer. 

 

kwds: 

 

- ``check`` -- Boolean (optional - default: ``True``). 

 

- ``normalize`` -- Boolean (optional Default: ``False``). 

 

OUTPUT: 

 

- A point in the domain of ``f``.` 

 

EXAMPLES:: 

 

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

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

sage: P(1, 1).nth_iterate(f, 4) 

doctest:warning 

... 

(32768 : 32768) 

""" 

from sage.misc.superseded import deprecation 

deprecation(23479, "use f.nth_iterate(P, n, **kwds) instead") 

n = ZZ(n) 

if n < 0: 

raise TypeError("must be a forward orbit") 

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

 

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

r""" 

Returns the orbit of this point by the map ``f``. 

 

If ``N`` is an integer it returns `[P,self(P),\ldots,self^N(P)]`. 

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

Automatically normalize the points if ``normalize=True``. Perform the checks on point initialization if 

``check=True`` 

 

INPUT: 

 

- ``f`` -- a :class:`SchemeMorphism_polynomial` with this point in the domain of ``f``. 

 

- ``N`` -- a non-negative integer or list or tuple of two non-negative integers. 

 

kwds: 

 

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

 

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

 

 

OUTPUT: 

 

- a list of points in the domain of ``f``. 

 

EXAMPLES:: 

 

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

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

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

doctest:warning 

... 

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

""" 

from sage.misc.superseded import deprecation 

deprecation(23479, "use f.orbit(P, N, **kwds) instead") 

if not f.is_endomorphism(): 

raise TypeError("map must be an endomorphism for iteration") 

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 = self 

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

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

 

if normalize: 

Q.normalize_coordinates() 

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

Q = f(Q, check) 

if normalize: 

Q.normalize_coordinates() 

Orb = [Q] 

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

Q = f(Q, check) 

if normalize: 

Q.normalize_coordinates() 

Orb.append(Q) 

return(Orb) 

 

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

r""" 

Evaluates the local Green's function with respect to the morphism ``G`` 

at the place ``v`` for this point 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: 

 

- ``G`` - a projective morphism whose local Green's function we are computing. 

 

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

 

kwds: 

 

- ``N`` - positive integer. number of terms of the series to use, default: 10. 

 

- ``prec`` - positive integer, float point or p-adic precision, default: 100. 

 

- ``error_bound`` - a positive real number. 

 

OUTPUT: 

 

- a real number. 

 

EXAMPLES:: 

 

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

sage: H = Hom(P,P) 

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

sage: Q = P(5, 1) 

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

doctest:warning 

... 

1.6460930160038721802875250367738355497198064992657997569827 

""" 

from sage.misc.superseded import deprecation 

deprecation(23479, "use G.green_function(P, N, **kwds) instead") 

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(self.codomain().base_ring()) 

GBR = G.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 = G.change_ring(K, check = False) 

d = F.degree() 

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

P = self.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 not G.is_endomorphism(): 

raise NotImplementedError("error bounds only for endomorphisms") 

 

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

Pv = [ (v(t).abs()) for t in P ] 

m = -1 

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

for n in range(dim + 1): 

if Pv[n] > m: 

j = n 

m = Pv[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: 

P.scale_by(1/P[j]) 

P = F(P, False) 

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

 

#else - prime or prime ideal for non-archimedean 

for i in range(N + 1): 

if BR == QQ: 

Pv = [ R(K(t).abs()) for t in P ] 

else: 

Pv = [ R(t.abs_non_arch(v)) for t in P ] 

m = -1 

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

for n in range(dim + 1): 

if Pv[n] > m: 

j = n 

m = Pv[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: 

P.scale_by(1/P[j]) 

P = F(P, False) 

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

 

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

r""" 

Evaluates the (absolute) canonical height of this point with respect to the map ``F``. 

 

Must be over number field or order of a number field or ``QQbar``. 

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: 

 

- ``F`` - a projective morphism. 

 

kwds: 

 

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

 

- ``N`` - positive integer. number of terms of the series to use in the local green functions. 

(optional - default:10) 

 

- ``prec`` - positive integer, float point or p-adic precision, default:100. 

 

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

 

OUTPUT: a real number. 

 

AUTHORS: 

 

- Original algorithm written by Elliot Wells [WELLS]_ 

 

- Wells' Algorithm implemented as part of GSOC 2017 by Rebecca Lauren Miller and Paul Fili 

 

 

EXAMPLES:: 

 

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

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

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

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

doctest:warning 

... 

3.7996079979254623065837411853 

 

:: 

 

sage: RSA768 = 123018668453011775513049495838496272077285356959533479219732245215\ 

1726400507263657518745202199786469389956474942774063845925192557326303453731548\ 

2685079170261221429134616704292143116022212404792747377940806653514195974598569\ 

02143413 

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

sage: H = End(P) 

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

sage: Q = P(RSA768,1) 

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

doctest:warning 

... 

931.18256422718241278672729195 

""" 

from sage.misc.superseded import deprecation 

deprecation(23479, "use F.canonical_height(P, **kwds) instead") 

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

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

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

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

 

#Wells' Algorithm 

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

# write our point with coordinates whose gcd is 1 

self.normalize_coordinates() 

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

self.clear_denominators() 

#assures integer coefficients 

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 = self[0] 

y_i = self[1] 

d = F.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 

return self.green_function(F, 0 , **kwds) - H + R(t).log() 

 

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 hieght, we can compute the height of a QQbar point 

#by choosing any number field it is defined over. 

P = self._number_field_from_algebraics() 

K = P.codomain().base_ring() 

f = F._number_field_from_algebraics() 

if K == QQ: 

K = f.base_ring() 

P = P.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] 

P = P.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") 

P = self 

f = F 

 

if bad_primes is None: 

bad_primes = [] 

for b in P: 

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

 

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

else: 

dv = R(2) 

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

 

# Non-Archimedean local heights 

for v in bad_primes: 

if K == QQ: 

dv = R(1) 

else: 

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

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

return h 

 

def global_height(self, prec=None): 

r""" 

Returns the absolute logarithmic height of the point. 

 

INPUT: 

 

- ``prec`` -- desired floating point precision (default: 

default RealField precision). 

 

OUTPUT: 

 

- a real number. 

 

EXAMPLES:: 

 

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

sage: Q = P.point([4, 4, 1/30]) 

sage: Q.global_height() 

4.78749174278205 

 

:: 

 

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

sage: Q = P([4, 1, 30]) 

sage: Q.global_height() 

3.40119738166216 

 

:: 

 

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

sage: k.<w> = NumberField(x^2+5) 

sage: A = ProjectiveSpace(k, 2, 'z') 

sage: A([3, 5*w+1, 1]).global_height(prec=100) 

2.4181409534757389986565376694 

 

:: 

 

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

sage: Q = P([QQbar(sqrt(3)), QQbar(sqrt(-2)), 1]) 

sage: Q.global_height() 

0.549306144334055 

""" 

K = self.codomain().base_ring() 

if K in _NumberFields or is_NumberFieldOrder(K): 

P = self 

elif K is QQbar: 

P = self._number_field_from_algebraics() 

else: 

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

return(max([P[i].global_height(prec=prec) for i in range(self.codomain().ambient_space().dimension_relative()+1)])) 

 

def local_height(self, v, prec=None): 

r""" 

Returns the maximum of the local height of the coordinates of this point. 

 

INPUT: 

 

- ``v`` -- a prime or prime ideal of the base ring. 

 

- ``prec`` -- desired floating point precision (default: 

default RealField precision). 

 

OUTPUT: 

 

- a real number. 

 

EXAMPLES:: 

 

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

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

sage: Q.local_height(5) 

3.21887582486820 

 

:: 

 

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

sage: Q = P([4, 1, 30]) 

sage: Q.local_height(2) 

0.693147180559945 

""" 

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

if K not in _NumberFields: 

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

return max([K(c).local_height(v, prec=prec) for c in self]) 

 

def local_height_arch(self, i, prec=None): 

r""" 

Returns the maximum of the local heights at the ``i``-th infinite place of this point. 

 

INPUT: 

 

- ``i`` -- an integer. 

 

- ``prec`` -- desired floating point precision (default: 

default RealField precision). 

 

OUTPUT: 

 

- a real number. 

 

EXAMPLES:: 

 

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

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

sage: Q.local_height_arch(0) 

1.38629436111989 

 

:: 

 

sage: P.<x,y,z> = ProjectiveSpace(QuadraticField(5, 'w'), 2) 

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

sage: Q.local_height_arch(1) 

3.401197381662155375413236691607 

""" 

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

if K not in _NumberFields: 

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

if K == QQ: 

return max(K(c).local_height_arch(prec=prec) for c in self) 

else: 

return max(K(c).local_height_arch(i, prec=prec) for c in self) 

 

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

r""" 

Returns the multiplier of this point of period ``n`` by the function ``f``. 

 

``f`` must be an endomorphism of projective space. 

 

INPUT: 

 

- ``f`` - a endomorphism of this point's codomain. 

 

- ``n`` - a positive integer, the period of this point. 

 

- ``check`` -- check if ``P`` is periodic of period ``n``, Default:True. 

 

OUTPUT: 

 

- a square matrix of size ``self.codomain().dimension_relative()`` in the 

``base_ring`` of this point. 

 

EXAMPLES:: 

 

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

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

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

sage: Q.multiplier(f, 1) 

[ 2 0 -8] 

[ 0 2 -8] 

[ 0 0 -2] 

""" 

try: 

return f.multiplier(self, n, check) 

except AttributeError: 

raise TypeError("map must be a dynamical system") 

 

def is_preperiodic(self, f, err=0.1, return_period=False): 

r""" 

Determine if the point is preperiodic with respect to the map ``f``. 

 

This is only implemented for projective space (not subschemes). 

There are two optional keyword arguments: 

``error_bound`` sets the error_bound used in the canonical height computation 

and ``return_period`` a boolean which controls if the period is returned if the 

point is preperiodic. If ``return_period`` is ``True`` and this point is not 

preperiodic, then `(0,0)` is returned for the period. 

 

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: 

 

- ``f`` -- an endomorphism of this point's codomain. 

 

kwds: 

 

- ``error_bound`` -- a positive real number (optional - default: 0.1). 

 

- ``return_period`` -- boolean (optional - default: ``False``). 

 

 

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: Q.is_preperiodic(f) 

True 

 

:: 

 

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

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

sage: Q = P(1, 4) 

sage: Q.is_preperiodic(f, return_period=True) 

(1, 3) 

sage: Q = P(1, 1) 

sage: Q.is_preperiodic(f, return_period=True) 

(0, 0) 

 

:: 

 

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

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

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

sage: f = DynamicalSystem_projective([x^5 + 5/4*x*y^4, y^5], domain=P) 

sage: Q = P([-1/2*a+1/2, 1]) 

sage: Q.is_preperiodic(f) 

True 

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

sage: Q.is_preperiodic(f) 

False 

 

:: 

 

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

sage: f = DynamicalSystem_projective([-38/45*x^2 + (2*y - 7/45*z)*x + (-1/2*y^2 - 1/2*y*z + z^2),\ 

-67/90*x^2 + (2*y + z*157/90)*x - y*z, z^2], domain=P) 

sage: Q = P([1, 3, 1]) 

sage: Q.is_preperiodic(f, return_period=True) 

(0, 9) 

 

:: 

 

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

sage: f = DynamicalSystem_projective([(-y - w)*x + (-13/30*y^2 + 13/30*w*y + w^2),\ 

-1/2*x^2 + (-y + 3/2*w)*x + (-1/3*y^2 + 4/3*w*y),-3/2*z^2 + 5/2*z*w + w^2,w^2], domain=P) 

sage: Q = P([3,0,4/3,1]) 

sage: Q.is_preperiodic(f, return_period=True) 

(2, 24) 

 

:: 

 

sage: set_verbose(-1) 

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

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

sage: Q = P([1, 1, 1]) 

sage: Q.is_preperiodic(f) 

True 

 

:: 

 

sage: set_verbose(-1) 

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

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

sage: Q = P([QQbar(sqrt(-1)), 1, 1]) 

sage: Q.is_preperiodic(f) 

True 

 

:: 

 

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

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

sage: Q = P(-1,4) 

sage: Q.is_preperiodic(f) 

True 

 

:: 

 

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

sage: H = End(P) 

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

sage: Q = P(-1,4) 

sage: Q.is_preperiodic(f) 

Traceback (most recent call last): 

... 

TypeError: map must be a dynamical system 

""" 

try: 

return f._is_preperiodic(self, err=err, return_period=return_period) 

except AttributeError: 

raise TypeError("map must be a dynamical system") 

 

class SchemeMorphism_point_projective_field(SchemeMorphism_point_projective_ring): 

""" 

A rational point of projective space over a field. 

 

INPUT: 

 

- ``X`` -- a homset of a subscheme of an ambient projective space 

over a field `K`. 

 

- ``v`` -- a list or tuple of coordinates in `K`. 

 

- ``check`` -- boolean (optional, default:``True``). Whether to 

check the input for consistency. 

 

EXAMPLES:: 

 

sage: P = ProjectiveSpace(3, RR) 

sage: P(2, 3, 4, 5) 

(0.400000000000000 : 0.600000000000000 : 0.800000000000000 : 1.00000000000000) 

""" 

 

def __init__(self, X, v, check=True): 

""" 

The Python constructor. 

 

See :class:`SchemeMorphism_point_projective_ring` for details. 

 

This function still normalizes points so that the rightmost non-zero coordinate is 1. 

This is to maintain functionality with current 

implementations of curves in projectives space (plane, conic, elliptic, etc). 

The :class:`SchemeMorphism_point_projective_ring` is for general use. 

 

EXAMPLES:: 

 

sage: P = ProjectiveSpace(2, QQ) 

sage: P(2, 3/5, 4) 

(1/2 : 3/20 : 1) 

 

:: 

 

sage: P = ProjectiveSpace(3, QQ) 

sage: P(0, 0, 0, 0) 

Traceback (most recent call last): 

... 

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

 

:: 

 

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

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

sage: X([2, 2, 2]) 

(1 : 1 : 1) 

 

:: 

 

sage: P = ProjectiveSpace(1, GF(7)) 

sage: Q=P([2, 1]) 

sage: Q[0].parent() 

Finite Field of size 7 

 

:: 

 

sage: P = ProjectiveSpace(QQ,1) 

sage: P.point(Infinity) 

(1 : 0) 

sage: P(infinity) 

(1 : 0) 

 

:: 

 

sage: P = ProjectiveSpace(QQ,2) 

sage: P(infinity) 

Traceback (most recent call last): 

... 

ValueError: +Infinity not well defined in dimension > 1 

sage: P.point(infinity) 

Traceback (most recent call last): 

... 

ValueError: +Infinity not well defined in dimension > 1 

""" 

SchemeMorphism.__init__(self, X) 

if check: 

from sage.schemes.elliptic_curves.ell_point import EllipticCurvePoint_field 

from sage.rings.ring import CommutativeRing 

d = X.codomain().ambient_space().ngens() 

if is_SchemeMorphism(v) or isinstance(v, EllipticCurvePoint_field): 

v = list(v) 

else: 

try: 

if isinstance(v.parent(), CommutativeRing): 

v = [v] 

except AttributeError: 

pass 

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

raise TypeError("argument v (= %s) must be a scheme point, list, or tuple"%str(v)) 

if len(v) != d and len(v) != d-1: 

raise TypeError("v (=%s) must have %s components"%(v, d)) 

 

R = X.value_ring() 

v = Sequence(v, R) 

if len(v) == d-1: # very common special case 

v.append(R(1)) 

 

n = len(v) 

all_zero = True 

for i in range(n): 

last = n-1-i 

if v[last]: 

all_zero = False 

c = v[last] 

if c == R.one(): 

break 

for j in range(last): 

v[j] /= c 

v[last] = R.one() 

break 

if all_zero: 

raise ValueError("%s does not define a valid point since all entries are 0"%repr(v)) 

 

X.extended_codomain()._check_satisfies_equations(v) 

 

self._coords = tuple(v) 

 

def __hash__(self): 

""" 

Computes the hash value of this point. 

 

OUTPUT: Integer. 

 

EXAMPLES:: 

 

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

sage: hash(P([1/2, 1])) 

-1503642134 # 32-bit 

-6819944855328768534 # 64-bit 

sage: hash(P.point([1, 2], False)) 

-1503642134 # 32-bit 

-6819944855328768534 # 64-bit 

""" 

P = copy(self) 

P.normalize_coordinates() 

return hash(tuple(P)) 

 

def normalize_coordinates(self): 

r""" 

Normalizes the point so that the last non-zero coordinate is `1`. 

 

OUTPUT: None. 

 

EXAMPLES:: 

 

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

sage: Q = P.point([GF(5)(1), GF(5)(3), GF(5)(0)], False); Q 

(1 : 3 : 0) 

sage: Q.normalize_coordinates(); Q 

(2 : 1 : 0) 

 

:: 

 

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

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

sage: Q = X.point([23, 23, 46], False); Q 

(23 : 23 : 46) 

sage: Q.normalize_coordinates(); Q 

(1/2 : 1/2 : 1) 

""" 

index = self.codomain().ambient_space().dimension_relative() 

while self[index] == 0: 

index -= 1 

self.scale_by(1/self[index]) 

 

def _number_field_from_algebraics(self): 

r""" 

Given a projective point defined over ``QQbar``, return the same point, but defined 

over a number field. 

 

This is only implemented for points of projective space. 

 

OUTPUT: scheme point 

 

EXAMPLES:: 

 

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

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

sage: Q = P([-1/2*QQbar(sqrt(2)) + QQbar(I), 1]) 

sage: S = Q._number_field_from_algebraics(); S 

(1/2*a^3 + a^2 - 1/2*a : 1) 

sage: S.codomain() 

Projective Space of dimension 1 over Number Field in a with defining polynomial y^4 + 1 

 

The following was fixed in :trac:`23808`:: 

 

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

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

sage: Q = P([-1/2*QQbar(sqrt(2)) + QQbar(I), 1]);Q 

(-0.7071067811865475? + 1*I : 1) 

sage: S = Q._number_field_from_algebraics(); S 

(1/2*a^3 + a^2 - 1/2*a : 1) 

sage: T = S.change_ring(QQbar) # Used to fail 

sage: T 

(-0.7071067811865475? + 1.000000000000000?*I : 1) 

sage: Q[0] == T[0] 

True 

""" 

from sage.schemes.projective.projective_space import is_ProjectiveSpace 

if not is_ProjectiveSpace(self.codomain()): 

raise NotImplementedError("not implemented for subschemes") 

 

# Trac #23808: Keep the embedding info associated with the number field K 

# used below, instead of in the separate embedding map phi which is 

# forgotten. 

K_pre,P,phi = number_field_elements_from_algebraics(list(self)) 

if K_pre is QQ: 

K = QQ 

else: 

from sage.rings.number_field.number_field import NumberField 

K = NumberField(K_pre.polynomial(), embedding=phi(K_pre.gen()), name='a') 

psi = K_pre.hom([K.gen()], K) # Identification of K_pre with K 

P = [ psi(p) for p in P ] # The elements of P were elements of K_pre 

from sage.schemes.projective.projective_space import ProjectiveSpace 

PS = ProjectiveSpace(K,self.codomain().dimension_relative(),'z') 

return(PS(P)) 

 

def clear_denominators(self): 

r""" 

scales by the least common multiple of the denominators. 

 

OUTPUT: None. 

 

EXAMPLES:: 

 

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

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

sage: Q = P([t, 3/t^2, 1]) 

sage: Q.clear_denominators(); Q 

(t^3 : 3 : t^2) 

 

:: 

 

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

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

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

sage: Q = P([1/w, 3, 0]) 

sage: Q.clear_denominators(); Q 

(w : 9 : 0) 

 

:: 

 

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

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

sage: Q = X([1/2, 1/2, 1]); 

sage: Q.clear_denominators(); Q 

(1 : 1 : 2) 

 

:: 

 

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

sage: Q = PS.point([1, 2/3], False); Q 

(1 : 2/3) 

sage: Q.clear_denominators(); Q 

(3 : 2) 

""" 

self.scale_by(lcm([t.denominator() for t in self])) 

 

def intersection_multiplicity(self, X): 

r""" 

Return the intersection multiplicity of the codomain of this point and ``X`` at this point. 

 

This uses the intersection_multiplicity implementations for projective/affine subschemes. This 

point must be a point of a projective subscheme. 

 

INPUT: 

 

- ``X`` -- a subscheme in the same ambient space as that of the codomain of this point. 

 

OUTPUT: Integer. 

 

EXAMPLES:: 

 

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

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

sage: Y = P.subscheme([x^3 - y*w^2 + z*w^2, x*y - z*w]) 

sage: Q1 = X([1/2, 1/4, 1/8, 1]) 

sage: Q1.intersection_multiplicity(Y) 

1 

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

sage: Q2.intersection_multiplicity(Y) 

5 

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

sage: Q3.intersection_multiplicity(Y) 

6 

 

:: 

 

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

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

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

sage: Q.intersection_multiplicity(X) 

Traceback (most recent call last): 

... 

TypeError: this point must be a point on a projective subscheme 

""" 

from sage.schemes.projective.projective_space import is_ProjectiveSpace 

if is_ProjectiveSpace(self.codomain()): 

raise TypeError("this point must be a point on a projective subscheme") 

return self.codomain().intersection_multiplicity(X, self) 

 

def multiplicity(self): 

r""" 

Return the multiplicity of this point on its codomain. 

 

Uses the subscheme multiplicity implementation. This point must be a point on 

a projective subscheme. 

 

OUTPUT: an integer. 

 

EXAMPLES:: 

 

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

sage: X = P.subscheme([y^6 - x^3*w^2*t + t^5*w, x^2 - t^2]) 

sage: Q1 = X([1,0,2,1,1]) 

sage: Q1.multiplicity() 

1 

sage: Q2 = X([0,0,-2,1,0]) 

sage: Q2.multiplicity() 

8 

""" 

from sage.schemes.projective.projective_space import is_ProjectiveSpace 

if is_ProjectiveSpace(self.codomain()): 

raise TypeError("this point must be a point on a projective subscheme") 

return self.codomain().multiplicity(self) 

 

class SchemeMorphism_point_projective_finite_field(SchemeMorphism_point_projective_field): 

 

def __hash__(self): 

r""" 

Returns the integer hash of this point. 

 

OUTPUT: Integer. 

 

EXAMPLES:: 

 

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

sage: hash(P(2, 1, 2)) 

41 

 

:: 

 

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

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

sage: hash(X(1, 1, 2)) 

81 

 

:: 

 

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

sage: hash(P(3, 4)) 

17 

 

:: 

 

sage: P.<x,y> = ProjectiveSpace(GF(13^3,'t'), 1) 

sage: hash(P(3, 4)) 

2201 

""" 

p = self.codomain().base_ring().order() 

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

return sum(hash(self[i])*p**i for i in range(N+1)) 

 

def orbit_structure(self,f): 

r""" 

This function returns the pair `[m,n]` where `m` is the 

preperiod and `n` is the period of the point by the map ``f``. 

 

Every point is preperiodic over a finite field so this is always possible. 

 

INPUT: 

 

- ``f`` -- a :class:`ScemeMorphism_polynomial` with this point in ``f.domain()``. 

 

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: P(1, 0, 1).orbit_structure(f) 

doctest:warning 

... 

[0, 1] 

""" 

from sage.misc.superseded import deprecation 

deprecation(23479, "use f.orbit_structure(P) instead") 

return f.orbit_structure(self) 

 

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

# Abelian varieties 

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

class SchemeMorphism_point_abelian_variety_field(AdditiveGroupElement, SchemeMorphism_point_projective_field): 

""" 

A rational point of an abelian variety over a field. 

 

EXAMPLES:: 

 

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

sage: origin = E(0) 

sage: origin.domain() 

Spectrum of Rational Field 

sage: origin.codomain() 

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

""" 

pass