Skip to main content
added 1041 characters in body
Source Link
Artes
  • 58.2k
  • 13
  • 161
  • 251

One should also look at the geometry section of

Next it would be veryeven more helpful and strongly recommended to look at this articlethese articles (some of them are particularly devoted to differential geometry topics, others only deal with useful geometric techniques) in the Mathematica Journal by Murray Eisenberg and David J. M. Park, Jr. :

One should also look at the geometry section of

Next it would be very helpful and strongly recommended to look at this article in the Mathematica Journal by Murray Eisenberg and David J. M. Park, Jr. :

One should also look at the geometry section of

One should also look at the geometry section of

Next it would be even more helpful and strongly recommended to look at these articles (some of them are particularly devoted to differential geometry topics, others only deal with useful geometric techniques) in the Mathematica Journal :

added explanations of the given functions
Source Link
Artes
  • 58.2k
  • 13
  • 161
  • 251

However if you need something straightforward and concise, look at this implementation below of a few fundamental objects in differential geometry. You need a metric g and a coordinate system xx on a mapan open set of a 4-dimentional (riemannian or lorentzian) manifold (but it is a straightforward to define these objects for other dimentions) as an input, eg.

The above is a Lorentzian metric tensor (in a given map) of a static spherically symmetric four dimentional manifold, and the following are the inverse metric, Christoffel symbol of the second kind, Riemann and Ricci curvature tensors and the Ricci scalar with brief descriptions of their usage:

enter image description here

 InverseMetric[ g_, xx_] := Block[{ res }, res = Simplify[ Inverse[g] ]; res ]   

enter image description here

 ChristoffelSymbol[g_, xx_] := Block[{n, ig, res}, n = 4; ig = InverseMetric[ g, xx]; res = Table[(1/2)*Sum[ ig[[i,s]]*(-D[ g[[j,k]], xx[[s]]] + D[ g[[j,s]], xx[[k]]] + D[ g[[s,k]], xx[[j]]]), {s, 1, n}], {i, 1, n}, {j, 1, n}, {k, 1, n}]; res ]   

enter image description here

 RiemannTensor[g_, xx_] := Block[{n, Chr, res}, n = 4; Chr = ChristoffelSymbol[ g, xx]; res = Table[ D[ Chr[[i,k,m]], xx[[l]]] - D[ Chr[[i,k,l]], xx[[m]]] + Sum[ Chr[[i,s,l]]*Chr[[s,k,m]], {s, 1, n}] - Sum[ Chr[[i,s,m]]*Chr[[s,k,l]], {s, 1, n}], {i, 1, n}, {k, 1, n}, {l, 1, n}, {m, 1, n}]; res ]  

enter image description here

 RicciTensor[g_, xx_] := Block[{Rie, res, n}, n = 4; Rie = RiemannTensor[ g, xx]; res = Table[ Sum[ Rie[[ s,i,s,j]], {s, 1, n}], {i, 1, n}, {j, 1, n}]; res ]    

enter image description here

 RicciScalar[g_, xx_] := Block[{Ricc,ig, res, n}, n = 4; Ricc = RicciTensor[ g, xx]; ig = InverseMetric[ g, xx]; res = Sum[ ig[[s,i]] Ricc[[s,i]], {s, 1, n}, {i, 1, n}]; Simplify[res] ] 

This is not an optimal implementation, but it is a good point to start building your own package. You could think about introducing a functional definition of the covariant derivative as well as lower and upper indices of covariant and contravariant tensors. One of the common difficulties with this is the multiplicity of definitions and conventions for Riemann and Ricci tensors etc, and that's why I added descriptions of the given functions.

However if you need something straightforward and concise, look at this implementation below of a few fundamental objects in differential geometry. You need a metric g and a coordinate system xx on a map of a 4-dimentional (riemannian or lorentzian) manifold (but it is a straightforward to define these objects for other dimentions) as an input, eg.

