Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

166

167

168

169

170

171

172

173

174

175

176

177

178

179

180

181

182

183

184

185

186

187

188

189

190

191

192

193

194

195

196

197

198

199

200

201

202

203

204

205

206

207

208

209

210

211

212

213

214

215

216

217

218

219

220

221

222

223

224

225

226

227

228

229

230

231

232

233

234

235

236

237

238

239

240

241

242

243

244

245

246

247

248

249

250

251

252

253

254

255

256

257

258

259

260

261

262

263

264

265

266

267

268

269

270

271

272

273

274

275

276

277

278

279

280

281

282

283

284

285

286

287

288

289

290

291

292

293

294

295

296

297

298

299

300

301

302

303

304

305

306

307

308

309

310

311

312

313

314

315

316

317

318

319

320

321

322

323

324

325

326

327

328

329

330

331

332

333

334

335

336

337

338

339

340

341

342

343

344

345

346

347

348

349

350

351

352

353

354

355

356

357

358

359

360

361

362

363

364

365

366

367

368

369

370

371

372

373

374

375

376

377

378

379

380

381

382

383

384

385

386

387

388

389

390

391

392

393

394

395

396

397

398

399

400

401

402

403

404

405

406

407

408

409

410

411

412

413

414

415

416

417

418

419

420

421

422

423

424

425

426

427

428

429

430

431

432

433

434

435

436

437

438

439

440

441

442

443

444

445

446

447

448

449

450

451

452

453

454

455

456

457

458

459

460

461

462

463

464

465

466

467

468

469

470

471

472

473

474

475

476

477

478

479

480

481

482

483

484

485

486

487

488

489

490

491

492

493

494

495

496

497

498

499

500

501

502

503

504

505

506

507

508

509

510

511

512

513

514

515

516

517

518

519

520

521

522

523

524

525

526

527

528

529

530

531

532

533

534

535

536

537

538

539

540

541

542

543

544

545

546

547

548

549

550

551

552

553

554

555

556

557

558

559

560

561

562

563

564

565

566

567

568

569

570

571

572

573

574

575

576

577

578

579

580

581

582

583

584

585

586

587

588

589

590

591

592

593

594

595

596

597

598

599

600

601

602

603

604

605

606

607

608

609

610

611

612

613

614

615

616

617

618

619

620

621

622

623

624

625

626

627

628

629

630

631

632

633

634

635

636

637

638

639

640

641

642

643

644

645

646

647

648

649

650

651

652

653

654

655

656

657

658

659

660

661

662

663

664

665

666

667

668

669

670

671

672

673

674

675

676

677

678

679

680

681

682

683

684

685

686

687

688

689

690

691

692

693

694

695

696

697

698

699

700

701

702

703

704

705

706

707

708

709

710

711

712

713

714

715

716

717

718

719

720

721

722

723

724

725

726

727

728

729

730

731

732

733

734

735

736

737

738

739

740

741

742

743

744

745

746

747

748

749

750

751

752

753

754

755

756

757

758

759

760

761

762

763

764

765

766

767

768

769

770

771

772

773

774

775

776

777

778

779

780

781

782

783

784

785

786

787

788

789

790

791

792

793

794

795

796

797

798

799

800

801

802

803

804

805

806

807

808

809

810

811

812

813

814

815

816

817

818

819

820

821

822

823

824

825

826

827

828

829

830

831

832

833

834

835

836

837

838

839

840

841

842

843

844

845

846

847

848

849

850

851

852

853

854

855

856

857

858

859

860

861

862

863

864

865

866

867

868

869

870

871

872

873

874

875

876

877

878

879

880

881

882

883

884

885

886

887

888

889

890

891

892

893

894

895

896

897

898

899

900

901

902

903

904

905

906

907

908

909

910

911

912

913

914

915

916

917

918

919

920

921

922

923

924

925

926

927

928

929

930

931

932

933

934

935

936

937

938

939

940

941

942

943

944

945

946

947

948

949

950

951

952

953

954

955

956

957

958

959

960

961

962

963

964

965

966

967

968

969

970

971

972

973

974

975

976

977

978

979

980

981

982

983

984

985

986

987

988

989

990

991

992

993

994

995

996

997

998

999

1000

1001

1002

1003

1004

1005

1006

1007

1008

1009

1010

1011

1012

1013

1014

1015

1016

1017

1018

1019

1020

1021

1022

1023

1024

1025

1026

1027

1028

1029

1030

1031

1032

1033

1034

1035

1036

1037

1038

1039

1040

1041

1042

1043

1044

1045

1046

1047

1048

1049

1050

1051

1052

1053

1054

1055

1056

1057

1058

1059

1060

1061

1062

1063

1064

1065

1066

1067

1068

1069

1070

1071

1072

1073

1074

1075

1076

1077

1078

1079

1080

1081

1082

1083

1084

1085

1086

1087

1088

1089

1090

1091

1092

1093

1094

1095

1096

1097

1098

1099

1100

1101

1102

1103

1104

1105

1106

1107

1108

1109

1110

1111

1112

1113

1114

1115

1116

1117

1118

1119

1120

1121

1122

1123

1124

1125

1126

1127

1128

1129

1130

1131

1132

1133

1134

1135

1136

1137

1138

1139

1140

1141

1142

1143

1144

1145

1146

1147

1148

1149

1150

1151

1152

1153

1154

1155

1156

1157

1158

1159

1160

1161

1162

1163

1164

1165

1166

1167

1168

1169

1170

1171

1172

1173

1174

1175

1176

1177

1178

1179

1180

1181

1182

1183

1184

1185

1186

1187

1188

1189

1190

1191

1192

1193

1194

1195

1196

1197

1198

1199

1200

1201

1202

1203

1204

1205

1206

1207

1208

1209

1210

1211

1212

1213

1214

1215

1216

1217

1218

1219

1220

1221

1222

1223

1224

1225

1226

1227

1228

1229

1230

1231

1232

1233

1234

1235

1236

1237

1238

1239

1240

1241

1242

1243

1244

1245

1246

1247

1248

1249

1250

1251

1252

1253

1254

1255

1256

1257

1258

1259

1260

1261

1262

1263

1264

1265

1266

1267

1268

1269

1270

1271

1272

1273

1274

1275

1276

1277

1278

1279

1280

1281

1282

1283

1284

1285

1286

1287

1288

1289

1290

1291

1292

1293

1294

1295

1296

1297

1298

1299

1300

1301

1302

1303

1304

1305

1306

1307

1308

1309

1310

1311

1312

1313

1314

1315

1316

1317

1318

1319

1320

1321

1322

1323

1324

1325

1326

1327

1328

1329

1330

1331

1332

1333

1334

1335

1336

1337

1338

1339

1340

1341

1342

1343

1344

1345

1346

1347

1348

1349

1350

1351

1352

1353

1354

1355

1356

1357

1358

1359

1360

1361

1362

1363

1364

1365

1366

1367

1368

1369

1370

1371

1372

1373

1374

1375

1376

1377

1378

1379

1380

1381

1382

1383

1384

1385

1386

1387

1388

1389

1390

1391

1392

1393

1394

1395

1396

1397

1398

1399

1400

1401

1402

1403

1404

1405

1406

1407

1408

1409

1410

1411

1412

1413

1414

1415

1416

1417

1418

1419

1420

1421

1422

1423

1424

1425

1426

1427

1428

1429

1430

1431

1432

1433

1434

1435

1436

1437

1438

1439

1440

1441

1442

1443

1444

1445

1446

1447

1448

1449

1450

1451

1452

1453

1454

1455

1456

1457

1458

1459

1460

1461

1462

1463

1464

1465

1466

1467

1468

1469

1470

1471

1472

1473

1474

1475

1476

1477

1478

1479

1480

1481

1482

1483

1484

1485

1486

1487

1488

1489

1490

1491

1492

1493

1494

1495

1496

1497

1498

1499

1500

1501

1502

1503

1504

1505

1506

1507

1508

1509

1510

1511

1512

1513

1514

1515

1516

1517

1518

1519

1520

1521

1522

1523

1524

1525

1526

1527

1528

1529

1530

1531

1532

1533

1534

1535

1536

1537

1538

1539

1540

1541

1542

1543

1544

1545

1546

1547

1548

1549

1550

1551

1552

1553

1554

1555

1556

1557

1558

1559

1560

1561

1562

1563

1564

1565

1566

1567

1568

1569

1570

1571

1572

1573

1574

1575

1576

1577

1578

1579

1580

1581

1582

1583

1584

1585

1586

1587

1588

1589

1590

1591

1592

1593

1594

1595

1596

1597

1598

1599

1600

1601

1602

1603

1604

1605

1606

1607

1608

1609

1610

1611

1612

1613

1614

1615

1616

1617

1618

1619

1620

1621

1622

1623

1624

1625

1626

1627

1628

1629

1630

1631

1632

1633

1634

1635

1636

1637

1638

1639

1640

1641

1642

1643

1644

1645

1646

1647

1648

1649

1650

1651

1652

1653

1654

1655

1656

1657

1658

1659

1660

1661

1662

1663

1664

1665

1666

1667

1668

1669

1670

1671

1672

1673

1674

1675

1676

1677

1678

1679

1680

1681

1682

1683

1684

1685

1686

1687

1688

1689

1690

1691

1692

1693

1694

1695

1696

1697

1698

1699

1700

1701

1702

1703

1704

1705

1706

1707

1708

1709

1710

1711

1712

1713

1714

1715

1716

1717

1718

1719

1720

1721

1722

1723

1724

1725

1726

1727

1728

1729

1730

1731

1732

1733

1734

1735

1736

1737

1738

1739

1740

1741

1742

1743

1744

1745

1746

1747

1748

1749

1750

1751

1752

1753

1754

1755

1756

1757

1758

1759

1760

1761

1762

1763

1764

1765

1766

1767

1768

1769

1770

1771

1772

1773

1774

1775

1776

1777

1778

1779

1780

1781

1782

1783

1784

1785

1786

1787

1788

1789

1790

1791

1792

1793

1794

1795

1796

1797

1798

1799

1800

1801

1802

1803

1804

1805

1806

1807

1808

1809

1810

1811

1812

1813

1814

1815

1816

1817

1818

1819

1820

1821

1822

1823

1824

1825

1826

1827

1828

1829

1830

1831

1832

1833

1834

1835

1836

1837

1838

1839

1840

1841

1842

1843

1844

1845

1846

1847

1848

1849

1850

1851

1852

1853

1854

1855

1856

1857

1858

1859

1860

1861

1862

1863

1864

1865

1866

1867

1868

1869

1870

1871

1872

1873

1874

1875

1876

1877

1878

1879

1880

1881

1882

1883

1884

1885

1886

1887

1888

1889

1890

1891

1892

1893

1894

1895

1896

1897

1898

1899

1900

1901

1902

1903

1904

1905

1906

1907

1908

1909

1910

1911

1912

1913

1914

1915

1916

1917

1918

1919

1920

1921

1922

1923

1924

1925

1926

1927

1928

1929

1930

1931

1932

1933

1934

1935

1936

1937

1938

1939

1940

1941

1942

1943

1944

1945

1946

1947

1948

1949

1950

1951

1952

1953

1954

1955

1956

1957

1958

1959

1960

1961

1962

1963

1964

1965

1966

1967

1968

1969

1970

1971

1972

1973

1974

1975

1976

1977

1978

1979

1980

1981

1982

1983

1984

1985

1986

1987

1988

1989

1990

1991

1992

1993

1994

1995

1996

1997

1998

1999

2000

2001

2002

2003

2004

2005

2006

2007

2008

2009

2010

2011

2012

2013

2014

2015

2016

2017

2018

2019

2020

2021

2022

2023

2024

2025

2026

2027

2028

2029

2030

2031

2032

2033

2034

2035

2036

2037

2038

2039

2040

2041

2042

2043

2044

2045

2046

2047

2048

2049

2050

2051

2052

2053

2054

2055

2056

2057

2058

2059

2060

2061

2062

2063

2064

2065

2066

2067

2068

2069

2070

2071

2072

2073

2074

2075

2076

2077

2078

2079

2080

2081

2082

2083

2084

2085

2086

2087

2088

2089

2090

2091

2092

2093

2094

2095

2096

2097

2098

2099

2100

2101

2102

2103

2104

2105

2106

2107

2108

2109

2110

2111

2112

2113

2114

2115

2116

2117

2118

2119

2120

2121

2122

2123

2124

2125

2126

2127

2128

2129

2130

2131

2132

2133

2134

2135

2136

2137

2138

2139

2140

2141

2142

2143

2144

2145

2146

2147

2148

2149

2150

2151

2152

2153

2154

2155

2156

2157

2158

2159

2160

2161

2162

2163

2164

2165

2166

2167

2168

2169

2170

2171

2172

2173

2174

2175

2176

2177

2178

2179

2180

2181

2182

2183

2184

2185

2186

2187

2188

2189

2190

2191

2192

2193

2194

2195

2196

2197

2198

2199

2200

2201

2202

2203

2204

2205

2206

2207

2208

2209

2210

2211

2212

2213

2214

2215

2216

2217

2218

2219

2220

2221

2222

2223

2224

2225

2226

2227

2228

2229

2230

2231

2232

2233

2234

2235

2236

2237

2238

2239

2240

2241

2242

2243

2244

2245

2246

2247

2248

2249

2250

2251

2252

2253

2254

2255

2256

2257

2258

2259

2260

2261

2262

2263

2264

2265

2266

2267

2268

2269

2270

2271

2272

2273

2274

2275

2276

2277

2278

2279

2280

2281

2282

2283

2284

2285

2286

2287

2288

2289

2290

2291

2292

2293

2294

2295

2296

2297

2298

2299

2300

2301

2302

2303

2304

2305

2306

2307

2308

2309

2310

2311

2312

2313

2314

2315

2316

2317

2318

2319

2320

2321

2322

2323

2324

2325

2326

2327

2328

2329

2330

2331

2332

2333

2334

2335

2336

2337

2338

2339

2340

2341

2342

2343

2344

2345

2346

2347

2348

2349

2350

2351

2352

2353

2354

2355

2356

2357

2358

2359

2360

2361

2362

2363

2364

2365

2366

2367

2368

2369

2370

2371

2372

2373

2374

2375

2376

2377

2378

2379

2380

2381

2382

2383

2384

2385

2386

2387

2388

2389

2390

2391

2392

2393

2394

2395

2396

2397

2398

2399

2400

2401

2402

2403

2404

2405

2406

2407

2408

2409

2410

2411

2412

2413

2414

2415

2416

2417

2418

2419

2420

2421

2422

2423

2424

2425

2426

2427

2428

2429

2430

2431

2432

2433

2434

2435

2436

2437

2438

2439

2440

2441

2442

2443

2444

2445

2446

2447

2448

2449

2450

2451

2452

2453

2454

2455

2456

2457

2458

2459

2460

2461

2462

2463

2464

2465

2466

2467

2468

2469

2470

2471

2472

2473

2474

2475

2476

2477

2478

2479

2480

2481

2482

2483

2484

2485

2486

2487

2488

2489

2490

2491

2492

2493

2494

2495

2496

2497

2498

2499

2500

2501

2502

2503

2504

2505

2506

2507

2508

2509

2510

2511

2512

2513

2514

2515

2516

2517

2518

2519

2520

2521

2522

2523

2524

2525

2526

2527

2528

2529

2530

2531

2532

2533

2534

2535

2536

2537

2538

2539

2540

2541

2542

2543

2544

2545

2546

2547

2548

2549

2550

2551

2552

2553

2554

2555

2556

2557

2558

2559

2560

2561

2562

2563

2564

2565

2566

2567

2568

2569

2570

2571

2572

2573

2574

2575

2576

2577

2578

2579

2580

2581

2582

2583

2584

2585

2586

2587

2588

2589

2590

2591

2592

2593

2594

2595

2596

2597

2598

2599

2600

2601

2602

2603

2604

2605

2606

2607

2608

2609

2610

2611

2612

2613

2614

2615

2616

2617

2618

2619

2620

2621

2622

2623

2624

2625

2626

2627

2628

2629

2630

2631

2632

2633

2634

2635

2636

2637

2638

2639

2640

2641

2642

2643

2644

2645

2646

2647

2648

2649

2650

2651

2652

2653

2654

2655

2656

2657

2658

2659

2660

2661

2662

2663

2664

2665

2666

2667

2668

2669

2670

2671

2672

2673

2674

2675

2676

2677

2678

2679

2680

2681

2682

2683

2684

2685

2686

2687

2688

2689

2690

2691

2692

2693

2694

2695

2696

2697

2698

2699

2700

2701

2702

2703

2704

2705

2706

2707

2708

2709

2710

2711

2712

2713

2714

2715

2716

2717

2718

2719

2720

2721

2722

2723

2724

2725

2726

2727

2728

2729

2730

2731

2732

2733

2734

2735

2736

2737

2738

2739

2740

2741

2742

2743

2744

2745

2746

2747

2748

2749

2750

2751

2752

2753

2754

2755

2756

2757

2758

2759

2760

2761

2762

2763

2764

2765

2766

2767

2768

2769

2770

2771

2772

2773

2774

2775

2776

2777

2778

2779

2780

2781

2782

2783

2784

2785

2786

2787

2788

2789

2790

2791

2792

2793

2794

2795

2796

2797

2798

2799

2800

2801

2802

2803

2804

2805

2806

2807

2808

2809

2810

2811

2812

2813

2814

2815

2816

2817

2818

2819

2820

2821

2822

2823

2824

2825

2826

2827

2828

2829

2830

2831

2832

2833

2834

2835

2836

2837

2838

2839

2840

2841

2842

2843

2844

2845

2846

2847

2848

2849

2850

2851

2852

2853

2854

2855

2856

2857

2858

2859

2860

2861

2862

2863

2864

2865

2866

2867

2868

2869

2870

2871

2872

2873

2874

2875

2876

2877

2878

2879

2880

2881

2882

2883

2884

2885

2886

2887

2888

2889

2890

2891

2892

2893

2894

2895

2896

2897

2898

2899

2900

2901

2902

2903

2904

2905

2906

2907

2908

2909

2910

2911

2912

2913

2914

2915

2916

2917

2918

2919

2920

2921

2922

2923

2924

2925

2926

2927

2928

2929

2930

2931

2932

2933

2934

2935

2936

2937

2938

2939

2940

2941

2942

2943

2944

2945

2946

2947

2948

2949

2950

2951

2952

2953

2954

2955

2956

2957

2958

2959

2960

2961

2962

2963

2964

2965

2966

2967

2968

2969

2970

2971

2972

2973

2974

2975

2976

2977

2978

2979

2980

2981

2982

2983

2984

2985

2986

2987

2988

2989

2990

2991

2992

2993

2994

2995

2996

2997

2998

2999

3000

3001

3002

3003

3004

3005

3006

3007

3008

3009

3010

3011

3012

3013

3014

3015

3016

3017

3018

3019

3020

3021

3022

3023

3024

3025

3026

3027

3028

3029

3030

3031

3032

3033

3034

3035

3036

3037

3038

3039

3040

3041

3042

3043

3044

3045

3046

3047

3048

3049

3050

3051

3052

3053

3054

3055

3056

3057

3058

3059

3060

3061

3062

3063

3064

3065

3066

3067

3068

3069

3070

3071

3072

3073

3074

3075

3076

3077

3078

3079

3080

3081

3082

3083

3084

3085

3086

3087

3088

3089

3090

3091

3092

3093

3094

3095

3096

3097

3098

3099

3100

3101

3102

3103

3104

3105

3106

3107

3108

3109

3110

3111

3112

3113

3114

3115

3116

3117

3118

3119

3120

3121

3122

3123

3124

3125

3126

3127

3128

3129

3130

3131

3132

3133

3134

3135

3136

3137

3138

3139

3140

3141

3142

3143

3144

3145

3146

3147

3148

3149

3150

3151

3152

3153

3154

3155

3156

3157

3158

3159

3160

3161

3162

3163

3164

3165

3166

3167

3168

3169

3170

3171

3172

3173

3174

3175

3176

3177

3178

3179

3180

3181

3182

3183

3184

3185

3186

3187

3188

3189

3190

3191

3192

3193

3194

3195

3196

3197

3198

3199

3200

3201

3202

3203

3204

3205

3206

3207

3208

3209

3210

3211

3212

3213

3214

3215

3216

3217

3218

3219

3220

3221

