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

r""" 

Topological Manifolds 

 

Given a topological field `K` (in most applications, `K = \RR` or 

`K = \CC`) and a non-negative integer `n`, a *topological manifold of 

dimension* `n` *over K* is a topological space `M` such that 

 

- `M` is a Hausdorff space, 

- `M` is second countable, 

- every point in `M` has a neighborhood homeomorphic to `K^n`. 

 

Topological manifolds are implemented via the class 

:class:`TopologicalManifold`. Open subsets of topological manifolds 

are also implemented via :class:`TopologicalManifold`, since they are 

topological manifolds by themselves. 

 

In the current setting, topological manifolds are mostly described by 

means of charts (see :class:`~sage.manifolds.chart.Chart`). 

 

:class:`TopologicalManifold` serves as a base class for more specific 

manifold classes. 

 

The user interface is provided by the generic function 

:func:`~sage.manifolds.manifold.Manifold`, with 

with the argument ``structure`` set to ``'topological'``. 

 

.. RUBRIC:: Example 1: the 2-sphere as a topological manifold of dimension 

2 over `\RR` 

 

One starts by declaring `S^2` as a 2-dimensional topological manifold:: 

 

sage: M = Manifold(2, 'S^2', structure='topological') 

sage: M 

2-dimensional topological manifold S^2 

 

Since the base topological field has not been specified in the argument list 

of ``Manifold``, `\RR` is assumed:: 

 

sage: M.base_field() 

Real Field with 53 bits of precision 

sage: dim(M) 

2 

 

Let us consider the complement of a point, the "North pole" say; this is an 

open subset of `S^2`, which we call `U`:: 

 

sage: U = M.open_subset('U'); U 

Open subset U of the 2-dimensional topological manifold S^2 

 

A standard chart on `U` is provided by the stereographic projection from the 

North pole to the equatorial plane:: 

 

sage: stereoN.<x,y> = U.chart(); stereoN 

Chart (U, (x, y)) 

 

Thanks to the operator ``<x,y>`` on the left-hand side, the coordinates 

declared in a chart (here `x` and `y`), are accessible by their names; 

they are Sage's symbolic variables:: 

 

sage: y 

y 

sage: type(y) 

<type 'sage.symbolic.expression.Expression'> 

 

The South pole is the point of coordinates `(x, y) = (0, 0)` in the above 

chart:: 

 

sage: S = U.point((0,0), chart=stereoN, name='S'); S 

Point S on the 2-dimensional topological manifold S^2 

 

Let us call `V` the open subset that is the complement of the South pole and 

let us introduce on it the chart induced by the stereographic projection from 

the South pole to the equatorial plane:: 

 

sage: V = M.open_subset('V'); V 

Open subset V of the 2-dimensional topological manifold S^2 

sage: stereoS.<u,v> = V.chart(); stereoS 

Chart (V, (u, v)) 

 

The North pole is the point of coordinates `(u, v) = (0, 0)` in this chart:: 

 

sage: N = V.point((0,0), chart=stereoS, name='N'); N 

Point N on the 2-dimensional topological manifold S^2 

 

To fully construct the manifold, we declare that it is the union of `U` 

and `V`:: 

 

sage: M.declare_union(U,V) 

 

and we provide the transition map between the charts ``stereoN`` = 

`(U, (x, y))` and ``stereoS`` = `(V, (u, v))`, denoting by `W` the 

intersection of `U` and `V` (`W` is the subset of `U` defined by 

`x^2 + y^2 \neq 0`, as well as the subset of `V` defined by 

`u^2 + v^2 \neq 0`):: 

 

sage: stereoN_to_S = stereoN.transition_map(stereoS, [x/(x^2+y^2), y/(x^2+y^2)], 

....: intersection_name='W', restrictions1= x^2+y^2!=0, 

....: restrictions2= u^2+v^2!=0) 

sage: stereoN_to_S 

Change of coordinates from Chart (W, (x, y)) to Chart (W, (u, v)) 

sage: stereoN_to_S.display() 

u = x/(x^2 + y^2) 

v = y/(x^2 + y^2) 

 

We give the name ``W`` to the Python variable representing `W = U \cap V`:: 

 

sage: W = U.intersection(V) 

 

The inverse of the transition map is computed by the method 

:meth:`sage.manifolds.chart.CoordChange.inverse`:: 

 

sage: stereoN_to_S.inverse() 

Change of coordinates from Chart (W, (u, v)) to Chart (W, (x, y)) 

sage: stereoN_to_S.inverse().display() 

x = u/(u^2 + v^2) 

y = v/(u^2 + v^2) 

 

At this stage, we have four open subsets on `S^2`:: 

 

sage: M.list_of_subsets() 

[2-dimensional topological manifold S^2, 

Open subset U of the 2-dimensional topological manifold S^2, 

Open subset V of the 2-dimensional topological manifold S^2, 

Open subset W of the 2-dimensional topological manifold S^2] 

 

`W` is the open subset that is the complement of the two poles:: 

 

sage: N in W or S in W 

False 

 

The North pole lies in `V` and the South pole in `U`:: 

 

sage: N in V, N in U 

(True, False) 

sage: S in U, S in V 

(True, False) 

 

The manifold's (user) atlas contains four charts, two of them 

being restrictions of charts to a smaller domain:: 

 

sage: M.atlas() 

[Chart (U, (x, y)), Chart (V, (u, v)), 

Chart (W, (x, y)), Chart (W, (u, v))] 

 

Let us consider the point of coordinates `(1, 2)` in the chart ``stereoN``:: 

 

sage: p = M.point((1,2), chart=stereoN, name='p'); p 

Point p on the 2-dimensional topological manifold S^2 

sage: p.parent() 

2-dimensional topological manifold S^2 

sage: p in W 

True 

 

The coordinates of `p` in the chart ``stereoS`` are computed by letting 

the chart act on the point:: 

 

sage: stereoS(p) 

(1/5, 2/5) 

 

Given the definition of `p`, we have of course:: 

 

sage: stereoN(p) 

(1, 2) 

 

Similarly:: 

 

sage: stereoS(N) 

(0, 0) 

sage: stereoN(S) 

(0, 0) 

 

A continuous map `S^2 \to \RR` (scalar field):: 

 

sage: f = M.scalar_field({stereoN: atan(x^2+y^2), stereoS: pi/2-atan(u^2+v^2)}, 

....: name='f') 

sage: f 

Scalar field f on the 2-dimensional topological manifold S^2 

sage: f.display() 

f: S^2 --> R 

on U: (x, y) |--> arctan(x^2 + y^2) 

on V: (u, v) |--> 1/2*pi - arctan(u^2 + v^2) 

sage: f(p) 

arctan(5) 

sage: f(N) 

1/2*pi 

sage: f(S) 

0 

sage: f.parent() 

Algebra of scalar fields on the 2-dimensional topological manifold S^2 

sage: f.parent().category() 

Category of commutative algebras over Symbolic Ring 

 

 

.. RUBRIC:: Example 2: the Riemann sphere as a topological manifold of 

dimension 1 over `\CC` 

 

We declare the Riemann sphere `\CC^*` as a 1-dimensional topological manifold 

over `\CC`:: 

 

sage: M = Manifold(1, 'C*', structure='topological', field='complex'); M 

Complex 1-dimensional topological manifold C* 

 

We introduce a first open subset, which is actually 

`\CC = \CC^*\setminus\{\infty\}` if we interpret `\CC^*` as the 

Alexandroff one-point compactification of `\CC`:: 

 

sage: U = M.open_subset('U') 

 

A natural chart on `U` is then nothing but the identity map of `\CC`, hence 

we denote the associated coordinate by `z`:: 

 

sage: Z.<z> = U.chart() 

 

The origin of the complex plane is the point of coordinate `z = 0`:: 

 

sage: O = U.point((0,), chart=Z, name='O'); O 

Point O on the Complex 1-dimensional topological manifold C* 

 

Another open subset of `\CC^*` is `V = \CC^*\setminus\{O\}`:: 

 

sage: V = M.open_subset('V') 

 

We define a chart on `V` such that the point at infinity is the point of 

coordinate `0` in this chart:: 

 

sage: W.<w> = V.chart(); W 

Chart (V, (w,)) 

sage: inf = M.point((0,), chart=W, name='inf', latex_name=r'\infty') 

sage: inf 

Point inf on the Complex 1-dimensional topological manifold C* 

 

To fully construct the Riemann sphere, we declare that it is the union 

of `U` and `V`:: 

 

sage: M.declare_union(U,V) 

 

and we provide the transition map between the two charts as `w = 1 / z` 

on `A = U \cap V`:: 

 

sage: Z_to_W = Z.transition_map(W, 1/z, intersection_name='A', 

....: restrictions1= z!=0, restrictions2= w!=0) 

sage: Z_to_W 

Change of coordinates from Chart (A, (z,)) to Chart (A, (w,)) 

sage: Z_to_W.display() 

w = 1/z 

sage: Z_to_W.inverse() 

Change of coordinates from Chart (A, (w,)) to Chart (A, (z,)) 

sage: Z_to_W.inverse().display() 

z = 1/w 

 

Let consider the complex number `i` as a point of the Riemann sphere:: 

 

sage: i = M((I,), chart=Z, name='i'); i 

Point i on the Complex 1-dimensional topological manifold C* 

 

Its coordinates w.r.t. the charts ``Z`` and ``W`` are:: 

 

sage: Z(i) 

(I,) 

sage: W(i) 

(-I,) 

 

and we have:: 

 

sage: i in U 

True 

sage: i in V 

True 

 

The following subsets and charts have been defined:: 

 

sage: M.list_of_subsets() 

[Open subset A of the Complex 1-dimensional topological manifold C*, 

Complex 1-dimensional topological manifold C*, 

Open subset U of the Complex 1-dimensional topological manifold C*, 

Open subset V of the Complex 1-dimensional topological manifold C*] 

sage: M.atlas() 

[Chart (U, (z,)), Chart (V, (w,)), Chart (A, (z,)), Chart (A, (w,))] 

 

A constant map `\CC^* \rightarrow \CC`:: 

 

sage: f = M.constant_scalar_field(3+2*I, name='f'); f 

Scalar field f on the Complex 1-dimensional topological manifold C* 

sage: f.display() 

f: C* --> C 

on U: z |--> 2*I + 3 

on V: w |--> 2*I + 3 

sage: f(O) 

2*I + 3 

sage: f(i) 

2*I + 3 

sage: f(inf) 

2*I + 3 

sage: f.parent() 

Algebra of scalar fields on the Complex 1-dimensional topological 

manifold C* 

sage: f.parent().category() 

Category of commutative algebras over Symbolic Ring 

 

AUTHORS: 

 

- Eric Gourgoulhon (2015): initial version 

- Travis Scrimshaw (2015): structure described via 

:class:`~sage.manifolds.structure.TopologicalStructure` or 

:class:`~sage.manifolds.structure.RealTopologicalStructure` 

 

 

REFERENCES: 

 

- [Lee2011]_ 

- [Lee2013]_ 

- [KN1963]_ 

- [Huy2005]_ 

 

""" 

 

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

