54
General relativity computations with SageManifolds ´ Eric Gourgoulhon Laboratoire Univers et Th´ eories (LUTH) CNRS / Observatoire de Paris / Universit´ e Paris Diderot 92190 Meudon, France http://luth.obspm.fr/ ~ luthier/gourgoulhon/ NewCompStar School 2016 Neutron stars: gravitational physics theory and observations Coimbra (Portugal) 5-9 September 2016 ´ Eric Gourgoulhon (LUTH) GR computations with SageManifolds NewCompStar, Coimbra, 6 Sept. 2016 1 / 29

General relativity computations with SageManifolds - Indico

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: General relativity computations with SageManifolds - Indico

General relativity computations with SageManifolds

Eric Gourgoulhon

Laboratoire Univers et Theories (LUTH)CNRS / Observatoire de Paris / Universite Paris Diderot

92190 Meudon, France

http://luth.obspm.fr/~luthier/gourgoulhon/

NewCompStar School 2016Neutron stars: gravitational physics theory and observations

Coimbra (Portugal)5-9 September 2016

Eric Gourgoulhon (LUTH) GR computations with SageManifolds NewCompStar, Coimbra, 6 Sept. 2016 1 / 29

Page 2: General relativity computations with SageManifolds - Indico

Outline

1 Computer differential geometry and tensor calculus

2 The SageManifolds project

3 Let us practice!

4 Other examples

5 Conclusion and perspectives

Eric Gourgoulhon (LUTH) GR computations with SageManifolds NewCompStar, Coimbra, 6 Sept. 2016 2 / 29

Page 3: General relativity computations with SageManifolds - Indico

Computer differential geometry and tensor calculus

Outline

1 Computer differential geometry and tensor calculus

2 The SageManifolds project

3 Let us practice!

4 Other examples

5 Conclusion and perspectives

Eric Gourgoulhon (LUTH) GR computations with SageManifolds NewCompStar, Coimbra, 6 Sept. 2016 3 / 29

Page 4: General relativity computations with SageManifolds - Indico

Computer differential geometry and tensor calculus

Introduction

Computer algebra system (CAS) started to be developed in the 1960’s; forinstance Macsyma (to become Maxima in 1998) was initiated in 1968 at MIT

In 1965, J.G. Fletcher developed the GEOM program, to compute the Riemanntensor of a given metric

In 1969, during his PhD under Pirani supervision, Ray d’Inverno wrote ALAM

(Atlas Lisp Algebraic Manipulator) and used it to compute theRiemann tensor of Bondi metric. The original calculations took Bondi and hiscollaborators 6 months to go. The computation with ALAM took 4 minutesand yielded to the discovery of 6 errors in the original paper [J.E.F. Skea,

Applications of SHEEP (1994)]

Since then, many softwares for tensor calculus have been developed...

Eric Gourgoulhon (LUTH) GR computations with SageManifolds NewCompStar, Coimbra, 6 Sept. 2016 4 / 29

Page 5: General relativity computations with SageManifolds - Indico

Computer differential geometry and tensor calculus

Introduction

Computer algebra system (CAS) started to be developed in the 1960’s; forinstance Macsyma (to become Maxima in 1998) was initiated in 1968 at MIT

In 1965, J.G. Fletcher developed the GEOM program, to compute the Riemanntensor of a given metric

In 1969, during his PhD under Pirani supervision, Ray d’Inverno wrote ALAM

(Atlas Lisp Algebraic Manipulator) and used it to compute theRiemann tensor of Bondi metric. The original calculations took Bondi and hiscollaborators 6 months to go. The computation with ALAM took 4 minutesand yielded to the discovery of 6 errors in the original paper [J.E.F. Skea,

Applications of SHEEP (1994)]

Since then, many softwares for tensor calculus have been developed...

Eric Gourgoulhon (LUTH) GR computations with SageManifolds NewCompStar, Coimbra, 6 Sept. 2016 4 / 29

Page 6: General relativity computations with SageManifolds - Indico

Computer differential geometry and tensor calculus

Introduction

Computer algebra system (CAS) started to be developed in the 1960’s; forinstance Macsyma (to become Maxima in 1998) was initiated in 1968 at MIT

In 1965, J.G. Fletcher developed the GEOM program, to compute the Riemanntensor of a given metric

In 1969, during his PhD under Pirani supervision, Ray d’Inverno wrote ALAM

(Atlas Lisp Algebraic Manipulator) and used it to compute theRiemann tensor of Bondi metric. The original calculations took Bondi and hiscollaborators 6 months to go. The computation with ALAM took 4 minutesand yielded to the discovery of 6 errors in the original paper [J.E.F. Skea,

Applications of SHEEP (1994)]

Since then, many softwares for tensor calculus have been developed...

Eric Gourgoulhon (LUTH) GR computations with SageManifolds NewCompStar, Coimbra, 6 Sept. 2016 4 / 29

Page 7: General relativity computations with SageManifolds - Indico

Computer differential geometry and tensor calculus

Introduction

Computer algebra system (CAS) started to be developed in the 1960’s; forinstance Macsyma (to become Maxima in 1998) was initiated in 1968 at MIT

In 1965, J.G. Fletcher developed the GEOM program, to compute the Riemanntensor of a given metric

In 1969, during his PhD under Pirani supervision, Ray d’Inverno wrote ALAM