3222

3223

3224

3225

3226

3227

3228

3229

3230

3231

3232

3233

3234

3235

3236

3237

3238

3239

3240

3241

3242

3243

3244

3245

3246

3247

3248

3249

3250

3251

3252

3253

3254

3255

3256

3257

3258

3259

3260

3261

3262

3263

3264

3265

3266

3267

3268

3269

3270

3271

3272

3273

3274

3275

3276

3277

3278

3279

3280

3281

3282

3283

3284

3285

3286

3287

3288

3289

3290

3291

3292

3293

3294

3295

3296

3297

3298

3299

3300

3301

3302

3303

3304

3305

3306

3307

3308

3309

3310

3311

3312

3313

3314

3315

3316

3317

3318

3319

3320

3321

3322

3323

3324

3325

3326

3327

3328

3329

3330

3331

3332

3333

3334

3335

3336

3337

3338

3339

3340

3341

3342

3343

3344

3345

3346

3347

3348

3349

3350

3351

3352

3353

3354

3355

3356

3357

3358

3359

3360

3361

3362

3363

3364

3365

3366

3367

3368

3369

3370

3371

3372

3373

3374

3375

3376

3377

3378

3379

3380

3381

3382

3383

3384

3385

3386

3387

3388

3389

3390

3391

3392

3393

3394

3395

3396

3397

3398

3399

3400

3401

3402

3403

3404

3405

3406

3407

3408

3409

3410

3411

3412

3413

3414

3415

3416

3417

3418

3419

3420

3421

3422

3423

3424

3425

3426

3427

3428

3429

3430

3431

3432

3433

3434

3435

3436

3437

3438

3439

3440

3441

3442

3443

3444

3445

3446

3447

3448

3449

3450

3451

3452

3453

3454

3455

3456

3457

3458

3459

3460

3461

3462

3463

3464

3465

3466

3467

3468

3469

3470

3471

3472

3473

3474

3475

3476

3477

3478

3479

3480

3481

3482

3483

3484

3485

3486

3487

3488

3489

3490

3491

3492

3493

3494

3495

3496

3497

3498

3499

3500

3501

3502

3503

3504

3505

3506

3507

3508

3509

3510

3511

3512

3513

3514

3515

3516

3517

3518

3519

3520

3521

3522

3523

3524

3525

3526

3527

3528

3529

3530

3531

3532

3533

3534

3535

3536

3537

3538

3539

3540

3541

3542

3543

3544

3545

3546

3547

3548

3549

3550

3551

3552

3553

3554

3555

3556

3557

3558

3559

3560

3561

3562

3563

3564

3565

3566

3567

3568

3569

3570

3571

3572

3573

3574

3575

3576

3577

3578

3579

3580

3581

3582

3583

3584

3585

3586

3587

3588

3589

3590

3591

3592

3593

3594

3595

3596

3597

3598

3599

3600

3601

3602

3603

3604

3605

3606

3607

3608

3609

3610

3611

3612

3613

3614

3615

3616

3617

3618

3619

3620

3621

3622

3623

3624

3625

3626

3627

3628

3629

3630

3631

3632

3633

3634

3635

3636

3637

3638

3639

3640

3641

3642

3643

3644

3645

3646

3647

3648

3649

3650

3651

3652

3653

3654

3655

3656

3657

3658

3659

3660

3661

3662

3663

3664

3665

3666

3667

3668

3669

3670

3671

3672

3673

3674

3675

3676

3677

3678

3679

3680

3681

3682

3683

3684

3685

3686

3687

3688

3689

3690

3691

3692

3693

3694

3695

3696

3697

3698

3699

3700

3701

3702

3703

3704

3705

3706

3707

3708

3709

3710

3711

3712

3713

3714

3715

3716

3717

r""" 

Tensor Fields 

 

The class :class:`TensorField` implements tensor fields on differentiable 

manifolds. The derived class 

:class:`~sage.manifolds.differentiable.tensorfield_paral.TensorFieldParal` 

is devoted to tensor fields with values on parallelizable manifolds. 

 

Various derived classes of :class:`TensorField` are devoted to specific tensor 

fields: 

 

* :class:`~sage.manifolds.differentiable.vectorfield.VectorField` for vector 

fields (rank-1 contravariant tensor fields) 

 

* :class:`~sage.manifolds.differentiable.automorphismfield.AutomorphismField` 

for fields of tangent-space automorphisms 

 

* :class:`~sage.manifolds.differentiable.diff_form.DiffForm` for differential 

forms (fully antisymmetric covariant tensor fields) 

 

AUTHORS: 

 

- Eric Gourgoulhon, Michal Bejger (2013-2015) : initial version 

- Travis Scrimshaw (2016): review tweaks 

- Eric Gourgoulhon (2018): operators divergence, Laplacian and d'Alembertian 

 

REFERENCES: 

 

- [KN1963]_ 

- [Lee2013]_ 

- [ONe1983]_ 

 

""" 

 

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

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

# Copyright (C) 2015 Michal Bejger <bejger@camk.edu.pl> 

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

# 

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

# 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 six import itervalues 

 

from sage.rings.integer import Integer 

from sage.structure.element import ModuleElement 

from sage.tensor.modules.free_module_tensor import FreeModuleTensor 

from sage.tensor.modules.tensor_with_indices import TensorWithIndices 

from sage.rings.integer_ring import ZZ 

 

class TensorField(ModuleElement): 

r""" 

Tensor field along a differentiable manifold. 

 

An instance of this class is a tensor field along a differentiable 

manifold `U` with values on a differentiable manifold `M`, via a 

differentiable map `\Phi: U \rightarrow M`. More precisely, given two 

non-negative integers `k` and `l` and a differentiable map 

 

.. MATH:: 

 

\Phi:\ U \longrightarrow M, 

 

a *tensor field of type* `(k,l)` *along* `U` *with values on* `M` is 

a differentiable map 

 

.. MATH:: 

 

t:\ U \longrightarrow T^{(k,l)}M 

 

(where `T^{(k,l)}M` is the tensor bundle of type `(k,l)` over `M`) such 

that 

 

.. MATH:: 

 

\forall p \in U,\ t(p) \in T^{(k,l)}(T_q M) 

 

i.e. `t(p)` is a tensor of type `(k,l)` on the tangent space `T_q M` at 

the point `q = \Phi(p)`, that is to say a multilinear map 

 

.. MATH:: 

 

t(p):\ \underbrace{T_q^*M\times\cdots\times T_q^*M}_{k\ \; \mbox{times}} 

\times \underbrace{T_q M\times\cdots\times T_q M}_{l\ \; \mbox{times}} 

\longrightarrow K 

 

where `T_q^* M` is the dual vector space to `T_q M` and `K` is the 

topological field over which the manifold `M` is defined. The integer `k+l` 

is called the *tensor rank*. 

 

The standard case of a tensor 

field *on* a differentiable manifold corresponds to `U=M` and 

`\Phi = \mathrm{Id}_M`. Other common cases are `\Phi` being an 

immersion and `\Phi` being a curve in `M` (`U` is then an open interval 

of `\RR`). 

 

If `M` is parallelizable, the class 

:class:`~sage.manifolds.differentiable.tensorfield_paral.TensorFieldParal` 

should be used instead. 

 

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

:class:`~sage.manifolds.differentiable.tensorfield_module.TensorFieldModule`. 

 

INPUT: 

 

- ``vector_field_module`` -- module `\mathfrak{X}(U,\Phi)` of vector 

fields along `U` associated with the map `\Phi: U \rightarrow M` (cf. 

:class:`~sage.manifolds.differentiable.vectorfield_module.VectorFieldModule`) 

- ``tensor_type`` -- pair `(k,l)` with `k` being the contravariant rank 

and `l` the covariant rank 

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

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

field; if none is provided, the LaTeX symbol is set to ``name`` 

- ``sym`` -- (default: ``None``) a symmetry or a list of symmetries among 

the tensor arguments: each symmetry is described by a tuple containing 

the positions of the involved arguments, with the convention 

``position = 0`` for the first argument; for instance: 

 

* ``sym = (0,1)`` for a symmetry between the 1st and 2nd arguments 

* ``sym = [(0,2), (1,3,4)]`` for a symmetry between the 1st and 3rd 

arguments and a symmetry between the 2nd, 4th and 5th arguments. 

 

- ``antisym`` -- (default: ``None``) antisymmetry or list of antisymmetries 

among the arguments, with the same convention as for ``sym`` 

- ``parent`` -- (default: ``None``) some specific parent (e.g. exterior 

power for differential forms); if ``None``, 

``vector_field_module.tensor_module(k,l)`` is used 

 

EXAMPLES: 

 

Tensor field of type (0,2) on the sphere `S^2`:: 

 

sage: M = Manifold(2, 'S^2') # 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: W = U.intersection(V) 

sage: t = M.tensor_field(0,2, name='t') ; t 

Tensor field t of type (0,2) on the 2-dimensional differentiable 

manifold S^2 

sage: t.parent() 

Module T^(0,2)(S^2) of type-(0,2) tensors fields on the 2-dimensional 

differentiable manifold S^2 

sage: t.parent().category() 

Category of modules over Algebra of differentiable scalar fields on the 

2-dimensional differentiable manifold S^2 

 

The parent of `t` is not a free module, for the sphere `S^2` is not 

parallelizable:: 

 

sage: isinstance(t.parent(), FiniteRankFreeModule) 

False 

 

To fully define `t`, we have to specify its components in some vector 

frames defined on subsets of `S^2`; let us start by the open subset `U`:: 

 

sage: eU = c_xy.frame() 

sage: t[eU,:] = [[1,0], [-2,3]] 

sage: t.display(eU) 

t = dx*dx - 2 dy*dx + 3 dy*dy 

 

To set the components of `t` on `V` consistently, we copy the expressions 

of the components in the common subset `W`:: 

 

sage: eV = c_uv.frame() 

sage: eVW = eV.restrict(W) 

sage: c_uvW = c_uv.restrict(W) 

sage: t[eV,0,0] = t[eVW,0,0,c_uvW].expr() # long time 

sage: t[eV,0,1] = t[eVW,0,1,c_uvW].expr() # long time 

sage: t[eV,1,0] = t[eVW,1,0,c_uvW].expr() # long time 

sage: t[eV,1,1] = t[eVW,1,1,c_uvW].expr() # long time 

 

Actually, the above operation can by performed in a single line by means 

of the method 

:meth:`~sage.manifolds.differentiable.tensorfield.TensorField.add_comp_by_continuation`:: 

 

sage: t.add_comp_by_continuation(eV, W, chart=c_uv) # long time 

 

At this stage, `t` is fully defined, having components in frames eU and eV 

and the union of the domains of eU and eV being the whole manifold:: 

 

sage: t.display(eV) # long time 

t = (u^4 - 4*u^3*v + 10*u^2*v^2 + 4*u*v^3 + v^4)/(u^8 + 4*u^6*v^2 + 6*u^4*v^4 + 4*u^2*v^6 + v^8) du*du 

- 4*(u^3*v + 2*u^2*v^2 - u*v^3)/(u^8 + 4*u^6*v^2 + 6*u^4*v^4 + 4*u^2*v^6 + v^8) du*dv 

+ 2*(u^4 - 2*u^3*v - 2*u^2*v^2 + 2*u*v^3 + v^4)/(u^8 + 4*u^6*v^2 + 6*u^4*v^4 + 4*u^2*v^6 + v^8) dv*du 

+ (3*u^4 + 4*u^3*v - 2*u^2*v^2 - 4*u*v^3 + 3*v^4)/(u^8 + 4*u^6*v^2 + 6*u^4*v^4 + 4*u^2*v^6 + v^8) dv*dv 

 

Let us consider two vector fields, `a` and `b`, on `S^2`:: 

 

sage: a = M.vector_field(name='a') 

sage: a[eU,:] = [-y,x] 

sage: a.add_comp_by_continuation(eV, W, chart=c_uv) 

sage: a.display(eV) 

a = -v d/du + u d/dv 

sage: b = M.vector_field(name='b') 

sage: b[eU,:] = [y,-1] 

sage: b.add_comp_by_continuation(eV, W, chart=c_uv) 

sage: b.display(eV) 

b = ((2*u + 1)*v^3 + (2*u^3 - u^2)*v)/(u^2 + v^2) d/du 

- (u^4 - v^4 + 2*u*v^2)/(u^2 + v^2) d/dv 

 

As a tensor field of type `(0,2)`, `t` acts on the pair `(a,b)`, 

resulting in a scalar field:: 

 

sage: f = t(a,b); f 

Scalar field t(a,b) on the 2-dimensional differentiable manifold S^2 

sage: f.display() # long time 

t(a,b): S^2 --> R 

on U: (x, y) |--> -2*x*y - y^2 - 3*x 

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

 

The vectors can be defined only on subsets of `S^2`, the domain of the 

result is then the common subset:: 

 

sage: s = t(a.restrict(U), b) ; s # long time 

Scalar field t(a,b) on the Open subset U of the 2-dimensional 

differentiable manifold S^2 

sage: s.display() # long time 

t(a,b): U --> R 

(x, y) |--> -2*x*y - y^2 - 3*x 

on W: (u, v) |--> -(3*u^3 + (3*u + 1)*v^2 + 2*u*v)/(u^4 + 2*u^2*v^2 + v^4) 

sage: s = t(a.restrict(U), b.restrict(W)) ; s # long time 

Scalar field t(a,b) on the Open subset W of the 2-dimensional 

differentiable manifold S^2 

sage: s.display() # long time 

t(a,b): W --> R 

(x, y) |--> -2*x*y - y^2 - 3*x 

(u, v) |--> -(3*u^3 + (3*u + 1)*v^2 + 2*u*v)/(u^4 + 2*u^2*v^2 + v^4) 

 

The tensor itself can be defined only on some open subset of `S^2`, 

yielding a result whose domain is this subset:: 

 

sage: s = t.restrict(V)(a,b); s # long time 

Scalar field t(a,b) on the Open subset V of the 2-dimensional 

differentiable manifold S^2 

sage: s.display() # long time 

t(a,b): V --> R 

(u, v) |--> -(3*u^3 + (3*u + 1)*v^2 + 2*u*v)/(u^4 + 2*u^2*v^2 + v^4) 

on W: (x, y) |--> -2*x*y - y^2 - 3*x 

 

Tests regarding the multiplication by a scalar field:: 

 

sage: f = M.scalar_field({c_xy: 1/(1+x^2+y^2), 

....: c_uv: (u^2 + v^2)/(u^2 + v^2 + 1)}, name='f') 

sage: t.parent().base_ring() is f.parent() 

True 

sage: s = f*t; s # long time 

Tensor field of type (0,2) on the 2-dimensional differentiable 

manifold S^2 

sage: s[[0,0]] == f*t[[0,0]] # long time 

True 

sage: s.restrict(U) == f.restrict(U) * t.restrict(U) # long time 

True 

sage: s = f*t.restrict(U); s 

Tensor field of type (0,2) on the Open subset U of the 2-dimensional 

differentiable manifold S^2 

sage: s.restrict(U) == f.restrict(U) * t.restrict(U) 

True 

 

.. RUBRIC:: Same examples with SymPy as the symbolic engine 

 

From now on, we ask that all symbolic calculus on manifold `M` are 

performed by SymPy:: 

 

sage: M.set_calculus_method('sympy') 

 

We define the tensor `t` as above:: 

 

sage: t = M.tensor_field(0,2, name='t') 

sage: t[eU,:] = [[1,0], [-2,3]] 

sage: t.display(eU) 

t = dx*dx - 2 dy*dx + 3 dy*dy 

sage: t.add_comp_by_continuation(eV, W, chart=c_uv) # long time 

sage: t.display(eV) # long time 

t = (u**4 - 4*u**3*v + 10*u**2*v**2 + 4*u*v**3 + v**4)/(u**8 + 

4*u**6*v**2 + 6*u**4*v**4 + 4*u**2*v**6 + v**8) du*du + 

4*u*v*(-u**2 - 2*u*v + v**2)/(u**8 + 4*u**6*v**2 + 6*u**4*v**4 

+ 4*u**2*v**6 + v**8) du*dv + 2*(u**4 - 2*u**3*v - 2*u**2*v**2 

+ 2*u*v**3 + v**4)/(u**8 + 4*u**6*v**2 + 6*u**4*v**4 + 

4*u**2*v**6 + v**8) dv*du + (3*u**4 + 4*u**3*v - 2*u**2*v**2 - 

4*u*v**3 + 3*v**4)/(u**8 + 4*u**6*v**2 + 6*u**4*v**4 + 

4*u**2*v**6 + v**8) dv*dv 

 

The default coordinate representations of tensor components are now 

SymPy objects:: 

 

sage: t[eV,1,1,c_uv].expr() # long time 

(3*u**4 + 4*u**3*v - 2*u**2*v**2 - 4*u*v**3 + 3*v**4)/(u**8 + 

4*u**6*v**2 + 6*u**4*v**4 + 4*u**2*v**6 + v**8) 

sage: type(t[eV,1,1,c_uv].expr()) # long time 

<class 'sympy.core.mul.Mul'> 

 

Let us consider two vector fields, `a` and `b`, on `S^2`:: 

 

sage: a = M.vector_field(name='a') 

sage: a[eU,:] = [-y,x] 

sage: a.add_comp_by_continuation(eV, W, chart=c_uv) 

sage: a.display(eV) 

a = -v d/du + u d/dv 

sage: b = M.vector_field(name='b') 

sage: b[eU,:] = [y,-1] 

sage: b.add_comp_by_continuation(eV, W, chart=c_uv) 

sage: b.display(eV) 

b = v*(2*u**3 - u**2 + 2*u*v**2 + v**2)/(u**2 + v**2) d/du 

+ (-u**4 - 2*u*v**2 + v**4)/(u**2 + v**2) d/dv 

 

As a tensor field of type `(0,2)`, `t` acts on the pair `(a,b)`, 

resulting in a scalar field:: 

 

sage: f = t(a,b) 

sage: f.display() # long time 

t(a,b): S^2 --> R 

on U: (x, y) |--> -2*x*y - 3*x - y**2 

on V: (u, v) |--> -(3*u**3 + 3*u*v**2 + 2*u*v + v**2)/(u**4 + 2*u**2*v**2 + v**4) 

 

The vectors can be defined only on subsets of `S^2`, the domain of the 

result is then the common subset:: 

 

sage: s = t(a.restrict(U), b) 

sage: s.display() # long time 

t(a,b): U --> R 

(x, y) |--> -2*x*y - 3*x - y**2 

on W: (u, v) |--> -(3*u**3 + 3*u*v**2 + 2*u*v + v**2)/(u**4 + 2*u**2*v**2 + v**4) 

sage: s = t(a.restrict(U), b.restrict(W)) # long time 

sage: s.display() # long time 

t(a,b): W --> R 

(x, y) |--> -2*x*y - 3*x - y**2 

(u, v) |--> -(3*u**3 + 3*u*v**2 + 2*u*v + v**2)/(u**4 + 2*u**2*v**2 + v**4) 

 

The tensor itself can be defined only on some open subset of `S^2`, 

yielding a result whose domain is this subset:: 

 

sage: s = t.restrict(V)(a,b) # long time 

sage: s.display() # long time 

t(a,b): V --> R 

(u, v) |--> -(3*u**3 + 3*u*v**2 + 2*u*v + v**2)/(u**4 + 2*u**2*v**2 + v**4) 

on W: (x, y) |--> -2*x*y - 3*x - y**2 

 

Tests regarding the multiplication by a scalar field:: 

 

sage: f = M.scalar_field({c_xy: 1/(1+x^2+y^2), 

....: c_uv: (u^2 + v^2)/(u^2 + v^2 + 1)}, name='f') 

sage: s = f*t # long time 

sage: s[[0,0]] == f*t[[0,0]] # long time 

True 

sage: s.restrict(U) == f.restrict(U) * t.restrict(U) # long time 

True 

sage: s = f*t.restrict(U) 

sage: s.restrict(U) == f.restrict(U) * t.restrict(U) 

True 

 

 

""" 

def __init__(self, vector_field_module, tensor_type, name=None, 

latex_name=None, sym=None, antisym=None, parent=None): 