# Copyright (C) 2015 Eric Gourgoulhon <eric.gourgoulhon@obspm.fr> 

# Copyright (C) 2015 Travis Scrimshaw <tscrimsh@umn.edu> 

# 

# 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.categories.fields import Fields 

from sage.categories.manifolds import Manifolds 

from sage.categories.homset import Hom 

from sage.rings.all import CC 

from sage.rings.real_mpfr import RR, RealField_class 

from sage.rings.complex_field import ComplexField_class 

from sage.misc.prandom import getrandbits 

from sage.misc.cachefunc import cached_method 

from sage.rings.integer import Integer 

from sage.structure.global_options import GlobalOptions 

from sage.manifolds.subset import ManifoldSubset 

from sage.manifolds.structure import( 

TopologicalStructure, RealTopologicalStructure, 

DifferentialStructure, RealDifferentialStructure) 

 

 

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

## Global options 

 

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

## Class 

 

class TopologicalManifold(ManifoldSubset): 

r""" 

Topological manifold over a topological field `K`. 

 

Given a topological field `K` (in most applications, `K = \RR` or 

`K = \CC`) and a non-negative integer `n`, a *topological manifold of 

dimension* `n` *over K* is a topological space `M` such that 

 

- `M` is a Hausdorff space, 

- `M` is second countable, and 

- every point in `M` has a neighborhood homeomorphic to `K^n`. 

 

This is a Sage *parent* class, the corresponding *element* 

class being :class:`~sage.manifolds.point.ManifoldPoint`. 

 

INPUT: 

 

- ``n`` -- positive integer; dimension of the manifold 

- ``name`` -- string; name (symbol) given to the manifold 

- ``field`` -- field `K` on which the manifold is 

defined; allowed values are 

 

- ``'real'`` or an object of type ``RealField`` (e.g., ``RR``) for 

a manifold over `\RR` 

- ``'complex'`` or an object of type ``ComplexField`` (e.g., ``CC``) 

for a manifold over `\CC` 

- an object in the category of topological fields (see 

:class:`~sage.categories.fields.Fields` and 

:class:`~sage.categories.topological_spaces.TopologicalSpaces`) 

for other types of manifolds 

 

- ``structure`` -- manifold structure (see 

:class:`~sage.manifolds.structure.TopologicalStructure` or 

:class:`~sage.manifolds.structure.RealTopologicalStructure`) 

- ``ambient`` -- (default: ``None``) if not ``None``, must be a 

topological manifold; the created object is then an open subset of 

``ambient`` 

- ``latex_name`` -- (default: ``None``) string; LaTeX symbol to 

denote the manifold; if none are provided, it is set to ``name`` 

- ``start_index`` -- (default: 0) integer; lower value of the range of 

indices used for "indexed objects" on the manifold, e.g., coordinates 

in a chart 

- ``category`` -- (default: ``None``) to specify the category; if 

``None``, ``Manifolds(field)`` is assumed (see the category 

:class:`~sage.categories.manifolds.Manifolds`) 

- ``unique_tag`` -- (default: ``None``) tag used to force the construction 

of a new object when all the other arguments have been used previously 

(without ``unique_tag``, the 

:class:`~sage.structure.unique_representation.UniqueRepresentation` 

behavior inherited from 

:class:`~sage.manifolds.subset.ManifoldSubset` 

would return the previously constructed object corresponding to these 

arguments) 

 

EXAMPLES: 

 

A 4-dimensional topological manifold (over `\RR`):: 

 

sage: M = Manifold(4, 'M', latex_name=r'\mathcal{M}', structure='topological') 

sage: M 

4-dimensional topological manifold M 

sage: latex(M) 

\mathcal{M} 

sage: type(M) 

<class 'sage.manifolds.manifold.TopologicalManifold_with_category'> 

sage: M.base_field() 

Real Field with 53 bits of precision 

sage: dim(M) 

4 

 

The input parameter ``start_index`` defines the range of indices 

on the manifold:: 

 

sage: M = Manifold(4, 'M', structure='topological') 

sage: list(M.irange()) 

[0, 1, 2, 3] 

sage: M = Manifold(4, 'M', structure='topological', start_index=1) 

sage: list(M.irange()) 

[1, 2, 3, 4] 

sage: list(Manifold(4, 'M', structure='topological', start_index=-2).irange()) 

[-2, -1, 0, 1] 

 

A complex manifold:: 

 

sage: N = Manifold(3, 'N', structure='topological', field='complex'); N 

Complex 3-dimensional topological manifold N 

 

A manifold over `\QQ`:: 

 

sage: N = Manifold(6, 'N', structure='topological', field=QQ); N 

6-dimensional topological manifold N over the Rational Field 

 

A manifold over `\QQ_5`, the field of 5-adic numbers:: 

 

sage: N = Manifold(2, 'N', structure='topological', field=Qp(5)); N 

2-dimensional topological manifold N over the 5-adic Field with capped 

relative precision 20 

 

A manifold is a Sage *parent* object, in the category of topological 

manifolds over a given topological field (see 

:class:`~sage.categories.manifolds.Manifolds`):: 

 

sage: isinstance(M, Parent) 

True 

sage: M.category() 

Category of manifolds over Real Field with 53 bits of precision 

sage: from sage.categories.manifolds import Manifolds 

sage: M.category() is Manifolds(RR) 

True 

sage: M.category() is Manifolds(M.base_field()) 

True 

sage: M in Manifolds(RR) 

True 

sage: N in Manifolds(Qp(5)) 

True 

 

The corresponding Sage *elements* are points:: 

 

sage: X.<t, x, y, z> = M.chart() 

sage: p = M.an_element(); p 

Point on the 4-dimensional topological manifold M 

sage: p.parent() 

4-dimensional topological manifold M 

sage: M.is_parent_of(p) 

True 

sage: p in M 

True 

 

The manifold's points are instances of class 

:class:`~sage.manifolds.point.ManifoldPoint`:: 

 

sage: isinstance(p, sage.manifolds.point.ManifoldPoint) 

True 

 

Since an open subset of a topological manifold `M` is itself a 

topological manifold, open subsets of `M` are instances of the class 

:class:`TopologicalManifold`:: 

 

sage: U = M.open_subset('U'); U 

Open subset U of the 4-dimensional topological manifold M 

sage: isinstance(U, sage.manifolds.manifold.TopologicalManifold) 

True 

sage: U.base_field() == M.base_field() 

True 

sage: dim(U) == dim(M) 

True 

sage: U.category() 

Join of Category of subobjects of sets and Category of manifolds over 

Real Field with 53 bits of precision 

 

The manifold passes all the tests of the test suite relative to its 

category:: 

 

sage: TestSuite(M).run() 

 

.. SEEALSO:: 

 

:mod:`sage.manifolds.manifold` 

""" 

def __init__(self, n, name, field, structure, ambient=None, 

latex_name=None, start_index=0, category=None, 

unique_tag=None): 

r""" 

Construct a topological manifold. 

 

TESTS:: 

 

sage: M = Manifold(3, 'M', latex_name=r'\mathbb{M}', 

....: structure='topological', start_index=1) 

sage: M 

3-dimensional topological manifold M 

sage: latex(M) 

\mathbb{M} 

sage: dim(M) 

3 

sage: X.<x,y,z> = M.chart() 

sage: TestSuite(M).run() 

 

Tests for open subsets:: 

 

sage: U = M.open_subset('U', coord_def={X: x>0}) 

sage: TestSuite(U).run() 

sage: U.category() is M.category().Subobjects() 

True 

 

""" 

# Initialization of the attributes _dim, _field, _field_type: 

self._dim = n 

if field == 'real': 

self._field = RR 

self._field_type = 'real' 

elif field == 'complex': 

self._field = CC 

self._field_type = 'complex' 

else: 

if field not in Fields(): 

raise TypeError("the argument 'field' must be a field") 

self._field = field 

if isinstance(field, RealField_class): 

self._field_type = 'real' 

elif isinstance(field, ComplexField_class): 

self._field_type = 'complex' 

else: 

self._field_type = 'neither_real_nor_complex' 

# Structure and category: 

self._structure = structure 

if ambient is None: 

ambient = self 

category = Manifolds(self._field).or_subcategory(category) 

category = self._structure.subcategory(category) 

else: 

category = ambient.category().Subobjects() 

# Initialization as a manifold set: 

ManifoldSubset.__init__(self, ambient, name, latex_name=latex_name, 

category=category) 

self._is_open = True 

self._open_covers.append([self]) # list of open covers of self 

# 

if not isinstance(start_index, (int, Integer)): 

raise TypeError("the starting index must be an integer") 

self._sindex = start_index 

# 

self._atlas = [] # list of charts defined on subsets of self 

self._top_charts = [] # list of charts defined on subsets of self 

# that are not subcharts of charts on larger subsets 

self._def_chart = None # default chart 

self._charts_by_coord = {} # dictionary of charts whose domain is self 

# (key: string formed by the coordinate 

# symbols separated by a white space) 

self._coord_changes = {} # dictionary of transition maps (key: pair of 

# of charts) 

# List of charts that individually cover self, i.e. whose 

# domains are self (if non-empty, self is a coordinate domain): 

self._covering_charts = [] 

# Algebra of scalar fields defined on self: 

self._scalar_field_algebra = self._structure.scalar_field_algebra(self) 

# The zero scalar field: 

self._zero_scalar_field = self._scalar_field_algebra.zero() 

# The unit scalar field: 

self._one_scalar_field = self._scalar_field_algebra.one() 

# The current calculus method on the manifold 

# (to be changed by set_calculus_method) 

self._calculus_method = 'SR' 

 

def _repr_(self): 

r""" 

Return a string representation of the manifold. 

 

TESTS:: 

 

sage: M = Manifold(3, 'M', structure='topological') 

sage: M._repr_() 

'3-dimensional topological manifold M' 

sage: repr(M) # indirect doctest 

'3-dimensional topological manifold M' 

sage: M # indirect doctest 

3-dimensional topological manifold M 

sage: M = Manifold(3, 'M', structure='topological', field='complex') 

sage: M._repr_() 

'Complex 3-dimensional topological manifold M' 

sage: M = Manifold(3, 'M', structure='topological', field=QQ) 

sage: M._repr_() 

'3-dimensional topological manifold M over the Rational Field' 

 

If the manifold is actually an open subset of a larger manifold, the 

string representation is different:: 

 

sage: U = M.open_subset('U') 

sage: U._repr_() 

'Open subset U of the 3-dimensional topological manifold M 

over the Rational Field' 

""" 

if self is self._manifold: 

if self._field_type == 'real': 

return "{}-dimensional {} manifold {}".format(self._dim, 

self._structure.name, 

self._name) 

elif self._field_type == 'complex': 

if isinstance(self._structure, DifferentialStructure): 