The above is a Lorentzian metric tensor (in a given map) of a static spherically symmetric four dimentional manifold, and the following are the inverse metric, Christoffel symbol of the second kind, Riemann and Ricci curvature tensors and Ricci scalar :

 InverseMetric[ g_, xx_] := Block[{ res }, res = Simplify[ Inverse[g] ]; res ]   ChristoffelSymbol[g_, xx_] := Block[{n, ig, res}, n = 4; ig = InverseMetric[ g, xx]; res = Table[(1/2)*Sum[ ig[[i,s]]*(-D[ g[[j,k]], xx[[s]]] + D[ g[[j,s]], xx[[k]]] + D[ g[[s,k]], xx[[j]]]), {s, 1, n}], {i, 1, n}, {j, 1, n}, {k, 1, n}]; res ]   RiemannTensor[g_, xx_] := Block[{n, Chr, res}, n = 4; Chr = ChristoffelSymbol[ g, xx]; res = Table[ D[ Chr[[i,k,m]], xx[[l]]] - D[ Chr[[i,k,l]], xx[[m]]] + Sum[ Chr[[i,s,l]]*Chr[[s,k,m]], {s, 1, n}] - Sum[ Chr[[i,s,m]]*Chr[[s,k,l]], {s, 1, n}], {i, 1, n}, {k, 1, n}, {l, 1, n}, {m, 1, n}]; res ]   RicciTensor[g_, xx_] := Block[{Rie, res, n}, n = 4; Rie = RiemannTensor[ g, xx]; res = Table[ Sum[ Rie[[ s,i,s,j]], {s, 1, n}], {i, 1, n}, {j, 1, n}]; res ]    RicciScalar[g_, xx_] := Block[{Ricc,ig, res, n}, n = 4; Ricc = RicciTensor[ g, xx]; ig = InverseMetric[ g, xx]; res = Sum[ ig[[s,i]] Ricc[[s,i]], {s, 1, n}, {i, 1, n}]; Simplify[res] ] 

This is not an optimal implementation, but it is a good point to start building your own package. You could think about introducing a functional definition of the covariant derivative as well as lower and upper indices of covariant and contravariant tensors. One of the common difficulties with this is multiplicity of definitions and conventions for Riemann and Ricci tensors etc.

However if you need something straightforward and concise, look at this implementation below of a few fundamental objects in differential geometry. You need a metric g and a coordinate system xx on an open set of a 4-dimentional (riemannian or lorentzian) manifold (but it is a straightforward to define these objects for other dimentions) as an input, eg.

The above is a Lorentzian metric tensor (in a given map) of a static spherically symmetric four dimentional manifold, and the following are the inverse metric, Christoffel symbol of the second kind, Riemann and Ricci curvature tensors and the Ricci scalar with brief descriptions of their usage:

enter image description here

 InverseMetric[ g_, xx_] := Block[{ res }, res = Simplify[ Inverse[g] ]; res ] 

enter image description here

 ChristoffelSymbol[g_, xx_] := Block[{n, ig, res}, n = 4; ig = InverseMetric[ g, xx]; res = Table[(1/2)*Sum[ ig[[i,s]]*(-D[ g[[j,k]], xx[[s]]] + D[ g[[j,s]], xx[[k]]] + D[ g[[s,k]], xx[[j]]]), {s, 1, n}], {i, 1, n}, {j, 1, n}, {k, 1, n}]; res ] 

enter image description here

 RiemannTensor[g_, xx_] := Block[{n, Chr, res}, n = 4; Chr = ChristoffelSymbol[ g, xx]; res = Table[ D[ Chr[[i,k,m]], xx[[l]]] - D[ Chr[[i,k,l]], xx[[m]]] + Sum[ Chr[[i,s,l]]*Chr[[s,k,m]], {s, 1, n}] - Sum[ Chr[[i,s,m]]*Chr[[s,k,l]], {s, 1, n}], {i, 1, n}, {k, 1, n}, {l, 1, n}, {m, 1, n}]; res ] 

enter image description here

 RicciTensor[g_, xx_] := Block[{Rie, res, n}, n = 4; Rie = RiemannTensor[ g, xx]; res = Table[ Sum[ Rie[[ s,i,s,j]], {s, 1, n}], {i, 1, n}, {j, 1, n}]; res ] 

enter image description here

 RicciScalar[g_, xx_] := Block[{Ricc,ig, res, n}, n = 4; Ricc = RicciTensor[ g, xx]; ig = InverseMetric[ g, xx]; res = Sum[ ig[[s,i]] Ricc[[s,i]], {s, 1, n}, {i, 1, n}]; Simplify[res] ] 