r""" 

Construct a tensor field. 

 

TESTS: 

 

Construction via ``parent.element_class``, and not via a direct call 

to ``TensorField``, to fit with the category framework:: 

 

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

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

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

sage: c_xy.<x,y> = U.chart() ; c_uv.<u,v> = V.chart() 

sage: transf = c_xy.transition_map(c_uv, (x+y, x-y), 

....: intersection_name='W', restrictions1= x>0, 

....: restrictions2= u+v>0) 

sage: inv = transf.inverse() 

sage: W = U.intersection(V) 

sage: e_xy = c_xy.frame() ; e_uv = c_uv.frame() 

sage: XM = M.vector_field_module() 

sage: T02 = M.tensor_field_module((0,2)) 

sage: t = T02.element_class(XM, (0,2), name='t'); t 

Tensor field t of type (0,2) on the 2-dimensional differentiable 

manifold M 

sage: t[e_xy,:] = [[1+x^2, x*y], [0, 1+y^2]] 

sage: t.add_comp_by_continuation(e_uv, W, c_uv) 

sage: t.display(e_xy) 

t = (x^2 + 1) dx*dx + x*y dx*dy + (y^2 + 1) dy*dy 

sage: t.display(e_uv) 

t = (3/16*u^2 + 1/16*v^2 + 1/2) du*du 

+ (-1/16*u^2 + 1/4*u*v + 1/16*v^2) du*dv 

+ (1/16*u^2 + 1/4*u*v - 1/16*v^2) dv*du 

+ (1/16*u^2 + 3/16*v^2 + 1/2) dv*dv 

sage: TestSuite(t).run(skip='_test_pickling') 

 

Construction with ``DifferentiableManifold.tensor_field``:: 

 

sage: t1 = M.tensor_field(0, 2, name='t'); t1 

Tensor field t of type (0,2) on the 2-dimensional differentiable 

manifold M 

sage: type(t1) == type(t) 

True 

 

""" 

if parent is None: 

parent = vector_field_module.tensor_module(*tensor_type) 

ModuleElement.__init__(self, parent) 

self._vmodule = vector_field_module 

self._tensor_type = tuple(tensor_type) 

self._tensor_rank = self._tensor_type[0] + self._tensor_type[1] 

self._name = name 

if latex_name is None: 

self._latex_name = self._name 

else: 

self._latex_name = latex_name 

self._domain = vector_field_module._domain 

self._ambient_domain = vector_field_module._ambient_domain 

self._restrictions = {} # dict. of restrictions of self on subdomains 

# of self._domain, with the subdomains as keys 

# Treatment of symmetry declarations: 

self._sym = [] 

if sym is not None and sym != []: 

if isinstance(sym[0], (int, Integer)): 

# a single symmetry is provided as a tuple -> 1-item list: 

sym = [tuple(sym)] 

for isym in sym: 

if len(isym) > 1: 

for i in isym: 

if i < 0 or i > self._tensor_rank - 1: 

raise IndexError("invalid position: {}".format(i) + 

" not in [0,{}]".format(self._tensor_rank-1)) 

self._sym.append(tuple(isym)) 

self._antisym = [] 

if antisym is not None and antisym != []: 

if isinstance(antisym[0], (int, Integer)): 

# a single antisymmetry is provided as a tuple -> 1-item list: 

antisym = [tuple(antisym)] 

for isym in antisym: 

if len(isym) > 1: 

for i in isym: 

if i < 0 or i > self._tensor_rank - 1: 

raise IndexError("invalid position: {}".format(i) + 

" not in [0,{}]".format(self._tensor_rank-1)) 

self._antisym.append(tuple(isym)) 

# Final consistency check: 

index_list = [] 

for isym in self._sym: 

index_list += isym 

for isym in self._antisym: 

index_list += isym 

if len(index_list) != len(set(index_list)): 

# There is a repeated index position: 

raise IndexError("incompatible lists of symmetries: the same " + 

"position appears more than once") 

# Initialization of derived quantities: 

self._init_derived() 

 

####### Required methods for ModuleElement (beside arithmetic) ####### 

 

def __bool__(self): 

r""" 

Return ``True`` if ``self`` is nonzero and ``False`` otherwise. 

 

This method is called by :meth:`is_zero`. 

 

EXAMPLES: 

 

Tensor field defined by parts on a 2-dimensional manifold:: 

 

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

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

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

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

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

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

sage: t = M.tensor_field(1, 2, name='t') 

sage: tu = U.tensor_field(1, 2, name='t') 

sage: tv = V.tensor_field(1, 2, name='t') 

sage: tu[0,0,0] = 0 

sage: tv[0,0,0] = 0 

sage: t.set_restriction(tv) 

sage: t.set_restriction(tu) 

sage: bool(t) 

False 

sage: t.is_zero() # indirect doctest 

True 

sage: tv[0,0,0] = 1 

sage: t.set_restriction(tv) 

sage: bool(t) 

True 

sage: t.is_zero() # indirect doctest 

False 

""" 

return any(bool(rst) for rst in self._restrictions.values()) 

 

__nonzero__ = __bool__ # For Python2 compatibility 

 

##### End of required methods for ModuleElement (beside arithmetic) ##### 

 

def _repr_(self): 

r""" 

String representation of ``self``. 

 

TESTS:: 

 

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

sage: t = M.tensor_field(1, 3, name='t') 

sage: t 

Tensor field t of type (1,3) on the 2-dimensional differentiable manifold M 

 

""" 

# Special cases 

if self._tensor_type == (0,2) and self._sym == [(0,1)]: 

description = "Field of symmetric bilinear forms " 

if self._name is not None: 

description += self._name + " " 

else: 

# Generic case 

description = "Tensor field " 

if self._name is not None: 

description += self._name + " " 

description += "of type ({},{}) ".format( 

self._tensor_type[0], self._tensor_type[1]) 

return self._final_repr(description) 

 

def _latex_(self): 

r""" 

LaTeX representation of ``self``. 

 

TESTS:: 

 

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

sage: t = M.tensor_field(1, 3, name='t') 

sage: t._latex_() 

't' 

sage: t = M.tensor_field(1, 3, name='t', latex_name=r'\tau') 

sage: latex(t) 

\tau 

 

""" 

if self._latex_name is None: 

return r'\mbox{' + str(self) + r'}' 

else: 

return self._latex_name 

 

def set_name(self, name=None, latex_name=None): 

r""" 

Set (or change) the text name and LaTeX name of ``self``. 

 

INPUT: 

 

- ``name`` -- string (default: ``None``); name given to the tensor 

field 

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

the tensor field; if ``None`` while ``name`` is provided, the LaTeX 

symbol is set to ``name`` 

 

EXAMPLES:: 

 

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

sage: t = M.tensor_field(1, 3); t 

Tensor field of type (1,3) on the 2-dimensional differentiable 

manifold M 

sage: t.set_name(name='t') 

sage: t 

Tensor field t of type (1,3) on the 2-dimensional differentiable 

manifold M 

sage: latex(t) 

t 

sage: t.set_name(latex_name=r'\tau') 

sage: latex(t) 

\tau 

sage: t.set_name(name='a') 

sage: t 

Tensor field a of type (1,3) on the 2-dimensional differentiable 

manifold M 

sage: latex(t) 

a 

 

""" 

if name is not None: 

self._name = name 

if latex_name is None: 

self._latex_name = self._name 

if latex_name is not None: 

self._latex_name = latex_name 

for rst in self._restrictions.values(): 

rst.set_name(name=name, latex_name=latex_name) 

 

def _new_instance(self): 

r""" 

Create an instance of the same class as ``self`` on the same 

vector field module, with the same tensor type and same symmetries 

 

TESTS:: 

 

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

sage: t = M.tensor_field(1, 3, name='t') 

sage: t1 = t._new_instance(); t1 

Tensor field of type (1,3) on the 2-dimensional differentiable 

manifold M 

sage: type(t1) == type(t) 

True 

sage: t1.parent() is t.parent() 

True 

 

""" 

return type(self)(self._vmodule, self._tensor_type, sym=self._sym, 

antisym=self._antisym, parent=self.parent()) 

 

def _final_repr(self, description): 

r""" 

Part of string representation common to all derived classes of 

:class:`TensorField`. 

 

TESTS:: 

 

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

sage: t = M.tensor_field(1, 3, name='t') 

sage: t._final_repr('Tensor field t ') 

'Tensor field t on the 2-dimensional differentiable manifold M' 

 

""" 

if self._domain == self._ambient_domain: 

description += "on the {}".format(self._domain) 

else: 

description += "along the {} ".format(self._domain) + \ 

"with values on the {}".format(self._ambient_domain) 

return description 

 

def _init_derived(self): 

r""" 

Initialize the derived quantities. 

 

TESTS:: 

 

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

sage: t = M.tensor_field(1, 3, name='t') 

sage: t._init_derived() 

 

""" 

self._lie_derivatives = {} # dict. of Lie derivatives of self (keys: id(vector)) 

 

def _del_derived(self): 

r""" 

Delete the derived quantities. 

 

TESTS:: 

 

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

sage: t = M.tensor_field(1, 3, name='t') 

sage: t._del_derived() 

 

""" 

# First deletes any reference to self in the vectors' dictionaries: 

for vid, val in self._lie_derivatives.items(): 

del val[0]._lie_der_along_self[id(self)] 

# Then clears the dictionary of Lie derivatives 

self._lie_derivatives.clear() 

 

#### Simple accessors #### 

 

def domain(self): 

r""" 

Return the manifold on which ``self`` is defined. 

 

OUTPUT: 

 

- instance of class 

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

 

EXAMPLES:: 

 

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

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

sage: t = M.tensor_field(1,2) 

sage: t.domain() 

2-dimensional differentiable manifold M 

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

sage: h = t.restrict(U) 

sage: h.domain() 

Open subset U of the 2-dimensional differentiable manifold M 

 

""" 

return self._domain 

 

def base_module(self): 

r""" 

Return the vector field module on which ``self`` acts as a tensor. 

 

OUTPUT: 

 

- instance of 

:class:`~sage.manifolds.differentiable.vectorfield_module.VectorFieldModule` 

 

EXAMPLES: 

 

The module of vector fields on the 2-sphere as a "base module":: 

 

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

sage: t = M.tensor_field(0,2) 

sage: t.base_module() 

Module X(S^2) of vector fields on the 2-dimensional differentiable 

manifold S^2 

sage: t.base_module() is M.vector_field_module() 

True 

sage: XM = M.vector_field_module() 

sage: XM.an_element().base_module() is XM 

True 

 

""" 

return self._vmodule 

 

def tensor_type(self): 

r""" 

Return the tensor type of ``self``. 

 

OUTPUT: 

 

- pair `(k,l)`, where `k` is the contravariant rank and `l` is 

the covariant rank 

 

EXAMPLES:: 

 

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

sage: t = M.tensor_field(1,2) 

sage: t.tensor_type() 

(1, 2) 

sage: v = M.vector_field() 

sage: v.tensor_type() 

(1, 0) 

 

""" 

return self._tensor_type 

 

def tensor_rank(self): 

r""" 

Return the tensor rank of ``self``. 

 

OUTPUT: 

 

- integer `k+l`, where `k` is the contravariant rank and `l` is 

the covariant rank 

 

EXAMPLES:: 

 

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

sage: t = M.tensor_field(1,2) 

sage: t.tensor_rank() 

3 

sage: v = M.vector_field() 

sage: v.tensor_rank() 

1 

 

""" 

return self._tensor_rank 

 

def symmetries(self): 

r""" 

Print the list of symmetries and antisymmetries. 

 

EXAMPLES:: 

 

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

sage: t = M.tensor_field(1,2) 

sage: t.symmetries() 

no symmetry; no antisymmetry 

sage: t = M.tensor_field(1,2, sym=(1,2)) 

sage: t.symmetries() 

symmetry: (1, 2); no antisymmetry 

sage: t = M.tensor_field(2,2, sym=(0,1), antisym=(2,3)) 

sage: t.symmetries() 

symmetry: (0, 1); antisymmetry: (2, 3) 

sage: t = M.tensor_field(2,2, antisym=[(0,1),(2,3)]) 

sage: t.symmetries() 

no symmetry; antisymmetries: [(0, 1), (2, 3)] 

 

""" 

if not self._sym: 

s = "no symmetry; " 

elif len(self._sym) == 1: 

s = "symmetry: {}; ".format(self._sym[0]) 

else: 

s = "symmetries: {}; ".format(self._sym) 

if not self._antisym: 

a = "no antisymmetry" 

elif len(self._antisym) == 1: 

a = "antisymmetry: {}".format(self._antisym[0]) 

else: 

a = "antisymmetries: {}".format(self._antisym) 

print(s + a) 

 

#### End of simple accessors ##### 

 

def set_restriction(self, rst): 

r""" 

Define a restriction of ``self`` to some subdomain. 

 

INPUT: 

 

- ``rst`` -- :class:`TensorField` of the same type and symmetries 

as the current tensor field ``self``, defined on a subdomain of 

the domain of ``self`` 

 

EXAMPLES:: 

 

sage: M = Manifold(2, 'M') # 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: t = M.tensor_field(1, 2, name='t') 

sage: s = U.tensor_field(1, 2) 

sage: s[0,0,1] = x+y 

sage: t.set_restriction(s) 

sage: t.display(c_xy.frame()) 

t = (x + y) d/dx*dx*dy 

sage: t.restrict(U) == s 

True 

 

""" 

if not isinstance(rst, TensorField): 

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

if not rst._domain.is_subset(self._domain): 

raise ValueError("the domain of the declared restriction is not " + 

"a subset of the field's domain") 

if not rst._ambient_domain.is_subset(self._ambient_domain): 

raise ValueError("the ambient domain of the declared " + 

"restriction is not a subset of the " + 

"field's ambient domain") 

if rst._tensor_type != self._tensor_type: 

raise ValueError("the declared restriction has not the same " + 

"tensor type as the current tensor field") 

if rst._tensor_type != self._tensor_type: 

raise ValueError("the declared restriction has not the same " + 

"tensor type as the current tensor field") 

if rst._sym != self._sym: 

raise ValueError("the declared restriction has not the same " + 

"symmetries as the current tensor field") 

if rst._antisym != self._antisym: 

raise ValueError("the declared restriction has not the same " + 

"antisymmetries as the current tensor field") 

self._restrictions[rst._domain] = rst.copy() 

self._restrictions[rst._domain].set_name(name=self._name, 

latex_name=self._latex_name) 

 

def restrict(self, subdomain, dest_map=None): 

r""" 

Return the restriction of ``self`` to some subdomain. 

 

If the restriction has not been defined yet, it is constructed here. 

 

INPUT: 

 

- ``subdomain`` -- 

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

open subset `U` of the tensor field domain `S` 

- ``dest_map`` -- 

:class:`~sage.manifolds.differentiable.diff_map.DiffMap` 

(default: ``None``); destination map `\Psi:\ U \rightarrow V`, 

where `V` is an open subset of the manifold `M` where the tensor 

field takes it values; if ``None``, the restriction of `\Phi` 

to `U` is used, `\Phi` being the differentiable map 

`S \rightarrow M` associated with the tensor field 

 

OUTPUT: 

 

- :class:`TensorField` representing the restriction 

 

EXAMPLES: 

 

Restrictions of a vector field on the 2-sphere:: 

 

sage: M = Manifold(2, 'S^2', start_index=1) 

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

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

sage: eN = stereoN.frame() # the associated vector frame 

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

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

sage: eS = stereoS.frame() # the associated vector frame 

sage: transf = 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: inv = transf.inverse() # transformation from stereoS to stereoN 

sage: W = U.intersection(V) # the complement of the North and South poles 

sage: stereoN_W = W.atlas()[0] # restriction of stereographic coord. from North pole to W 

sage: stereoS_W = W.atlas()[1] # restriction of stereographic coord. from South pole to W 

sage: eN_W = stereoN_W.frame() ; eS_W = stereoS_W.frame() 

sage: v = M.vector_field('v') 

sage: v.set_comp(eN)[1] = 1 # given the default settings, this can be abriged to v[1] = 1 

sage: v.display() 

v = d/dx 

sage: vU = v.restrict(U) ; vU 

Vector field v on the Open subset U of the 2-dimensional 

differentiable manifold S^2 

sage: vU.display() 

v = d/dx 

sage: vU == eN[1] 

True 

sage: vW = v.restrict(W) ; vW 

Vector field v on the Open subset W of the 2-dimensional 

differentiable manifold S^2 

sage: vW.display() 

v = d/dx 

sage: vW.display(eS_W, stereoS_W) 

v = (-u^2 + v^2) d/du - 2*u*v d/dv 

sage: vW == eN_W[1] 

True 

 

At this stage, defining the restriction of ``v`` to the open 

subset ``V`` fully specifies ``v``:: 

 

sage: v.restrict(V)[1] = vW[eS_W, 1, stereoS_W].expr() # note that eS is the default frame on V 

sage: v.restrict(V)[2] = vW[eS_W, 2, stereoS_W].expr() 

sage: v.display(eS, stereoS) 

v = (-u^2 + v^2) d/du - 2*u*v d/dv 

sage: v.restrict(U).display() 

v = d/dx 

sage: v.restrict(V).display() 

v = (-u^2 + v^2) d/du - 2*u*v d/dv 

 

The restriction of the vector field to its own domain is of course 

itself:: 

 

sage: v.restrict(M) is v 

True 

sage: vU.restrict(U) is vU 

True 

 

""" 

if (subdomain == self._domain 

and (dest_map is None or dest_map == self._vmodule._dest_map)): 

return self 

if subdomain not in self._restrictions: 

if not subdomain.is_subset(self._domain): 

raise ValueError("the provided domain is not a subset of " + 

"the field's domain") 

if dest_map is None: 

dest_map = self._vmodule._dest_map.restrict(subdomain) 

elif not dest_map._codomain.is_subset(self._ambient_domain): 

raise ValueError("the argument 'dest_map' is not compatible " + 

"with the ambient domain of " + 

"the {}".format(self)) 

# First one tries to get the restriction from a tighter domain: 

for dom, rst in self._restrictions.items(): 

if subdomain.is_subset(dom): 

self._restrictions[subdomain] = rst.restrict(subdomain) 

break 

# If this fails, the restriction is created from scratch: 

else: 

smodule = subdomain.vector_field_module(dest_map=dest_map) 

self._restrictions[subdomain] = smodule.tensor( 

self._tensor_type, 

name=self._name, 

latex_name=self._latex_name, 

sym=self._sym, 

antisym=self._antisym, 

specific_type=type(self)) 

return self._restrictions[subdomain] 

 

def set_comp(self, basis=None): 

r""" 

Return the components of ``self`` in a given vector frame 

for assignment. 

 

The components with respect to other frames having the same domain 

as the provided vector frame are deleted, in order to avoid any 

inconsistency. To keep them, use the method :meth:`add_comp` instead. 

 

INPUT: 

 

- ``basis`` -- (default: ``None``) vector frame in which the 

components are defined; if none is provided, the components are 

assumed to refer to the tensor field domain's default frame 

 

OUTPUT: 

 

- components in the given frame, as a 

:class:`~sage.tensor.modules.comp.Components`; if such 

components did not exist previously, they are created 

 

EXAMPLES:: 

 

sage: M = Manifold(2, 'M') # 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: e_uv = c_uv.frame() 

sage: t = M.tensor_field(1, 2, name='t') 

sage: t.set_comp(e_uv) 

3-indices components w.r.t. Coordinate frame (V, (d/du,d/dv)) 

sage: t.set_comp(e_uv)[1,0,1] = u+v 

sage: t.display(e_uv) 

t = (u + v) d/dv*du*dv 

 

Setting the components in a new frame (``e``):: 

 

sage: e = V.vector_frame('e') 

sage: t.set_comp(e) 

3-indices components w.r.t. Vector frame (V, (e_0,e_1)) 

sage: t.set_comp(e)[0,1,1] = u*v 

sage: t.display(e) 

t = u*v e_0*e^1*e^1 

 

Since the frames ``e`` and ``e_uv`` are defined on the same domain, the 

components w.r.t. ``e_uv`` have been erased:: 

 

sage: t.display(c_uv.frame()) 

Traceback (most recent call last): 

... 

ValueError: no basis could be found for computing the components 

in the Coordinate frame (V, (d/du,d/dv)) 

 

""" 

if basis is None: 

basis = self._domain._def_frame 

self._del_derived() # deletes the derived quantities 

rst = self.restrict(basis._domain, dest_map=basis._dest_map) 

return rst.set_comp(basis) 

 

def add_comp(self, basis=None): 