return "{}-dimensional complex manifold {}".format( 

self._dim, 

self._name) 

else: 

return "Complex {}-dimensional {} manifold {}".format( 

self._dim, 

self._structure.name, 

self._name) 

return "{}-dimensional {} manifold {} over the {}".format( 

self._dim, 

self._structure.name, 

self._name, 

self._field) 

else: 

return "Open subset {} of the {}".format(self._name, self._manifold) 

 

def _an_element_(self): 

r""" 

Construct some point on the manifold. 

 

EXAMPLES:: 

 

sage: M = Manifold(2, 'M', structure='topological') 

sage: X.<x,y> = M.chart() 

sage: p = M._an_element_(); p 

Point on the 2-dimensional topological manifold M 

sage: p.coord() 

(0, 0) 

sage: U = M.open_subset('U', coord_def={X: y>1}); U 

Open subset U of the 2-dimensional topological manifold M 

sage: p = U._an_element_(); p 

Point on the 2-dimensional topological manifold M 

sage: p in U 

True 

sage: p.coord() 

(0, 2) 

sage: V = U.open_subset('V', coord_def={X.restrict(U): x<-pi}) 

sage: p = V._an_element_(); p 

Point on the 2-dimensional topological manifold M 

sage: p in V 

True 

sage: p.coord() 

(-pi - 1, 2) 

 

""" 

from sage.rings.infinity import Infinity 

if self._def_chart is None: 

return self.element_class(self) 

# Attempt to construct a point in the domain of the default chart 

chart = self._def_chart 

if self._field_type == 'real': 

coords = [] 

for coord_range in chart._bounds: 

xmin = coord_range[0][0] 

xmax = coord_range[1][0] 

if xmin == -Infinity: 

if xmax == Infinity: 

x = 0 

else: 

x = xmax - 1 

else: 

if xmax == Infinity: 

x = xmin + 1 

else: 

x = (xmin + xmax)/2 

coords.append(x) 

else: 

coords = self._dim*[0] 

if not chart.valid_coordinates(*coords): 

# Attempt to construct a point in the domain of other charts 

if self._field_type == 'real': 

for ch in self._atlas: 

if ch is self._def_chart: 

continue # since this case has already been attempted 

coords = [] 

for coord_range in ch._bounds: 

xmin = coord_range[0][0] 

xmax = coord_range[1][0] 

if xmin == -Infinity: 

if xmax == Infinity: 

x = 0 

else: 

x = xmax - 1 

else: 

if xmax == Infinity: 

x = xmin + 1 

else: 

x = (xmin + xmax)/2 

coords.append(x) 

if ch.valid_coordinates(*coords): 

chart = ch 

break 

else: 

# A generic element with specific coordinates could not be 

# automatically generated, due to too complex coordinate 

# conditions. An element without any coordinate set is 

# returned instead: 

return self.element_class(self) 

else: 

# Case of manifolds over a field different from R 

for ch in self._atlas: 

if ch is self._def_chart: 

continue # since this case has already been attempted 

if ch.valid_coordinates(*coords): 

chart = ch 

break 

else: 

return self.element_class(self) 

# The point is constructed with check_coords=False since the check 

# has just been performed above: 

return self.element_class(self, coords=coords, chart=chart, 

check_coords=False) 

 

def __contains__(self, point): 

r""" 

Check whether a point is contained in the manifold. 

 

EXAMPLES:: 

 

sage: M = Manifold(2, 'M', structure='topological') 

sage: X.<x,y> = M.chart() 

sage: p = M.point((1,2), chart=X) 

sage: M.__contains__(p) 

True 

sage: p in M # indirect doctest 

True 

sage: U = M.open_subset('U', coord_def={X: x>0}) 

sage: U.__contains__(p) 

True 

sage: p in U # indirect doctest 

True 

sage: V = U.open_subset('V', coord_def={X.restrict(U): y<0}) 

sage: V.__contains__(p) 

False 

sage: p in V # indirect doctest 

False 

 

""" 

# for efficiency, a quick test first: 

if point.parent() is self: 

return True 

if point.parent().is_subset(self): 

return True 

for chart in self._atlas: 

if chart in point._coordinates: 

if chart.valid_coordinates( *(point._coordinates[chart]) ): 

return True 

for chart in point._coordinates: 

for schart in chart._subcharts: 

if schart in self._atlas and schart.valid_coordinates( 

*(point._coordinates[chart]) ): 

return True 

return False 

 

def open_subset(self, name, latex_name=None, coord_def={}): 

r""" 

Create an open subset of the manifold. 

 

An open subset is a set that is (i) included in the manifold and (ii) 

open with respect to the manifold's topology. It is a topological 

manifold by itself. Hence the returned object is an instance of 

:class:`TopologicalManifold`. 

 

INPUT: 

 

- ``name`` -- name given to the open subset 

- ``latex_name`` -- (default: ``None``) LaTeX symbol to denote 

the subset; if none are provided, it is set to ``name`` 

- ``coord_def`` -- (default: {}) definition of the subset in 

terms of coordinates; ``coord_def`` must a be dictionary with keys 

charts on the manifold and values the symbolic expressions formed 

by the coordinates to define the subset 

 

OUTPUT: 

 

- the open subset, as an instance of :class:`TopologicalManifold` 

 

EXAMPLES: 

 

Creating an open subset of a 2-dimensional manifold:: 

 

sage: M = Manifold(2, 'M', structure='topological') 

sage: A = M.open_subset('A'); A 

Open subset A of the 2-dimensional topological manifold M 

 

As an open subset of a topological manifold, ``A`` is itself a 

topological manifold, on the same topological field and of the same 

dimension as ``M``:: 

 

sage: isinstance(A, sage.manifolds.manifold.TopologicalManifold) 

True 

sage: A.base_field() == M.base_field() 

True 

sage: dim(A) == dim(M) 

True 

sage: A.category() is M.category().Subobjects() 

True 

 

Creating an open subset of ``A``:: 

 

sage: B = A.open_subset('B'); B 

Open subset B of the 2-dimensional topological manifold M 

 

We have then:: 

 

sage: A.subsets() # random (set output) 

{Open subset B of the 2-dimensional topological manifold M, 

Open subset A of the 2-dimensional topological manifold M} 

sage: B.is_subset(A) 

True 

sage: B.is_subset(M) 

True 

 

Defining an open subset by some coordinate restrictions: the open 

unit disk in `\RR^2`:: 

 

sage: M = Manifold(2, 'R^2', structure='topological') 

sage: c_cart.<x,y> = M.chart() # Cartesian coordinates on R^2 

sage: U = M.open_subset('U', coord_def={c_cart: x^2+y^2<1}); U 

Open subset U of the 2-dimensional topological manifold R^2 

 

Since the argument ``coord_def`` has been set, ``U`` is automatically 

provided with a chart, which is the restriction of the Cartesian one 

to ``U``:: 

 

sage: U.atlas() 

[Chart (U, (x, y))] 

 

Therefore, one can immediately check whether a point belongs 

to ``U``:: 

 

sage: M.point((0,0)) in U 

True 

sage: M.point((1/2,1/3)) in U 

True 

sage: M.point((1,2)) in U 

False 

 

""" 

resu = TopologicalManifold(self._dim, name, self._field, 

self._structure, ambient=self._manifold, 

latex_name=latex_name, 

start_index=self._sindex) 

resu._calculus_method = self._calculus_method 

resu._supersets.update(self._supersets) 

for sd in self._supersets: 

sd._subsets.add(resu) 

self._top_subsets.add(resu) 

# Charts on the result from the coordinate definition: 

for chart, restrictions in coord_def.items(): 

if chart not in self._atlas: 

raise ValueError("the {} does not belong to ".format(chart) + 

"the atlas of {}".format(self)) 

chart.restrict(resu, restrictions) 

# Transition maps on the result inferred from those of self: 

for chart1 in coord_def: 

for chart2 in coord_def: 

if chart2 != chart1 and (chart1, chart2) in self._coord_changes: 

self._coord_changes[(chart1, chart2)].restrict(resu) 

return resu 

 

def get_chart(self, coordinates, domain=None): 

r""" 

Get a chart from its coordinates. 

 

The chart must have been previously created by the method 

:meth:`chart`. 

 

INPUT: 

 

- ``coordinates`` -- single string composed of the coordinate symbols 

separated by a space 

- ``domain`` -- (default: ``None``) string containing the name of the 

chart's domain, which must be a subset of the current manifold; if 

``None``, the current manifold is assumed 

 

OUTPUT: 

 

- instance of 

:class:`~sage.manifolds.chart.Chart` (or of the subclass 

:class:`~sage.manifolds.chart.RealChart`) representing the chart 

corresponding to the above specifications 

 

EXAMPLES:: 

 

sage: M = Manifold(2, 'M', structure='topological') 

sage: X.<x,y> = M.chart() 

sage: M.get_chart('x y') 

Chart (M, (x, y)) 

sage: M.get_chart('x y') is X 

True 

sage: U = M.open_subset('U', coord_def={X: (y!=0,x<0)}) 

sage: Y.<r, ph> = U.chart(r'r:(0,+oo) ph:(0,2*pi):\phi') 

sage: M.atlas() 

[Chart (M, (x, y)), Chart (U, (x, y)), Chart (U, (r, ph))] 

sage: M.get_chart('x y', domain='U') 

Chart (U, (x, y)) 

sage: M.get_chart('x y', domain='U') is X.restrict(U) 

True 

sage: U.get_chart('r ph') 

Chart (U, (r, ph)) 

sage: M.get_chart('r ph', domain='U') 

Chart (U, (r, ph)) 

sage: M.get_chart('r ph', domain='U') is Y 

True 

 

""" 

if domain is None: 

dom = self 

else: 

dom = self.get_subset(domain) 

try: 

return dom._charts_by_coord[coordinates] 

except KeyError: 

raise KeyError("the coordinates '{}' ".format(coordinates) + 

"do not correspond to any chart with " + 

"the {} as domain".format(dom)) 

 

def dimension(self): 

r""" 

Return the dimension of the manifold over its base field. 

 

EXAMPLES:: 

 

sage: M = Manifold(2, 'M', structure='topological') 

sage: M.dimension() 

2 

 

A shortcut is ``dim()``:: 

 

sage: M.dim() 

2 

 

The Sage global function ``dim`` can also be used:: 

 

sage: dim(M) 

2 

 

""" 

return self._dim 

 

dim = dimension 

 

def base_field(self): 

r""" 

Return the field on which the manifold is defined. 

 

OUTPUT: 

 

- a topological field 

 

EXAMPLES:: 

 

sage: M = Manifold(3, 'M', structure='topological') 

sage: M.base_field() 

Real Field with 53 bits of precision 

sage: M = Manifold(3, 'M', structure='topological', field='complex') 

sage: M.base_field() 

Complex Field with 53 bits of precision 

sage: M = Manifold(3, 'M', structure='topological', field=QQ) 

sage: M.base_field() 

Rational Field 

 

""" 

return self._field 

 