(Atlas Lisp Algebraic Manipulator) and used it to compute theRiemann tensor of Bondi metric. The original calculations took Bondi and hiscollaborators 6 months to go. The computation with ALAM took 4 minutesand yielded to the discovery of 6 errors in the original paper [J.E.F. Skea,

Applications of SHEEP (1994)]

Since then, many softwares for tensor calculus have been developed...

Eric Gourgoulhon (LUTH) GR computations with SageManifolds NewCompStar, Coimbra, 6 Sept. 2016 4 / 29

Page 8: General relativity computations with SageManifolds - Indico

Computer differential geometry and tensor calculus

An example of modern software: The xAct suite

Free packages for tensor computer algebra in Mathematica, developed by JoseMartın-Garcıa et al. http://www.xact.es/

xCore

Mathematica tools

xPerm

Permutation Group theory

xTensor

Abstract tensor algebra

Invar"Riemann tensor Invariants"

J.M. Martín-García,

R. Portugal and D. Yllanes.

Spinors"Spinor calculus in GR"

A. García-Parrado and

J.M. Martín-García.

xCoba"Component tensor algebra"

J.M. Martín-García and

D. Yllanes.

xPert"Perturbation theory"

D. Brizuela, J.M. Martín-García

and G. Mena Marugán.

Harmonics "Tensor spherical harmonics"

D. Brizuela, J.M. Martín-García

and G. Mena Marugán.

The xAct system

SymManipulator"Symmetrized tensor expressions"

T. Bäckdahl.

xperm.c

C-language module

MathLink

xPrint

"Graphical front-end"

A. Stecchina.

[Garcıa-Parrado Gomez-Lobo & Martın-Garcıa, Comp. Phys. Comm. 183, 2214 (2012)]

Eric Gourgoulhon (LUTH) GR computations with SageManifolds NewCompStar, Coimbra, 6 Sept. 2016 5 / 29

Page 9: General relativity computations with SageManifolds - Indico

Computer differential geometry and tensor calculus

Software for differential geometry

Packages for general purpose computer algebra systems:

xAct free package for Mathematica [J.-M. Martin-Garcia]

Ricci free package for Mathematica [J. L. Lee]

MathTensor package for Mathematica [S. M. Christensen & L. Parker]

DifferentialGeometry included in Maple [I. M. Anderson & E. S. Cheb-Terrab]

Atlas 2 for Maple and Mathematica

· · ·

Standalone applications:

SHEEP, Classi, STensor, based on Lisp, developed in 1970’s and 1980’s (free)[R. d’Inverno, I. Frick, J. Aman, J. Skea, et al.]

Cadabra field theory (free) [K. Peeters]

SnapPy topology and geometry of 3-manifolds, based on Python (free) [M.

Culler, N. M. Dunfield & J. R. Weeks]

· · ·

cf. the complete list at http://www.xact.es/links.htmlEric Gourgoulhon (LUTH) GR computations with SageManifolds NewCompStar, Coimbra, 6 Sept. 2016 6 / 29

Page 10: General relativity computations with SageManifolds - Indico

Computer differential geometry and tensor calculus

SageMath in a few words

SageMath (nickname: Sage) is a free open-source mathematics softwaresystem

it is based on the Python programming languageit makes use of many pre-existing open-sources packages, among which

Maxima, Pynac (symbolic calculations)GAP (group theory)PARI/GP (number theory)Singular (polynomial computations)matplotlib (high quality 2D figures)

and provides a uniform interface to them

William Stein (Univ. of Washington) created SageMath in 2005; since then,∼100 developers (mostly mathematicians) have joined the SageMath team

SageMath is now supported by European Union via the open-math projectOpenDreamKit (2015-2019, within the Horizon 2020 program)

The mission

Create a viable free open source alternative to Magma, Maple, Mathematica andMatlab.

Eric Gourgoulhon (LUTH) GR computations with SageManifolds NewCompStar, Coimbra, 6 Sept. 2016 7 / 29

Page 11: General relativity computations with SageManifolds - Indico

Computer differential geometry and tensor calculus

SageMath in a few words

SageMath (nickname: Sage) is a free open-source mathematics softwaresystem

it is based on the Python programming language

it makes use of many pre-existing open-sources packages, among which

Maxima, Pynac (symbolic calculations)GAP (group theory)PARI/GP (number theory)Singular (polynomial computations)matplotlib (high quality 2D figures)

and provides a uniform interface to them

William Stein (Univ. of Washington) created SageMath in 2005; since then,∼100 developers (mostly mathematicians) have joined the SageMath team

SageMath is now supported by European Union via the open-math projectOpenDreamKit (2015-2019, within the Horizon 2020 program)

The mission

Create a viable free open source alternative to Magma, Maple, Mathematica andMatlab.

Eric Gourgoulhon (LUTH) GR computations with SageManifolds NewCompStar, Coimbra, 6 Sept. 2016 7 / 29

Page 12: General relativity computations with SageManifolds - Indico

Computer differential geometry and tensor calculus

SageMath in a few words

SageMath (nickname: Sage) is a free open-source mathematics softwaresystem

it is based on the Python programming languageit makes use of many pre-existing open-sources packages, among which

Maxima, Pynac (symbolic calculations)GAP (group theory)PARI/GP (number theory)Singular (polynomial computations)matplotlib (high quality 2D figures)