r""" 

Return the components of ``self`` in a given vector frame 

for assignment. 

 

The components with respect to other frames having the same domain 

as the provided vector frame are kept. To delete them, use the 

method :meth:`set_comp` instead. 

 

INPUT: 

 

- ``basis`` -- (default: ``None``) vector frame in which the 

components are defined; if ``None``, the components are assumed 

to refer to the tensor field domain's default frame 

 

OUTPUT: 

 

- components in the given frame, as a 

:class:`~sage.tensor.modules.comp.Components`; if such 

components did not exist previously, they are created 

 

EXAMPLES:: 

 

sage: M = Manifold(2, 'M') # 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: e_uv = c_uv.frame() 

sage: t = M.tensor_field(1, 2, name='t') 

sage: t.add_comp(e_uv) 

3-indices components w.r.t. Coordinate frame (V, (d/du,d/dv)) 

sage: t.add_comp(e_uv)[1,0,1] = u+v 

sage: t.display(e_uv) 

t = (u + v) d/dv*du*dv 

 

Setting the components in a new frame:: 

 

sage: e = V.vector_frame('e') 

sage: t.add_comp(e) 

3-indices components w.r.t. Vector frame (V, (e_0,e_1)) 

sage: t.add_comp(e)[0,1,1] = u*v 

sage: t.display(e) 

t = u*v e_0*e^1*e^1 

 

The components with respect to ``e_uv`` are kept:: 

 

sage: t.display(e_uv) 

t = (u + v) d/dv*du*dv 

 

""" 

if basis is None: 

basis = self._domain._def_frame 

self._del_derived() # deletes the derived quantities 

rst = self.restrict(basis._domain, dest_map=basis._dest_map) 

return rst.add_comp(basis) 

 

def add_comp_by_continuation(self, frame, subdomain, chart=None): 

r""" 

Set components with respect to a vector frame by continuation of the 

coordinate expression of the components in a subframe. 

 

The continuation is performed by demanding that the components have 

the same coordinate expression as those on the restriction of the 

frame to a given subdomain. 

 

INPUT: 

 

- ``frame`` -- vector frame `e` in which the components are to be set 

- ``subdomain`` -- open subset of `e`'s domain in which the 

components are known or can be evaluated from other components 

- ``chart`` -- (default: ``None``) coordinate chart on `e`'s domain in 

which the extension of the expression of the components is to be 

performed; if ``None``, the default's chart of `e`'s domain is 

assumed 

 

EXAMPLES: 

 

Components of a vector field on the sphere `S^2`:: 

 

sage: M = Manifold(2, 'S^2', start_index=1) 

sage: # The two open subsets covered by stereographic coordinates (North and South): 

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

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

sage: c_xy.<x,y> = U.chart() ; c_uv.<u,v> = V.chart() # stereographic coordinates 

sage: transf = 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: inv = transf.inverse() 

sage: W = U.intersection(V) # The complement of the two poles 

sage: eU = c_xy.frame() ; eV = c_uv.frame() 

sage: a = M.vector_field('a') 

sage: a[eU,:] = [x, 2+y] 

 

At this stage, the vector field has been defined only on the open 

subset ``U`` (through its components in the frame ``eU``):: 

 

sage: a.display(eU) 

a = x d/dx + (y + 2) d/dy 

 

The components with respect to the restriction of ``eV`` to the common 

subdomain ``W``, in terms of the ``(u,v)`` coordinates, are obtained 

by a change-of-frame formula on ``W``:: 

 

sage: a.display(eV.restrict(W), c_uv.restrict(W)) 

a = (-4*u*v - u) d/du + (2*u^2 - 2*v^2 - v) d/dv 

 

The continuation consists in extending the definition of the vector 

field to the whole open subset ``V`` by demanding that the components 

in the frame eV have the same coordinate expression as the above one:: 

 

sage: a.add_comp_by_continuation(eV, W, chart=c_uv) 

 

We have then:: 

 

sage: a.display(eV) 

a = (-4*u*v - u) d/du + (2*u^2 - 2*v^2 - v) d/dv 

 

and `a` is defined on the entire manifold `S^2`. 

 

""" 

dom = frame._domain 

if not dom.is_subset(self._domain): 

raise ValueError("the vector frame is not defined on a subset " + 

"of the tensor field domain") 

if chart is None: 

chart = dom._def_chart 

sframe = frame.restrict(subdomain) 

schart = chart.restrict(subdomain) 

scomp = self.comp(sframe) 

resu = self.add_comp(frame) # _del_derived is performed here 

for ind in resu.non_redundant_index_generator(): 

resu[[ind]] = dom.scalar_field({chart: scomp[[ind]].expr(schart)}) 

 

def comp(self, basis=None, from_basis=None): 

r""" 

Return the components in a given vector frame. 

 

If the components are not known already, they are computed by the 

tensor change-of-basis formula from components in another vector frame. 

 

INPUT: 

 

- ``basis`` -- (default: ``None``) vector frame in which the components 

are required; if none is provided, the components are assumed to 

refer to the tensor field domain's default frame 

- ``from_basis`` -- (default: ``None``) vector frame from which the 

required components are computed, via the tensor change-of-basis 

formula, if they are not known already in the basis ``basis`` 

 

OUTPUT: 

 

- components in the vector frame ``basis``, as a 

:class:`~sage.tensor.modules.comp.Components` 

 

EXAMPLES: 

 

Components of a type-`(1,1)` tensor field defined on two 

open subsets:: 

 

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

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

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

sage: e = U.default_frame() ; e 

Coordinate frame (U, (d/dx,d/dy)) 

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

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

sage: f = V.default_frame() ; f 

Coordinate frame (V, (d/du,d/dv)) 

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

sage: t = M.tensor_field(1,1, name='t') 

sage: t[e,0,0] = - x + y^3 

sage: t[e,0,1] = 2+x 

sage: t[f,1,1] = - u*v 

sage: t.comp(e) 

2-indices components w.r.t. Coordinate frame (U, (d/dx,d/dy)) 

sage: t.comp(e)[:] 

[y^3 - x x + 2] 

[ 0 0] 

sage: t.comp(f) 

2-indices components w.r.t. Coordinate frame (V, (d/du,d/dv)) 

sage: t.comp(f)[:] 

[ 0 0] 

[ 0 -u*v] 

 

Since ``e`` is ``M``'s default frame, the argument ``e`` can 

be omitted:: 

 

sage: e is M.default_frame() 

True 

sage: t.comp() is t.comp(e) 

True 

 

Example of computation of the components via a change of frame:: 

 

sage: a = V.automorphism_field() 

sage: a[:] = [[1+v, -u^2], [0, 1-u]] 

sage: h = f.new_frame(a, 'h') 

sage: t.comp(h) 

2-indices components w.r.t. Vector frame (V, (h_0,h_1)) 

sage: t.comp(h)[:] 

[ 0 -u^3*v/(v + 1)] 

[ 0 -u*v] 

 

""" 

if basis is None: 

basis = self._domain._def_frame 

rst = self.restrict(basis._domain, dest_map=basis._dest_map) 

return rst.comp(basis=basis, from_basis=from_basis) 

 

def display(self, basis=None, chart=None): 

r""" 

Display the tensor field in terms of its expansion with respect 

to a given vector frame. 

 

The output is either text-formatted (console mode) or LaTeX-formatted 

(notebook mode). 

 

INPUT: 

 

- ``basis`` -- (default: ``None``) vector frame with respect to 

which the tensor is expanded; if ``None``, the default frame 

of the domain of definition of the tensor field is assumed 

- ``chart`` -- (default: ``None``) chart with respect to which the 

components of the tensor field in the selected frame are expressed; 

if ``None``, the default chart of the vector frame domain is assumed 

 

EXAMPLES: 

 

Display of a type-`(1,1)` tensor field defined on two open subsets:: 

 

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

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

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

sage: e = U.default_frame() ; e 

Coordinate frame (U, (d/dx,d/dy)) 

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

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

sage: f = V.default_frame() ; f 

Coordinate frame (V, (d/du,d/dv)) 

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

sage: t = M.tensor_field(1,1, name='t') 

sage: t[e,0,0] = - x + y^3 

sage: t[e,0,1] = 2+x 

sage: t[f,1,1] = - u*v 

sage: t.display(e) 

t = (y^3 - x) d/dx*dx + (x + 2) d/dx*dy 

sage: t.display(f) 

t = -u*v d/dv*dv 

 

Since ``e`` is ``M``'s default frame, the argument ``e`` can 

be omitted:: 

 

sage: e is M.default_frame() 

True 

sage: t.display() 

t = (y^3 - x) d/dx*dx + (x + 2) d/dx*dy 

 

Similarly, since ``f`` is ``V``'s default frame, the argument ``f`` 

can be omitted when considering the restriction of ``t`` to ``V``:: 

 

sage: t.restrict(V).display() 

t = -u*v d/dv*dv 

 

Display with respect to a frame in which ``t`` has not been 

initialized (automatic use of a change-of-frame formula):: 

 

sage: a = V.automorphism_field() 

sage: a[:] = [[1+v, -u^2], [0, 1-u]] 

sage: h = f.new_frame(a, 'h') 

sage: t.display(h) 

t = -u^3*v/(v + 1) h_0*h^1 - u*v h_1*h^1 

 

A shortcut of ``display()`` is ``disp()``:: 

 

sage: t.disp(h) 

t = -u^3*v/(v + 1) h_0*h^1 - u*v h_1*h^1 

 

""" 

if basis is None: 

if self._vmodule._dest_map.is_identity(): 

basis = self._domain._def_frame 

else: 

for rst in self._restrictions.values(): 

try: 

return rst.display() 

except ValueError: 

pass 

if basis is None: # should be "is still None" ;-) 

raise ValueError("a frame must be provided for the display") 

rst = self.restrict(basis._domain, dest_map=basis._dest_map) 

return rst.display(basis, chart) 

 

disp = display 

 

def display_comp(self, frame=None, chart=None, coordinate_labels=True, 

only_nonzero=True, only_nonredundant=False): 

r""" 

Display the tensor components with respect to a given frame, 

one per line. 

 

The output is either text-formatted (console mode) or LaTeX-formatted 

(notebook mode). 

 

INPUT: 

 

- ``frame`` -- (default: ``None``) vector frame with respect to which 

the tensor field components are defined; if ``None``, then 

 

* if ``chart`` is not ``None``, the coordinate frame associated to 

``chart`` is used 

* otherwise, the default basis of the vector field module on which 

the tensor field is defined is used 

 

- ``chart`` -- (default: ``None``) chart specifying the coordinate 

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

tensor field domain is used 

- ``coordinate_labels`` -- (default: ``True``) boolean; if ``True``, 

coordinate symbols are used by default (instead of integers) as 

index labels whenever ``frame`` is a coordinate frame 

- ``only_nonzero`` -- (default: ``True``) boolean; if ``True``, only 

nonzero components are displayed 

- ``only_nonredundant`` -- (default: ``False``) boolean; if ``True``, 

only nonredundant components are displayed in case of symmetries 

 

EXAMPLES: 

 

Display of the components of a type-`(1,1)` tensor field defined 

on two open subsets:: 

 

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

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

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

sage: e = U.default_frame() 

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

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

sage: f = V.default_frame() 

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

sage: t = M.tensor_field(1,1, name='t') 

sage: t[e,0,0] = - x + y^3 

sage: t[e,0,1] = 2+x 

sage: t[f,1,1] = - u*v 

sage: t.display_comp(e) 

t^x_x = y^3 - x 

t^x_y = x + 2 

sage: t.display_comp(f) 

t^v_v = -u*v 

 

Components in a chart frame:: 

 

sage: t.display_comp(chart=c_xy) 

t^x_x = y^3 - x 

t^x_y = x + 2 

sage: t.display_comp(chart=c_uv) 

t^v_v = -u*v 

 

See documentation of 

:meth:`sage.manifolds.differentiable.tensorfield_paral.TensorFieldParal.display_comp` 

for more options. 

 

""" 

if frame is None: 

if chart is not None: 

frame = chart.frame() 

else: 

if self._vmodule._dest_map.is_identity(): 

frame = self._domain.default_frame() 

else: 

for rst in self._restrictions.values(): 

try: 

return rst.display_comp(chart=chart, 

coordinate_labels=coordinate_labels, 

only_nonzero=only_nonzero, 

only_nonredundant=only_nonredundant) 

except ValueError: 

pass 

if frame is None: # should be "is still None" ;-) 

raise ValueError("a frame must be provided for the display") 

rst = self.restrict(frame.domain(), dest_map=frame._dest_map) 

return rst.display_comp(frame=frame, chart=chart, 

coordinate_labels=coordinate_labels, 

only_nonzero=only_nonzero, 

only_nonredundant=only_nonredundant) 

 

 

def __getitem__(self, args): 

r""" 

Return a component with respect to some frame. 

 

INPUT: 

 

- ``args`` -- list of indices defining the component; if ``[:]`` is 

provided, all the components are returned 

 

The frame can be passed as the first item of ``args``. If not, the 

default frame of the tensor field's domain is assumed. If ``args`` 

is a string, this method acts as a shortcut for tensor contractions 

and symmetrizations, the string containing abstract indices. 

 

TESTS:: 

 

sage: M = Manifold(2, 'M') # 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: e_xy = c_xy.frame() 

sage: t = M.tensor_field(1, 1, name='t') 

sage: t[e_xy, :] = [[x+y, -2], [3*y^2, x*y]] 

sage: t.__getitem__((1,0)) 

3*y^2 

sage: t.__getitem__((1,1)) 

x*y 

sage: t.__getitem__((e_xy,1,0)) 

3*y^2 

sage: t.__getitem__(slice(None)) 

[x + y -2] 

[3*y^2 x*y] 

sage: t.__getitem__((e_xy,slice(None))) 

[x + y -2] 

[3*y^2 x*y] 

sage: t.__getitem__('^a_a') # trace 

Scalar field on the 2-dimensional differentiable manifold M 

sage: t.__getitem__('^a_a').display() 

M --> R 

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

 

""" 

if isinstance(args, str): # tensor with specified indices 

return TensorWithIndices(self, args).update() 

if isinstance(args, list): # case of [[...]] syntax 

if not isinstance(args[0], (int, Integer, slice)): 

frame = args[0] 

args = args[1:] 

else: 

frame = self._domain._def_frame 

else: 

if isinstance(args, (int, Integer, slice)): 

frame = self._domain._def_frame 

elif not isinstance(args[0], (int, Integer, slice)): 

frame = args[0] 

args = args[1:] 

else: 

frame = self._domain._def_frame 

return self.comp(frame)[args] 

 

def __setitem__(self, args, value): 

r""" 

Sets a component with respect to some vector frame. 

 

INPUT: 

 

- ``args`` -- list of indices; if ``[:]`` is provided, all the 

components are set; the frame can be passed as the first item 

of ``args``; if not, the default frame of the tensor field's 

domain is assumed 

- ``value`` -- the value to be set or a list of values if 

``args = [:]`` 

 

TESTS:: 

 

sage: M = Manifold(2, 'M') # 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: e_xy = c_xy.frame() 

sage: t = M.tensor_field(1, 1, name='t') 

sage: t.__setitem__((e_xy, 0, 1), x+y^2) 

sage: t.display(e_xy) 

t = (y^2 + x) d/dx*dy 

sage: t.__setitem__((0, 1), x+y^2) # same as above since e_xy is the default frame on M 

sage: t.display() 

t = (y^2 + x) d/dx*dy 

sage: t.__setitem__(slice(None), [[x+y, -2], [3*y^2, x*y]]) 

sage: t.display() 

t = (x + y) d/dx*dx - 2 d/dx*dy + 3*y^2 d/dy*dx + x*y d/dy*dy 

 

""" 

if isinstance(args, list): # case of [[...]] syntax 

if not isinstance(args[0], (int, Integer, slice)): 

frame = args[0] 

args = args[1:] 

else: 

frame = self._domain._def_frame 

else: 

if isinstance(args, (int, Integer, slice)): 

frame = self._domain._def_frame 

elif not isinstance(args[0], (int, Integer, slice)): 

frame = args[0] 

args = args[1:] 

else: 

frame = self._domain._def_frame 

self.set_comp(frame)[args] = value 

 

def copy(self): 

r""" 

Return an exact copy of ``self``. 

 

.. NOTE:: 

 

The name and the derived quantities are not copied. 

 

EXAMPLES: 

 

Copy of a type-`(1,1)` tensor field on a 2-dimensional manifold:: 

 

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

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

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

sage: c_xy.<x,y> = U.chart() ; c_uv.<u,v> = V.chart() 

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

....: intersection_name='W', restrictions1= x>0, 

....: restrictions2= u+v>0) 

sage: uv_to_xy = xy_to_uv.inverse() 

sage: e_xy = c_xy.frame(); e_uv = c_uv.frame() 

sage: t = M.tensor_field(1, 1, name='t') 

sage: t[e_xy,:] = [[x+y, 0], [2, 1-y]] 

sage: t.add_comp_by_continuation(e_uv, U.intersection(V), c_uv) 

sage: s = t.copy(); s 

Tensor field of type (1,1) on 

the 2-dimensional differentiable manifold M 

sage: s.display(e_xy) 

(x + y) d/dx*dx + 2 d/dy*dx + (-y + 1) d/dy*dy 

sage: s == t 

True 

 

If the original tensor field is modified, the copy is not:: 

 

sage: t[e_xy,0,0] = -1 

sage: t.display(e_xy) 

t = -d/dx*dx + 2 d/dy*dx + (-y + 1) d/dy*dy 

sage: s.display(e_xy) 

(x + y) d/dx*dx + 2 d/dy*dx + (-y + 1) d/dy*dy 

sage: s == t 

False 

 

""" 

resu = self._new_instance() 

for dom, rst in self._restrictions.items(): 

resu._restrictions[dom] = rst.copy() 

return resu 

 

def _common_subdomains(self, other): 

r""" 

Return the list of subdomains of ``self._domain`` on which 

both ``self`` and ``other`` have known restrictions. 

 

TESTS:: 

 

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

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

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

sage: c_xy.<x,y> = U.chart() ; c_uv.<u,v> = V.chart() 

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

....: intersection_name='W', restrictions1= x>0, 

....: restrictions2= u+v>0) 

sage: uv_to_xy = xy_to_uv.inverse() 

sage: e_xy = c_xy.frame(); e_uv = c_uv.frame() 

sage: t = M.tensor_field(1, 1, name='t') 

sage: t[e_xy,:] = [[x+y, 0], [2, 0]] 

sage: t.add_comp_by_continuation(e_uv, U.intersection(V), c_uv) 

sage: sorted(t._common_subdomains(t), key=str) 

[Open subset U of the 2-dimensional differentiable manifold M, 

Open subset V of the 2-dimensional differentiable manifold M, 

Open subset W of the 2-dimensional differentiable manifold M] 

sage: a = M.tensor_field(1, 1, name='a') 

sage: t._common_subdomains(a) 

[] 

sage: a[e_xy, 0, 1] = 0 

sage: t._common_subdomains(a) 

[Open subset U of the 2-dimensional differentiable manifold M] 

sage: a[e_uv, 0, 0] = 0 

sage: sorted(t._common_subdomains(a), key=str) 

[Open subset U of the 2-dimensional differentiable manifold M, 

Open subset V of the 2-dimensional differentiable manifold M] 

 

""" 

resu = [] 

for dom in self._restrictions: 

if dom in other._restrictions: 

resu.append(dom) 

return resu 

 

def __eq__(self, other): 

r""" 

Comparison (equality) operator. 

 

INPUT: 

 

- ``other`` -- a tensor field or 0 

 

OUTPUT: 

 

- ``True`` if ``self`` is equal to ``other`` and ``False`` otherwise 

 

TESTS:: 

 

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

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

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

sage: c_xy.<x,y> = U.chart() ; c_uv.<u,v> = V.chart() 

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

....: intersection_name='W', restrictions1= x>0, 

....: restrictions2= u+v>0) 

sage: uv_to_xy = xy_to_uv.inverse() 

sage: e_xy = c_xy.frame(); e_uv = c_uv.frame() 

sage: t = M.tensor_field(1, 1, name='t') 

sage: t[e_xy,:] = [[x+y, 0], [2, 1-y]] 

sage: t.add_comp_by_continuation(e_uv, U.intersection(V), c_uv) 

sage: t == t 

True 

sage: t == t.copy() 

True 

sage: a = M.tensor_field(1, 1, name='a') 

sage: a.set_restriction(t.restrict(U)) 

sage: t == a # False since a has not been defined on V 

False 

sage: a.set_restriction(t.restrict(V)) 

sage: t == a # True now 

True 

sage: a[e_xy, 0, 0] = -1 

sage: t == a # False since a has been reset on U (domain of e_xy) 

False 

sage: t.parent().zero() == 0 

True 

 

""" 