def base_field_type(self): 

r""" 

Return the type of topological field on which the manifold is defined. 

 

OUTPUT: 

 

- a string describing the field, with three possible values: 

 

- ``'real'`` for the real field `\RR` 

- ``'complex'`` for the complex field `\CC` 

- ``'neither_real_nor_complex'`` for a field different from `\RR` 

and `\CC` 

 

EXAMPLES:: 

 

sage: M = Manifold(3, 'M', structure='topological') 

sage: M.base_field_type() 

'real' 

sage: M = Manifold(3, 'M', structure='topological', field='complex') 

sage: M.base_field_type() 

'complex' 

sage: M = Manifold(3, 'M', structure='topological', field=QQ) 

sage: M.base_field_type() 

'neither_real_nor_complex' 

 

""" 

return self._field_type 

 

def start_index(self): 

r""" 

Return the first value of the index range used on the manifold. 

 

This is the parameter ``start_index`` passed at the construction of 

the manifold. 

 

OUTPUT: 

 

- the integer `i_0` such that all indices of indexed objects on the 

manifold range from `i_0` to `i_0 + n - 1`, where `n` is the 

manifold's dimension 

 

EXAMPLES:: 

 

sage: M = Manifold(3, 'M', structure='topological') 

sage: M.start_index() 

0 

sage: M = Manifold(3, 'M', structure='topological', start_index=1) 

sage: M.start_index() 

1 

 

""" 

return self._sindex 

 

def irange(self, start=None): 

r""" 

Single index generator. 

 

INPUT: 

 

- ``start`` -- (default: ``None``) initial value `i_0` of the index; 

if none are provided, the value returned by :meth:`start_index()` 

is assumed 

 

OUTPUT: 

 

- an iterable index, starting from `i_0` and ending at 

`i_0 + n - 1`, where `n` is the manifold's dimension 

 

EXAMPLES: 

 

Index range on a 4-dimensional manifold:: 

 

sage: M = Manifold(4, 'M', structure='topological') 

sage: list(M.irange()) 

[0, 1, 2, 3] 

sage: list(M.irange(2)) 

[2, 3] 

 

Index range on a 4-dimensional manifold with starting index=1:: 

 

sage: M = Manifold(4, 'M', structure='topological', start_index=1) 

sage: list(M.irange()) 

[1, 2, 3, 4] 

sage: list(M.irange(2)) 

[2, 3, 4] 

 

In general, one has always:: 

 

sage: next(M.irange()) == M.start_index() 

True 

 

""" 

si = self._sindex 

imax = self._dim + si 

if start is None: 

i = si 

else: 

i = start 

while i < imax: 

yield i 

i += 1 

 

def index_generator(self, nb_indices): 

r""" 

Generator of index series. 

 

INPUT: 

 

- ``nb_indices`` -- number of indices in a series 

 

OUTPUT: 

 

- an iterable index series for a generic component with the specified 

number of indices 

 

EXAMPLES: 

 

Indices on a 2-dimensional manifold:: 

 

sage: M = Manifold(2, 'M', structure='topological', start_index=1) 

sage: list(M.index_generator(2)) 

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

 

Loops can be nested:: 

 

sage: for ind1 in M.index_generator(2): 

....: print("{} : {}".format(ind1, list(M.index_generator(2)))) 

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

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

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

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

""" 

si = self._sindex 

imax = self._dim - 1 + si 

ind = [si for k in range(nb_indices)] 

ind_end = [si for k in range(nb_indices)] 

ind_end[0] = imax+1 

while ind != ind_end: 

yield tuple(ind) 

ret = 1 

for pos in range(nb_indices-1,-1,-1): 

if ind[pos] != imax: 

ind[pos] += ret 

ret = 0 

elif ret == 1: 

if pos == 0: 

ind[pos] = imax + 1 # end point reached 

else: 

ind[pos] = si 

ret = 1 

 

def atlas(self): 

r""" 

Return the list of charts that have been defined on the manifold. 

 

EXAMPLES: 

 

Let us consider `\RR^2` as a 2-dimensional manifold:: 

 

sage: M = Manifold(2, 'R^2', structure='topological') 

 

Immediately after the manifold creation, the atlas is empty, since no 

chart has been defined yet:: 

 

sage: M.atlas() 

[] 

 

Let us introduce the chart of Cartesian coordinates:: 

 

sage: c_cart.<x,y> = M.chart() 

sage: M.atlas() 

[Chart (R^2, (x, y))] 

 

The complement of the half line `\{y = 0, x \geq 0\}`:: 

 

sage: U = M.open_subset('U', coord_def={c_cart: (y!=0,x<0)}) 

sage: U.atlas() 

[Chart (U, (x, y))] 

sage: M.atlas() 

[Chart (R^2, (x, y)), Chart (U, (x, y))] 

 

Spherical (polar) coordinates on ``U``:: 

 

sage: c_spher.<r, ph> = U.chart(r'r:(0,+oo) ph:(0,2*pi):\phi') 

sage: U.atlas() 

[Chart (U, (x, y)), Chart (U, (r, ph))] 

sage: M.atlas() 

[Chart (R^2, (x, y)), Chart (U, (x, y)), Chart (U, (r, ph))] 

 

.. SEEALSO:: 

 

:meth:`top_charts` 

 

""" 

return list(self._atlas) # Make a (shallow) copy 

 

def top_charts(self): 

r""" 

Return the list of charts defined on subsets of the current manifold 

that are not subcharts of charts on larger subsets. 

 

OUTPUT: 

 

- list of charts defined on open subsets of the manifold but not on 

larger subsets 

 

EXAMPLES: 

 

Charts on a 2-dimensional manifold:: 

 

sage: M = Manifold(2, 'M', structure='topological') 

sage: X.<x,y> = M.chart() 

sage: U = M.open_subset('U', coord_def={X: x>0}) 

sage: Y.<u,v> = U.chart() 

sage: M.top_charts() 

[Chart (M, (x, y)), Chart (U, (u, v))] 

 

Note that the (user) atlas contains one more chart: ``(U, (x,y))``, 

which is not a "top" chart:: 

 

sage: M.atlas() 

[Chart (M, (x, y)), Chart (U, (x, y)), Chart (U, (u, v))] 

 

.. SEEALSO:: 

 

:meth:`atlas` for the complete list of charts defined on the 

manifold. 

 

""" 

return list(self._top_charts) # Make a (shallow) copy 

 

def default_chart(self): 

r""" 

Return the default chart defined on the manifold. 

 

Unless changed via :meth:`set_default_chart`, the *default chart* 

is the first one defined on a subset of the manifold (possibly itself). 

 

OUTPUT: 

 

- instance of :class:`~sage.manifolds.chart.Chart` 

representing the default chart 

 

EXAMPLES: 

 

Default chart on a 2-dimensional manifold and on some subsets:: 

 

sage: M = Manifold(2, 'M', structure='topological') 

sage: M.chart('x y') 

Chart (M, (x, y)) 

sage: M.chart('u v') 

Chart (M, (u, v)) 

sage: M.default_chart() 

Chart (M, (x, y)) 

sage: A = M.open_subset('A') 

sage: A.chart('t z') 

Chart (A, (t, z)) 

sage: A.default_chart() 

Chart (A, (t, z)) 

 

""" 

return self._def_chart 

 

def set_default_chart(self, chart): 

r""" 

Changing the default chart on ``self``. 

 

INPUT: 

 

- ``chart`` -- a chart (must be defined on some subset ``self``) 

 

EXAMPLES: 

 

Charts on a 2-dimensional manifold:: 

 

sage: M = Manifold(2, 'M', structure='topological') 

sage: c_xy.<x,y> = M.chart() 

sage: c_uv.<u,v> = M.chart() 

sage: M.default_chart() 

Chart (M, (x, y)) 

sage: M.set_default_chart(c_uv) 

sage: M.default_chart() 

Chart (M, (u, v)) 

 

""" 

from .chart import Chart 

if not isinstance(chart, Chart): 

raise TypeError("{} is not a chart".format(chart)) 

if chart._domain is not self: 

if self.is_manifestly_coordinate_domain(): 

raise TypeError("the chart domain must coincide with " + 

"the {}".format(self)) 

if chart not in self._atlas: 

raise ValueError("the chart must be defined on the " + 

"{}".format(self)) 

self._def_chart = chart 

 

def coord_change(self, chart1, chart2): 

r""" 

Return the change of coordinates (transition map) between two charts 

defined on the manifold. 

 

The change of coordinates must have been defined previously, for 

instance by the method 

:meth:`~sage.manifolds.chart.Chart.transition_map`. 

 

INPUT: 

 

- ``chart1`` -- chart 1 

- ``chart2`` -- chart 2 

 

OUTPUT: 

 

- instance of :class:`~sage.manifolds.chart.CoordChange` 

representing the transition map from chart 1 to chart 2 

 

EXAMPLES: 

 

Change of coordinates on a 2-dimensional manifold:: 

 

sage: M = Manifold(2, 'M', structure='topological') 

sage: c_xy.<x,y> = M.chart() 

sage: c_uv.<u,v> = M.chart() 

sage: c_xy.transition_map(c_uv, (x+y, x-y)) # defines the coord. change 

Change of coordinates from Chart (M, (x, y)) to Chart (M, (u, v)) 

sage: M.coord_change(c_xy, c_uv) # returns the coord. change defined above 

Change of coordinates from Chart (M, (x, y)) to Chart (M, (u, v)) 

 

""" 

if (chart1, chart2) not in self._coord_changes: 

raise TypeError("the change of coordinates from " + 

"{} to {}".format(chart1, chart2) + " has not " + 

"been defined on the {}".format(self)) 

return self._coord_changes[(chart1, chart2)] 

 

def coord_changes(self): 