and provides a uniform interface to them

William Stein (Univ. of Washington) created SageMath in 2005; since then,∼100 developers (mostly mathematicians) have joined the SageMath team

SageMath is now supported by European Union via the open-math projectOpenDreamKit (2015-2019, within the Horizon 2020 program)

The mission

Create a viable free open source alternative to Magma, Maple, Mathematica andMatlab.

Eric Gourgoulhon (LUTH) GR computations with SageManifolds NewCompStar, Coimbra, 6 Sept. 2016 7 / 29

Page 13: General relativity computations with SageManifolds - Indico

Computer differential geometry and tensor calculus

SageMath in a few words

SageMath (nickname: Sage) is a free open-source mathematics softwaresystem

it is based on the Python programming languageit makes use of many pre-existing open-sources packages, among which

Maxima, Pynac (symbolic calculations)

GAP (group theory)PARI/GP (number theory)Singular (polynomial computations)matplotlib (high quality 2D figures)

and provides a uniform interface to them

William Stein (Univ. of Washington) created SageMath in 2005; since then,∼100 developers (mostly mathematicians) have joined the SageMath team

SageMath is now supported by European Union via the open-math projectOpenDreamKit (2015-2019, within the Horizon 2020 program)

The mission

Create a viable free open source alternative to Magma, Maple, Mathematica andMatlab.

Eric Gourgoulhon (LUTH) GR computations with SageManifolds NewCompStar, Coimbra, 6 Sept. 2016 7 / 29

Page 14: General relativity computations with SageManifolds - Indico

Computer differential geometry and tensor calculus

SageMath in a few words

SageMath (nickname: Sage) is a free open-source mathematics softwaresystem

it is based on the Python programming languageit makes use of many pre-existing open-sources packages, among which

Maxima, Pynac (symbolic calculations)GAP (group theory)

PARI/GP (number theory)Singular (polynomial computations)matplotlib (high quality 2D figures)

and provides a uniform interface to them

William Stein (Univ. of Washington) created SageMath in 2005; since then,∼100 developers (mostly mathematicians) have joined the SageMath team

SageMath is now supported by European Union via the open-math projectOpenDreamKit (2015-2019, within the Horizon 2020 program)

The mission

Create a viable free open source alternative to Magma, Maple, Mathematica andMatlab.

Eric Gourgoulhon (LUTH) GR computations with SageManifolds NewCompStar, Coimbra, 6 Sept. 2016 7 / 29

Page 15: General relativity computations with SageManifolds - Indico

Computer differential geometry and tensor calculus

SageMath in a few words

SageMath (nickname: Sage) is a free open-source mathematics softwaresystem

it is based on the Python programming languageit makes use of many pre-existing open-sources packages, among which

Maxima, Pynac (symbolic calculations)GAP (group theory)PARI/GP (number theory)

Singular (polynomial computations)matplotlib (high quality 2D figures)

and provides a uniform interface to them

William Stein (Univ. of Washington) created SageMath in 2005; since then,∼100 developers (mostly mathematicians) have joined the SageMath team

SageMath is now supported by European Union via the open-math projectOpenDreamKit (2015-2019, within the Horizon 2020 program)

The mission

Create a viable free open source alternative to Magma, Maple, Mathematica andMatlab.

Eric Gourgoulhon (LUTH) GR computations with SageManifolds NewCompStar, Coimbra, 6 Sept. 2016 7 / 29

Page 16: General relativity computations with SageManifolds - Indico

Computer differential geometry and tensor calculus

SageMath in a few words

SageMath (nickname: Sage) is a free open-source mathematics softwaresystem

it is based on the Python programming languageit makes use of many pre-existing open-sources packages, among which

Maxima, Pynac (symbolic calculations)GAP (group theory)PARI/GP (number theory)Singular (polynomial computations)

matplotlib (high quality 2D figures)

and provides a uniform interface to them

William Stein (Univ. of Washington) created SageMath in 2005; since then,∼100 developers (mostly mathematicians) have joined the SageMath team

SageMath is now supported by European Union via the open-math projectOpenDreamKit (2015-2019, within the Horizon 2020 program)

The mission

Create a viable free open source alternative to Magma, Maple, Mathematica andMatlab.

Eric Gourgoulhon (LUTH) GR computations with SageManifolds NewCompStar, Coimbra, 6 Sept. 2016 7 / 29

Page 17: General relativity computations with SageManifolds - Indico

Computer differential geometry and tensor calculus

SageMath in a few words

SageMath (nickname: Sage) is a free open-source mathematics softwaresystem

it is based on the Python programming languageit makes use of many pre-existing open-sources packages, among which

Maxima, Pynac (symbolic calculations)GAP (group theory)PARI/GP (number theory)Singular (polynomial computations)matplotlib (high quality 2D figures)

and provides a uniform interface to them

William Stein (Univ. of Washington) created SageMath in 2005; since then,∼100 developers (mostly mathematicians) have joined the SageMath team

SageMath is now supported by European Union via the open-math projectOpenDreamKit (2015-2019, within the Horizon 2020 program)

The mission

Create a viable free open source alternative to Magma, Maple, Mathematica andMatlab.

Eric Gourgoulhon (LUTH) GR computations with SageManifolds NewCompStar, Coimbra, 6 Sept. 2016 7 / 29