if other is self: 

return True 

if other in ZZ: # to compare with 0 

if other == 0: 

return self.is_zero() 

return False 

elif not isinstance(other, TensorField): 

return False 

else: # other is another tensor field 

if other._vmodule != self._vmodule: 

return False 

if other._tensor_type != self._tensor_type: 

return False 

# Non-trivial open covers of the domain: 

open_covers = self._domain.open_covers()[1:] # the open cover 0 

# is trivial 

for oc in open_covers: 

resu = True 

for dom in oc: 

try: 

resu = resu and \ 

bool(self.restrict(dom) == other.restrict(dom)) 

except ValueError: 

break 

else: 

# If this point is reached, no exception has occured; hence 

# the result is valid and can be returned: 

return resu 

# If this point is reached, the comparison has not been possible 

# on any open cover; we then compare the restrictions to 

# subdomains: 

if not self._restrictions: 

return False # self is not initialized 

if len(self._restrictions) != len(other._restrictions): 

return False # the restrictions are not on the same subdomains 

resu = True 

for dom, rst in self._restrictions.items(): 

if dom in other._restrictions: 

resu = resu and bool(rst == other._restrictions[dom]) 

else: 

return False # the restrictions are not on the same 

# subdomains 

return resu 

 

def __ne__(self, other): 

r""" 

Inequality operator. 

 

INPUT: 

 

- ``other`` -- a tensor field or 0 

 

OUTPUT: 

 

- ``True`` if ``self`` is different from ``other`` and ``False`` 

otherwise 

 

TESTS:: 

 

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

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

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

sage: c_xy.<x,y> = U.chart() ; c_uv.<u,v> = V.chart() 

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

....: intersection_name='W', restrictions1= x>0, 

....: restrictions2= u+v>0) 

sage: uv_to_xy = xy_to_uv.inverse() 

sage: e_xy = c_xy.frame(); e_uv = c_uv.frame() 

sage: t = M.tensor_field(1, 1, name='t') 

sage: t[e_xy,:] = [[x+y, 0], [2, 1-y]] 

sage: t.add_comp_by_continuation(e_uv, U.intersection(V), c_uv) 

sage: t != t 

False 

sage: t != t.copy() 

False 

sage: t != 0 

True 

 

""" 

return not (self == other) 

 

def __pos__(self): 

r""" 

Unary plus operator. 

 

OUTPUT: 

 

- an exact copy of ``self`` 

 

TESTS:: 

 

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

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

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

sage: c_xy.<x,y> = U.chart() ; c_uv.<u,v> = V.chart() 

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

....: intersection_name='W', restrictions1= x>0, 

....: restrictions2= u+v>0) 

sage: uv_to_xy = xy_to_uv.inverse() 

sage: e_xy = c_xy.frame(); e_uv = c_uv.frame() 

sage: t = M.tensor_field(1, 1, name='t') 

sage: t[e_xy,:] = [[x+y, 0], [2, 1-y]] 

sage: t.add_comp_by_continuation(e_uv, U.intersection(V), c_uv) 

sage: s = t.__pos__(); s 

Tensor field +t of type (1,1) on the 2-dimensional differentiable 

manifold M 

sage: s.display(e_xy) 

+t = (x + y) d/dx*dx + 2 d/dy*dx + (-y + 1) d/dy*dy 

 

""" 

resu = self._new_instance() 

for dom, rst in self._restrictions.items(): 

resu._restrictions[dom] = + rst 

if self._name is not None: 

resu._name = '+' + self._name 

if self._latex_name is not None: 

resu._latex_name = '+' + self._latex_name 

return resu 

 

def __neg__(self): 

r""" 

Unary minus operator. 

 

OUTPUT: 

 

- the tensor field `-T`, where `T` is ``self`` 

 

TESTS:: 

 

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

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

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

sage: c_xy.<x,y> = U.chart() ; c_uv.<u,v> = V.chart() 

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

....: intersection_name='W', restrictions1= x>0, 

....: restrictions2= u+v>0) 

sage: uv_to_xy = xy_to_uv.inverse() 

sage: e_xy = c_xy.frame(); e_uv = c_uv.frame() 

sage: t = M.tensor_field(1, 1, name='t') 

sage: t[e_xy, :] = [[x, -x], [y, -y]] 

sage: t.add_comp_by_continuation(e_uv, U.intersection(V), c_uv) 

sage: t.display(e_xy) 

t = x d/dx*dx - x d/dx*dy + y d/dy*dx - y d/dy*dy 

sage: t.display(e_uv) 

t = u d/du*dv + v d/dv*dv 

sage: s = t.__neg__(); s 

Tensor field -t of type (1,1) on the 2-dimensional differentiable 

manifold M 

sage: s.display(e_xy) 

-t = -x d/dx*dx + x d/dx*dy - y d/dy*dx + y d/dy*dy 

sage: s.display(e_uv) 

-t = -u d/du*dv - v d/dv*dv 

sage: s == -t # indirect doctest 

True 

 

""" 

resu = self._new_instance() 

for dom, rst in self._restrictions.items(): 

resu._restrictions[dom] = - rst 

if self._name is not None: 

resu._name = '-' + self._name 

if self._latex_name is not None: 

resu._latex_name = '-' + self._latex_name 

return resu 

 

######### ModuleElement arithmetic operators ######## 

 

def _add_(self, other): 

r""" 

Tensor field addition. 

 

INPUT: 

 

- ``other`` -- a tensor field, in the same tensor module as ``self`` 

 

OUTPUT: 

 

- the tensor field resulting from the addition of ``self`` 

and ``other`` 

 

TESTS:: 

 

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

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

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

sage: c_xy.<x,y> = U.chart() ; c_uv.<u,v> = V.chart() 

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

....: intersection_name='W', restrictions1= x>0, 

....: restrictions2= u+v>0) 

sage: uv_to_xy = xy_to_uv.inverse() 

sage: e_xy = c_xy.frame(); e_uv = c_uv.frame() 

sage: a = M.tensor_field(1, 1, name='a') 

sage: a[e_xy,:] = [[x, 1], [y, 0]] 

sage: a.add_comp_by_continuation(e_uv, U.intersection(V), c_uv) 

sage: b = M.tensor_field(1, 1, name='b') 

sage: b[e_xy,:] = [[2, y], [x, -x]] 

sage: b.add_comp_by_continuation(e_uv, U.intersection(V), c_uv) 

sage: s = a._add_(b); s 

Tensor field a+b of type (1,1) on the 2-dimensional differentiable 

manifold M 

sage: a.display(e_xy) 

a = x d/dx*dx + d/dx*dy + y d/dy*dx 

sage: b.display(e_xy) 

b = 2 d/dx*dx + y d/dx*dy + x d/dy*dx - x d/dy*dy 

sage: s.display(e_xy) 

a+b = (x + 2) d/dx*dx + (y + 1) d/dx*dy + (x + y) d/dy*dx - x d/dy*dy 

sage: s == a + b # indirect doctest 

True 

sage: z = a.parent().zero(); z 

Tensor field zero of type (1,1) on the 2-dimensional differentiable 

manifold M 

sage: a._add_(z) == a 

True 

sage: z._add_(a) == a 

True 

 

""" 

resu_rst = {} 

for dom in self._common_subdomains(other): 

resu_rst[dom] = self._restrictions[dom] + other._restrictions[dom] 

some_rst = next(itervalues(resu_rst)) 

resu_sym = some_rst._sym 

resu_antisym = some_rst._antisym 

resu = self._vmodule.tensor(self._tensor_type, sym=resu_sym, 

antisym=resu_antisym) 

resu._restrictions = resu_rst 

if self._name is not None and other._name is not None: 

resu._name = self._name + '+' + other._name 

if self._latex_name is not None and other._latex_name is not None: 

resu._latex_name = self._latex_name + '+' + other._latex_name 

return resu 

 

def _sub_(self, other): 

r""" 

Tensor field subtraction. 

 

INPUT: 

 

- ``other`` -- a tensor field, in the same tensor module as ``self`` 

 

OUTPUT: 

 

- the tensor field resulting from the subtraction of ``other`` 

from ``self`` 

 

TESTS:: 

 

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

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

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

sage: c_xy.<x,y> = U.chart() ; c_uv.<u,v> = V.chart() 

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

....: intersection_name='W', restrictions1= x>0, 

....: restrictions2= u+v>0) 

sage: uv_to_xy = xy_to_uv.inverse() 

sage: e_xy = c_xy.frame(); e_uv = c_uv.frame() 

sage: a = M.tensor_field(1, 1, name='a') 

sage: a[e_xy,:] = [[x, 1], [y, 0]] 

sage: a.add_comp_by_continuation(e_uv, U.intersection(V), c_uv) 

sage: b = M.tensor_field(1, 1, name='b') 

sage: b[e_xy,:] = [[2, y], [x, -x]] 

sage: b.add_comp_by_continuation(e_uv, U.intersection(V), c_uv) 

sage: s = a._sub_(b); s 

Tensor field a-b of type (1,1) on the 2-dimensional differentiable 

manifold M 

sage: a.display(e_xy) 

a = x d/dx*dx + d/dx*dy + y d/dy*dx 

sage: b.display(e_xy) 

b = 2 d/dx*dx + y d/dx*dy + x d/dy*dx - x d/dy*dy 

sage: s.display(e_xy) 

a-b = (x - 2) d/dx*dx + (-y + 1) d/dx*dy + (-x + y) d/dy*dx + x d/dy*dy 

sage: s == a - b 

True 

sage: z = a.parent().zero() 

sage: a._sub_(z) == a 

True 

sage: z._sub_(a) == -a 

True 

 

""" 

resu_rst = {} 

for dom in self._common_subdomains(other): 

resu_rst[dom] = self._restrictions[dom] - other._restrictions[dom] 

some_rst = next(itervalues(resu_rst)) 

resu_sym = some_rst._sym 

resu_antisym = some_rst._antisym 

resu = self._vmodule.tensor(self._tensor_type, sym=resu_sym, 

antisym=resu_antisym) 

resu._restrictions = resu_rst 

if self._name is not None and other._name is not None: 

resu._name = self._name + '-' + other._name 

if self._latex_name is not None and other._latex_name is not None: 

resu._latex_name = self._latex_name + '-' + other._latex_name 

return resu 

 

def _rmul_(self, scalar): 

r""" 

Reflected multiplication operator: performs ``scalar * self`` 

 

This is actually the multiplication by an element of the ring over 

which the tensor field module is constructed. 

 

INPUT: 

 

- ``scalar`` -- scalar field in the scalar field algebra over which 

the module containing ``self`` is defined 

 

OUTPUT: 

 

- the tensor field ``scalar * self`` 

 

TESTS:: 

 

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

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

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

sage: c_xy.<x,y> = U.chart() ; c_uv.<u,v> = V.chart() 

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

....: intersection_name='W', restrictions1= x>0, 

....: restrictions2= u+v>0) 

sage: uv_to_xy = xy_to_uv.inverse() 

sage: e_xy = c_xy.frame(); e_uv = c_uv.frame() 

sage: a = M.tensor_field(1, 1, name='a') 

sage: a[e_xy,:] = [[x, 1], [y, 0]] 

sage: a.add_comp_by_continuation(e_uv, U.intersection(V), c_uv) 

sage: f = M.scalar_field({c_xy: 1/(1+x^2+y^2)}, name='f') 

sage: f.add_expr_by_continuation(c_uv, U.intersection(V)) 

sage: f.display() 

f: M --> R 

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

on V: (u, v) |--> 2/(u^2 + v^2 + 2) 

sage: s = a._rmul_(f); s 

Tensor field of type (1,1) on the 2-dimensional differentiable 

manifold M 

sage: a.display(e_xy) 

a = x d/dx*dx + d/dx*dy + y d/dy*dx 

sage: s.display(e_xy) 

x/(x^2 + y^2 + 1) d/dx*dx + 1/(x^2 + y^2 + 1) d/dx*dy + y/(x^2 + y^2 + 1) d/dy*dx 

sage: a.display(e_uv) 

a = (1/2*u + 1/2) d/du*du + (1/2*u - 1/2) d/du*dv + (1/2*v + 1/2) d/dv*du + (1/2*v - 1/2) d/dv*dv 

sage: s.display(e_uv) 

(u + 1)/(u^2 + v^2 + 2) d/du*du + (u - 1)/(u^2 + v^2 + 2) d/du*dv + (v + 1)/(u^2 + v^2 + 2) d/dv*du + (v - 1)/(u^2 + v^2 + 2) d/dv*dv 

sage: s == f*a # indirect doctest 

True 

sage: z = a.parent().zero(); z 

Tensor field zero of type (1,1) on the 2-dimensional differentiable 

manifold M 

sage: a._rmul_(M.zero_scalar_field()) == z 

True 

sage: z._rmul_(f) == z 

True 

 

""" 

resu = self._new_instance() 

for dom, rst in self._restrictions.items(): 

resu._restrictions[dom] = scalar.restrict(dom) * rst 

return resu 

 

######### End of ModuleElement arithmetic operators ######## 

 

# TODO: Move to acted_upon or _rmul_ 

def __mul__(self, other): 

r""" 

Tensor product (or multiplication of the right by a scalar). 

 

INPUT: 

 

- ``other`` -- tensor field on the same manifold as ``self`` (or an 

object that can be coerced to a scalar field on the same manifold 

as ``self``) 

 

OUTPUT: 

 

- the tensor field resulting from the tensor product of ``self`` 

with ``other`` (or from the product ``other * self`` if ``other`` 

is a scalar) 

 

TESTS:: 

 

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

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

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

sage: c_xy.<x,y> = U.chart() ; c_uv.<u,v> = V.chart() 

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

....: intersection_name='W', restrictions1= x>0, 

....: restrictions2= u+v>0) 

sage: uv_to_xy = xy_to_uv.inverse() 

sage: e_xy = c_xy.frame(); e_uv = c_uv.frame() 

sage: a = M.tensor_field(1, 1, name='a') 

sage: a[e_xy,:] = [[x, 1], [y, 0]] 

sage: a.add_comp_by_continuation(e_uv, U.intersection(V), c_uv) 

 

Tensor product with another tensor field:: 

 

sage: b = M.vector_field(name='b') 

sage: b[e_xy, :] = [x, y] 

sage: b.add_comp_by_continuation(e_uv, U.intersection(V), c_uv) 

sage: s = a.__mul__(b); s 

Tensor field of type (2,1) on the 2-dimensional differentiable 

manifold M 

sage: s.display(e_xy) 

a*b = x^2 d/dx*d/dx*dx + x d/dx*d/dx*dy + x*y d/dx*d/dy*dx 

+ y d/dx*d/dy*dy + x*y d/dy*d/dx*dx + y^2 d/dy*d/dy*dx 

sage: s.display(e_uv) 

a*b = (1/2*u^2 + 1/2*u) d/du*d/du*du + (1/2*u^2 - 1/2*u) d/du*d/du*dv 

+ 1/2*(u + 1)*v d/du*d/dv*du + 1/2*(u - 1)*v d/du*d/dv*dv 

+ (1/2*u*v + 1/2*u) d/dv*d/du*du + (1/2*u*v - 1/2*u) d/dv*d/du*dv 

+ (1/2*v^2 + 1/2*v) d/dv*d/dv*du + (1/2*v^2 - 1/2*v) d/dv*d/dv*dv 

 

Multiplication on the right by a scalar field:: 

 

sage: f = M.scalar_field({c_xy: x*y}, name='f') 

sage: f.add_expr_by_continuation(c_uv, U.intersection(V)) 

sage: s = a.__mul__(f); s 

Tensor field of type (1,1) on the 2-dimensional differentiable 

manifold M 

sage: s.display(e_xy) 

x^2*y d/dx*dx + x*y d/dx*dy + x*y^2 d/dy*dx 

sage: s.display(e_uv) 

(1/8*u^3 - 1/8*(u + 1)*v^2 + 1/8*u^2) d/du*du 

+ (1/8*u^3 - 1/8*(u - 1)*v^2 - 1/8*u^2) d/du*dv 

+ (1/8*u^2*v - 1/8*v^3 + 1/8*u^2 - 1/8*v^2) d/dv*du 

+ (1/8*u^2*v - 1/8*v^3 - 1/8*u^2 + 1/8*v^2) d/dv*dv 

sage: s == f*a 

True 

 

Multiplication on the right by a number:: 

 

sage: s = a.__mul__(2); s 

Tensor field of type (1,1) on the 2-dimensional differentiable 

manifold M 

sage: s.display(e_xy) 

2*x d/dx*dx + 2 d/dx*dy + 2*y d/dy*dx 

sage: s.display(e_uv) 

(u + 1) d/du*du + (u - 1) d/du*dv + (v + 1) d/dv*du 

+ (v - 1) d/dv*dv 

sage: s.restrict(U) == 2*a.restrict(U) 

True 

sage: s.restrict(V) == 2*a.restrict(V) 

True 

sage: s == 2*a 

True 

 

Test with SymPy as calculus engine:: 

 

sage: M.set_calculus_method('sympy') 

sage: f.add_expr_by_continuation(c_uv, U.intersection(V)) 

sage: s = a.__mul__(f); s 

Tensor field of type (1,1) on the 2-dimensional differentiable 

manifold M 

sage: s.display(e_xy) 

x**2*y d/dx*dx + x*y d/dx*dy + x*y**2 d/dy*dx 

sage: s.display(e_uv) 

(u**3/8 + u**2/8 - u*v**2/8 - v**2/8) d/du*du + (u**3/8 - 

u**2/8 - u*v**2/8 + v**2/8) d/du*dv + (u**2*v/8 + u**2/8 - 

v**3/8 - v**2/8) d/dv*du + (u**2*v/8 - u**2/8 - v**3/8 + 

v**2/8) d/dv*dv 

sage: s == f*a 

True 

 

""" 

if not isinstance(other, TensorField): 

# Multiplication by a scalar field or a number 

return other * self 

# Tensor product: 

dom_resu = self._domain.intersection(other._domain) 

ambient_dom_resu = self._ambient_domain.intersection(other._ambient_domain) 

self_r = self.restrict(dom_resu) 

other_r = other.restrict(dom_resu) 

if ambient_dom_resu.is_manifestly_parallelizable(): 

# call of the FreeModuleTensor version: 

return FreeModuleTensor.__mul__(self_r, other_r) 

dest_map = self._vmodule._dest_map 

dest_map_resu = dest_map.restrict(dom_resu, subcodomain=ambient_dom_resu) 

vmodule = dom_resu.vector_field_module(dest_map=dest_map_resu) 

com_dom = [] 

for dom in self_r._restrictions: 

if dom in other_r._restrictions: 

com_dom.append(dom) 

resu_rst = [] 

for dom in com_dom: 

self_rr = self_r._restrictions[dom] 

other_rr = other_r._restrictions[dom] 

resu_rst.append(self_rr * other_rr) 

k1, l1 = self._tensor_type 

k2, l2 = other._tensor_type 

resu = vmodule.tensor((k1+k2, l1+l2), 

sym=resu_rst[0]._sym, 

antisym=resu_rst[0]._antisym) 

for rst in resu_rst: 

resu._restrictions[rst._domain] = rst 

return resu 

 

def __truediv__(self, scalar): 