r""" 

Return the changes of coordinates (transition maps) defined on 

subsets of the manifold. 

 

OUTPUT: 

 

- dictionary of changes of coordinates, with pairs of charts as keys 

 

EXAMPLES: 

 

Various changes of coordinates on a 2-dimensional manifold:: 

 

sage: M = Manifold(2, 'M', structure='topological') 

sage: c_xy.<x,y> = M.chart() 

sage: c_uv.<u,v> = M.chart() 

sage: xy_to_uv = c_xy.transition_map(c_uv, [x+y, x-y]) 

sage: M.coord_changes() 

{(Chart (M, (x, y)), 

Chart (M, (u, v))): Change of coordinates from Chart (M, (x, y)) to Chart (M, (u, v))} 

sage: uv_to_xy = xy_to_uv.inverse() 

sage: M.coord_changes() # random (dictionary output) 

{(Chart (M, (u, v)), 

Chart (M, (x, y))): Change of coordinates from Chart (M, (u, v)) to Chart (M, (x, y)), 

(Chart (M, (x, y)), 

Chart (M, (u, v))): Change of coordinates from Chart (M, (x, y)) to Chart (M, (u, v))} 

sage: c_rs.<r,s> = M.chart() 

sage: uv_to_rs = c_uv.transition_map(c_rs, [-u+2*v, 3*u-v]) 

sage: M.coord_changes() # random (dictionary output) 

{(Chart (M, (u, v)), 

Chart (M, (r, s))): Change of coordinates from Chart (M, (u, v)) to Chart (M, (r, s)), 

(Chart (M, (u, v)), 

Chart (M, (x, y))): Change of coordinates from Chart (M, (u, v)) to Chart (M, (x, y)), 

(Chart (M, (x, y)), 

Chart (M, (u, v))): Change of coordinates from Chart (M, (x, y)) to Chart (M, (u, v))} 

sage: xy_to_rs = uv_to_rs * xy_to_uv 

sage: M.coord_changes() # random (dictionary output) 

{(Chart (M, (u, v)), 

Chart (M, (r, s))): Change of coordinates from Chart (M, (u, v)) to Chart (M, (r, s)), 

(Chart (M, (u, v)), 

Chart (M, (x, y))): Change of coordinates from Chart (M, (u, v)) to Chart (M, (x, y)), 

(Chart (M, (x, y)), 

Chart (M, (u, v))): Change of coordinates from Chart (M, (x, y)) to Chart (M, (u, v)), 

(Chart (M, (x, y)), 

Chart (M, (r, s))): Change of coordinates from Chart (M, (x, y)) to Chart (M, (r, s))} 

 

""" 

return self._coord_changes 

 

def is_manifestly_coordinate_domain(self): 

r""" 

Return ``True`` if the manifold is known to be the domain of some 

coordinate chart and ``False`` otherwise. 

 

If ``False`` is returned, either the manifold cannot be the domain of 

some coordinate chart or no such chart has been declared yet. 

 

EXAMPLES:: 

 

sage: M = Manifold(2, 'M', structure='topological') 

sage: U = M.open_subset('U') 

sage: X.<x,y> = U.chart() 

sage: U.is_manifestly_coordinate_domain() 

True 

sage: M.is_manifestly_coordinate_domain() 

False 

sage: Y.<u,v> = M.chart() 

sage: M.is_manifestly_coordinate_domain() 

True 

 

""" 

return bool(self._covering_charts) 

 

def chart(self, coordinates='', names=None, calc_method=None): 

r""" 

Define a chart, the domain of which is the manifold. 

 

A *chart* is a pair `(U, \varphi)`, where `U` is the current 

manifold and `\varphi: U \rightarrow V \subset K^n` 

is a homeomorphism from `U` to an open subset `V` of `K^n`, `K` 

being the field on which the manifold is defined. 

 

The components `(x^1, \ldots, x^n)` of `\varphi`, defined by 

`\varphi(p) = (x^1(p), \ldots, x^n(p)) \in K^n` for any point 

`p \in U`, are called the *coordinates* of the chart `(U, \varphi)`. 

 

See :class:`~sage.manifolds.chart.Chart` for a complete 

documentation. 

 

INPUT: 

 

- ``coordinates`` -- (default: ``''`` (empty string)) string 

defining the coordinate symbols and ranges, see below 

- ``names`` -- (default: ``None``) unused argument, except if 

``coordinates`` is not provided; it must then be a tuple containing 

the coordinate symbols (this is guaranteed if the shortcut operator 

``<,>`` is used) 

- ``calc_method`` -- (default: ``None``) string defining the calculus 

method to be used on this chart; must be one of 

 

- ``'SR'``: Sage's default symbolic engine (Symbolic Ring) 

- ``'sympy'``: SymPy 

- ``None``: the current calculus method defined on the manifold is 

used (cf. :meth:`set_calculus_method`) 

 

The coordinates declared in the string ``coordinates`` are 

separated by ``' '`` (whitespace) and each coordinate has at most three 

fields, separated by a colon (``':'``): 

 

1. The coordinate symbol (a letter or a few letters). 

2. (optional, only for manifolds over `\RR`) The interval `I` 

defining the coordinate range: if not provided, the coordinate 

is assumed to span all `\RR`; otherwise `I` must be provided 

in the form ``(a,b)`` (or equivalently ``]a,b[``) 

The bounds ``a`` and ``b`` can be ``+/-Infinity``, ``Inf``, 

``infinity``, ``inf`` or ``oo``. For *singular* coordinates, 

non-open intervals such as ``[a,b]`` and 

``(a,b]`` (or equivalently ``]a,b]``) are allowed. Note that 

the interval declaration must not contain any space character. 

3. (optional) The LaTeX spelling of the coordinate; if not provided 

the coordinate symbol given in the first field will be used. 

 

The order of the fields 2 and 3 does not matter and each of them can 

be omitted. If it contains any LaTeX expression, the string 

``coordinates`` must be declared with the prefix 'r' (for "raw") to 

allow for a proper treatment of the backslash character (see 

examples below). If no interval range and no LaTeX spelling is to 

be provided for any coordinate, the argument ``coordinates`` can be 

omitted when the shortcut operator ``<,>`` is used via Sage 

preparser (see examples below). 

 

OUTPUT: 

 

- the created chart, as an instance of 

:class:`~sage.manifolds.chart.Chart` or of the subclass 

:class:`~sage.manifolds.chart.RealChart` for manifolds over `\RR`. 

 

EXAMPLES: 

 

Chart on a 2-dimensional manifold:: 

 

sage: M = Manifold(2, 'M', structure='topological') 

sage: U = M.open_subset('U') 

sage: X = U.chart('x y'); X 

Chart (U, (x, y)) 

sage: X[0] 

x 

sage: X[1] 

y 

sage: X[:] 

(x, y) 

 

The declared coordinates are not known at the global level:: 

 

sage: y 

Traceback (most recent call last): 

... 

NameError: name 'y' is not defined 

 

They can be recovered by the operator ``[:]`` applied to the chart:: 

 

sage: (x, y) = X[:] 

sage: y 

y 

sage: type(y) 

<type 'sage.symbolic.expression.Expression'> 

 

But a shorter way to proceed is to use the operator ``<,>`` in the 

left-hand side of the chart declaration (there is then no need to 

pass the string 'x y' to chart()):: 

 

sage: M = Manifold(2, 'M', structure='topological') 

sage: U = M.open_subset('U') 

sage: X.<x,y> = U.chart(); X 

Chart (U, (x, y)) 

 

Indeed, the declared coordinates are then known at the global level:: 

 

sage: y 

y 

sage: (x,y) == X[:] 

True 

 

Actually the instruction ``X.<x,y> = U.chart()`` is 

equivalent to the combination of the two instructions 

``X = U.chart('x y')`` and ``(x,y) = X[:]``. 

 

See the documentation of class 

:class:`~sage.manifolds.chart.Chart` for more examples, 

especially regarding the coordinates ranges and restrictions. 

 

""" 

if calc_method is None: 

calc_method = self._calculus_method 

return self._structure.chart(self, coordinates=coordinates, 

names=names, calc_method=calc_method) 

 

def is_open(self): 

""" 

Return if ``self`` is an open set. 

 

In the present case (manifold or open subset of it), always 

return ``True``. 

 

TESTS:: 

 

sage: M = Manifold(2, 'M', structure='topological') 

sage: M.is_open() 

True 

 

""" 

return True 

 

def scalar_field_algebra(self): 

r""" 

Return the algebra of scalar fields defined the manifold. 

 

See :class:`~sage.manifolds.scalarfield_algebra.ScalarFieldAlgebra` 

for a complete documentation. 

 

OUTPUT: 

 

- instance of 

:class:`~sage.manifolds.scalarfield_algebra.ScalarFieldAlgebra` 

representing the algebra `C^0(U)` of all scalar fields defined 

on `U` = ``self`` 

 

EXAMPLES: 

 

Scalar algebra of a 3-dimensional open subset:: 

 

sage: M = Manifold(3, 'M', structure='topological') 

sage: U = M.open_subset('U') 

sage: CU = U.scalar_field_algebra() ; CU 

Algebra of scalar fields on the Open subset U of the 3-dimensional topological manifold M 

sage: CU.category() 

Category of commutative algebras over Symbolic Ring 

sage: CU.zero() 

Scalar field zero on the Open subset U of the 3-dimensional topological manifold M 

 

The output is cached:: 

 

sage: U.scalar_field_algebra() is CU 

True 

 

""" 

return self._scalar_field_algebra 

 

def scalar_field(self, coord_expression=None, chart=None, name=None, 

latex_name=None): 

r""" 

Define a scalar field on the manifold. 

 

See :class:`~sage.manifolds.scalarfield.ScalarField` (or 

:class:`~sage.manifolds.differentiable.scalarfield.DiffScalarField` 

if the manifold is differentiable) for a complete documentation. 

 

INPUT: 

 

- ``coord_expression`` -- (default: ``None``) coordinate expression(s) 

of the scalar field; this can be either 

 

* a single coordinate expression; if the argument ``chart`` is 

``'all'``, this expression is set to all the charts defined 

on the open set; otherwise, the expression is set in the 

specific chart provided by the argument ``chart`` 

* a dictionary of coordinate expressions, with the charts as keys 

 

- ``chart`` -- (default: ``None``) chart defining the coordinates 

used in ``coord_expression`` when the latter is a single 

coordinate expression; if ``None``, the default chart of the 

open set is assumed; if ``chart=='all'``, ``coord_expression`` is 

assumed to be independent of the chart (constant scalar field) 

 

- ``name`` -- (default: ``None``) name given to the scalar field 

 

- ``latex_name`` -- (default: ``None``) LaTeX symbol to denote the 

scalar field; if ``None``, the LaTeX symbol is set to ``name`` 

 

If ``coord_expression`` is ``None`` or does not fully specified the 

scalar field, other coordinate expressions can be added subsequently 

by means of the methods 

:meth:`~sage.manifolds.scalarfield.ScalarField.add_expr`, 

:meth:`~sage.manifolds.scalarfield.ScalarField.add_expr_by_continuation`, 

or :meth:`~sage.manifolds.scalarfield.ScalarField.set_expr` 

 

OUTPUT: 

 

- instance of :class:`~sage.manifolds.scalarfield.ScalarField` 

(or of the subclass 

:class:`~sage.manifolds.differentiable.scalarfield.DiffScalarField` 

if the manifold is differentiable) representing the defined scalar 

field 

 

EXAMPLES: 

 

A scalar field defined by its coordinate expression in the open 

set's default chart:: 

 

sage: M = Manifold(3, 'M', structure='topological') 

sage: U = M.open_subset('U') 

sage: c_xyz.<x,y,z> = U.chart() 

sage: f = U.scalar_field(sin(x)*cos(y) + z, name='F'); f 

Scalar field F on the Open subset U of the 3-dimensional topological manifold M 

sage: f.display() 

F: U --> R 

(x, y, z) |--> cos(y)*sin(x) + z 

sage: f.parent() 

Algebra of scalar fields on the Open subset U of the 3-dimensional topological manifold M 

sage: f in U.scalar_field_algebra() 

True 

 

Equivalent definition with the chart specified:: 

 

sage: f = U.scalar_field(sin(x)*cos(y) + z, chart=c_xyz, name='F') 

sage: f.display() 

F: U --> R 

(x, y, z) |--> cos(y)*sin(x) + z 

 

Equivalent definition with a dictionary of coordinate expression(s):: 

 

sage: f = U.scalar_field({c_xyz: sin(x)*cos(y) + z}, name='F') 

sage: f.display() 

F: U --> R 

(x, y, z) |--> cos(y)*sin(x) + z 

 

See the documentation of class 

:class:`~sage.manifolds.scalarfield.ScalarField` for more 

examples. 

 

.. SEEALSO:: 

 

:meth:`constant_scalar_field`, :meth:`zero_scalar_field`, 

:meth:`one_scalar_field` 

 

""" 