This is not an optimal implementation, but it is a good point to start building your own package. You could think about introducing a functional definition of the covariant derivative as well as lower and upper indices of covariant and contravariant tensors. One of the common difficulties with this is the multiplicity of definitions and conventions for Riemann and Ricci tensors etc, and that's why I added descriptions of the given functions.

added 114 characters in body
Source Link
Artes
  • 58.2k
  • 13
  • 161
  • 251

If you are looking for a package for tensor calculus, especially in General Relativity, the best choice is xAct made by José M. Martín-García (as far as I know he actually develops built-in functionality for the next versionfuture versions of Mathematica):

However if you need something straightforward and concise, look at this implementation below of a few fundamental objects in differential geometry. You need a metric g and a coordinate system xx on a map of a 4-dimentional metric(riemannian or lorentzian) manifold (but it is a straightforward to define thisthese objects for other dimentions) as an input g and a coordinate system xx, eg.

The above is a Lorentzian metric tensor (in a given map) of a static spherically symmetric four dimentional manifold, and the following are the inverse metric, Christoffel symbol of the second kind, Riemann and Ricci curvature tensors and Ricci scalar :

This is far from beingnot an optimal implementation, but it is a good point to start building your own package. You could think about introducing a functional definition of the covariant derivative as well as lower and upper indices of covariant and contravariant tensors. One of the common difficulties with this is multiplicity of definitions and conventions for Riemann and Ricci tensors etc.

It is resonableBesides of the above I recommend to look at the Wolfram Demonstrations :

another interesting thing by the same author :e.g.

Obviously you could find many helpful things here at the Wolfram Demonstrations :

For example :

Next it would be very helpful and strongly recommended to look at this article in the Mathematica Journal by Murray Eisenberg and David J. M. Park, Jr. :

If you are looking for a package for tensor calculus, especially in General Relativity, the best choice is xAct made by José M. Martín-García (as far as I know he actually develops built-in functionality for the next version of Mathematica):

However if you need something straightforward and concise, look at this implementation below of a few fundamental objects in differential geometry. You need a 4-dimentional metric (but it is a straightforward to define this objects for other dimentions) as an input g and a coordinate system xx, eg.

The above is a Lorentzian metric tensor of a static spherically symmetric four dimentional manifold,

This is far from being an optimal implementation, but it is a good point to start building your own package.

It is resonable to look at :

another interesting thing by the same author :

Obviously you could find many helpful things here at the Wolfram Demonstrations :

For example :

Next it would be very helpful to look at this article in the Mathematica Journal by Murray Eisenberg and David J. M. Park, Jr. :

If you are looking for a package for tensor calculus, especially in General Relativity, the best choice is xAct made by José M. Martín-García (as far as I know he actually develops built-in functionality for the future versions of Mathematica):

However if you need something straightforward and concise, look at this implementation below of a few fundamental objects in differential geometry. You need a metric g and a coordinate system xx on a map of a 4-dimentional (riemannian or lorentzian) manifold (but it is a straightforward to define these objects for other dimentions) as an input, eg.

The above is a Lorentzian metric tensor (in a given map) of a static spherically symmetric four dimentional manifold, and the following are the inverse metric, Christoffel symbol of the second kind, Riemann and Ricci curvature tensors and Ricci scalar :

This is not an optimal implementation, but it is a good point to start building your own package. You could think about introducing a functional definition of the covariant derivative as well as lower and upper indices of covariant and contravariant tensors. One of the common difficulties with this is multiplicity of definitions and conventions for Riemann and Ricci tensors etc.

Besides of the above I recommend to look at the Wolfram Demonstrations :

e.g.

Next it would be very helpful and strongly recommended to look at this article in the Mathematica Journal by Murray Eisenberg and David J. M. Park, Jr. :

added 2643 characters in body
Source Link
Artes
  • 58.2k
  • 13
  • 161
  • 251
Loading
added 662 characters in body
Source Link
Artes
  • 58.2k
  • 13
  • 161
  • 251
Loading
Source Link
Artes
  • 58.2k
  • 13
  • 161
  • 251
Loading