r""" 

Division by a scalar field. 

 

INPUT: 

 

- ``scalar`` -- scalar field in the scalar field algebra over which 

the module containing ``self`` is defined 

 

OUTPUT: 

 

- the tensor field ``scalar * self`` 

 

TESTS:: 

 

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

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

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

sage: c_xy.<x,y> = U.chart() ; c_uv.<u,v> = V.chart() 

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

....: intersection_name='W', restrictions1= x>0, 

....: restrictions2= u+v>0) 

sage: uv_to_xy = xy_to_uv.inverse() 

sage: e_xy = c_xy.frame(); e_uv = c_uv.frame() 

sage: a = M.tensor_field(1, 1, name='a') 

sage: a[e_xy,:] = [[x, 1], [y, 0]] 

sage: a.add_comp_by_continuation(e_uv, U.intersection(V), c_uv) 

sage: f = M.scalar_field({c_xy: 1/(1+x^2+y^2)}, name='f') 

sage: f.add_expr_by_continuation(c_uv, U.intersection(V)) 

sage: f.display() 

f: M --> R 

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

on V: (u, v) |--> 2/(u^2 + v^2 + 2) 

sage: s = a.__div__(f); s 

Tensor field of type (1,1) on the 2-dimensional differentiable 

manifold M 

sage: s.display(e_xy) 

(x^3 + x*y^2 + x) d/dx*dx + (x^2 + y^2 + 1) d/dx*dy 

+ (y^3 + (x^2 + 1)*y) d/dy*dx 

sage: f*s == a 

True 

 

Division by a number:: 

 

sage: s = a.__div__(2); s 

Tensor field of type (1,1) on the 2-dimensional differentiable 

manifold M 

sage: s.display(e_xy) 

1/2*x d/dx*dx + 1/2 d/dx*dy + 1/2*y d/dy*dx 

sage: s.display(e_uv) 

(1/4*u + 1/4) d/du*du + (1/4*u - 1/4) d/du*dv 

+ (1/4*v + 1/4) d/dv*du + (1/4*v - 1/4) d/dv*dv 

sage: s == a/2 

True 

sage: 2*s == a 

True 

 

""" 

resu = self._new_instance() 

for dom, rst in self._restrictions.items(): 

resu._restrictions[dom] = rst / scalar 

return resu 

 

__div__ = __truediv__ 

 

def __call__(self, *args): 

r""" 

The tensor field acting on 1-forms and vector fields as a 

multilinear map. 

 

In the particular case of tensor field of type `(1,1)`, the action can 

be on a single vector field, the tensor field being identified to a 

field of tangent-space endomorphisms. The output is then a vector 

field. 

 

INPUT: 

 

- ``*args`` -- list of `k` 1-forms and `l` vector fields, ``self`` 

being a tensor of type `(k,l)` 

 

OUTPUT: 

 

- either the scalar field resulting from the action of ``self`` on 

the 1-forms and vector fields passed as arguments or the vector 

field resulting from the action of ``self`` as a field of 

tangent-space endomorphisms (case of a type-(1,1) tensor field) 

 

TESTS: 

 

Action of a tensor field of type `(1,1)` on the 2-sphere:: 

 

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

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

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

sage: c_xy.<x,y> = U.chart() ; c_uv.<u,v> = V.chart() 

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

....: intersection_name='W', restrictions1= x>0, 

....: restrictions2= u+v>0) 

sage: uv_to_xy = xy_to_uv.inverse() 

sage: e_xy = c_xy.frame(); e_uv = c_uv.frame() 

sage: t = M.tensor_field(1,1, name='t') 

sage: t[e_xy,:] = [[x, 1], [y, 0]] 

sage: t.add_comp_by_continuation(e_uv, U.intersection(V), c_uv) 

sage: w = M.vector_field(name='w') 

sage: w[e_xy,:] = [y^2, x^2] 

sage: w.add_comp_by_continuation(e_uv, U.intersection(V), c_uv) 

sage: a = M.one_form(name='a') 

sage: a[e_xy,:] = [-1+y, x*y] 

sage: a.add_comp_by_continuation(e_uv, U.intersection(V), c_uv) 

 

The tensor field acting on a pair (1-form, vector field):: 

 

sage: s = t.__call__(a,w); s 

Scalar field t(a,w) on the 2-dimensional differentiable manifold M 

sage: s.display() 

t(a,w): M --> R 

on U: (x, y) |--> x*y^4 + x*y^3 + x^2*y - x*y^2 - x^2 

on V: (u, v) |--> 1/32*u^5 - 1/32*(3*u + 2)*v^4 + 1/32*v^5 

+ 1/16*u^4 + 1/16*(u^2 + 2*u - 4)*v^3 + 1/16*(u^3 - 4)*v^2 

- 1/4*u^2 - 1/32*(3*u^4 + 4*u^3 - 8*u^2 + 16*u)*v 

sage: s.restrict(U) == t.restrict(U)(a.restrict(U), w.restrict(U)) 

True 

sage: s.restrict(V) == t.restrict(V)(a.restrict(V), w.restrict(V)) 

True 

 

The tensor field acting on vector field, as a field of tangent-space 

endomorphisms:: 

 

sage: s = t.__call__(w); s 

Vector field t(w) on the 2-dimensional differentiable manifold M 

sage: s.display(e_xy) 

t(w) = (x*y^2 + x^2) d/dx + y^3 d/dy 

sage: s.display(e_uv) 

t(w) = (1/4*u^3 + 1/4*(u + 1)*v^2 + 1/4*u^2 - 1/2*(u^2 - u)*v) d/du 

+ (-1/4*(2*u - 1)*v^2 + 1/4*v^3 + 1/4*u^2 + 1/4*(u^2 + 2*u)*v) d/dv 

sage: s.restrict(U) == t.restrict(U)(w.restrict(U)) 

True 

sage: s.restrict(V) == t.restrict(V)(w.restrict(V)) 

True 

 

""" 

p = len(args) 

if p == 1 and self._tensor_type == (1,1): 

# type-(1,1) tensor acting as a a field of tangent-space 

# endomorphisms: 

vector = args[0] 

if vector._tensor_type != (1,0): 

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

dom_resu = self._domain.intersection(vector._domain) 

if dom_resu.is_manifestly_parallelizable(): 

# call of the TensorFieldParal version: 

return self.restrict(dom_resu)(vector.restrict(dom_resu)) 

if self._name is not None and vector._name is not None: 

name_resu = "{}({})".format(self._name, vector._name) 

else: 

name_resu = None 

if self._latex_name is not None and vector._latex_name is not None: 

latex_name_resu = r"{}\left({}\right)".format(self._latex_name, 

vector._latex_name) 

else: 

latex_name_resu = None 

dest_map = vector._vmodule._dest_map 

dest_map_resu = dest_map.restrict(dom_resu) 

resu = dom_resu.vector_field(name=name_resu, 

latex_name=latex_name_resu, 

dest_map=dest_map_resu) 

for dom in self._common_subdomains(vector): 

if dom.is_subset(dom_resu): 

resu._restrictions[dom] = \ 

self._restrictions[dom](vector._restrictions[dom]) 

return resu 

# Generic case 

if p != self._tensor_rank: 

raise TypeError("{} arguments must be ".format(self._tensor_rank) + 

"provided") 

# Domain of the result 

dom_resu = self._domain 

ambient_dom = self._ambient_domain 

for arg in args: 

dom_resu = dom_resu.intersection(arg._domain) 

ambient_dom = ambient_dom.intersection(arg._ambient_domain) 

self_r = self.restrict(dom_resu) 

args_r = [args[i].restrict(dom_resu) for i in range(p)] 

if ambient_dom.is_manifestly_parallelizable(): 

# TensorFieldParal version 

return self_r(*args_r) 

else: 

resu = dom_resu.scalar_field() 

com_dom = [] 

for dom in self_r._restrictions: 

for arg in args_r: 

if dom not in arg._restrictions: 

break 

else: 

com_dom.append(dom) 

for dom in com_dom: 

self_rr = self_r._restrictions[dom] 

args_rr = [args_r[i]._restrictions[dom] for i in range(p)] 

resu_rr = self_rr(*args_rr) 

if resu_rr.is_trivial_zero(): 

for chart in resu_rr._domain._atlas: 

resu._express[chart] = chart.zero_function() 

else: 

for chart, expr in resu_rr._express.items(): 

resu._express[chart] = expr 

if resu.is_trivial_zero(): 

return dom_resu._zero_scalar_field 

# Name of the output: 

res_name = None 

if self._name is not None: 

res_name = self._name + "(" 

for i in range(p-1): 

if args[i]._name is not None: 

res_name += args[i]._name + "," 

else: 

res_name = None 

break 

if res_name is not None: 

if args[p-1]._name is not None: 

res_name += args[p-1]._name + ")" 

else: 

res_name = None 

resu._name = res_name 

# LaTeX symbol of the output: 

res_latex = None 

if self._latex_name is not None: 

res_latex = self._latex_name + r"\left(" 

for i in range(p-1): 

if args[i]._latex_name is not None: 

res_latex += args[i]._latex_name + "," 

else: 

res_latex = None 

break 

if res_latex is not None: 

if args[p-1]._latex_name is not None: 

res_latex += args[p-1]._latex_name + r"\right)" 

else: 

res_latex = None 

resu._latex_name = res_latex 

return resu 

 

def trace(self, pos1=0, pos2=1): 

r""" 

Trace (contraction) on two slots of the tensor field. 

 

INPUT: 

 

- ``pos1`` -- (default: 0) position of the first index for the 

contraction, with the convention ``pos1=0`` for the first slot 

- ``pos2`` -- (default: 1) position of the second index for the 

contraction, with the same convention as for ``pos1``. The variance 

type of ``pos2`` must be opposite to that of ``pos1`` 

 

OUTPUT: 

 

- tensor field resulting from the ``(pos1, pos2)`` contraction 

 

EXAMPLES: 

 

Trace of a type-`(1,1)` tensor field on a 2-dimensional 

non-parallelizable manifold:: 

 

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

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

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

sage: c_xy.<x,y> = U.chart() ; c_uv.<u,v> = V.chart() 

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

....: intersection_name='W', restrictions1= x>0, 

....: restrictions2= u+v>0) 

sage: uv_to_xy = xy_to_uv.inverse() 

sage: e_xy = c_xy.frame(); e_uv = c_uv.frame() 

sage: W = U.intersection(V) 

sage: a = M.tensor_field(1,1, name='a') 

sage: a[e_xy,:] = [[1,x], [2,y]] 

sage: a.add_comp_by_continuation(e_uv, W, chart=c_uv) 

sage: s = a.trace() ; s 

Scalar field on the 2-dimensional differentiable manifold M 

sage: s.display() 

M --> R 

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

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

sage: s == a.trace(0,1) # explicit mention of the positions 

True 

 

Instead of the explicit call to the method :meth:`trace`, one 

may use the index notation with Einstein convention (summation over 

repeated indices); it suffices to pass the indices as a string inside 

square brackets:: 

 

sage: a['^i_i'] 

Scalar field on the 2-dimensional differentiable manifold M 

sage: a['^i_i'] == s 

True 

 

Any letter can be used to denote the repeated index:: 

 

sage: a['^b_b'] == s 

True 

 

Trace of a type-`(1,2)` tensor field:: 

 

sage: b = M.tensor_field(1,2, name='b') ; b 

Tensor field b of type (1,2) on the 2-dimensional differentiable 

manifold M 

sage: b[e_xy,:] = [[[0,x+y], [y,0]], [[0,2], [3*x,-2]]] 

sage: b.add_comp_by_continuation(e_uv, W, chart=c_uv) # long time 

sage: s = b.trace(0,1) ; s # contraction on first and second slots 

1-form on the 2-dimensional differentiable manifold M 

sage: s.display(e_xy) 

3*x dx + (x + y - 2) dy 

sage: s.display(e_uv) # long time 

(5/4*u + 3/4*v - 1) du + (1/4*u + 3/4*v + 1) dv 

 

Use of the index notation:: 

 

sage: b['^k_ki'] 

1-form on the 2-dimensional differentiable manifold M 

sage: b['^k_ki'] == s # long time 

True 

 

Indices not involved in the contraction may be replaced by dots:: 

 

sage: b['^k_k.'] == s # long time 

True 

 

The symbol ``^`` may be omitted:: 

 

sage: b['k_k.'] == s # long time 

True 

 

LaTeX notations are allowed:: 

 

sage: b['^{k}_{ki}'] == s # long time 

True 

 

Contraction on first and third slots:: 

 

sage: s = b.trace(0,2) ; s 

1-form on the 2-dimensional differentiable manifold M 

sage: s.display(e_xy) 

2 dx + (y - 2) dy 

sage: s.display(e_uv) # long time 

(1/4*u - 1/4*v) du + (-1/4*u + 1/4*v + 2) dv 

 

Use of index notation:: 

 

sage: b['^k_.k'] == s # long time 

True 

 

""" 

# The indices at pos1 and pos2 must be of different types: 

k_con = self._tensor_type[0] 

l_cov = self._tensor_type[1] 

if pos1 < k_con and pos2 < k_con: 

raise IndexError("contraction on two contravariant indices is " + 

"not allowed") 

if pos1 >= k_con and pos2 >= k_con: 

raise IndexError("contraction on two covariant indices is " + 

"not allowed") 

resu_rst = [] 

for rst in self._restrictions.values(): 

resu_rst.append(rst.trace(pos1, pos2)) 

if (k_con, l_cov) == (1,1): 

# scalar field result 

resu = self._domain.scalar_field() 

all_zero = True 

for rst in resu_rst: 

if rst == 0: 

for chart in rst._domain._atlas: 

resu._express[chart] = 0 

else: 

all_zero = False 

for chart, funct in rst._express.items(): 

resu._express[chart] = funct 

if all_zero: 

resu = self._domain._zero_scalar_field 

else: 

# tensor field result 

resu = self._vmodule.tensor((k_con-1, l_cov-1), 

sym=resu_rst[0]._sym, antisym=resu_rst[0]._antisym) 

for rst in resu_rst: 

resu._restrictions[rst._domain] = rst 

return resu 

 

def contract(self, *args): 

r""" 

Contraction of ``self`` with another tensor field on one or 

more indices. 

 

INPUT: 

 

- ``pos1`` -- positions of the indices in the current tensor field 

involved in the contraction; ``pos1`` must be a sequence of integers, 

with 0 standing for the first index position, 1 for the second one, 

etc.; if ``pos1`` is not provided, a single contraction on the last 

index position of the tensor field is assumed 

- ``other`` -- the tensor field to contract with 

- ``pos2`` -- positions of the indices in ``other`` involved in the 

contraction, with the same conventions as for ``pos1``; if ``pos2`` 

is not provided, a single contraction on the first index position of 

``other`` is assumed 

 

OUTPUT: 

 

- tensor field resulting from the contraction at the positions 

``pos1`` and ``pos2`` of the tensor field with ``other`` 

 

EXAMPLES: 

 

Contractions of a type-`(1,1)` tensor field with a type-`(2,0)` 

one on a 2-dimensional non-parallelizable manifold:: 

 

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

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

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

sage: c_xy.<x,y> = U.chart() ; c_uv.<u,v> = V.chart() 

sage: transf = c_xy.transition_map(c_uv, (x+y, x-y), intersection_name='W', 

....: restrictions1= x>0, restrictions2= u+v>0) 

sage: inv = transf.inverse() 

sage: W = U.intersection(V) 

sage: eU = c_xy.frame() ; eV = c_uv.frame() 

sage: a = M.tensor_field(1,1, name='a') 

sage: a[eU,:] = [[1,x], [0,2]] 

sage: a.add_comp_by_continuation(eV, W, chart=c_uv) 

sage: b = M.tensor_field(2,0, name='b') 

sage: b[eU,:] = [[y,-1], [x+y,2]] 

sage: b.add_comp_by_continuation(eV, W, chart=c_uv) 

sage: s = a.contract(b) ; s # contraction on last index of a and first one of b 

Tensor field of type (2,0) on the 2-dimensional differentiable 

manifold M 

 

Check 1: components with respect to the manifold's default 

frame (``eU``):: 

 

sage: [[bool(s[i,j] == sum(a[i,k]*b[k,j] for k in M.irange())) 

....: for j in M.irange()] for i in M.irange()] 

[[True, True], [True, True]] 

 

Check 2: components with respect to the frame ``eV``:: 

 

sage: [[bool(s[eV,i,j] == sum(a[eV,i,k]*b[eV,k,j] 

....: for k in M.irange())) 

....: for j in M.irange()] for i in M.irange()] 

[[True, True], [True, True]] 

 

Instead of the explicit call to the method :meth:`contract`, one 

may use the index notation with Einstein convention (summation over 

repeated indices); it suffices to pass the indices as a string inside 

square brackets:: 

 

sage: a['^i_k']*b['^kj'] == s 

True 

 

Indices not involved in the contraction may be replaced by dots:: 

 

sage: a['^._k']*b['^k.'] == s 

True 

 

LaTeX notation may be used:: 

 

sage: a['^{i}_{k}']*b['^{kj}'] == s 

True 

 

Contraction on the last index of ``a`` and last index of ``b``:: 

 

sage: s = a.contract(b, 1) ; s 

Tensor field of type (2,0) on the 2-dimensional differentiable 

manifold M 

sage: a['^i_k']*b['^jk'] == s 

True 

 

Contraction on the first index of ``b`` and the last index of ``a``:: 

 

sage: s = b.contract(0,a,1) ; s 

Tensor field of type (2,0) on the 2-dimensional differentiable 

manifold M 

sage: b['^ki']*a['^j_k'] == s 

True 

 

The domain of the result is the intersection of the domains of 

the two tensor fields:: 

 

sage: aU = a.restrict(U) ; bV = b.restrict(V) 

sage: s = aU.contract(b) ; s 

Tensor field of type (2,0) on the Open subset U of the 

2-dimensional differentiable manifold M 

sage: s = a.contract(bV) ; s 

Tensor field of type (2,0) on the Open subset V of the 

2-dimensional differentiable manifold M 

sage: s = aU.contract(bV) ; s 

Tensor field of type (2,0) on the Open subset W of the 

2-dimensional differentiable manifold M 

sage: s0 = a.contract(b) 

sage: s == s0.restrict(W) 

True 

 

The contraction can be performed on more than one index: ``c`` being a 

type-`(2,2)` tensor, contracting the indices in positions 2 and 3 

of ``c`` with respectively those in positions 0 and 1 of ``b`` is:: 

 

sage: c = a*a ; c 

Tensor field of type (2,2) on the 2-dimensional differentiable 

manifold M 

sage: s = c.contract(2,3, b, 0,1) ; s # long time 

Tensor field of type (2,0) on the 2-dimensional differentiable 

manifold M 

sage: s == c['^.._kl']*b['^kl'] # the same double contraction in index notation; long time 

True 

 

The symmetries are either conserved or destroyed by the contraction:: 

 

sage: c = c.symmetrize(0,1).antisymmetrize(2,3) 

sage: c.symmetries() 

symmetry: (0, 1); antisymmetry: (2, 3) 

sage: s = b.contract(0, c, 2) ; s 

Tensor field of type (3,1) on the 2-dimensional differentiable 

manifold M 

sage: s.symmetries() 

symmetry: (1, 2); no antisymmetry 

 

Case of a scalar field result:: 

 

sage: a = M.one_form('a') 

sage: a[eU,:] = [y, 1+x] 

sage: a.add_comp_by_continuation(eV, W, chart=c_uv) 

sage: b = M.vector_field('b') 

sage: b[eU,:] = [x, y^2] 

sage: b.add_comp_by_continuation(eV, W, chart=c_uv) 

sage: a.display(eU) 

a = y dx + (x + 1) dy 

sage: b.display(eU) 

b = x d/dx + y^2 d/dy 

sage: s = a.contract(b) ; s 

Scalar field on the 2-dimensional differentiable manifold M 

sage: s.display() 

M --> R 

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

on V: (u, v) |--> 1/8*u^3 - 1/8*u*v^2 + 1/8*v^3 + 1/2*u^2 - 1/8*(u^2 + 4*u)*v 

sage: s == a['_i']*b['^i'] # use of index notation 

True 

sage: s == b.contract(a) 

True 

 

Case of a vanishing scalar field result:: 

 

sage: b = M.vector_field('b') 

sage: b[eU,:] = [1+x, -y] 

sage: b.add_comp_by_continuation(eV, W, chart=c_uv) 

sage: s = a.contract(b) ; s 

Scalar field zero on the 2-dimensional differentiable manifold M 

sage: s.display() 

zero: M --> R 

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

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

 

""" 

nargs = len(args) 

for i, arg in enumerate(args): 

if isinstance(arg, TensorField): 

other = arg 

it = i 

break 

else: 

raise TypeError("a tensor field must be provided in the " + 

"argument list") 

if it == 0: 

pos1 = (self._tensor_rank - 1,) 

else: 

pos1 = args[:it] 

if it == nargs-1: 

pos2 = (0,) 

else: 

pos2 = args[it+1:] 

ncontr = len(pos1) # number of contractions 