if isinstance(coord_expression, dict): 

# check validity of entry 

for chart in coord_expression: 

if not chart._domain.is_subset(self): 

raise ValueError("the {} is not defined ".format(chart) + 

"on some subset of the " + str(self)) 

alg = self.scalar_field_algebra() 

return alg.element_class(alg, coord_expression=coord_expression, 

name=name, latex_name=latex_name, chart=chart) 

 

def constant_scalar_field(self, value, name=None, latex_name=None): 

r""" 

Define a constant scalar field on the manifold. 

 

INPUT: 

 

- ``value`` -- constant value of the scalar field, either a numerical 

value or a symbolic expression not involving any chart coordinates 

- ``name`` -- (default: ``None``) name given to the scalar field 

- ``latex_name`` -- (default: ``None``) LaTeX symbol to denote the 

scalar field; if ``None``, the LaTeX symbol is set to ``name`` 

 

OUTPUT: 

 

- instance of :class:`~sage.manifolds.scalarfield.ScalarField` 

representing the scalar field whose constant value is ``value`` 

 

EXAMPLES: 

 

A constant scalar field on the 2-sphere:: 

 

sage: M = Manifold(2, 'M', structure='topological') # the 2-dimensional sphere S^2 

sage: U = M.open_subset('U') # complement of the North pole 

sage: c_xy.<x,y> = U.chart() # stereographic coordinates from the North pole 

sage: V = M.open_subset('V') # complement of the South pole 

sage: c_uv.<u,v> = V.chart() # stereographic coordinates from the South pole 

sage: M.declare_union(U,V) # S^2 is the union of U and V 

sage: xy_to_uv = c_xy.transition_map(c_uv, (x/(x^2+y^2), y/(x^2+y^2)), 

....: intersection_name='W', 

....: restrictions1= x^2+y^2!=0, 

....: restrictions2= u^2+v^2!=0) 

sage: uv_to_xy = xy_to_uv.inverse() 

sage: f = M.constant_scalar_field(-1) ; f 

Scalar field on the 2-dimensional topological manifold M 

sage: f.display() 

M --> R 

on U: (x, y) |--> -1 

on V: (u, v) |--> -1 

 

We have:: 

 

sage: f.restrict(U) == U.constant_scalar_field(-1) 

True 

sage: M.constant_scalar_field(0) is M.zero_scalar_field() 

True 

 

.. SEEALSO:: 

 

:meth:`zero_scalar_field`, :meth:`one_scalar_field` 

""" 

if value == 0: 

return self.zero_scalar_field() 

alg = self.scalar_field_algebra() 

return alg.element_class(alg, coord_expression=value, name=name, 

latex_name=latex_name, chart='all') 

 

def zero_scalar_field(self): 

r""" 

Return the zero scalar field defined on ``self``. 

 

OUTPUT: 

 

- a :class:`~sage.manifolds.scalarfield.ScalarField` 

representing the constant scalar field with value `0` 

 

EXAMPLES:: 

 

sage: M = Manifold(2, 'M', structure='topological') 

sage: X.<x,y> = M.chart() 

sage: f = M.zero_scalar_field() ; f 

Scalar field zero on the 2-dimensional topological manifold M 

sage: f.display() 

zero: M --> R 

(x, y) |--> 0 

sage: f.parent() 

Algebra of scalar fields on the 2-dimensional topological manifold M 

sage: f is M.scalar_field_algebra().zero() 

True 

 

""" 

return self._zero_scalar_field 

 

def one_scalar_field(self): 

r""" 

Return the constant scalar field with value the unit element 

of the base field of ``self``. 

 

OUTPUT: 

 

- a :class:`~sage.manifolds.scalarfield.ScalarField` representing 

the constant scalar field with value the unit element 

of the base field of ``self`` 

 

EXAMPLES:: 

 

sage: M = Manifold(2, 'M', structure='topological') 

sage: X.<x,y> = M.chart() 

sage: f = M.one_scalar_field(); f 

Scalar field 1 on the 2-dimensional topological manifold M 

sage: f.display() 

1: M --> R 

(x, y) |--> 1 

sage: f.parent() 

Algebra of scalar fields on the 2-dimensional topological manifold M 

sage: f is M.scalar_field_algebra().one() 

True 

 

""" 

return self._one_scalar_field 

 

class options(GlobalOptions): 

r""" 

Sets and displays the options for manifolds. If no parameters 

are set, then the function returns a copy of the options dictionary. 

 

The ``options`` to manifolds can be accessed as the method 

:obj:`Manifold.options`. 

 

@OPTIONS@ 

 

EXAMPLES:: 

 

sage: M = Manifold(2, 'M', structure='topological') 

sage: X.<x,y> = M.chart() 

sage: g = function('g')(x, y) 

 

For coordinate functions, the display is more "textbook" like:: 

 

sage: f = X.function(diff(g, x) + diff(g, y)) 

sage: f 

d(g)/dx + d(g)/dy 

sage: latex(f) 

\frac{\partial\,g}{\partial x} + \frac{\partial\,g}{\partial y} 

 

One can switch to Pynac notation by changing ``textbook_output`` 

to ``False``:: 

 

sage: Manifold.options.textbook_output=False 

sage: f 

diff(g(x, y), x) + diff(g(x, y), y) 

sage: latex(f) 

\frac{\partial}{\partial x}g\left(x, y\right) 

+ \frac{\partial}{\partial y}g\left(x, y\right) 

sage: Manifold.options._reset() 

 

If there is a clear understanding that `u` and `v` are functions of 

`(x,y)`, the explicit mention of the latter can be cumbersome in lengthy 

tensor expressions:: 

 

sage: f = X.function(function('u')(x, y) * function('v')(x, y)) 

sage: f 

u(x, y)*v(x, y) 

 

We can switch it off by:: 

 

sage: M.options.omit_function_arguments=True 

sage: f 

u*v 

sage: M.options._reset() 

""" 

NAME = 'manifolds' 

module = 'sage.manifolds' 

option_class = 'TopologicalManifold' 

textbook_output = dict(default=True, 

description='textbook-like output instead of the Pynac output for derivatives', 

checker=lambda x: isinstance(x, bool)) 

omit_function_arguments = dict(default=False, 

description='Determine whether the arguments of symbolic functions are printed', 

checker=lambda x: isinstance(x, bool)) 

 

def _Hom_(self, other, category=None): 

r""" 

Construct the set of morphisms (i.e. continuous maps) 

``self`` to ``other``. 

 

INPUT: 

 

- ``other`` -- an open subset of some topological manifold over the 

same field as ``self`` 

- ``category`` -- (default: ``None``) not used here (to ensure 

compatibility with generic hook ``_Hom_``) 

 

OUTPUT: 

 

- the homset `\mathrm{Hom}(U,V)`, where `U` is ``self`` 

and `V` is ``other`` 

 

.. SEEALSO:: 

 

For more documentation, see 

:class:`~sage.manifolds.manifold_homset.TopologicalManifoldHomset`. 

 

EXAMPLES:: 

 

sage: M = Manifold(2, 'M', structure='topological') 

sage: N = Manifold(3, 'N', structure='topological') 

sage: H = M._Hom_(N); H 

Set of Morphisms from 2-dimensional topological manifold M to 

3-dimensional topological manifold N in Category of manifolds over 

Real Field with 53 bits of precision 

 

The result is cached:: 

 

sage: H is Hom(M, N) 

True 

 

""" 

return self._structure.homset(self, other) 

 

def continuous_map(self, codomain, coord_functions=None, chart1=None, 

chart2=None, name=None, latex_name=None): 

r""" 

Define a continuous map from ``self`` to ``codomain``. 

 

INPUT: 

 

- ``codomain`` -- :class:`TopologicalManifold`; the map's codomain 

- ``coord_functions`` -- (default: ``None``) if not ``None``, 

must be either 

 

- (i) a dictionary of the coordinate expressions (as lists 

(or tuples) of the coordinates of the image expressed in 

terms of the coordinates of the considered point) with the 

pairs of charts ``(chart1, chart2)`` as keys (``chart1`` being 

a chart on ``self`` and ``chart2`` a chart on ``codomain``); 

- (ii) a single coordinate expression in a given pair of charts, the 

latter being provided by the arguments ``chart1`` and ``chart2``; 

 

in both cases, if the dimension of the codomain is `1`, a single 

coordinate expression can be passed instead of a tuple with 

a single element 

- ``chart1`` -- (default: ``None``; used only in case (ii) above) 

chart on ``self`` defining the start coordinates involved in 

``coord_functions`` for case (ii); if ``None``, the coordinates 

are assumed to refer to the default chart of ``self`` 

- ``chart2`` -- (default: ``None``; used only in case (ii) above) 

chart on ``codomain`` defining the target coordinates involved in 

``coord_functions`` for case (ii); if ``None``, the coordinates 

are assumed to refer to the default chart of ``codomain`` 

- ``name`` -- (default: ``None``) name given to the continuous map 

- ``latex_name`` -- (default: ``None``) LaTeX symbol to denote the 

continuous map; if ``None``, the LaTeX symbol is set to ``name`` 

 

OUTPUT: 

 

- the continuous map as an instance of 

:class:`~sage.manifolds.continuous_map.ContinuousMap` 

 

EXAMPLES: 

 

A continuous map between an open subset of `S^2` covered by regular 

spherical coordinates and `\RR^3`:: 

 

sage: M = Manifold(2, 'S^2', structure='topological') 

sage: U = M.open_subset('U') 

sage: c_spher.<th,ph> = U.chart(r'th:(0,pi):\theta ph:(0,2*pi):\phi') 

sage: N = Manifold(3, 'R^3', latex_name=r'\RR^3', structure='topological') 

sage: c_cart.<x,y,z> = N.chart() # Cartesian coord. on R^3 

sage: Phi = U.continuous_map(N, (sin(th)*cos(ph), sin(th)*sin(ph), cos(th)), 

....: name='Phi', latex_name=r'\Phi') 

sage: Phi 

Continuous map Phi from the Open subset U of the 2-dimensional topological manifold S^2 to the 3-dimensional topological manifold R^3 

 

The same definition, but with a dictionary with pairs of charts as 

keys (case (i) above):: 

 

sage: Phi1 = U.continuous_map(N, 

....: {(c_spher, c_cart): (sin(th)*cos(ph), sin(th)*sin(ph), cos(th))}, 

....: name='Phi', latex_name=r'\Phi') 

sage: Phi1 == Phi 

True 

 

The continuous map acting on a point:: 

 

sage: p = U.point((pi/2, pi)) ; p 

Point on the 2-dimensional topological manifold S^2 

sage: Phi(p) 

Point on the 3-dimensional topological manifold R^3 

sage: Phi(p).coord(c_cart) 

(-1, 0, 0) 

sage: Phi1(p) == Phi(p) 

True 

 

TESTS:: 

 

sage: M = Manifold(2, 'M', structure='topological') 

sage: M.continuous_map(ZZ) 

Traceback (most recent call last): 

... 

ValueError: Integer Ring is not a manifold 

over Real Field with 53 bits of precision 

 

.. SEEALSO:: 

 

See :class:`~sage.manifolds.continuous_map.ContinuousMap` 

for the complete documentation and more examples. 

 

.. TODO:: 

 

Allow the construction of continuous maps from ``self`` to the 

base field (considered as a trivial 1-dimensional manifold). 

 

""" 

