Subject: DeRhamComplex?
If we were to create a new domain that allows metric to be part of the definition,
what should it be called?
On 7 October 2014 12:13 Kurt Pagani wrote to fricas-devel@googlegroups.com:
I have no idea. You tell me? I can't yet overview how the final module(s) should
look like. What I have in mind is first to complete this by functions like proj
(projection on homogeneous parts, subspaces), push forward/pull back, interior
product and Lie derivative which is possible which little effort, second
to have simplicial homology (e.g. a type Simplex) then using FreeAbelianGroup?(Simplex),
defining boundaryOperator and so on such that one can deal with integration of
differential forms over simplicial complexes (Stokes theorem, Hodge pairing and
so on you know). It's almost all there but one has to organize it. It should be
a teamwork to becoming really useful, so any suggestions welcome.
spad
)abbrev domain DIFGEOM DifferentialGeometry
DifferentialGeometry(dim:NNI, CoefRing, listIndVar : DirectProduct(dim,Symbol), g:SMR) : Export == Implement where
CoefRing : Join(IntegralDomain, Comparable)
ASY ==> AntiSymm(R, listIndVar)
DERHAM ==> DeRhamComplex(CoefRing, members listIndVar)
DIFRING ==> DifferentialRing
LALG ==> LeftAlgebra
FMR ==> FreeMod(R, EAB)
I ==> Integer
L ==> List
EAB ==> ExtAlgBasis -- these are exponents of basis elements in order
NNI ==> NonNegativeInteger
O ==> OutputForm
R ==> Expression(CoefRing)
SMR ==> SquareMatrix(dim,R)
Export == Join(LALG(R), RetractableTo(R)) with
leadingCoefficient : % -> R
++ leadingCoefficient(df) returns the leading
++ coefficient of differential form df.
leadingBasisTerm : % -> %
++ leadingBasisTerm(df) returns the leading
++ basis term of differential form df.
reductum : % -> %
++ reductum(df), where df is a differential form,
++ returns df minus the leading
++ term of df if df has two or more terms, and
++ 0 otherwise.
coefficient : (%, %) -> R
++ coefficient(df, u), where df is a differential form,
++ returns the coefficient of df containing the basis term u
++ if such a term exists, and 0 otherwise.
generator : NNI -> %
++ generator(n) returns the nth basis term for a differential form.
homogeneous? : % -> Boolean
++ homogeneous?(df) tests if all of the terms of
++ differential form df have the same degree.
retractable? : % -> Boolean
++ retractable?(df) tests if differential form df is a 0-form,
++ i.e., if degree(df) = 0.
degree : % -> NNI
++ changed from I to NNI , then works
++ degree(df) returns the homogeneous degree of differential form df.
map : (R -> R, %) -> %
++ map(f, df) replaces each coefficient x of differential
++ form df by \spad{f(x)}.
totalDifferential : R -> %
++ totalDifferential(x) returns the total differential
++ (gradient) form for element x.
exteriorDifferential : % -> %
++ exteriorDifferential(df) returns the exterior
++ derivative (gradient, curl, divergence, ...) of
++ the differential form df.
--=-=-=-=-=-==-=-==-=-==-=-==-=-==-=-==-=-==-=-==-=-==-=-==-=-==-=-==-=-==-=-=
dim : % -> NNI
++ dimension of underlying space
++ that is dim ExtAlg = 2^dim
hodgeStar : (%) -> %
++ computes the Hodge dual of the differential form % with respect
++ to a metric g.
dot : (%,%) -> R
++ computes the inner product of two differential forms w.r.t. g
proj : (%,NNI) -> %
++ projection to homogeneous terms of degree p
interiorProduct : (Vector(R),%) -> %
++ calculates the interior product i_X(a) of the vector field X
++ with the differential form a (w.r.t. metric g).
lieDerivative : (Vector(R),%) -> %
++ calculates the Lie derivative L_X(a) of the differential
++ form a with respect to the vector field X (w.r.t. metric g).
--=-=-=-=-=-==-=-==-=-==-=-==-=-==-=-==-=-==-=-==-=-==-=-==-=-==-=-==-=-==-=-=
Implement == DERHAM add
Rep := DERHAM
terms : % -> List Record(k : EAB, c : R)
terms(a) ==
-- it is the case that there are at least two terms in a
a pretend List Record(k : EAB, c : R)
--=-=-=-=-=-==-=-==-=-==-=-==-=-==-=-==-=-==-=-==-=-==-=-==-=-==-=-==-=-==-=-=
-- error messages
err2:="Not implemented"
err3:="Degenerate metric"
err4:="Index out of range"
-- coord space dimension
dim(f) == dim
-- flip 0->1, 1->0
flip(b:ExtAlgBasis):ExtAlgBasis ==
bl := b pretend List(NNI)
[(i+1) rem 2 for i in bl] pretend ExtAlgBasis
-- list the positions of a's (a=0,1) in x
pos(x:EAB, a:NNI):List(NNI) ==
y:= x pretend List(NNI)
[j for j in 1..#y | y.j=a]
-- compute dot of singletons
dot1(r:Record(k : EAB, c : R),s:Record(k : EAB, c : R)):R ==
test(r.k ~= s.k) => 0::R
idx := pos(r.k,1)
idx = [] => r.c * s.c
reduce("*",[1/g(j,j) for j in idx]::List(R)) * r.c * s.c
-- export
dot(x,y) ==
tx := terms(x)
ty := terms(y)
reduce("+",[dot1(tx.j,ty.j) for j in 1..#tx])
-- export
hodgeStar(x) ==
not diagonal? g => error(err2)
v := sqrt(abs(determinant(g))) -- volume factor
v = 0 => error(err3)
t := terms(x)
s := [copy(r) for r in t] -- we need a copy of x!
for j in 1..#t repeat
s.j.k := flip(s.j.k)
fs:= [s.j] pretend %
ft:= [t.j] pretend %
s.j.c := s.j.c * v * dot1(t.j,t.j)/leadingCoefficient(ft*fs)
s pretend %
-- export
proj(x,p) ==
p < 0 or p > dim => error(err4)
t := terms(x)
idx := [j for j in 1..#t | #pos(t.j.k,1)=p]
s := [copy(t.j) for j in idx::List(NNI)]
s pretend %
interiorProduct(v,x) ==
f := reduce("+", [generator(i)$% for i in 1..dim]::List(%))
t := terms(f)
for j in 1..dim repeat
t.(dim-j+1).c := g(j,j)*v(j) -- reverse order!
f -- term manipulations are destructive ;)
dg:R := determinant(g)
sg:R := dg/abs(dg)
if odd?(dim) then
m:R := sg
else
m:R := (-1)^degree(x) * sg
m * hodgeStar(f * hodgeStar(x))
lieDerivative(v,x) ==
a := exteriorDifferential(interiorProduct(v,x))
b := interiorProduct(v, exteriorDifferential(x))
a+b
--=-=-=-=-=-==-=-==-=-==-=-==-=-==-=-==-=-==-=-==-=-==-=-==-=-==-=-==-=-==-=-=
spad
Compiling FriCAS source code from file
/var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/4948188826556596757-25px001.spad
using old system compiler.
DIFGEOM abbreviates domain DifferentialGeometry
------------------------------------------------------------------------
initializing NRLIB DIFGEOM for DifferentialGeometry
compiling into NRLIB DIFGEOM
****** Domain: CoefRing already in scope
compiling local terms : $ -> List Record(k: ExtAlgBasis,c: Expression CoefRing)
DIFGEOM;terms is replaced by a
Time: 0.05 SEC.
compiling exported dim : $ -> NonNegativeInteger
Time: 0 SEC.
compiling local flip : ExtAlgBasis -> ExtAlgBasis
Time: 0 SEC.
compiling local pos : (ExtAlgBasis,NonNegativeInteger) -> List NonNegativeInteger
Time: 0.03 SEC.
compiling local dot1 : (Record(k: ExtAlgBasis,c: Expression CoefRing),Record(k: ExtAlgBasis,c: Expression CoefRing)) -> Expression CoefRing
Time: 0.17 SEC.
compiling exported dot : ($,$) -> Expression CoefRing
Time: 0.02 SEC.
compiling exported hodgeStar : $ -> $
Time: 1.60 SEC.
compiling exported proj : ($,NonNegativeInteger) -> $
Time: 0.07 SEC.
compiling exported interiorProduct : (Vector Expression CoefRing,$) -> $
Time: 0.06 SEC.
compiling exported lieDerivative : (Vector Expression CoefRing,$) -> $
Time: 0 SEC.
(time taken in buildFunctor: 0)
;;; *** |DifferentialGeometry| REDEFINED
;;; *** |DifferentialGeometry| REDEFINED
Time: 0 SEC.
Warnings:
[1] dot1: k has no value
[2] dot1: c has no value
[3] hodgeStar: c has no value
Cumulative Statistics for Constructor DifferentialGeometry
Time: 2.00 seconds
--------------non extending category----------------------
.. DifferentialGeometry(#1,#2,#3,#4) of cat
(|Join| (|LeftAlgebra| (|Expression| |#2|))
(|RetractableTo| (|Expression| |#2|))
(CATEGORY |domain|
(SIGNATURE |leadingCoefficient| ((|Expression| |#2|) $))
(SIGNATURE |leadingBasisTerm| ($ $)) (SIGNATURE |reductum| ($ $))
(SIGNATURE |coefficient| ((|Expression| |#2|) $ $))
(SIGNATURE |generator| ($ (|NonNegativeInteger|)))
(SIGNATURE |homogeneous?| ((|Boolean|) $))
(SIGNATURE |retractable?| ((|Boolean|) $))
(SIGNATURE |degree| ((|NonNegativeInteger|) $))
(SIGNATURE |map|
($ (|Mapping| (|Expression| |#2|) (|Expression| |#2|)) $))
(SIGNATURE |totalDifferential| ($ (|Expression| |#2|)))
(SIGNATURE |exteriorDifferential| ($ $))
(SIGNATURE |#1| ((|NonNegativeInteger|) $))
(SIGNATURE |hodgeStar| ($ $))
(SIGNATURE |dot| ((|Expression| |#2|) $ $))
(SIGNATURE |proj| ($ $ (|NonNegativeInteger|)))
(SIGNATURE |interiorProduct| ($ (|Vector| (|Expression| |#2|)) $))
(SIGNATURE |lieDerivative| ($ (|Vector| (|Expression| |#2|)) $)))) has no degree : % -> Integer
finalizing NRLIB DIFGEOM
Processing DifferentialGeometry for Browser database:
--->-->DifferentialGeometry(constructor): Not documented!!!!
--------(leadingCoefficient ((Expression CoefRing) %))---------
--------(leadingBasisTerm (% %))---------
--------(reductum (% %))---------
--------(coefficient ((Expression CoefRing) % %))---------
--------(generator (% (NonNegativeInteger)))---------
--------(homogeneous? ((Boolean) %))---------
--------(retractable? ((Boolean) %))---------
--------(degree ((NonNegativeInteger) %))---------
--->-->DifferentialGeometry((degree ((NonNegativeInteger) %))): Improper first word in comments: changed
"changed from \\spad{I} to NNI ,{} then works degree(\\spad{df}) returns the homogeneous degree of differential form \\spad{df}."
--------(map (% (Mapping (Expression CoefRing) (Expression CoefRing)) %))---------
--------(totalDifferential (% (Expression CoefRing)))---------
--------(exteriorDifferential (% %))---------
--------(dim ((NonNegativeInteger) %))---------
--->-->DifferentialGeometry((dim ((NonNegativeInteger) %))): Improper first word in comments: dimension
"dimension of underlying space that is dim ExtAlg = 2^dim"
--------(hodgeStar (% %))---------
--->-->DifferentialGeometry((hodgeStar (% %))): Improper first word in comments: computes
"computes the Hodge dual of the differential form \\% with respect to a metric \\spad{g}."
--------(dot ((Expression CoefRing) % %))---------
--->-->DifferentialGeometry((dot ((Expression CoefRing) % %))): Improper first word in comments: computes
"computes the inner product of two differential forms \\spad{w}.\\spad{r}.\\spad{t}. \\spad{g}"
--------(proj (% % (NonNegativeInteger)))---------
--->-->DifferentialGeometry((proj (% % (NonNegativeInteger)))): Improper first word in comments: projection
"projection to homogeneous terms of degree \\spad{p}"
--------(interiorProduct (% (Vector (Expression CoefRing)) %))---------
--->-->DifferentialGeometry((interiorProduct (% (Vector (Expression CoefRing)) %))): Improper first word in comments: calculates
"calculates the interior product i_X(a) of the vector field \\spad{X} with the differential form a (\\spad{w}.\\spad{r}.\\spad{t}. metric \\spad{g})."
--------(lieDerivative (% (Vector (Expression CoefRing)) %))---------
--->-->DifferentialGeometry((lieDerivative (% (Vector (Expression CoefRing)) %))): Improper first word in comments: calculates
"calculates the Lie derivative \\spad{L_X}(a) of the differential form a with respect to the vector field \\spad{X} (\\spad{w}.\\spad{r}.\\spad{t}. metric \\spad{g})."
--->-->DifferentialGeometry(): Missing Description
; compiling file "/var/aw/var/LatexWiki/DIFGEOM.NRLIB/DIFGEOM.lsp" (written 09 OCT 2014 01:05:29 AM):
; /var/aw/var/LatexWiki/DIFGEOM.NRLIB/DIFGEOM.fasl written
; compilation finished in 0:00:00.106
------------------------------------------------------------------------
DifferentialGeometry is now explicitly exposed in frame initial
DifferentialGeometry will be automatically loaded when needed from
/var/aw/var/LatexWiki/DIFGEOM.NRLIB/DIFGEOM
fricas
G:=diagonalMatrix([1,1,1])
Type: Matrix(Integer)
fricas
X := DIFGEOM(3,Integer,[x,y,z],G)
Type: Type
fricas
[dx,dy,dz] := [generator(i)$X for i in 1..3]
Type: List(DifferentialGeometry
?(3,
Integer,
[x,
y,
z],
[[1,
0,
0],
[0,
1,
0],
[0,
0,
1]]))
fricas
f : BOP := operator('f);
fricas
g : BOP := operator('g);
fricas
h : BOP := operator('h);
fricas
sigma := f(x,y,z) * dx + g(x,y,z) * dy + h(x,y,z) * dz
Type: DifferentialGeometry
?(3,
Integer,
[x,
y,
z],
[[1,
0,
0],
[0,
1,
0],
[0,
0,
1]])
fricas
dot(sigma,sigma)
Type: Expression(Integer)
fricas
hodgeStar(sigma)
Type: DifferentialGeometry
?(3,
Integer,
[x,
y,
z],
[[1,
0,
0],
[0,
1,
0],
[0,
0,
1]])
fricas
)lib DIFGEOM
DifferentialGeometry is already explicitly exposed in frame initial
DifferentialGeometry will be automatically loaded when needed from
/var/aw/var/LatexWiki/DIFGEOM.NRLIB/DIFGEOM
fricas
G:=diagonalMatrix([1,1,1])
Type: Matrix(Integer)
fricas
X := DIFGEOM(3,Integer,[x',y,z],G)
Type: Type
fricas
Y := DIFGEOM(3,Integer,[x,y',z],G)
Type: Type
fricas
xy:X
Type: Void
fricas
xy:=generator(1)$X
Type: DifferentialGeometry
?(3,
Integer,
[x',
y,
z],
[[1,
0,
0],
[0,
1,
0],
[0,
0,
1]])
fricas
xy:=generator(1)$Y
Cannot convert right-hand side of assignment
dx
to an object of the type DifferentialGeometry(3,Integer,[x',y,z],
[[1,0,0],[0,1,0],[0,0,1]]) of the left-hand side.