if len(pos2) != ncontr: 

raise IndexError("different number of indices for the contraction") 

if self._domain.is_subset(other._domain): 

if not self._ambient_domain.is_subset(other._ambient_domain): 

raise ValueError("incompatible ambient domains for contraction") 

elif other._domain.is_subset(self._domain): 

if not other._ambient_domain.is_subset(self._ambient_domain): 

raise ValueError("incompatible ambient domains for contraction") 

dom_resu = self._domain.intersection(other._domain) 

ambient_dom_resu = self._ambient_domain.intersection(other._ambient_domain) 

self_r = self.restrict(dom_resu) 

other_r = other.restrict(dom_resu) 

k1, l1 = self._tensor_type 

k2, l2 = other._tensor_type 

tensor_type_resu = (k1 + k2 - ncontr, l1 + l2 - ncontr) 

if ambient_dom_resu.is_manifestly_parallelizable(): 

# call of the FreeModuleTensor version: 

args = pos1 + (other_r,) + pos2 

return FreeModuleTensor.contract(self_r, *args) 

com_dom = [] 

for dom in self_r._restrictions: 

if dom in other_r._restrictions: 

com_dom.append(dom) 

resu_rst = [] 

for dom in com_dom: 

self_rr = self_r._restrictions[dom] 

other_rr = other_r._restrictions[dom] 

args = pos1 + (other_rr,) + pos2 

resu_rst.append(self_rr.contract(*args)) 

if tensor_type_resu == (0,0): 

# scalar field result 

resu = dom_resu.scalar_field() 

all_zero = True 

for rst in resu_rst: 

if rst == 0: 

for chart in rst._domain._atlas: 

resu._express[chart] = 0 

else: 

all_zero = False 

for chart, funct in rst._express.items(): 

resu._express[chart] = funct 

if all_zero: 

resu = dom_resu._zero_scalar_field 

else: 

# tensor field result 

dest_map = self._vmodule._dest_map 

dest_map_resu = dest_map.restrict(dom_resu, 

subcodomain=ambient_dom_resu) 

vmodule = dom_resu.vector_field_module(dest_map=dest_map_resu) 

 

resu = vmodule.tensor(tensor_type_resu, sym=resu_rst[0]._sym, 

antisym=resu_rst[0]._antisym) 

for rst in resu_rst: 

resu._restrictions[rst._domain] = rst 

return resu 

 

def symmetrize(self, *pos): 

r""" 

Symmetrization over some arguments. 

 

INPUT: 

 

- ``pos`` -- (default: ``None``) list of argument positions involved 

in the symmetrization (with the convention ``position=0`` for the 

first argument); if ``None``, the symmetrization is performed 

over all the arguments 

 

OUTPUT: 

 

- the symmetrized tensor field (instance of :class:`TensorField`) 

 

EXAMPLES: 

 

Symmetrization of a type-`(0,2)` tensor field on a 2-dimensional 

non-parallelizable manifold:: 

 

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

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

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

sage: c_xy.<x,y> = U.chart() ; c_uv.<u,v> = V.chart() 

sage: transf = c_xy.transition_map(c_uv, (x+y, x-y), intersection_name='W', 

....: restrictions1= x>0, restrictions2= u+v>0) 

sage: inv = transf.inverse() 

sage: W = U.intersection(V) 

sage: eU = c_xy.frame() ; eV = c_uv.frame() 

sage: a = M.tensor_field(0,2, name='a') 

sage: a[eU,:] = [[1,x], [2,y]] 

sage: a.add_comp_by_continuation(eV, W, chart=c_uv) 

sage: a[eV,:] 

[ 1/4*u + 3/4 -1/4*u + 3/4] 

[ 1/4*v - 1/4 -1/4*v - 1/4] 

sage: s = a.symmetrize() ; s 

Field of symmetric bilinear forms on the 2-dimensional 

differentiable manifold M 

sage: s[eU,:] 

[ 1 1/2*x + 1] 

[1/2*x + 1 y] 

sage: s[eV,:] 

[ 1/4*u + 3/4 -1/8*u + 1/8*v + 1/4] 

[-1/8*u + 1/8*v + 1/4 -1/4*v - 1/4] 

sage: s == a.symmetrize(0,1) # explicit positions 

True 

 

.. SEEALSO:: 

 

For more details and examples, see 

:meth:`sage.tensor.modules.free_module_tensor.FreeModuleTensor.symmetrize`. 

 

""" 

resu_rst = [] 

for rst in self._restrictions.values(): 

resu_rst.append(rst.symmetrize(*pos)) 

resu = self._vmodule.tensor(self._tensor_type, sym=resu_rst[0]._sym, 

antisym=resu_rst[0]._antisym) 

for rst in resu_rst: 

resu._restrictions[rst._domain] = rst 

return resu 

 

def antisymmetrize(self, *pos): 

r""" 

Antisymmetrization over some arguments. 

 

INPUT: 

 

- ``pos`` -- (default: ``None``) list of argument positions involved 

in the antisymmetrization (with the convention ``position=0`` for 

the first argument); if ``None``, the antisymmetrization is 

performed over all the arguments 

 

OUTPUT: 

 

- the antisymmetrized tensor field (instance of :class:`TensorField`) 

 

EXAMPLES: 

 

Antisymmetrization of a type-`(0,2)` tensor field on a 2-dimensional 

non-parallelizable manifold:: 

 

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

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

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

sage: c_xy.<x,y> = U.chart() ; c_uv.<u,v> = V.chart() 

sage: transf = c_xy.transition_map(c_uv, (x+y, x-y), intersection_name='W', 

....: restrictions1= x>0, restrictions2= u+v>0) 

sage: inv = transf.inverse() 

sage: W = U.intersection(V) 

sage: eU = c_xy.frame() ; eV = c_uv.frame() 

sage: a = M.tensor_field(0,2, name='a') 

sage: a[eU,:] = [[1,x], [2,y]] 

sage: a.add_comp_by_continuation(eV, W, chart=c_uv) 

sage: a[eV,:] 

[ 1/4*u + 3/4 -1/4*u + 3/4] 

[ 1/4*v - 1/4 -1/4*v - 1/4] 

sage: s = a.antisymmetrize() ; s 

2-form on the 2-dimensional differentiable manifold M 

sage: s[eU,:] 

[ 0 1/2*x - 1] 

[-1/2*x + 1 0] 

sage: s[eV,:] 

[ 0 -1/8*u - 1/8*v + 1/2] 

[ 1/8*u + 1/8*v - 1/2 0] 

sage: s == a.antisymmetrize(0,1) # explicit positions 

True 

sage: s == a.antisymmetrize(1,0) # the order of positions does not matter 

True 

 

.. SEEALSO:: 

 

For more details and examples, see 

:meth:`sage.tensor.modules.free_module_tensor.FreeModuleTensor.antisymmetrize`. 

 

""" 

resu_rst = [] 

for rst in self._restrictions.values(): 

resu_rst.append(rst.antisymmetrize(*pos)) 

resu = self._vmodule.tensor(self._tensor_type, sym=resu_rst[0]._sym, 

antisym=resu_rst[0]._antisym) 

for rst in resu_rst: 

resu._restrictions[rst._domain] = rst 

return resu 

 

def lie_derivative(self, vector): 

r""" 

Lie derivative of ``self`` with respect to a vector field. 

 

INPUT: 

 

- ``vector`` -- vector field with respect to which the Lie derivative 

is to be taken 

 

OUTPUT: 

 

- the tensor field that is the Lie derivative of the current tensor 

field with respect to ``vector`` 

 

EXAMPLES: 

 

Lie derivative of a type-`(1,1)` tensor field along a vector field on 

the 2-sphere:: 

 

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

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

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

sage: c_xy.<x,y> = U.chart() ; c_uv.<u,v> = V.chart() 

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

....: intersection_name='W', restrictions1= x>0, 

....: restrictions2= u+v>0) 

sage: uv_to_xy = xy_to_uv.inverse() 

sage: e_xy = c_xy.frame(); e_uv = c_uv.frame() 

sage: t = M.tensor_field(1,1, name='t') 

sage: t[e_xy,:] = [[x, 1], [y, 0]] 

sage: t.add_comp_by_continuation(e_uv, U.intersection(V), c_uv) 

sage: w = M.vector_field(name='w') 

sage: w[e_xy,:] = [-y, x] 

sage: w.add_comp_by_continuation(e_uv, U.intersection(V), c_uv) 

sage: lt = t.lie_derivative(w); lt 

Tensor field of type (1,1) on the 2-dimensional differentiable 

manifold M 

sage: lt.display(e_xy) 

d/dx*dx - x d/dx*dy + (-y - 1) d/dy*dy 

sage: lt.display(e_uv) 

-1/2*u d/du*du + (1/2*u + 1) d/du*dv + (-1/2*v + 1) d/dv*du + 1/2*v d/dv*dv 

 

The result is cached:: 

 

sage: t.lie_derivative(w) is lt 

True 

 

An alias is ``lie_der``:: 

 

sage: t.lie_der(w) is t.lie_derivative(w) 

True 

 

Lie derivative of a vector field:: 

 

sage: a = M.vector_field(name='a') 

sage: a[e_xy,:] = [1-x, x-y] 

sage: a.add_comp_by_continuation(e_uv, U.intersection(V), c_uv) 

sage: a.lie_der(w) 

Vector field on the 2-dimensional differentiable manifold M 

sage: a.lie_der(w).display(e_xy) 

x d/dx + (-y - 1) d/dy 

sage: a.lie_der(w).display(e_uv) 

(v - 1) d/du + (u + 1) d/dv 

 

The Lie derivative is antisymmetric:: 

 

sage: a.lie_der(w) == - w.lie_der(a) 

True 

 

and it coincides with the commutator of the two vector fields:: 

 

sage: f = M.scalar_field({c_xy: 3*x-1, c_uv: 3/2*(u+v)-1}) 

sage: a.lie_der(w)(f) == w(a(f)) - a(w(f)) # long time 

True 

 

""" 

if vector._tensor_type != (1,0): 

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

 

# The Lie derivative is cached in _lie_derivates while neither 

# the tensor field nor ``vector`` have been modified 

if id(vector) not in self._lie_derivatives: 

# the computation must be performed: 

resu_rst = [] 

for dom, rst in self._restrictions.items(): 

resu_rst.append(rst.lie_der(vector.restrict(dom))) 

resu = self._vmodule.tensor(self._tensor_type, 

sym=resu_rst[0]._sym, 

antisym=resu_rst[0]._antisym) 

for rst in resu_rst: 

resu._restrictions[rst._domain] = rst 

self._lie_derivatives[id(vector)] = (vector, resu) 

vector._lie_der_along_self[id(self)] = self 

return self._lie_derivatives[id(vector)][1] 

 

lie_der = lie_derivative 

 

def at(self, point): 

r""" 

Value of ``self`` at a point of its domain. 

 

If the current tensor field is 

 

.. MATH:: 

 

t:\ U \longrightarrow T^{(k,l)} M 

 

associated with the differentiable map 

 

.. MATH:: 

 

\Phi:\ U \longrightarrow M, 

 

where `U` and `M` are two manifolds (possibly `U = M` and 

`\Phi = \mathrm{Id}_M`), then for any point `p \in U`, `t(p)` 

is a tensor on the tangent space to `M` at the point `\Phi(p)`. 

 

INPUT: 

 

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

point `p` in the domain of the tensor field `U` 

 

OUTPUT: 

 

- :class:`~sage.tensor.modules.free_module_tensor.FreeModuleTensor` 

representing the tensor `t(p)` on the tangent vector space 

`T_{\Phi(p)} M` 

 

EXAMPLES: 

 

Tensor on a tangent space of a non-parallelizable 2-dimensional 

manifold:: 

 

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

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

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

sage: c_xy.<x,y> = U.chart() ; c_uv.<u,v> = V.chart() 

sage: transf = c_xy.transition_map(c_uv, (x+y, x-y), 

....: intersection_name='W', restrictions1= x>0, 

....: restrictions2= u+v>0) 

sage: inv = transf.inverse() 

sage: W = U.intersection(V) 

sage: eU = c_xy.frame() ; eV = c_uv.frame() 

sage: a = M.tensor_field(1,1, name='a') 

sage: a[eU,:] = [[1+y,x], [0,x+y]] 

sage: a.add_comp_by_continuation(eV, W, chart=c_uv) 

sage: a.display(eU) 

a = (y + 1) d/dx*dx + x d/dx*dy + (x + y) d/dy*dy 

sage: a.display(eV) 

a = (u + 1/2) d/du*du + (-1/2*u - 1/2*v + 1/2) d/du*dv 

+ 1/2 d/dv*du + (1/2*u - 1/2*v + 1/2) d/dv*dv 

sage: p = M.point((2,3), chart=c_xy, name='p') 

sage: ap = a.at(p) ; ap 

Type-(1,1) tensor a on the Tangent space at Point p on the 

2-dimensional differentiable manifold M 

sage: ap.parent() 

Free module of type-(1,1) tensors on the Tangent space at Point p 

on the 2-dimensional differentiable manifold M 

sage: ap.display(eU.at(p)) 

a = 4 d/dx*dx + 2 d/dx*dy + 5 d/dy*dy 

sage: ap.display(eV.at(p)) 

a = 11/2 d/du*du - 3/2 d/du*dv + 1/2 d/dv*du + 7/2 d/dv*dv 

sage: p.coord(c_uv) # to check the above expression 

(5, -1) 

 

""" 

if point not in self._domain: 

raise ValueError("the {} is not a point in the ".format(point) + 

"domain of {}".format(self)) 

for dom, rst in self._restrictions.items(): 

if point in dom: 

return rst.at(point) 

 

def up(self, metric, pos=None): 

r""" 

Compute a metric dual of the tensor field by raising some index with a 

given metric. 

 

If `T` is the tensor field, `(k,l)` its type and `p` the position of a 

covariant index (i.e. `k\leq p < k+l`), this method called with 

``pos`` `=p` yields the tensor field `T^\sharp` of type `(k+1,l-1)` 

whose components are 

 

.. MATH:: 

 

(T^\sharp)^{a_1\ldots a_{k+1}}_{\phantom{a_1\ldots a_{k+1}}\, 

b_1 \ldots b_{l-1}} = g^{a_{k+1} i} \, 

T^{a_1\ldots a_k}_{\phantom{a_1\ldots a_k}\, b_1 \ldots b_{p-k} 

\, i \, b_{p-k+1}\ldots b_{l-1}}, 

 

`g^{ab}` being the components of the inverse metric. 

 

The reverse operation is :meth:`TensorField.down`. 

 

INPUT: 

 

- ``metric`` -- metric `g`, as an instance of 

:class:`~sage.manifolds.differentiable.metric.PseudoRiemannianMetric` 

- ``pos`` -- (default: ``None``) position of the index (with the 

convention ``pos=0`` for the first index); if ``None``, the raising 

is performed over all the covariant indices, starting from the first 

one 

 

OUTPUT: 

 

- the tensor field `T^\sharp` resulting from the index raising 

operation 

 

EXAMPLES: 

 

Raising the index of a 1-form results in a vector field:: 

 

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

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

sage: g = M.metric('g') 

sage: g[1,1], g[1,2], g[2,2] = 1+x, x*y, 1-y 

sage: w = M.one_form() 

sage: w[:] = [-1, 2] 

sage: v = w.up(g) ; v 

Vector field on the 2-dimensional differentiable manifold M 

sage: v.display() 

((2*x - 1)*y + 1)/(x^2*y^2 + (x + 1)*y - x - 1) d/dx 

- (x*y + 2*x + 2)/(x^2*y^2 + (x + 1)*y - x - 1) d/dy 

sage: ig = g.inverse(); ig[:] 

[ (y - 1)/(x^2*y^2 + (x + 1)*y - x - 1) x*y/(x^2*y^2 + (x + 1)*y - x - 1)] 

[ x*y/(x^2*y^2 + (x + 1)*y - x - 1) -(x + 1)/(x^2*y^2 + (x + 1)*y - x - 1)] 

 

Using the index notation instead of :meth:`up`:: 

 

sage: v == ig['^ab']*w['_b'] 

True 

 

The reverse operation:: 

 

sage: w1 = v.down(g) ; w1 

1-form on the 2-dimensional differentiable manifold M 

sage: w1.display() 

-dx + 2 dy 

sage: w1 == w 

True 

 

The reverse operation in index notation:: 

 

sage: g['_ab']*v['^b'] == w 

True 

 

Raising the indices of a tensor field of type (0,2):: 

 

sage: t = M.tensor_field(0, 2) 

sage: t[:] = [[1,2], [3,4]] 

sage: tu0 = t.up(g, 0) ; tu0 # raising the first index 

Tensor field of type (1,1) on the 2-dimensional differentiable 

manifold M 

sage: tu0[:] 

[ ((3*x + 1)*y - 1)/(x^2*y^2 + (x + 1)*y - x - 1) 2*((2*x + 1)*y - 1)/(x^2*y^2 + (x + 1)*y - x - 1)] 

[ (x*y - 3*x - 3)/(x^2*y^2 + (x + 1)*y - x - 1) 2*(x*y - 2*x - 2)/(x^2*y^2 + (x + 1)*y - x - 1)] 

sage: tu0 == ig['^ac']*t['_cb'] # the same operation in index notation 

True 

sage: tuu0 = tu0.up(g) ; tuu0 # the two indices have been raised, starting from the first one 

Tensor field of type (2,0) on the 2-dimensional differentiable 

manifold M 

sage: tuu0 == tu0['^a_c']*ig['^cb'] # the same operation in index notation 

True 

sage: tu1 = t.up(g, 1) ; tu1 # raising the second index 

Tensor field of type (1,1) on the 2-dimensional differentiable 

manifold M 

sage: tu1 == ig['^ac']*t['_bc'] # the same operation in index notation 

True 

sage: tu1[:] 

[((2*x + 1)*y - 1)/(x^2*y^2 + (x + 1)*y - x - 1) ((4*x + 3)*y - 3)/(x^2*y^2 + (x + 1)*y - x - 1)] 

[ (x*y - 2*x - 2)/(x^2*y^2 + (x + 1)*y - x - 1) (3*x*y - 4*x - 4)/(x^2*y^2 + (x + 1)*y - x - 1)] 

sage: tuu1 = tu1.up(g) ; tuu1 # the two indices have been raised, starting from the second one 

Tensor field of type (2,0) on the 2-dimensional differentiable 

manifold M 

sage: tuu1 == tu1['^a_c']*ig['^cb'] # the same operation in index notation 

True 

sage: tuu0 == tuu1 # the order of index raising is important 

False 

sage: tuu = t.up(g) ; tuu # both indices are raised, starting from the first one 

Tensor field of type (2,0) on the 2-dimensional differentiable 

manifold M 

sage: tuu0 == tuu # the same order for index raising has been applied 

True 

sage: tuu1 == tuu # to get tuu1, indices have been raised from the last one, contrary to tuu 

False 

sage: d0tuu = tuu.down(g, 0) ; d0tuu # the first index is lowered again 

Tensor field of type (1,1) on the 2-dimensional differentiable 

manifold M 

sage: dd0tuu = d0tuu.down(g) ; dd0tuu # the second index is then lowered 

Tensor field of type (0,2) on the 2-dimensional differentiable 

manifold M 

sage: d1tuu = tuu.down(g, 1) ; d1tuu # lowering operation, starting from the last index 

Tensor field of type (1,1) on the 2-dimensional differentiable 

manifold M 

sage: dd1tuu = d1tuu.down(g) ; dd1tuu 

Tensor field of type (0,2) on the 2-dimensional differentiable 

manifold M 

sage: ddtuu = tuu.down(g) ; ddtuu # both indices are lowered, starting from the last one 

Tensor field of type (0,2) on the 2-dimensional differentiable 

manifold M 

sage: ddtuu == t # should be true 

True 

sage: dd0tuu == t # not true, because of the order of index lowering to get dd0tuu 

False 

sage: dd1tuu == t # should be true 

True 

 

""" 

n_con = self._tensor_type[0] # number of contravariant indices = k 

if pos is None: 

result = self 

for p in range(n_con, self._tensor_rank): 

k = result._tensor_type[0] 

result = result.up(metric, k) 

return result 

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

raise TypeError("the argument 'pos' must be an integer") 

if pos<n_con or pos>self._tensor_rank-1: 

print("pos = {}".format(pos)) 