if (not isinstance(codomain, TopologicalManifold) 

or codomain.base_field() != self.base_field()): 

raise ValueError("{} is not a manifold over {}".format(codomain, self.base_field())) 

homset = Hom(self, codomain) 

if coord_functions is None: 

coord_functions = {} 

if not isinstance(coord_functions, dict): 

# Turn coord_functions into a dictionary: 

if chart1 is None: 

chart1 = self._def_chart 

elif chart1 not in self._atlas: 

raise ValueError("{} is not a chart ".format(chart1) + 

"defined on the {}".format(self)) 

if chart2 is None: 

chart2 = codomain._def_chart 

elif chart2 not in codomain._atlas: 

raise ValueError("{} is not a chart ".format(chart2) + 

" defined on the {}".format(codomain)) 

coord_functions = {(chart1, chart2): coord_functions} 

return homset(coord_functions, name=name, latex_name=latex_name) 

 

def homeomorphism(self, codomain, coord_functions=None, chart1=None, 

chart2=None, name=None, latex_name=None): 

r""" 

Define a homeomorphism between the current manifold and another one. 

 

See :class:`~sage.manifolds.continuous_map.ContinuousMap` for a 

complete documentation. 

 

INPUT: 

 

- ``codomain`` -- :class:`TopologicalManifold`; codomain of 

the homeomorphism 

- ``coord_functions`` -- (default: ``None``) if not ``None``, 

must be either 

 

- (i) a dictionary of the coordinate expressions (as lists 

(or tuples) of the coordinates of the image expressed in 

terms of the coordinates of the considered point) with the 

pairs of charts ``(chart1, chart2)`` as keys (``chart1`` being 

a chart on ``self`` and ``chart2`` a chart on ``codomain``); 

- (ii) a single coordinate expression in a given pair of charts, the 

latter being provided by the arguments ``chart1`` and ``chart2``; 

 

in both cases, if the dimension of the codomain is `1`, a single 

coordinate expression can be passed instead of a tuple with 

a single element 

- ``chart1`` -- (default: ``None``; used only in case (ii) above) 

chart on ``self`` defining the start coordinates involved in 

``coord_functions`` for case (ii); if ``None``, the coordinates 

are assumed to refer to the default chart of ``self`` 

- ``chart2`` -- (default: ``None``; used only in case (ii) above) 

chart on ``codomain`` defining the target coordinates involved in 

``coord_functions`` for case (ii); if ``None``, the coordinates 

are assumed to refer to the default chart of ``codomain`` 

- ``name`` -- (default: ``None``) name given to the homeomorphism 

- ``latex_name`` -- (default: ``None``) LaTeX symbol to denote the 

homeomorphism; if ``None``, the LaTeX symbol is set to ``name`` 

 

OUTPUT: 

 

- the homeomorphism, as an instance of 

:class:`~sage.manifolds.continuous_map.ContinuousMap` 

 

EXAMPLES: 

 

Homeomorphism between the open unit disk in `\RR^2` and `\RR^2`:: 

 

sage: forget() # for doctests only 

sage: M = Manifold(2, 'M', structure='topological') # the open unit disk 

sage: c_xy.<x,y> = M.chart('x:(-1,1) y:(-1,1)') # Cartesian coord on M 

sage: c_xy.add_restrictions(x^2+y^2<1) 

sage: N = Manifold(2, 'N', structure='topological') # R^2 

sage: c_XY.<X,Y> = N.chart() # canonical coordinates on R^2 

sage: Phi = M.homeomorphism(N, [x/sqrt(1-x^2-y^2), y/sqrt(1-x^2-y^2)], 

....: name='Phi', latex_name=r'\Phi') 

sage: Phi 

Homeomorphism Phi from the 2-dimensional topological manifold M to 

the 2-dimensional topological manifold N 

sage: Phi.display() 

Phi: M --> N 

(x, y) |--> (X, Y) = (x/sqrt(-x^2 - y^2 + 1), y/sqrt(-x^2 - y^2 + 1)) 

 

The inverse homeomorphism:: 

 

sage: Phi^(-1) 

Homeomorphism Phi^(-1) from the 2-dimensional topological 

manifold N to the 2-dimensional topological manifold M 

sage: (Phi^(-1)).display() 

Phi^(-1): N --> M 

(X, Y) |--> (x, y) = (X/sqrt(X^2 + Y^2 + 1), Y/sqrt(X^2 + Y^2 + 1)) 

 

See the documentation of 

:class:`~sage.manifolds.continuous_map.ContinuousMap` for more 

examples. 

 

""" 

homset = Hom(self, codomain) 

if coord_functions is None: 

coord_functions = {} 

if not isinstance(coord_functions, dict): 

# Turn coord_functions into a dictionary: 

if chart1 is None: 

chart1 = self._def_chart 

elif chart1 not in self._atlas: 

raise ValueError("{} is not a chart ".format(chart1) + 

"defined on the {}".format(self)) 

if chart2 is None: 

chart2 = codomain._def_chart 

elif chart2 not in codomain._atlas: 

raise ValueError("{} is not a chart ".format(chart2) + 

" defined on the {}".format(codomain)) 

coord_functions = {(chart1, chart2): coord_functions} 

return homset(coord_functions, name=name, latex_name=latex_name, 

is_isomorphism=True) 

 

@cached_method 

def identity_map(self): 

r""" 

Identity map of ``self``. 

 

The identity map of a topological manifold `M` is the trivial 

homeomorphism: 

 

.. MATH:: 

 

\begin{array}{cccc} 

\mathrm{Id}_M: & M & \longrightarrow & M \\ 

& p & \longmapsto & p 

\end{array} 

 

OUTPUT: 

 

- the identity map as an instance of 

:class:`~sage.manifolds.continuous_map.ContinuousMap` 

 

EXAMPLES: 

 

Identity map of a complex manifold:: 

 

sage: M = Manifold(2, 'M', structure='topological', field='complex') 

sage: X.<x,y> = M.chart() 

sage: id = M.identity_map(); id 

Identity map Id_M of the Complex 2-dimensional topological manifold M 

sage: id.parent() 

Set of Morphisms from Complex 2-dimensional topological manifold M 

to Complex 2-dimensional topological manifold M in Category of 

manifolds over Complex Field with 53 bits of precision 

sage: id.display() 

Id_M: M --> M 

(x, y) |--> (x, y) 

 

The identity map acting on a point:: 

 

sage: p = M((1+I, 3-I), name='p'); p 

Point p on the Complex 2-dimensional topological manifold M 

sage: id(p) 

Point p on the Complex 2-dimensional topological manifold M 

sage: id(p) == p 

True 

 

.. SEEALSO:: 

 

See :class:`~sage.manifolds.continuous_map.ContinuousMap` 

for the complete documentation. 

 

""" 

return Hom(self, self).one() 

 

def set_calculus_method(self, method): 

r""" 

Set the calculus method to be used for coordinate computations on this 

manifold. 

 

The provided method is transmitted to all coordinate charts defined on 

the manifold. 

 

INPUT: 

 

- ``method`` -- string specifying the method to be used for 

coordinate computations on this manifold; one of 

 

- ``'SR'``: Sage's default symbolic engine (Symbolic Ring) 

- ``'sympy'``: SymPy 

 

The default calculus method relies on Sage's Symbolic Ring:: 

 

sage: M = Manifold(3, 'M', structure='topological') 

sage: X.<x,y,z> = M.chart() 

sage: f = M.scalar_field(sin(x)*cos(y) + z^2, name='F') 

sage: f.expr() 

z^2 + cos(y)*sin(x) 

sage: type(f.expr()) 

<type 'sage.symbolic.expression.Expression'> 

sage: parent(f.expr()) 

Symbolic Ring 

sage: f.display() 

F: M --> R 

(x, y, z) |--> z^2 + cos(y)*sin(x) 

 

Changing to SymPy:: 

 

sage: M.set_calculus_method('sympy') 

sage: f.expr() 

z**2 + sin(x)*cos(y) 

sage: type(f.expr()) 

<class 'sympy.core.add.Add'> 

sage: parent(f.expr()) 

<class 'sympy.core.add.Add'> 

sage: f.display() 

F: M --> R 

(x, y, z) |--> z**2 + sin(x)*cos(y) 

 

Changing back to the Symbolic Ring:: 

 

sage: M.set_calculus_method('SR') 

sage: f.display() 

F: M --> R 

(x, y, z) |--> z^2 + cos(y)*sin(x) 

 

""" 

self._calculus_method = method 

for chart in self._atlas : 

chart.set_calculus_method(method) 

 

 

 

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

## Constructor function 

 

def Manifold(dim, name, latex_name=None, field='real', structure='smooth', 

start_index=0, **extra_kwds): 