Page 18: General relativity computations with SageManifolds - Indico

Computer differential geometry and tensor calculus

SageMath in a few words

SageMath (nickname: Sage) is a free open-source mathematics softwaresystem

it is based on the Python programming languageit makes use of many pre-existing open-sources packages, among which

Maxima, Pynac (symbolic calculations)GAP (group theory)PARI/GP (number theory)Singular (polynomial computations)matplotlib (high quality 2D figures)

and provides a uniform interface to them

William Stein (Univ. of Washington) created SageMath in 2005; since then,∼100 developers (mostly mathematicians) have joined the SageMath team

SageMath is now supported by European Union via the open-math projectOpenDreamKit (2015-2019, within the Horizon 2020 program)

The mission

Create a viable free open source alternative to Magma, Maple, Mathematica andMatlab.

Eric Gourgoulhon (LUTH) GR computations with SageManifolds NewCompStar, Coimbra, 6 Sept. 2016 7 / 29

Page 19: General relativity computations with SageManifolds - Indico

Computer differential geometry and tensor calculus

SageMath in a few words

SageMath (nickname: Sage) is a free open-source mathematics softwaresystem

it is based on the Python programming languageit makes use of many pre-existing open-sources packages, among which

Maxima, Pynac (symbolic calculations)GAP (group theory)PARI/GP (number theory)Singular (polynomial computations)matplotlib (high quality 2D figures)

and provides a uniform interface to them

William Stein (Univ. of Washington) created SageMath in 2005; since then,∼100 developers (mostly mathematicians) have joined the SageMath team

SageMath is now supported by European Union via the open-math projectOpenDreamKit (2015-2019, within the Horizon 2020 program)

The mission

Create a viable free open source alternative to Magma, Maple, Mathematica andMatlab.

Eric Gourgoulhon (LUTH) GR computations with SageManifolds NewCompStar, Coimbra, 6 Sept. 2016 7 / 29

Page 20: General relativity computations with SageManifolds - Indico

Computer differential geometry and tensor calculus

SageMath in a few words

SageMath (nickname: Sage) is a free open-source mathematics softwaresystem

it is based on the Python programming languageit makes use of many pre-existing open-sources packages, among which

Maxima, Pynac (symbolic calculations)GAP (group theory)PARI/GP (number theory)Singular (polynomial computations)matplotlib (high quality 2D figures)

and provides a uniform interface to them

William Stein (Univ. of Washington) created SageMath in 2005; since then,∼100 developers (mostly mathematicians) have joined the SageMath team

SageMath is now supported by European Union via the open-math projectOpenDreamKit (2015-2019, within the Horizon 2020 program)

The mission

Create a viable free open source alternative to Magma, Maple, Mathematica andMatlab.

Eric Gourgoulhon (LUTH) GR computations with SageManifolds NewCompStar, Coimbra, 6 Sept. 2016 7 / 29

Page 21: General relativity computations with SageManifolds - Indico

Computer differential geometry and tensor calculus

SageMath in a few words

SageMath (nickname: Sage) is a free open-source mathematics softwaresystem

it is based on the Python programming languageit makes use of many pre-existing open-sources packages, among which

Maxima, Pynac (symbolic calculations)GAP (group theory)PARI/GP (number theory)Singular (polynomial computations)matplotlib (high quality 2D figures)

and provides a uniform interface to them

William Stein (Univ. of Washington) created SageMath in 2005; since then,∼100 developers (mostly mathematicians) have joined the SageMath team

SageMath is now supported by European Union via the open-math projectOpenDreamKit (2015-2019, within the Horizon 2020 program)

The mission

Create a viable free open source alternative to Magma, Maple, Mathematica andMatlab.

Eric Gourgoulhon (LUTH) GR computations with SageManifolds NewCompStar, Coimbra, 6 Sept. 2016 7 / 29

Page 22: General relativity computations with SageManifolds - Indico

Computer differential geometry and tensor calculus

Some advantages of SageMath

SageMath is free

Freedom means

1 everybody can use it, by downloading the software fromhttp://sagemath.org

2 everybody can examine the source code and improve it

SageMath is based on Python

no need to learn any specific syntax to use it

easy access for students

Python is a very powerful object oriented language, with a neat syntax

SageMath is developing and spreading fast

...sustained by an enthousiast community of developers

Eric Gourgoulhon (LUTH) GR computations with SageManifolds NewCompStar, Coimbra, 6 Sept. 2016 8 / 29

Page 23: General relativity computations with SageManifolds - Indico

Computer differential geometry and tensor calculus

Some advantages of SageMath

SageMath is free

Freedom means

1 everybody can use it, by downloading the software fromhttp://sagemath.org

2 everybody can examine the source code and improve it

SageMath is based on Python

no need to learn any specific syntax to use it

easy access for students

Python is a very powerful object oriented language, with a neat syntax

SageMath is developing and spreading fast

...sustained by an enthousiast community of developers

Eric Gourgoulhon (LUTH) GR computations with SageManifolds NewCompStar, Coimbra, 6 Sept. 2016 8 / 29

Page 24: General relativity computations with SageManifolds - Indico

Computer differential geometry and tensor calculus

Some advantages of SageMath

SageMath is free

Freedom means

1 everybody can use it, by downloading the software fromhttp://sagemath.org