raise ValueError("position out of range") 

return self.contract(pos, metric.inverse(), 0) 

 

def down(self, metric, pos=None): 

r""" 

Compute a metric dual of the tensor field by lowering some index with a 

given metric. 

 

If `T` is the tensor field, `(k,l)` its type and `p` the position of a 

contravariant index (i.e. `0\leq p < k`), this method called with 

``pos`` `=p` yields the tensor field `T^\flat` of type `(k-1,l+1)` 

whose components are 

 

.. MATH:: 

 

(T^\flat)^{a_1\ldots a_{k-1}}_{\phantom{a_1\ldots a_{k-1}} 

\, b_1 \ldots b_{l+1}} = g_{b_1 i} \, 

T^{a_1\ldots a_{p} \, i \, a_{p+1}\ldots a_{k-1}}_{\phantom{a_1 

\ldots a_{p} \, i \, a_{p+1}\ldots a_{k-1}}\, b_2 \ldots b_{l+1}}, 

 

`g_{ab}` being the components of the metric tensor. 

 

The reverse operation is :meth:`TensorField.up`. 

 

INPUT: 

 

- ``metric`` -- metric `g`, as an instance of 

:class:`~sage.manifolds.differentiable.metric.PseudoRiemannianMetric` 

- ``pos`` -- (default: ``None``) position of the index (with the 

convention ``pos=0`` for the first index); if ``None``, the lowering 

is performed over all the contravariant indices, starting from the 

last one 

 

OUTPUT: 

 

- the tensor field `T^\flat` resulting from the index lowering 

operation 

 

EXAMPLES: 

 

Lowering the index of a vector field results in a 1-form:: 

 

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

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

sage: g = M.metric('g') 

sage: g[1,1], g[1,2], g[2,2] = 1+x, x*y, 1-y 

sage: v = M.vector_field() 

sage: v[:] = [-1,2] 

sage: w = v.down(g) ; w 

1-form on the 2-dimensional differentiable manifold M 

sage: w.display() 

(2*x*y - x - 1) dx + (-(x + 2)*y + 2) dy 

 

Using the index notation instead of :meth:`down`:: 

 

sage: w == g['_ab']*v['^b'] 

True 

 

The reverse operation:: 

 

sage: v1 = w.up(g) ; v1 

Vector field on the 2-dimensional differentiable manifold M 

sage: v1 == v 

True 

 

Lowering the indices of a tensor field of type (2,0):: 

 

sage: t = M.tensor_field(2, 0) 

sage: t[:] = [[1,2], [3,4]] 

sage: td0 = t.down(g, 0) ; td0 # lowering the first index 

Tensor field of type (1,1) on the 2-dimensional differentiable 

manifold M 

sage: td0 == g['_ac']*t['^cb'] # the same operation in index notation 

True 

sage: td0[:] 

[ 3*x*y + x + 1 (x - 3)*y + 3] 

[4*x*y + 2*x + 2 2*(x - 2)*y + 4] 

sage: tdd0 = td0.down(g) ; tdd0 # the two indices have been lowered, starting from the first one 

Tensor field of type (0,2) on the 2-dimensional differentiable 

manifold M 

sage: tdd0 == g['_ac']*td0['^c_b'] # the same operation in index notation 

True 

sage: tdd0[:] 

[ 4*x^2*y^2 + x^2 + 5*(x^2 + x)*y + 2*x + 1 2*(x^2 - 2*x)*y^2 + (x^2 + 2*x - 3)*y + 3*x + 3] 

[(3*x^2 - 4*x)*y^2 + (x^2 + 3*x - 2)*y + 2*x + 2 (x^2 - 5*x + 4)*y^2 + (5*x - 8)*y + 4] 

sage: td1 = t.down(g, 1) ; td1 # lowering the second index 

Tensor field of type (1,1) on the 2-dimensional differentiable 

manifold M 

sage: td1 == g['_ac']*t['^bc'] # the same operation in index notation 

True 

sage: td1[:] 

[ 2*x*y + x + 1 (x - 2)*y + 2] 

[4*x*y + 3*x + 3 (3*x - 4)*y + 4] 

sage: tdd1 = td1.down(g) ; tdd1 # the two indices have been lowered, starting from the second one 

Tensor field of type (0,2) on the 2-dimensional differentiable 

manifold M 

sage: tdd1 == g['_ac']*td1['^c_b'] # the same operation in index notation 

True 

sage: tdd1[:] 

[ 4*x^2*y^2 + x^2 + 5*(x^2 + x)*y + 2*x + 1 (3*x^2 - 4*x)*y^2 + (x^2 + 3*x - 2)*y + 2*x + 2] 

[2*(x^2 - 2*x)*y^2 + (x^2 + 2*x - 3)*y + 3*x + 3 (x^2 - 5*x + 4)*y^2 + (5*x - 8)*y + 4] 

sage: tdd1 == tdd0 # the order of index lowering is important 

False 

sage: tdd = t.down(g) ; tdd # both indices are lowered, starting from the last one 

Tensor field of type (0,2) on the 2-dimensional differentiable 

manifold M 

sage: tdd[:] 

[ 4*x^2*y^2 + x^2 + 5*(x^2 + x)*y + 2*x + 1 (3*x^2 - 4*x)*y^2 + (x^2 + 3*x - 2)*y + 2*x + 2] 

[2*(x^2 - 2*x)*y^2 + (x^2 + 2*x - 3)*y + 3*x + 3 (x^2 - 5*x + 4)*y^2 + (5*x - 8)*y + 4] 

sage: tdd0 == tdd # to get tdd0, indices have been lowered from the first one, contrary to tdd 

False 

sage: tdd1 == tdd # the same order for index lowering has been applied 

True 

sage: u0tdd = tdd.up(g, 0) ; u0tdd # the first index is raised again 

Tensor field of type (1,1) on the 2-dimensional differentiable 

manifold M 

sage: uu0tdd = u0tdd.up(g) ; uu0tdd # the second index is then raised 

Tensor field of type (2,0) on the 2-dimensional differentiable 

manifold M 

sage: u1tdd = tdd.up(g, 1) ; u1tdd # raising operation, starting from the last index 

Tensor field of type (1,1) on the 2-dimensional differentiable 

manifold M 

sage: uu1tdd = u1tdd.up(g) ; uu1tdd 

Tensor field of type (2,0) on the 2-dimensional differentiable 

manifold M 

sage: uutdd = tdd.up(g) ; uutdd # both indices are raised, starting from the first one 

Tensor field of type (2,0) on the 2-dimensional differentiable 

manifold M 

sage: uutdd == t # should be true 

True 

sage: uu0tdd == t # should be true 

True 

sage: uu1tdd == t # not true, because of the order of index raising to get uu1tdd 

False 

 

""" 

n_con = self._tensor_type[0] # number of contravariant indices = k 

if pos is None: 

result = self 

for p in range(0, n_con): 

k = result._tensor_type[0] 

result = result.down(metric, k-1) 

return result 

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

raise TypeError("the argument 'pos' must be an integer") 

if pos<0 or pos>=n_con: 

print("pos = {}".format(pos)) 

raise ValueError("position out of range") 

return metric.contract(1, self, pos) 

 

def divergence(self, metric=None): 

r""" 

Return the divergence of ``self`` (with respect to a given 

metric). 

 

The divergence is taken on the *last* index: if 

``self`` is a tensor field `t` of type `(k,0)` with `k\geq 1`, the 

divergence of `t` with respect to the metric `g` is the tensor field 

of type `(k-1,0)` defined by 

 

.. MATH:: 

 

(\mathrm{div}\, t)^{a_1\ldots a_{k-1}} = 

\nabla_i t^{a_1\ldots a_{k-1} i} = 

(\nabla t)^{a_1\ldots a_{k-1} i}_{\phantom{a_1\ldots a_{k-1} i}\, i} 

 

where `\nabla` is the Levi-Civita connection of `g` (cf. 

:class:`~sage.manifolds.differentiable.levi_civita_connection.LeviCivitaConnection`). 

 

This definition is extended to tensor fields of type `(k,l)` with 

`k\geq 0` and `l\geq 1`, by raising the last index with the metric `g`: 

`\mathrm{div}\, t` is then the tensor field of type `(k,l-1)` defined by 

 

.. MATH:: 

 

(\mathrm{div}\, t)^{a_1\ldots a_k}_{\phantom{a_1\ldots a_k}\, b_1 

\ldots b_{l-1}} = \nabla_i (g^{ij} t^{a_1\ldots a_k}_{\phantom{a_1 

\ldots a_k}\, b_1\ldots b_{l-1} j}) 

= (\nabla t^\sharp)^{a_1\ldots a_k i}_{\phantom{a_1\ldots a_k i}\, 

b_1\ldots b_{l-1} i} 

 

where `t^\sharp` is the tensor field deduced from `t` by raising the 

last index with the metric `g` (see :meth:`up`). 

 

INPUT: 

 

- ``metric`` -- (default: ``None``) the pseudo-Riemannian metric `g` 

involved in the definition of the divergence; if none is provided, 

the domain of ``self`` is supposed to be endowed with a default 

metric (i.e. is supposed to be pseudo-Riemannian manifold, see 

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

and the latter is used to define the divergence. 

 

OUTPUT: 

 

- instance of either 

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

if `(k,l)=(1,0)` (``self`` is a vector field) or `(k,l)=(0,1)` 

(``self`` is a 1-form) or of :class:`TensorField` if `k+l\geq 2` 

representing the divergence of ``self`` with respect to ``metric`` 

 

EXAMPLES: 

 

Divergence of a vector field in the Euclidean plane:: 

 

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

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

sage: g = M.metric() 

sage: g[0,0], g[1,1] = 1, 1 

sage: v = M.vector_field('v') 

sage: v[:] = x, y 

sage: s = v.divergence(); s 

Scalar field div(v) on the 2-dimensional Riemannian manifold M 

sage: s.display() 

div(v): M --> R 

(x, y) |--> 2 

 

A shortcut alias of ``divergence`` is ``div``:: 

 

sage: v.div() == s 

True 

 

The function :func:`~sage.manifolds.operators.div` from the 

:mod:`~sage.manifolds.operators` module can be used instead of the 

method :meth:`divergence`:: 

 

sage: from sage.manifolds.operators import div 

sage: div(v) == s 

True 

 

The divergence can be taken with respect to a metric tensor that is 

not the default one:: 

 

sage: h = M.lorentzian_metric('h') 

sage: h[0,0], h[1,1] = -1, 1/(1+x^2+y^2) 

sage: s = v.div(h); s 

Scalar field div_h(v) on the 2-dimensional Riemannian manifold M 

sage: s.display() 

div_h(v): M --> R 

(x, y) |--> (x^2 + y^2 + 2)/(x^2 + y^2 + 1) 

 

The standard formula 

 

.. MATH:: 

 

\mathrm{div}_h \, v = \frac{1}{\sqrt{\det h}} 

\frac{\partial}{\partial x^i} \left( \sqrt{\det h} \, v^i \right) 

 

is checked as follows:: 

 

sage: sqrth = h.sqrt_abs_det().expr(); sqrth 

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

sage: s == 1/sqrth * sum( (sqrth*v[i]).diff(i) for i in M.irange()) 

True 

 

A divergence-free vector:: 

 

sage: w = M.vector_field('w') 

sage: w[:] = -y, x 

sage: w.div().display() 

div(w): M --> R 

(x, y) |--> 0 

sage: w.div(h).display() 

div_h(w): M --> R 

(x, y) |--> 0 

 

Divergence of a type-``(2,0)`` tensor field:: 

 

sage: t = v*w; t 

Tensor field v*w of type (2,0) on the 2-dimensional Riemannian 

manifold M 

sage: s = t.div(); s 

Vector field div(v*w) on the 2-dimensional Riemannian manifold M 

sage: s.display() 

div(v*w) = -y d/dx + x d/dy 

 

""" 

n_con = self._tensor_type[0] # number of contravariant indices = k 

n_cov = self._tensor_type[1] # number of covariant indices = l 

default_metric = metric is None 

if default_metric: 

metric = self._domain.metric() 

nabla = metric.connection() 

if n_cov == 0: 

resu = nabla(self).trace(n_con-1, n_con) 

else: 

tup = self.up(metric, self._tensor_rank-1) 

resu = nabla(tup).trace(n_con, self._tensor_rank) 

if self._name is not None: 

if default_metric: 

resu._name = "div({})".format(self._name) 

resu._latex_name = r"\mathrm{div}\left(" + self._latex_name + \ 

r"\right)" 

else: 

resu._name = "div_{}({})".format(metric._name, self._name) 

resu._latex_name = r"\mathrm{div}_{" + metric._latex_name + \ 

r"}\left(" + self._latex_name + r"\right)" 

# The name is propagated to possible restrictions of self: 

for restrict in resu._restrictions.values(): 

restrict.set_name(resu._name, latex_name=resu._latex_name) 

return resu 

 

div = divergence 

 

def laplacian(self, metric=None): 

r""" 

Return the Laplacian of ``self`` with respect to a given 

metric (Laplace-Beltrami operator). 

 

If ``self`` is a tensor field `t` of type `(k,l)`, the Laplacian of `t` 

with respect to the metric `g` is the tensor field of type `(k,l)` 

defined by 

 

.. MATH:: 

 

(\Delta t)^{a_1\ldots a_k}_{\phantom{a_1\ldots a_k}\,{b_1\ldots b_k}} 

= \nabla_i \nabla^i 

t^{a_1\ldots a_k}_{\phantom{a_1\ldots a_k}\,{b_1\ldots b_k}} 

 

where `\nabla` is the Levi-Civita connection of `g` (cf. 

:class:`~sage.manifolds.differentiable.levi_civita_connection.LeviCivitaConnection`) 

and `\nabla^i := g^{ij} \nabla_j`. The operator 

`\Delta = \nabla_i \nabla^i` is called the *Laplace-Beltrami operator* 

of metric `g`. 

 

INPUT: 

 

- ``metric`` -- (default: ``None``) the pseudo-Riemannian metric `g` 

involved in the definition of the Laplacian; if none is provided, the 

domain of ``self`` is supposed to be endowed with a default metric 

(i.e. is supposed to be pseudo-Riemannian manifold, see 

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

and the latter is used to define the Laplacian 

 

OUTPUT: 

 

- instance of :class:`TensorField` representing the Laplacian of 

``self`` 

 

EXAMPLES: 

 

Laplacian of a vector field in the Euclidean plane:: 

 

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

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

sage: g = M.metric() 

sage: g[0,0], g[1,1] = 1, 1 

sage: v = M.vector_field(name='v') 

sage: v[:] = x^3 + y^2, x*y 

sage: Dv = v.laplacian(); Dv 

Vector field Delta(v) on the 2-dimensional Riemannian manifold M 

sage: Dv.display() 

Delta(v) = (6*x + 2) d/dx 

 

The function :func:`~sage.manifolds.operators.laplacian` from the 

:mod:`~sage.manifolds.operators` module can be used instead of the 

method :meth:`laplacian`:: 

 

sage: from sage.manifolds.operators import laplacian 

sage: laplacian(v) == Dv 

True 

 

In the present case (Euclidean metric and Cartesian coordinates), the 

components of the Laplacian are the Laplacians of the components:: 

 

sage: all([Dv[[i]] == laplacian(v[[i]]) for i in M.irange()]) 

True 

 

The Laplacian can be taken with respect to a metric tensor that is 

not the default one:: 

 

sage: h = M.lorentzian_metric('h') 

sage: h[0,0], h[1,1] = -1, 1+x^2 

sage: Dv = v.laplacian(h); Dv 

Vector field Delta_h(v) on the 2-dimensional Riemannian manifold M 

sage: Dv.display() 

Delta_h(v) = -(8*x^5 - 2*x^4 - x^2*y^2 + 15*x^3 - 4*x^2 

+ 6*x - 2)/(x^4 + 2*x^2 + 1) d/dx - 3*x^3*y/(x^4 + 2*x^2 + 1) d/dy 

 

""" 

n_con = self._tensor_type[0] # number of contravariant indices = k 

trank = self._tensor_rank # k + l 

default_metric = metric is None 

if default_metric: 

metric = self._domain.metric() 

nabla = metric.connection() 

tmp = nabla(nabla(self).up(metric, pos=trank)) 

resu = tmp.trace(n_con, trank+1) 

if self._name is not None: 

if default_metric: 

resu._name = "Delta({})".format(self._name) 

resu._latex_name = r"\Delta\left(" + self._latex_name + \ 

r"\right)" 

else: 

resu._name = "Delta_{}({})".format(metric._name, self._name) 

resu._latex_name = r"\Delta_{" + metric._latex_name + \ 

r"}\left(" + self._latex_name + r"\right)" 

# The name is propagated to possible restrictions of self: 

for restrict in resu._restrictions.values(): 

restrict.set_name(resu._name, latex_name=resu._latex_name) 

return resu 

 

def dalembertian(self, metric=None): 

r""" 

Return the d'Alembertian of ``self`` with respect to a given 

Lorentzian metric. 

 

The *d'Alembertian* of a tensor field `t` with respect to a Lorentzian 

metric `g` is nothing but the Laplace-Beltrami operator of `g` applied 

to `t` (see :meth:`laplacian`); if ``self`` a tensor field `t` of type 

`(k,l)`, the d'Alembertian of `t` with respect to `g` is then the 

tensor field of type `(k,l)` defined by 

 

.. MATH:: 

 

(\Box t)^{a_1\ldots a_k}_{\phantom{a_1\ldots a_k}\,{b_1\ldots b_k}} 

= \nabla_i \nabla^i 

t^{a_1\ldots a_k}_{\phantom{a_1\ldots a_k}\,{b_1\ldots b_k}} 

 

where `\nabla` is the Levi-Civita connection of `g` (cf. 

:class:`~sage.manifolds.differentiable.levi_civita_connection.LeviCivitaConnection`) 

and `\nabla^i := g^{ij} \nabla_j`. 

 

.. NOTE:: 

 

If the metric `g` is not Lorentzian, the name *d'Alembertian* is 

not appropriate and one should use :meth:`laplacian` instead. 

 

INPUT: 

 

- ``metric`` -- (default: ``None``) the Lorentzian metric `g` 

involved in the definition of the d'Alembertian; if none is provided, 

the domain of ``self`` is supposed to be endowed with a default 

Lorentzian metric (i.e. is supposed to be Lorentzian manifold, see 

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

and the latter is used to define the d'Alembertian 

 

OUTPUT: 

 

- instance of :class:`TensorField` representing the d'Alembertian of 

``self`` 

 

EXAMPLES: 

 

d'Alembertian of a vector field in Minkowski spacetime, representing 

the electric field of a simple plane electromagnetic wave:: 

 

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

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

sage: g = M.metric() 

sage: g[0,0], g[1,1], g[2,2], g[3,3] = -1, 1, 1, 1 

sage: e = M.vector_field(name='e') 

sage: e[1] = cos(t-z) 

sage: e.display() # plane wave propagating in the z direction 

e = cos(t - z) d/dx 

sage: De = e.dalembertian(); De 

Vector field Box(e) on the 4-dimensional Lorentzian manifold M 

 

The function :func:`~sage.manifolds.operators.dalembertian` from the 

:mod:`~sage.manifolds.operators` module can be used instead of the 

method :meth:`dalembertian`:: 

 

sage: from sage.manifolds.operators import dalembertian 

sage: dalembertian(e) == De 

True 

 

We check that the electric field obeys the wave equation:: 

 

sage: De.display() 

Box(e) = 0 

 

""" 

default_metric = metric is None 

if default_metric: 

metric = self._domain.metric() 

nm2 = self._domain.dim() - 2 

if metric.signature() not in [nm2, -nm2]: 

raise TypeError("the {} is not a Lorentzian ".format(metric) + 

"metric; use laplacian() instead") 

resu = self.laplacian(metric=metric) 

if self._name is not None: 

if default_metric: 

resu._name = "Box({})".format(self._name) 

resu._latex_name = r"\Box\left(" + self._latex_name + \ 

r"\right)" 

else: 

resu._name = "Box_{}({})".format(metric._name, self._name) 

resu._latex_name = r"\Box_{" + metric._latex_name + \ 

r"}\left(" + self._latex_name + r"\right)" 

# The name is propagated to possible restrictions of self: 

for restrict in resu._restrictions.values(): 

restrict.set_name(resu._name, latex_name=resu._latex_name) 

return resu