r""" 

Construct a manifold of a given type over a topological field. 

 

Given a topological field `K` (in most applications, `K = \RR` or 

`K = \CC`) and a non-negative integer `n`, a *topological manifold of 

dimension* `n` *over K* is a topological space `M` such that 

 

- `M` is a Hausdorff space, 

- `M` is second countable, and 

- every point in `M` has a neighborhood homeomorphic to `K^n`. 

 

A *real manifold* is a manifold over `\RR`. A *differentiable* (resp. 

*smooth*, resp. *analytic*) *manifold* is a manifold such that all 

transition maps are *differentiable* (resp. *smooth*, resp. *analytic*). A 

*pseudo-Riemannian manifold* is a real differentiable manifold equipped 

with a metric tensor `g` (i.e. a field of non-degenerate symmetric bilinear 

forms), with the two subcases of *Riemannian manifold* (`g` 

positive-definite) and *Lorentzian manifold* (`g` has signature `n-2` or 

`2-n`). 

 

INPUT: 

 

- ``dim`` -- positive integer; dimension of the manifold 

- ``name`` -- string; name (symbol) given to the manifold 

- ``latex_name`` -- (default: ``None``) string; LaTeX symbol to 

denote the manifold; if none are provided, it is set to ``name`` 

- ``field`` -- (default: ``'real'``) field `K` on which the 

manifold is defined; allowed values are 

 

- ``'real'`` or an object of type ``RealField`` (e.g. ``RR``) for a 

manifold over `\RR` 

- ``'complex'`` or an object of type ``ComplexField`` (e.g. ``CC``) 

for a manifold over `\CC` 

- an object in the category of topological fields (see 

:class:`~sage.categories.fields.Fields` and 

:class:`~sage.categories.topological_spaces.TopologicalSpaces`) 

for other types of manifolds 

 

- ``structure`` -- (default: ``'smooth'``) to specify the structure or 

type of manifold; allowed values are 

 

- ``'topological'`` or ``'top'`` for a topological manifold 

- ``'differentiable'`` or ``'diff'`` for a differentiable manifold 

- ``'smooth'`` for a smooth manifold 

- ``'analytic'`` for an analytic manifold 

- ``'pseudo-Riemannian'`` for a real differentiable manifold equipped 

with a pseudo-Riemannian metric; the signature is specified via the 

keyword argument ``signature`` (see below) 

- ``'Riemannian'`` for a real differentiable manifold equipped with a 

Riemannian (i.e. positive definite) metric 

- ``'Lorentzian'`` for a real differentiable manifold equipped with a 

Lorentzian metric; the signature convention is specified by the 

keyword argument ``signature='positive'`` (default) or ``'negative'`` 

 

- ``start_index`` -- (default: 0) integer; lower value of the range of 

indices used for "indexed objects" on the manifold, e.g. coordinates 

in a chart 

- ``extra_kwds`` -- keywords meaningful only for some specific types 

of manifolds: 

 

- ``diff_degree`` -- (only for differentiable manifolds; default: 

``infinity``): the degree of differentiability 

- ``metric_name`` -- (only for pseudo-Riemannian manifolds; default: 

``'g'``) string; name (symbol) given to the metric 

- ``metric_latex_name`` -- (only for pseudo-Riemannian manifolds; 

default: ``None``) string; LaTeX symbol to denote the metric; if none 

is provided, the symbol is set to ``metric_name`` 

- ``signature`` -- (only for pseudo-Riemannian manifolds; default: 

``None``) signature `S` of the metric as a single integer: 

`S = n_+ - n_-`, where `n_+` (resp. `n_-`) is the number of positive 

terms (resp. negative terms) in any diagonal writing of the 

metric components; if ``signature`` is not provided, `S` is set to the 

manifold's dimension (Riemannian signature); for Lorentzian manifolds 

the values ``signature='positive'`` (default) or 

``signature='negative'`` are allowed to indicate the chosen signature 

convention. 

 

OUTPUT: 

 

- a manifold of the specified type, as an instance of 

:class:`~sage.manifolds.manifold.TopologicalManifold` or one of its 

subclasses 

:class:`~sage.manifolds.differentiable.manifold.DifferentiableManifold` 

or 

:class:`~sage.manifolds.differentiable.pseudo_riemannian.PseudoRiemannianManifold` 

 

EXAMPLES: 

 

A 3-dimensional real topological manifold:: 

 

sage: M = Manifold(3, 'M', structure='topological'); M 

3-dimensional topological manifold M 

 

Given the default value of the parameter ``field``, the above is 

equivalent to:: 

 

sage: M = Manifold(3, 'M', structure='topological', field='real'); M 

3-dimensional topological manifold M 

 

A complex topological manifold:: 

 

sage: M = Manifold(3, 'M', structure='topological', field='complex'); M 

Complex 3-dimensional topological manifold M 

 

A topological manifold over `\QQ`:: 

 

sage: M = Manifold(3, 'M', structure='topological', field=QQ); M 

3-dimensional topological manifold M over the Rational Field 

 

A 3-dimensional real differentiable manifold of class `C^4`:: 

 

sage: M = Manifold(3, 'M', field='real', structure='differentiable', 

....: diff_degree=4); M 

3-dimensional differentiable manifold M 

 

Since the default value of the parameter ``field`` is ``'real'``, the above 

is equivalent to:: 

 

sage: M = Manifold(3, 'M', structure='differentiable', diff_degree=4) 

sage: M 

3-dimensional differentiable manifold M 

sage: M.base_field_type() 

'real' 

 

A 3-dimensional real smooth manifold:: 

 

sage: M = Manifold(3, 'M', structure='differentiable', diff_degree=+oo) 

sage: M 

3-dimensional differentiable manifold M 

 

Instead of ``structure='differentiable', diff_degree=+oo``, it suffices to 

use ``structure='smooth'`` to get the same result:: 

 

sage: M = Manifold(3, 'M', structure='smooth'); M 

3-dimensional differentiable manifold M 

sage: M.diff_degree() 

+Infinity 

 

Actually, since ``'smooth'`` is the default value of the parameter 

``structure``, the creation of a real smooth manifold can be shortened to:: 

 

sage: M = Manifold(3, 'M'); M 

3-dimensional differentiable manifold M 

sage: M.diff_degree() 

+Infinity 

 

For a complex smooth manifold, we have to set the parameter ``field``:: 

 

sage: M = Manifold(3, 'M', field='complex'); M 

3-dimensional complex manifold M 

sage: M.diff_degree() 

+Infinity 

 

See the documentation of classes 

:class:`~sage.manifolds.manifold.TopologicalManifold`, 

:class:`~sage.manifolds.differentiable.manifold.DifferentiableManifold` 

and 

:class:`~sage.manifolds.differentiable.pseudo_riemannian.PseudoRiemannianManifold` 

for more detailed examples. 

 

.. RUBRIC:: Uniqueness of manifold objects 

 

Suppose we construct a manifold named `M`:: 

 

sage: M = Manifold(2, 'M', structure='topological') 

sage: X.<x,y> = M.chart() 

 

At some point, we change our mind and would like to restart with a new 

manifold, using the same name `M` and keeping the previous manifold for 

reference:: 

 

sage: M_old = M # for reference 

sage: M = Manifold(2, 'M', structure='topological') 

 

This results in a brand new object:: 

 

sage: M.atlas() 

[] 

 

The object ``M_old`` is intact:: 

 

sage: M_old.atlas() 

[Chart (M, (x, y))] 

 

Both objects have the same display:: 

 

sage: M 

2-dimensional topological manifold M 

sage: M_old 

2-dimensional topological manifold M 

 

but they are different:: 

 

sage: M != M_old 

True 

 

Let us introduce a chart on ``M``, using the same coordinate symbols 

as for ``M_old``:: 

 

sage: X.<x,y> = M.chart() 

 

The charts are displayed in the same way:: 

 

sage: M.atlas() 

[Chart (M, (x, y))] 

sage: M_old.atlas() 

[Chart (M, (x, y))] 

 

but they are actually different:: 

 

sage: M.atlas()[0] != M_old.atlas()[0] 

True 

 

Moreover, the two manifolds ``M`` and ``M_old`` are still considered 

distinct:: 

 

sage: M != M_old 

True 

 

This reflects the fact that the equality of manifold objects holds only 

for identical objects, i.e. one has ``M1 == M2`` if, and only if, 

``M1 is M2``. Actually, the manifold classes inherit from 

:class:`~sage.misc.fast_methods.WithEqualityById`:: 

 

sage: isinstance(M, sage.misc.fast_methods.WithEqualityById) 

True 

""" 

from time import time 

from sage.rings.infinity import infinity 

from sage.manifolds.differentiable.manifold import DifferentiableManifold 

from sage.manifolds.differentiable.pseudo_riemannian import PseudoRiemannianManifold 

# Some sanity checks 

if not isinstance(dim, (int, Integer)): 

raise TypeError("the manifold dimension must be an integer") 

if dim < 1: 

raise ValueError("the manifold dimension must be strictly positive") 

 

if structure in ['topological', 'top']: 

if field == 'real' or isinstance(field, RealField_class): 

structure = RealTopologicalStructure() 

else: 

structure = TopologicalStructure() 

return TopologicalManifold(dim, name, field, structure, 

latex_name=latex_name, 

start_index=start_index, 

unique_tag=getrandbits(128)*time()) 

elif structure in ['differentiable', 'diff', 'smooth']: 

if 'diff_degree' in extra_kwds: 

diff_degree = extra_kwds['diff_degree'] 

if structure == 'smooth' and diff_degree != infinity: 

raise ValueError("diff_degree = {} is ".format(diff_degree) + 

"not compatible with a smooth structure") 

else: 

diff_degree = infinity 

if field == 'real' or isinstance(field, RealField_class): 

structure = RealDifferentialStructure() 

else: 

structure = DifferentialStructure() 

return DifferentiableManifold(dim, name, field, structure, 

diff_degree=diff_degree, 

latex_name=latex_name, 

start_index=start_index, 

unique_tag=getrandbits(128)*time()) 

elif structure in ['pseudo-Riemannian', 'Riemannian', 'Lorentzian']: 

if 'diff_degree' in extra_kwds: 

diff_degree = extra_kwds['diff_degree'] 

else: 

diff_degree = infinity 

if 'metric_name' in extra_kwds: 

metric_name = extra_kwds['metric_name'] 

else: 

metric_name = 'g' 

if 'metric_latex_name' in extra_kwds: 

metric_latex_name = extra_kwds['metric_latex_name'] 

else: 

metric_latex_name = None 

if structure == 'pseudo-Riemannian': 

if 'signature' in extra_kwds: 

signature = extra_kwds['signature'] 

else: 

signature = None 

elif structure == 'Riemannian': 

signature = dim 

elif structure == 'Lorentzian': 

if 'signature' in extra_kwds: 

signat = extra_kwds['signature'] 

if signat == 'positive' or signat == dim - 2: 

signature = dim - 2 

elif signat == 'negative' or signat == 2 - dim: 

signature = 2 - dim 

else: 

raise ValueError("signature {} not ".format(signat) + 

"compatible with a Lorentzian " + 

"manifold of dimension {}".format(dim)) 

else: 

signature = dim - 2 # default value for a Lorentzian manifold 

return PseudoRiemannianManifold(dim, name, metric_name=metric_name, 

signature=signature, 

diff_degree=diff_degree, 

latex_name=latex_name, 

metric_latex_name=metric_latex_name, 

start_index=start_index, 

unique_tag=getrandbits(128)*time()) 

raise NotImplementedError("manifolds of type {} are ".format(structure) + 

"not implemented") 

 

Manifold.options = TopologicalManifold.options 

 

# Deprecations from trac:18555. July 2016 

from sage.misc.superseded import deprecated_function_alias 

Manifold.global_options=deprecated_function_alias(18555, TopologicalManifold.options) 

ManifoldOptions = deprecated_function_alias(18555, TopologicalManifold.options) 

TopologicalManifold.global_options=deprecated_function_alias(18555, TopologicalManifold.options)