2 everybody can examine the source code and improve it

SageMath is based on Python

no need to learn any specific syntax to use it

easy access for students

Python is a very powerful object oriented language, with a neat syntax

SageMath is developing and spreading fast

...sustained by an enthousiast community of developers

Eric Gourgoulhon (LUTH) GR computations with SageManifolds NewCompStar, Coimbra, 6 Sept. 2016 8 / 29

Page 25: General relativity computations with SageManifolds - Indico

Computer differential geometry and tensor calculus

Object-oriented notation in Python

As an object-oriented language, Python (and hence SageMath) makes use of thefollowing postfix notation (same in C++, Java, etc.):

result = object.function(arguments)

In a procedural language, this would be written as

result = function(object,arguments)

Examples

1. riem = g.riemann()

2. lie t v = t.lie der(v)

NB: no argument in example 1

Eric Gourgoulhon (LUTH) GR computations with SageManifolds NewCompStar, Coimbra, 6 Sept. 2016 9 / 29

Page 26: General relativity computations with SageManifolds - Indico

Computer differential geometry and tensor calculus

Object-oriented notation in Python

As an object-oriented language, Python (and hence SageMath) makes use of thefollowing postfix notation (same in C++, Java, etc.):

result = object.function(arguments)

In a procedural language, this would be written as

result = function(object,arguments)

Examples

1. riem = g.riemann()

2. lie t v = t.lie der(v)

NB: no argument in example 1

Eric Gourgoulhon (LUTH) GR computations with SageManifolds NewCompStar, Coimbra, 6 Sept. 2016 9 / 29

Page 27: General relativity computations with SageManifolds - Indico

Computer differential geometry and tensor calculus

SageMath approach to computer mathematics

SageMath relies on a Parent / Element scheme: each object x on which somecalculus is performed has a “parent”, which is another SageMath object Xrepresenting the set to which x belongs.The calculus rules on x are determined by the algebraic structure of X.Conversion rules prior to an operation, e.g. x+ y with x and y having differentparents, are defined at the level of the parents

Example

sage: x = 4 ; x.parent()

Integer Ring

sage: y = 4/3 ; y.parent()

Rational Field

sage: s = x + y ; s.parent()

Rational Field

sage: y.parent().has_coerce_map_from(x.parent())

True

This approach is similar to that of Magma and is different from that ofMathematica, in which everything is a tree of symbols

Eric Gourgoulhon (LUTH) GR computations with SageManifolds NewCompStar, Coimbra, 6 Sept. 2016 10 / 29

Page 28: General relativity computations with SageManifolds - Indico

Computer differential geometry and tensor calculus

SageMath approach to computer mathematics

SageMath relies on a Parent / Element scheme: each object x on which somecalculus is performed has a “parent”, which is another SageMath object Xrepresenting the set to which x belongs.The calculus rules on x are determined by the algebraic structure of X.Conversion rules prior to an operation, e.g. x+ y with x and y having differentparents, are defined at the level of the parents

Example

sage: x = 4 ; x.parent()

Integer Ring

sage: y = 4/3 ; y.parent()

Rational Field

sage: s = x + y ; s.parent()

Rational Field

sage: y.parent().has_coerce_map_from(x.parent())

True

This approach is similar to that of Magma and is different from that ofMathematica, in which everything is a tree of symbols

Eric Gourgoulhon (LUTH) GR computations with SageManifolds NewCompStar, Coimbra, 6 Sept. 2016 10 / 29

Page 29: General relativity computations with SageManifolds - Indico

Computer differential geometry and tensor calculus

SageMath approach to computer mathematics

SageMath relies on a Parent / Element scheme: each object x on which somecalculus is performed has a “parent”, which is another SageMath object Xrepresenting the set to which x belongs.The calculus rules on x are determined by the algebraic structure of X.Conversion rules prior to an operation, e.g. x+ y with x and y having differentparents, are defined at the level of the parents

Example

sage: x = 4 ; x.parent()

Integer Ring

sage: y = 4/3 ; y.parent()

Rational Field

sage: s = x + y ; s.parent()

Rational Field

sage: y.parent().has_coerce_map_from(x.parent())

True

This approach is similar to that of Magma and is different from that ofMathematica, in which everything is a tree of symbols

Eric Gourgoulhon (LUTH) GR computations with SageManifolds NewCompStar, Coimbra, 6 Sept. 2016 10 / 29

Page 30: General relativity computations with SageManifolds - Indico

The SageManifolds project

Outline

1 Computer differential geometry and tensor calculus

2 The SageManifolds project

3 Let us practice!

4 Other examples

5 Conclusion and perspectives

Eric Gourgoulhon (LUTH) GR computations with SageManifolds NewCompStar, Coimbra, 6 Sept. 2016 11 / 29

Page 31: General relativity computations with SageManifolds - Indico

The SageManifolds project

The SageManifolds project

http://sagemanifolds.obspm.fr/

Aim

Implement real smooth manifolds of arbitrary dimension in Sage and tensorcalculus on them

In particular:

one should be able to introduce an arbitrary number of coordinate charts ona given manifold, with the relevant transition maps

tensor fields must be manipulated as such and not through their componentswith respect to a specific (possibly coordinate) vector frame

Concretely, the project amounts to creating new Python classes, such asManifold, Chart, TensorField or Metric, within SageMath’s Parent/Elementframework.

Eric Gourgoulhon (LUTH) GR computations with SageManifolds NewCompStar, Coimbra, 6 Sept. 2016 12 / 29

Page 32: General relativity computations with SageManifolds - Indico

The SageManifolds project

The SageManifolds project

http://sagemanifolds.obspm.fr/

Aim

Implement real smooth manifolds of arbitrary dimension in Sage and tensorcalculus on them

In particular:

one should be able to introduce an arbitrary number of coordinate charts ona given manifold, with the relevant transition maps

tensor fields must be manipulated as such and not through their componentswith respect to a specific (possibly coordinate) vector frame

Concretely, the project amounts to creating new Python classes, such asManifold, Chart, TensorField or Metric, within SageMath’s Parent/Elementframework.

Eric Gourgoulhon (LUTH) GR computations with SageManifolds NewCompStar, Coimbra, 6 Sept. 2016 12 / 29

Page 33: General relativity computations with SageManifolds - Indico

The SageManifolds project

Implementing coordinate charts

Given a (topological) manifold M of dimension n ≥ 1, a coordinate chart is ahomeomorphism ϕ : U → V , where U is an open subset of M and V is an opensubset of Rn.

In general, more than one chart is required to cover the entire manifold:

Examples:

at least 2 charts are necessary to cover the n-dimensional sphere Sn (n ≥ 1)and the torus T2

at least 3 charts are necessary to cover the real projective plane RP2

In SageManifolds, an arbitrary number of charts can be introduced

To fully specify the manifold, one shall also provide the transition maps onoverlapping chart domains (SageManifolds class CoordChange)

Eric Gourgoulhon (LUTH) GR computations with SageManifolds NewCompStar, Coimbra, 6 Sept. 2016 13 / 29

Page 34: General relativity computations with SageManifolds - Indico

The SageManifolds project

Implementing coordinate charts

Given a (topological) manifold M of dimension n ≥ 1, a coordinate chart is ahomeomorphism ϕ : U → V , where U is an open subset of M and V is an opensubset of Rn.

In general, more than one chart is required to cover the entire manifold:

Examples:

at least 2 charts are necessary to cover the n-dimensional sphere Sn (n ≥ 1)and the torus T2

at least 3 charts are necessary to cover the real projective plane RP2

In SageManifolds, an arbitrary number of charts can be introduced

To fully specify the manifold, one shall also provide the transition maps onoverlapping chart domains (SageManifolds class CoordChange)

Eric Gourgoulhon (LUTH) GR computations with SageManifolds NewCompStar, Coimbra, 6 Sept. 2016 13 / 29

Page 35: General relativity computations with SageManifolds - Indico

The SageManifolds project

Implementing coordinate charts

Given a (topological) manifold M of dimension n ≥ 1, a coordinate chart is ahomeomorphism ϕ : U → V , where U is an open subset of M and V is an opensubset of Rn.

In general, more than one chart is required to cover the entire manifold:

Examples:

at least 2 charts are necessary to cover the n-dimensional sphere Sn (n ≥ 1)and the torus T2

at least 3 charts are necessary to cover the real projective plane RP2

In SageManifolds, an arbitrary number of charts can be introduced

To fully specify the manifold, one shall also provide the transition maps onoverlapping chart domains (SageManifolds class CoordChange)

Eric Gourgoulhon (LUTH) GR computations with SageManifolds NewCompStar, Coimbra, 6 Sept. 2016 13 / 29

Page 36: General relativity computations with SageManifolds - Indico

The SageManifolds project

Implementing scalar fields

A scalar field on manifold M is a smooth mapping

f : U ⊂M −→ Rp 7−→ f(p)

where U is an open subset of M .

A scalar field maps points, not coordinates, to real numbers=⇒ an object f in the ScalarField class has different coordinaterepresentations in different charts defined on U .

The various coordinate representations F , F , ... of f are stored as a Pythondictionary whose keys are the charts C, C, ...:

f. express ={C : F, C : F , . . .

}with f( p︸︷︷︸

point

) = F ( x1, . . . , xn︸ ︷︷ ︸coord. of pin chart C

) = F ( x1, . . . , xn︸ ︷︷ ︸coord. of pin chart C

) = . . .

Eric Gourgoulhon (LUTH) GR computations with SageManifolds NewCompStar, Coimbra, 6 Sept. 2016 14 / 29

Page 37: General relativity computations with SageManifolds - Indico

The SageManifolds project

Implementing scalar fields

A scalar field on manifold M is a smooth mapping

f : U ⊂M −→ Rp 7−→ f(p)

where U is an open subset of M .

A scalar field maps points, not coordinates, to real numbers=⇒ an object f in the ScalarField class has different coordinaterepresentations in different charts defined on U .

The various coordinate representations F , F , ... of f are stored as a Pythondictionary whose keys are the charts C, C, ...:

f. express ={C : F, C : F , . . .

}with f( p︸︷︷︸

point

) = F ( x1, . . . , xn︸ ︷︷ ︸coord. of pin chart C

) = F ( x1, . . . , xn︸ ︷︷ ︸coord. of pin chart C

) = . . .

Eric Gourgoulhon (LUTH) GR computations with SageManifolds NewCompStar, Coimbra, 6 Sept. 2016 14 / 29

Page 38: General relativity computations with SageManifolds - Indico

The SageManifolds project

Implementing scalar fields

A scalar field on manifold M is a smooth mapping

f : U ⊂M −→ Rp 7−→ f(p)

where U is an open subset of M .

A scalar field maps points, not coordinates, to real numbers=⇒ an object f in the ScalarField class has different coordinaterepresentations in different charts defined on U .

The various coordinate representations F , F , ... of f are stored as a Pythondictionary whose keys are the charts C, C, ...:

f. express ={C : F, C : F , . . .

}with f( p︸︷︷︸

point

) = F ( x1, . . . , xn︸ ︷︷ ︸coord. of pin chart C

) = F ( x1, . . . , xn︸ ︷︷ ︸coord. of pin chart C

) = . . .

Eric Gourgoulhon (LUTH) GR computations with SageManifolds NewCompStar, Coimbra, 6 Sept. 2016 14 / 29

Page 39: General relativity computations with SageManifolds - Indico

The SageManifolds project

The scalar field algebra

Given an open subset U ⊂M , the set C∞(U) of scalar fields defined on U hasnaturally the structure of a commutative algebra over R:

1 it is clearly a vector space over R2 it is endowed with a commutative ring structure by pointwise multiplication:

∀f, g ∈ C∞(U), ∀p ∈ U, (f.g)(p) := f(p)g(p)

The algebra C∞(U) is implemented in SageManifolds via the classScalarFieldAlgebra.

Eric Gourgoulhon (LUTH) GR computations with SageManifolds NewCompStar, Coimbra, 6 Sept. 2016 15 / 29

Page 40: General relativity computations with SageManifolds - Indico

The SageManifolds project

Classes for scalar fields

UniqueRepresentation Parent

ScalarFieldAlgebraring: SR

element: ScalarField

category: CommutativeAlgebras(SR)

CommutativeAlgebraElement

ScalarFieldparent: ScalarFieldAlgebra

Native Sage class

SageManifolds class(differential part)

Eric Gourgoulhon (LUTH) GR computations with SageManifolds NewCompStar, Coimbra, 6 Sept. 2016 16 / 29

Page 41: General relativity computations with SageManifolds - Indico

Let us practice!

Outline

1 Computer differential geometry and tensor calculus

2 The SageManifolds project

3 Let us practice!

4 Other examples

5 Conclusion and perspectives

Eric Gourgoulhon (LUTH) GR computations with SageManifolds NewCompStar, Coimbra, 6 Sept. 2016 17 / 29

Page 42: General relativity computations with SageManifolds - Indico

Let us practice!

Various ways to install/access SageMath

Install on your computer:3 options:

compile from source (Linux, MacOS X):

git clone git://github.com/sagemath/sage.git

cd sage

MAKE=’make -j8’ make

install a compiled binary version (Linux, MacOS X)run in virtual machine (Windows)

Sage Debian Live USB key:http://sagedebianlive.metelu.net/

comes along with SageMath (boosted with octave, scilab), Geogebra, LaTex,gimp, vlc, LibreOffice,...

SageMathCloud:https://cloud.sagemath.com/

SageMathCell:Single cell mode: http://sagecell.sagemath.org/

Eric Gourgoulhon (LUTH) GR computations with SageManifolds NewCompStar, Coimbra, 6 Sept. 2016 18 / 29

Page 43: General relativity computations with SageManifolds - Indico

Let us practice!

Various ways to run SageMath

Console mode:run the command sage

Standard Sage Notebook:run the command sage -n

=⇒ worksheet file format: sws

Jupyter Notebook1:run the command sage -n jupyter

=⇒ worksheet file format: ipynb

SageMathCloud:in your browser, open https://cloud.sagemath.com/

=⇒ worksheet file format: sagews, ipynb

1the future standard notebookEric Gourgoulhon (LUTH) GR computations with SageManifolds NewCompStar, Coimbra, 6 Sept. 2016 19 / 29

Page 44: General relativity computations with SageManifolds - Indico

Let us practice!

Deriving and solving the TOV equations

See the worksheet athttp://nbviewer.jupyter.org/github/egourgoulhon/NewCompStarSchool/blob/

master/WorkSheets/TOV.ipynb

The source is stored at GitHub, from which it can be downloaded:https://github.com/egourgoulhon/NewCompStarSchool

A copy of the worksheet is also publicly available on the SageMathCloud (click on theicon “Files”):https://cloud.sagemath.com/projects/

8f20b8d0-aac0-4454-95d5-dc929acae1e5/files/TOV.ipynb

Eric Gourgoulhon (LUTH) GR computations with SageManifolds NewCompStar, Coimbra, 6 Sept. 2016 20 / 29

Page 45: General relativity computations with SageManifolds - Indico

Other examples

Outline

1 Computer differential geometry and tensor calculus

2 The SageManifolds project

3 Let us practice!

4 Other examples

5 Conclusion and perspectives

Eric Gourgoulhon (LUTH) GR computations with SageManifolds NewCompStar, Coimbra, 6 Sept. 2016 21 / 29

Page 46: General relativity computations with SageManifolds - Indico

Other examples

The 2-sphere example

Stereographic coordinates on the2-sphere

Two charts:

X1: S2 \ {N} → R2

X2: S2 \ {S} → R2

← picture obtained via functionChart.plot()

See the worksheet athttp://sagemanifolds.obspm.fr/examples/html/SM_sphere_S2.html

Eric Gourgoulhon (LUTH) GR computations with SageManifolds NewCompStar, Coimbra, 6 Sept. 2016 22 / 29

Page 47: General relativity computations with SageManifolds - Indico

Other examples

The 2-sphere example

Vector frame associatedwith the stereographiccoordinates (x, y) from theNorth pole

∂∂x

∂∂y

← picture obtained viafunctionVectorField.plot()

Eric Gourgoulhon (LUTH) GR computations with SageManifolds NewCompStar, Coimbra, 6 Sept. 2016 23 / 29

Page 48: General relativity computations with SageManifolds - Indico

Other examples

Charts on Schwarzschild spacetimeThe Carter-Penrose diagram

-3 -2 -1 1 2 3X

-1.5

-1

-0.5

0.5

1

1.5

T

r= 0

r ′= 0

I

II

III

IV

Two charts of standard Schwarzschild-Droste coordinates (t, r, θ, ϕ) plotted in terms ofcompactified coordinates (T , X, θ, ϕ); see the worksheet athttp://luth.obspm.fr/~luthier/gourgoulhon/bh16/sage.html

Eric Gourgoulhon (LUTH) GR computations with SageManifolds NewCompStar, Coimbra, 6 Sept. 2016 24 / 29

Page 49: General relativity computations with SageManifolds - Indico

Conclusion and perspectives

Outline

1 Computer differential geometry and tensor calculus

2 The SageManifolds project

3 Let us practice!

4 Other examples

5 Conclusion and perspectives

Eric Gourgoulhon (LUTH) GR computations with SageManifolds NewCompStar, Coimbra, 6 Sept. 2016 25 / 29

Page 50: General relativity computations with SageManifolds - Indico

Conclusion and perspectives

Conclusion and perspectives

SageManifolds is a work in progress∼ 64,000 lines of Python code up to now (including comments and doctests)

A preliminary version (v0.9) is freely available (GPL) athttp://sagemanifolds.obspm.fr/

Eric Gourgoulhon (LUTH) GR computations with SageManifolds NewCompStar, Coimbra, 6 Sept. 2016 26 / 29

Page 51: General relativity computations with SageManifolds - Indico

Conclusion and perspectives

Current status

Already present (v0.9):

maps between manifolds, pullback operator

submanifolds, pushforward operator

curves in manifolds

standard tensor calculus (tensor product, contraction, symmetrization, etc.),even on non-parallelizable manifolds

all monoterm tensor symmetries

exterior calculus (wedge product, exterior derivative, Hodge duality)

Lie derivatives of tensor fields

affine connections, curvature, torsion

pseudo-Riemannian metrics, Weyl tensor

some plotting capabilities (charts, points, curves, vector fields)

parallelization (on tensor components) of CPU demanding computations, viathe Python library multiprocessing

Eric Gourgoulhon (LUTH) GR computations with SageManifolds NewCompStar, Coimbra, 6 Sept. 2016 27 / 29

Page 52: General relativity computations with SageManifolds - Indico

Conclusion and perspectives

Current status

Not implemented yet (but should be soon):

extrinsic geometry of pseudo-Riemannian submanifoldscomputation of geodesics (numerical integration via SageMath/GSL or Gyoto)integrals on submanifolds

Future prospects:

add more graphical outputsadd more functionalities: symplectic forms, fibre bundles, spinors, variationalcalculus, etc.connection with numerical relativity: using SageMath to explorenumerically-generated spacetimes

Eric Gourgoulhon (LUTH) GR computations with SageManifolds NewCompStar, Coimbra, 6 Sept. 2016 28 / 29

Page 53: General relativity computations with SageManifolds - Indico

Conclusion and perspectives

Current status

Not implemented yet (but should be soon):

extrinsic geometry of pseudo-Riemannian submanifoldscomputation of geodesics (numerical integration via SageMath/GSL or Gyoto)integrals on submanifolds

Future prospects:

add more graphical outputsadd more functionalities: symplectic forms, fibre bundles, spinors, variationalcalculus, etc.connection with numerical relativity: using SageMath to explorenumerically-generated spacetimes

Eric Gourgoulhon (LUTH) GR computations with SageManifolds NewCompStar, Coimbra, 6 Sept. 2016 28 / 29

Page 54: General relativity computations with SageManifolds - Indico

Conclusion and perspectives

Integration into SageMath

SageManifolds is aimed to be fully integrated into SageMath

The algebraic part (tensors on free modules of finite rank) has beensubmitted to SageMath Trac as ticket #15916 and got a positive review=⇒ integrated in SageMath 6.6

The differential part has been split in various tickets for submission toSageMath Trac (cf. the metaticket #18528); 4 tickets have been alreadyaccepted and integrated in SageMath 7.3

Until complete integration, the full SageManifold has to be downloaded fromhttp://sagemanifolds.obspm.fr/

SageManifolds v0.9 is installed in the SageMathCloud =⇒ open a freeaccount and use it online: https://cloud.sagemath.com/

Want to join the project or simply to stay tuned?

visit http://sagemanifolds.obspm.fr/(download page, documentation, example worksheets, mailing list)

Eric Gourgoulhon (LUTH) GR computations with SageManifolds NewCompStar, Coimbra, 6 Sept. 2016 29 / 29