login  home  contents  what's new  discussion  bug reports help  links  subscribe  changes  refresh  edit

)abbrev package DFORM DifferentialForms
++ Author: Kurt Pagani <nilqed@gmail.com>
++ Date Created: October 2014
++ Revised: Sat Sep 17 17:10:00 CET 2016
++ Description: Basic differential form methods
++ Requirements: DeRhamComplex, FriCAS 1.3 or later.
++ Documentation: Sphinx, folder doc and/or do
++ - [pdf]latex dform.spad -> dvi or pdf file.
++ - run two times to get refs and labels correct.
++
DifferentialForms(R,v) : Exports == Implementation where
R: Join(IntegralDomain,Comparable)
v: List Symbol
X   ==> Expression R
OF  ==> OutputForm
DRC ==> DeRhamComplex(R,v)
CHC ==> ChainComplex(R,#v)
BOP ==> BasicOperator
NNI ==> NonNegativeInteger
SMR ==> SquareMatrix(#v,X)
EAB ==> ExtAlgBasis
REA ==> Record(k : EAB, c : X)
SGCF ==> SymmetricGroupCombinatoricFunctions
Exports ==  with
_* : (List X, List DRC) -> DRC
++ v*w computes the sum of the products v_i * w_i
++ where v_i is a scalar and w_i a differential form.
++ This is for convenience only, just to deal with
++ differential form valued vectors.
_* : (List DRC, List DRC) -> DRC
++ w1*w2 computes the sum of the exterior products
++ w1_i * w2_i, where w1,w2 are differential forms.
d : DRC -> DRC
++ d w computes the exterior derivative and is just an
++ abbreviation for the fucntion "exteriorDifferential"
++ defined in the domain "DeRhamComplex".
one :  -> DRC
++ one() gives 1@DeRhamComplex, i.e. "1" as a differential
++ form. This is useful to intern elements of the function
++ ring (just multiply them by one()$DFORM). zero : -> DRC ++ zero() gives the zero form, i.e. 0@DRC. baseForms : () -> List DRC ++ baseForms()$M returns a list of all base forms in the
++ space M=DFORM(Ring,Coordinates).
coordVector : () -> List X
++ coordVector()$M returns a list of the coordinates in ++ the space M=DFORM(Ring,Coordinates). coordSymbols : () -> List Symbol ++ coordSymbols()$M returns a list of the coordinates as
++ symbols. This is useful for example if the differential
++ operators "D" are going to be used.
vectorField : Symbol -> List X
++ vectorField(V) creates a vector (actually a list) whose
++ components are given by V[j](x[1],...,x[n]), j=1..n,
++ whereby "x" are the space coordinates (possibly not the
++ same symbol).
scalarField : Symbol -> X
++ scalarField(s) creates a scalar function s(x[1],...,[n]),
++ whereby "x" are the space coordinates (possibly not the
++ same symbol).
covectorField : Symbol -> List DRC
++ covectorField(Y) creates a covector (actually a list)
++ whose components are given by w[j](x[1],...,x[n]),
++ j=1..n.
zeroForm : Symbol -> DRC
++ zeroForm(s) creates a zero form with symbol "s". This
++ is the same as scalarField(s)*one().
volumeForm : SMR -> DRC
++ volumeForm(g) returns the volume form with respect to
++ the (pseudo-) metric "g".
conjBasisTerm : DRC -> DRC
++ Return the complement of a basis term w.r.t. volumeForm
atomizeBasisTerm : DRC -> List DRC
++ Given a basis term, e.g. dx*dy*du, atomizeBasisTerm  returns
++ a list of the generators (atoms), i.e. [dx,dy,du] for our example.
monomials : NNI -> List DRC
++ List of all monomials of degree p (p in 1..n).
++ This is a basis for Lambda(n,p).
hodgeStar : (SMR,DRC) -> DRC
++ computes the Hodge dual of the differential form % with respect
++ to a metric g.
dot : (SMR,DRC,DRC) -> X
++ computes the inner product of two differential forms w.r.t. g
proj : (NNI,DRC) -> DRC
++ projection to homogeneous terms of degree p
interiorProduct : (Vector(X),DRC) -> DRC
++ Calculates the interior product i_X(a) of the vector field X
++ with the differential form a.
lieDerivative : (Vector(X),DRC) -> DRC
++ Calculates the Lie derivative L_X(a) of the differential
++ form a with respect to the vector field X.
s : SMR -> X
++ s(g) determines the sign of determinant(g) and is related to the
++ signature of g (n=p+q,t=p-q,s=(-)^(n-t)/2 => s=(-)^q.
invHodgeStar : (SMR,DRC) -> DRC
++ invHodgeStar is the inverse of hodgeStar.
codifferential : (SMR,DRC) -> DRC
++ codifferential(g,x), also known as "delta", computes the
++ co-differential of a form.
hodgeLaplacian : (SMR,DRC) -> DRC
++ hodgeLaplacian(g,x) also known as "Laplace-de Rham operator" is
++ defined on any manifold equipped with a (pseudo-) Riemannian
++ metric and is given by d codifferential(g,x)+ codifferential(g, d x).
++ Note that in the Euclidean case hodgeLaplacian = - Laplacian.
-- error messages
err1:="Metric tensor must be symmetric"
err2:="Degenerate metric"
err3:="Index out of range"
err4:="Not implemented"
err5:="Basis term expected"
err6:="Zero is not a basis term"
-- conversion functions (not very nice ;)
eab2li(x:EAB):List(Integer) == x pretend List(Integer)
drc2rea(x:DRC):List(REA) == x pretend List(REA)
n:NNI:=#v
d(f) == exteriorDifferential(f)
one () == 1@DRC
zero() == 0@DRC
baseForms() == [generator(j)$DRC for j in 1..n] coordVector() == [s::X for s in v] coordSymbols() == v vectorField(s:Symbol):List X == ls:=[subscript(s,[j::OF]) for j in 1..n] op:=[operator t for t in ls] x:=[a::X for a in v] [f x for f in op] scalarField(s:Symbol):X == f:=operator s f [a::X for a in v] covectorField(s:Symbol):List DRC == vf:=vectorField(s) [a*1@DRC for a in vf] zeroForm(s:Symbol):DRC == scalarField(s)*1@DRC (l:List(X) * x:List DRC):DRC == l:List DRC:=[l.j * x.j for j in 1..n] reduce(_+,l) (x:List DRC * y:List DRC):DRC == l:List DRC:=[x.j * y.j for j in 1..n] reduce(_+,l) volumeForm(g:SMR):DRC == sqrt(abs(determinant(g)))*reduce(_*,baseForms()) monomials(p:NNI):List DRC == bf:=baseForms() p=0 => [1$DRC]
p=1 => bf
np:=[reverse subSet(n,p,i)$SGCF for i in 0..binomial(n,p)-1] [reduce(_*,[bf.(1+s.j) for j in 1..p]) for s in np] -- flip 0->1, 1->0 flip(b:EAB):EAB == --bl := convert(b)$EAB
bl:=eab2li(b)
[(i+1) rem 2 for i in bl]::EAB
-- list the positions of a's (a=0,1) in x
pos(x:EAB, a:Integer):List(Integer) ==
y:List(Integer):=eab2li(x)
[j for j in 1..#y | y.j=a]
-- compute dot of singletons, diagonal g
dot1(g:SMR,r:REA, s:REA):X ==
test(r.k ~= s.k) => 0::X
idx := pos(r.k,1)
idx = [] => r.c * s.c
reduce("*",[1/g(j,j) for j in idx]::List(X)) * r.c * s.c
-- compute dot of singleton terms, general symmetric g
dot2(g:SMR,r:REA, s:REA):X ==
pr := pos(r.k,1) -- list positions of 1 in r
ps := pos(s.k,1) -- list positions of 1 in s
test(#pr ~= #ps) => 0::X  -- not same degree => 0
pr = []  => r.c * s.c -- empty pr,ps => product of coefs
G := inverse(g)::SMR -- compute the inverse of the metric g
test(#pr = 1) => G(pr.1,ps.1)::X * r.c * s.c -- only one element
M:Matrix(X) -- the minor
M := matrix([[G(pr.i,ps.j)::X for j in 1..#ps] for i in 1..#pr])
determinant(M)::X * r.c * s.c
-- export
dot(g:SMR,x:DRC,y:DRC):X ==
not symmetric? g => error(err1)
tx:List REA := drc2rea(x)
ty:List REA := drc2rea(y)
tx = [] or ty = [] => 0::X
if diagonal? g then -- better performance
a:List(X):=concat[[dot1(g,tx.j,ty.l)::X for j in 1..#tx] for l in 1..#ty]
reduce(_+,a)
else
b:List(X):=concat[[dot2(g,tx.j,ty.l)::X for j in 1..#tx] for l in 1..#ty]
reduce(_+,b)
proj(p,x) ==
x=0 => x
homogeneous? x and degree(x)=p => x
if degree(a)=p then
else
proj(p, reductum x)
conjBasisTerm(x:DRC):DRC ==
x=0$DRC => error(err6) x ~= leadingBasisTerm(x) => error(err5) t:EAB:=drc2rea(x).1.k l:List(Integer):=exponents(t) m:List(DRC):=[generator(i)$DRC for i in 1..#l | l.i=0]
m=[] => 1$DRC reduce(_*,m) atomizeBasisTerm(x:DRC):List(DRC) == x=0$DRC => error(err6)
t:EAB:=drc2rea(x).1.k
l:List(Integer):=exponents(t)
[generator(i)$DRC for i in 1..#l | l.i=1] intProdBasisTerm(w:Vector X, x:DRC):DRC == x ~= leadingBasisTerm(x) => error(err5) degree(x)=0 => 0$DRC
degree(x)=1 => w.position(x,baseForms()) * 1$DRC a:List(DRC):=atomizeBasisTerm(x) b:DRC:=reduce(_*,rest a) -- i_w is an antiderivative => intProdBasisTerm(w,a.1)*b - a.1 * intProdBasisTerm(w,b) interiorProduct(w:Vector X, x:DRC):DRC == x=0$DRC => x
interiorProduct(w, reductum(x))
lieDerivative(w:Vector X,x:DRC):DRC ==
a := exteriorDifferential(interiorProduct(w,x))
b := interiorProduct(w, exteriorDifferential(x))
a+b
hodgeStarBT(g:SMR,x:DRC):DRC ==
q:=sqrt(abs(determinant(g)))
p:=degree(x)
J:=monomials(p)
s:=[eps(y)*dot(g,y,x)*conjBasisTerm(y) for y in J]
q*reduce(_+,s)
hodgeStar(g:SMR,x:DRC):DRC ==
x=0$DRC => x leadingCoefficient(x)*hodgeStarBT(g,leadingBasisTerm(x)) + _ hodgeStar(g, reductum(x)) s(g:SMR):X == det:X:=determinant g sd:Union(Integer,"failed"):=sign(det)$ElementaryFunctionSign(Integer,X)
sd case "failed" => 's?::X
sd case Integer => coerce(sd)$X invHodgeStar(g:SMR,x:DRC):DRC == x=0$DRC => x
k:X:=coerce(degree y)$X c:X:=s(g)*(-1)^(k*(coerce(n)$X-k))
invHodgeStar(g, reductum(x))
codifferential(g:SMR,x:DRC):DRC ==
x=0$DRC => 0 y:DRC:=leadingBasisTerm(x) k:X:=coerce(degree y)$X
c:X:=s(g)*(-1)^(coerce(n)$X*(k-1)+1) c*hodgeStar(g,d hodgeStar(g,leadingCoefficient(x)*y)) + _ codifferential(g,reductum(x)) hodgeLaplacian(g:SMR,x:DRC):DRC == d codifferential(g,x)+ codifferential(g, d x) spad  Compiling FriCAS source code from file /var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/7780364366861049302-25px001.spad using old system compiler. DFORM abbreviates package DifferentialForms ------------------------------------------------------------------------ initializing NRLIB DFORM for DifferentialForms compiling into NRLIB DFORM ****** Domain: R already in scope compiling local eab2li : ExtAlgBasis -> List Integer DFORM;eab2li is replaced by x Time: 0.02 SEC. compiling local drc2rea : DeRhamComplex(R,v) -> List Record(k: ExtAlgBasis,c: Expression R) DFORM;drc2rea is replaced by x Time: 0 SEC. compiling exported d : DeRhamComplex(R,v) -> DeRhamComplex(R,v) Time: 0.02 SEC. compiling exported one : () -> DeRhamComplex(R,v) Time: 0 SEC. compiling exported zero : () -> DeRhamComplex(R,v) Time: 0 SEC. compiling exported baseForms : () -> List DeRhamComplex(R,v) Time: 0.01 SEC. compiling exported coordVector : () -> List Expression R Time: 0 SEC. compiling exported coordSymbols : () -> List Symbol Time: 0 SEC. compiling exported vectorField : Symbol -> List Expression R Time: 0.02 SEC. compiling exported scalarField : Symbol -> Expression R Time: 0 SEC. compiling exported covectorField : Symbol -> List DeRhamComplex(R,v) Time: 0 SEC. compiling exported zeroForm : Symbol -> DeRhamComplex(R,v) Time: 0.01 SEC. compiling exported * : (List Expression R,List DeRhamComplex(R,v)) -> DeRhamComplex(R,v) Time: 0.02 SEC. compiling exported * : (List DeRhamComplex(R,v),List DeRhamComplex(R,v)) -> DeRhamComplex(R,v) Time: 0.03 SEC. compiling exported volumeForm : SquareMatrix(# v,Expression R) -> DeRhamComplex(R,v) Time: 0.08 SEC. compiling exported monomials : NonNegativeInteger -> List DeRhamComplex(R,v) Time: 0.01 SEC. compiling local flip : ExtAlgBasis -> ExtAlgBasis Time: 0 SEC. compiling local pos : (ExtAlgBasis,Integer) -> List Integer Time: 0.02 SEC. compiling local dot1 : (SquareMatrix(# v,Expression R),Record(k: ExtAlgBasis,c: Expression R),Record(k: ExtAlgBasis,c: Expression R)) -> Expression R Time: 0.46 SEC. compiling local dot2 : (SquareMatrix(# v,Expression R),Record(k: ExtAlgBasis,c: Expression R),Record(k: ExtAlgBasis,c: Expression R)) -> Expression R Time: 0.80 SEC. compiling exported dot : (SquareMatrix(# v,Expression R),DeRhamComplex(R,v),DeRhamComplex(R,v)) -> Expression R Time: 0.01 SEC. compiling exported proj : (NonNegativeInteger,DeRhamComplex(R,v)) -> DeRhamComplex(R,v) Time: 0.01 SEC. compiling exported conjBasisTerm : DeRhamComplex(R,v) -> DeRhamComplex(R,v) Time: 0.02 SEC. compiling exported atomizeBasisTerm : DeRhamComplex(R,v) -> List DeRhamComplex(R,v) Time: 0.02 SEC. compiling local intProdBasisTerm : (Vector Expression R,DeRhamComplex(R,v)) -> DeRhamComplex(R,v) Time: 0.07 SEC. compiling exported interiorProduct : (Vector Expression R,DeRhamComplex(R,v)) -> DeRhamComplex(R,v) Time: 0 SEC. compiling exported lieDerivative : (Vector Expression R,DeRhamComplex(R,v)) -> DeRhamComplex(R,v) Time: 0.01 SEC. compiling local eps : DeRhamComplex(R,v) -> Expression R Time: 0 SEC. compiling local hodgeStarBT : (SquareMatrix(# v,Expression R),DeRhamComplex(R,v)) -> DeRhamComplex(R,v) Time: 0.07 SEC. compiling exported hodgeStar : (SquareMatrix(# v,Expression R),DeRhamComplex(R,v)) -> DeRhamComplex(R,v) Time: 0.01 SEC. compiling exported s : SquareMatrix(# v,Expression R) -> Expression R Time: 0.04 SEC. compiling exported invHodgeStar : (SquareMatrix(# v,Expression R),DeRhamComplex(R,v)) -> DeRhamComplex(R,v) Time: 0.15 SEC. compiling exported codifferential : (SquareMatrix(# v,Expression R),DeRhamComplex(R,v)) -> DeRhamComplex(R,v) Time: 0.74 SEC. compiling exported hodgeLaplacian : (SquareMatrix(# v,Expression R),DeRhamComplex(R,v)) -> DeRhamComplex(R,v) Time: 0 SEC. (time taken in buildFunctor: 0) ;;; *** |DifferentialForms| REDEFINED ;;; *** |DifferentialForms| REDEFINED Time: 0 SEC. Semantic Errors: [1] invHodgeStar: k is BOTH a variable and a literal [2] invHodgeStar: c is BOTH a variable and a literal [3] codifferential: k is BOTH a variable and a literal [4] codifferential: c is BOTH a variable and a literal Warnings: [1] dot1: k has no value [2] dot1: c has no value [3] dot2: k has no value [4] dot2: c has no value [5] conjBasisTerm: k has no value [6] atomizeBasisTerm: k has no value [7] s: not known that (AlgebraicallyClosedField) is of mode (CATEGORY domain (IF (has R (IntegralDomain)) (PROGN (ATTRIBUTE (AlgebraicallyClosedFunctionSpace R)) (ATTRIBUTE (TranscendentalFunctionCategory)) (ATTRIBUTE (CombinatorialOpsCategory)) (ATTRIBUTE (LiouvillianFunctionCategory)) (ATTRIBUTE (SpecialFunctionCategory)) (SIGNATURE reduce ($ $)) (SIGNATURE number? ((Boolean)$)) (IF (has R (PolynomialFactorizationExplicit)) (ATTRIBUTE (PolynomialFactorizationExplicit)) noBranch) (SIGNATURE setSimplifyDenomsFlag ((Boolean) (Boolean))) (SIGNATURE getSimplifyDenomsFlag ((Boolean)))) noBranch))
[8] s: not known that (TranscendentalFunctionCategory) is of mode (CATEGORY domain (IF (has R (IntegralDomain)) (PROGN (ATTRIBUTE (AlgebraicallyClosedFunctionSpace R)) (ATTRIBUTE (TranscendentalFunctionCategory)) (ATTRIBUTE (CombinatorialOpsCategory)) (ATTRIBUTE (LiouvillianFunctionCategory)) (ATTRIBUTE (SpecialFunctionCategory)) (SIGNATURE reduce ()) (SIGNATURE number? ((Boolean) $)) (IF (has R (PolynomialFactorizationExplicit)) (ATTRIBUTE (PolynomialFactorizationExplicit)) noBranch) (SIGNATURE setSimplifyDenomsFlag ((Boolean) (Boolean))) (SIGNATURE getSimplifyDenomsFlag ((Boolean)))) noBranch)) [9] s: not known that (FunctionSpace (Integer)) is of mode (CATEGORY domain (IF (has R (IntegralDomain)) (PROGN (ATTRIBUTE (AlgebraicallyClosedFunctionSpace R)) (ATTRIBUTE (TranscendentalFunctionCategory)) (ATTRIBUTE (CombinatorialOpsCategory)) (ATTRIBUTE (LiouvillianFunctionCategory)) (ATTRIBUTE (SpecialFunctionCategory)) (SIGNATURE reduce ($ $)) (SIGNATURE number? ((Boolean)$)) (IF (has R (PolynomialFactorizationExplicit)) (ATTRIBUTE (PolynomialFactorizationExplicit)) noBranch) (SIGNATURE setSimplifyDenomsFlag ((Boolean) (Boolean))) (SIGNATURE getSimplifyDenomsFlag ((Boolean)))) noBranch))
Cumulative Statistics for Constructor DifferentialForms
Time: 2.65 seconds
finalizing NRLIB DFORM
Processing DifferentialForms for Browser database:
--------constructor---------
--------(* ((DeRhamComplex R v) (List (Expression R)) (List (DeRhamComplex R v))))---------
--------(* ((DeRhamComplex R v) (List (DeRhamComplex R v)) (List (DeRhamComplex R v))))---------
--------(d ((DeRhamComplex R v) (DeRhamComplex R v)))---------
--------(one ((DeRhamComplex R v)))---------
--------(zero ((DeRhamComplex R v)))---------
--------(baseForms ((List (DeRhamComplex R v))))---------
--------(coordVector ((List (Expression R))))---------
--------(coordSymbols ((List (Symbol))))---------
--------(vectorField ((List (Expression R)) (Symbol)))---------
--------(scalarField ((Expression R) (Symbol)))---------
--------(covectorField ((List (DeRhamComplex R v)) (Symbol)))---------
--------(zeroForm ((DeRhamComplex R v) (Symbol)))---------
--------(volumeForm ((DeRhamComplex R v) (SquareMatrix (# v) (Expression R))))---------
--------(conjBasisTerm ((DeRhamComplex R v) (DeRhamComplex R v)))---------
--->-->DifferentialForms((conjBasisTerm ((DeRhamComplex R v) (DeRhamComplex R v)))): Improper first word in comments: Return
--------(atomizeBasisTerm ((List (DeRhamComplex R v)) (DeRhamComplex R v)))---------
--->-->DifferentialForms((atomizeBasisTerm ((List (DeRhamComplex R v)) (DeRhamComplex R v)))): Improper first word in comments: Given
"Given a basis term,{} \\spadignore{e.g.} dx*dy*du,{} atomizeBasisTerm returns a list of the generators (atoms),{} \\spadignore{i.e.} [\\spad{dx},{}dy,{}du] for our example."
--------(monomials ((List (DeRhamComplex R v)) (NonNegativeInteger)))---------
--->-->DifferentialForms((monomials ((List (DeRhamComplex R v)) (NonNegativeInteger)))): Improper first word in comments: List
--------(hodgeStar ((DeRhamComplex R v) (SquareMatrix (# v) (Expression R)) (DeRhamComplex R v)))---------
--->-->DifferentialForms((hodgeStar ((DeRhamComplex R v) (SquareMatrix (# v) (Expression R)) (DeRhamComplex R v)))): Improper first word in comments: computes
"computes the Hodge dual of the differential form \\% with respect to a metric \\spad{g}."
--------(dot ((Expression R) (SquareMatrix (# v) (Expression R)) (DeRhamComplex R v) (DeRhamComplex R v)))---------
--->-->DifferentialForms((dot ((Expression R) (SquareMatrix (# v) (Expression R)) (DeRhamComplex R v) (DeRhamComplex R v)))): Improper first word in comments: computes
--------(proj ((DeRhamComplex R v) (NonNegativeInteger) (DeRhamComplex R v)))---------
--->-->DifferentialForms((proj ((DeRhamComplex R v) (NonNegativeInteger) (DeRhamComplex R v)))): Improper first word in comments: projection
"projection to homogeneous terms of degree \\spad{p}"
--------(interiorProduct ((DeRhamComplex R v) (Vector (Expression R)) (DeRhamComplex R v)))---------
--->-->DifferentialForms((interiorProduct ((DeRhamComplex R v) (Vector (Expression R)) (DeRhamComplex R v)))): Improper first word in comments: Calculates
"Calculates the interior product i_X(a) of the vector field \\spad{X} with the differential form a."
--------(lieDerivative ((DeRhamComplex R v) (Vector (Expression R)) (DeRhamComplex R v)))---------
--->-->DifferentialForms((lieDerivative ((DeRhamComplex R v) (Vector (Expression R)) (DeRhamComplex R v)))): 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}."
--------(s ((Expression R) (SquareMatrix (# v) (Expression R))))---------
--->-->DifferentialForms((s ((Expression R) (SquareMatrix (# v) (Expression R))))): Missing right pren
--------(invHodgeStar ((DeRhamComplex R v) (SquareMatrix (# v) (Expression R)) (DeRhamComplex R v)))---------
--->-->DifferentialForms((invHodgeStar ((DeRhamComplex R v) (SquareMatrix (# v) (Expression R)) (DeRhamComplex R v)))): Improper initial operator in comments: is
"invHodgeStar is the inverse of hodgeStar."
--------(codifferential ((DeRhamComplex R v) (SquareMatrix (# v) (Expression R)) (DeRhamComplex R v)))---------
--------(hodgeLaplacian ((DeRhamComplex R v) (SquareMatrix (# v) (Expression R)) (DeRhamComplex R v)))---------
; compiling file "/var/aw/var/LatexWiki/DFORM.NRLIB/DFORM.lsp" (written 16 JUL 2018 09:49:30 PM):
; /var/aw/var/LatexWiki/DFORM.NRLIB/DFORM.fasl written
; compilation finished in 0:00:00.232
------------------------------------------------------------------------
DifferentialForms is now explicitly exposed in frame initial
DifferentialForms will be automatically loaded when needed from
/var/aw/var/LatexWiki/DFORM.NRLIB/DFORM

Test flavours

fricas
-- =======================================
DFORM tests (package DifferentialForms) -- ======================================= -- Requires: -- .... DeRhamComplex (src/derham.spad) or FriCAS 1.3 or later. -- .... DifferentialForms (dform.spad). -- Version 1.1: 09-ARP-2016 -- Version 1.2: 17-DEC-2016 -- -- FriCAS Computer Algebra System -- Version: FriCAS 1.3.0 -- Timestamp: Don Sep 29 21:26:01 CEST 2016
fricas
)set break resume

fricas
)expose UnittestCount UnittestAux Unittest
UnittestCount is now explicitly exposed in frame initial
UnittestAux is now explicitly exposed in frame initial
Unittest is now explicitly exposed in frame initial

fricas
)expose DFORM
DifferentialForms is already explicitly exposed in frame initial
-----------------
testsuite "dform"
All user variables and function definitions have been cleared.
Type: Void
fricas
testcase  "all"
All user variables and function definitions have been cleared.
Type: Void
fricas
-----------------
-----------
-- Setup --
-----------
n:=7 -- dim of base space (n>=2 !), may change in course
 (1)
Type: PositiveInteger?
fricas
N:=91 -- number of tests
 (2)
Type: PositiveInteger?
fricas
O ==> OutputForm
Type: Void
fricas
-- HodgeStar package for DERHAM(R,v)
R:=Integer  -- Ring
 (3)
Type: Type
fricas
v:=[subscript(x,[j::OutputForm]) for j in 1..n] -- (x_1,..,x_n)
 (4)
Type: List(Symbol)
fricas
M:=DFORM(R,v)
 (5)
Type: Type
fricas
-- basis 1-forms and coordinate vector
dx:=baseForms()$M -- [dx[1],...,dx[n]]  (6) Type: List(DeRhamComplex?(Integer,[x[1],x[2],x[3],x[4],x[5],x[6],x[7]])) fricas x:=coordVector()$M    -- [x[1],...,x[n]]
 (7)
Type: List(Expression(Integer))
fricas
xs:=coordSymbols()$M -- as above but as List Symbol (for differentiate, D)  (8) Type: List(Symbol) fricas -- operator, vector field, scalar field, symbol a:=operator 'a -- operator  (9) Type: BasicOperator? fricas b:=vectorField(b)$M    -- generic vector field [b1(x1..xn),...,bn(x1..xn)]
 (10)
Type: List(Expression(Integer))
fricas
c:=vectorField(c)$M  (11) Type: List(Expression(Integer)) fricas P:=scalarField(P)$M    -- scalar field P(x1,..,xn)
 (12)
Type: Expression(Integer)
fricas
-- (pseudo-) random form & zeroForm
rd:=reduce(_*,[dx.j for j in 1..random(n)$NNI+1])  (13) Type: DeRhamComplex?(Integer,[x[1],x[2],x[3],x[4],x[5],x[6],x[7]]) fricas nf:=zeroForm(nf)$M
 (14)
Type: DeRhamComplex?(Integer,[x[1],x[2],x[3],x[4],x[5],x[6],x[7]])
fricas
-- metric
g:=diagonalMatrix([1 for i in 1..n])$SquareMatrix(n,EXPR R) -- Euclidean  (15) Type: SquareMatrix?(7,Expression(Integer)) fricas h:=diagonalMatrix(c)$SquareMatrix(n,EXPR R)
 (16)
Type: SquareMatrix?(7,Expression(Integer))
fricas
-- vector field
vf:=vector b
 (17)
Type: Vector(Expression(Integer))
fricas
-- Result list
res:List(Boolean):=[false for j in 1..N]
 (18)
Type: List(Boolean)
fricas
--
res.1 := test (dx.1=d(x.1*one()$M))  (19) Type: Boolean fricas res.2 := test (#dx = n)  (20) Type: Boolean fricas res.3 := test (#x = n)  (21) Type: Boolean fricas res.4 := test (a x = a(x))  (22) Type: Boolean fricas res.5 := test (#b = n)  (23) Type: Boolean fricas -- null Form (i.e. degree 0) res.6 := test (zeroForm('a)$M = a(x)*one()$M)  (24) Type: Boolean fricas res.7 := test (d zeroForm('a)$M = reduce(_+,[D(a(x),xs.i)*dx.i for i in 1..n]))
 (25)
Type: Boolean
fricas
-- products (à la Flanders, vector forms)
res.8 := test ( x*dx = reduce(_+,[x.i*dx.i for i in 1..n]))
 (26)
Type: Boolean
fricas
res.9 := test ( dx * dx = 0)
 (27)
Type: Boolean
fricas
res.10 := test ( (x*dx)*dx = -dx*(x*dx))
 (28)
Type: Boolean
fricas
-- (co-)vector field
res.11 := test (vectorField(W)$M * dx = dx * vectorField(W)$M)
 (29)
Type: Boolean
fricas
res.12 := test (typeOf(vectorField(S)$M)::O=List(Expression(R))::O)  (30) Type: Boolean fricas res.13 := test (typeOf(covectorField(K)$M)::O=List(DERHAM(R,v))::O)
 (31)
Type: Boolean
fricas
res.14 := test (typeOf(vectorField(W)$M * covectorField(K)$M)::O=DERHAM(R,v)::O)
 (32)
Type: Boolean
fricas
-- dot products w.r.t. g
res.15 := reduce(_and,[test ( dot(g,dx.j,dx.j)$M = 1) for j in 1..n])  (33) Type: Boolean fricas res.16 := reduce(_and,[test ( dot(g,dx.j,dx.(j+1))$M = 0) for j in 1..n-1])
 (34)
Type: Boolean
fricas
res.17 := reduce(_and,[test ( dot(g,dx.1*dx.j,dx.1*dx.j)$M = 1) for j in 2..n])  (35) Type: Boolean fricas res.18 := reduce(_and,[test ( dot(h,dx.j,dx.j)$M = 1/c.j) for j in 1..n])
 (36)
Type: Boolean
fricas
res.19 := reduce(_and,[test ( dot(h,dx.j,dx.(j+1))$M = 0) for j in 1..n-1])  (37) Type: Boolean fricas res.20 := reduce(_and,[test ( dot(h,dx.1*dx.j,dx.1*dx.j)$M = 1/(c.1*c.j)) _
for j in 2..n])
 (38)
Type: Boolean
fricas
-- Hodge star
res.21 := test (one()$M*hodgeStar(g,1)$M = dot(g,1,1)$M * volumeForm(g)$M)
 (39)
Type: Boolean
fricas
res.22 := test (rd*hodgeStar(g,rd)$M = dot(g,rd,rd)$M * volumeForm(g)$M)  (40) Type: Boolean fricas res.23 := test (degree(hodgeStar(g,dx.n)$M) = n-1)
 (41)
Type: Boolean
fricas
res.24 := test (one()$M*hodgeStar(h,1)$M = dot(h,1,1)$M * volumeForm(h)$M)
 (42)
Type: Boolean
fricas
res.25 := test (rd*hodgeStar(h,rd)$M = dot(h,rd,rd)$M * volumeForm(h)$M)  (43) Type: Boolean fricas res.26 := test (degree(hodgeStar(h,dx.n)$M) = n-1)
 (44)
Type: Boolean
fricas
-- Projections
res.27 := test (proj(0,nf+b*dx+d(b*dx))$M = nf)  (45) Type: Boolean fricas res.28 := test (proj(1,nf+b*dx+d(b*dx))$M = b*dx)
 (46)
Type: Boolean
fricas
res.29 := test (proj(2,nf+b*dx+d(b*dx))$M = d(b*dx))  (47) Type: Boolean fricas res.30 := test (proj(n,volumeForm(g)$M)$M = volumeForm(g)$M)
 (48)
Type: Boolean
fricas
res.31 := test (proj(random(n)$NNI,volumeForm(g)$M)$M = 0)  (49) Type: Boolean fricas -- Interior product res.32 := test (interiorProduct(vf,dx.1)$M = b.1)
 (50)
Type: Boolean
fricas
res.33 := test (interiorProduct(vf,dx.n)$M = b.n)  (51) Type: Boolean fricas res.34 := test (d interiorProduct(vf, volumeForm(g)$M)$M = _ reduce(_+,[D(b.j,xs.j) for j in 1..n])*volumeForm(g)$M)
 (52)
Type: Boolean
fricas
-- Lie derivative
res.35 := test ( d interiorProduct(vf,b*dx)$M + _ interiorProduct(vf,d(b*dx))$M = lieDerivative(vf,b*dx)$M)  (53) Type: Boolean fricas -- Version 1.2 fricas )clear values n R v M x xs dx a b c p g h P vf n:=4 -- dim of base space (n>=2 !)  (54) Type: PositiveInteger? fricas O ==> OutputForm Type: Void fricas -- HodgeStar package for DERHAM(R,v) R:=Integer -- Ring  (55) Type: Type fricas v:=[subscript(x,[j::OutputForm]) for j in 1..n] -- (x_1,..,x_n)  (56) Type: List(Symbol) fricas M:=DFORM(R,v)  (57) Type: Type fricas -- basis 1-forms and coordinate vector dx:=baseForms()$M     -- [dx[1],...,dx[n]]
 (58)
Type: List(DeRhamComplex?(Integer,[x[1],x[2],x[3],x[4]]))
fricas
x:=coordVector()$M -- [x[1],...,x[n]]  (59) Type: List(Expression(Integer)) fricas xs:=coordSymbols()$M  -- as above but as List Symbol (for differentiate, D)
 (60)
Type: List(Symbol)
fricas
-- operator, vector field, scalar field, symbol
a:=operator 'a         -- operator
 (61)
Type: BasicOperator?
fricas
b:=vectorField(b)$M -- generic vector field [b1(x1..xn),...,bn(x1..xn)]  (62) Type: List(Expression(Integer)) fricas c:=vectorField(c)$M
 (63)
Type: List(Expression(Integer))
fricas
P:=scalarField(P)$M -- scalar field P(x1,..,xn)  (64) Type: Expression(Integer) fricas -- metric g:=diagonalMatrix([1 for i in 1..n])$SquareMatrix(n,EXPR R)  -- Euclidean
 (65)
Type: SquareMatrix?(4,Expression(Integer))
fricas
h:=diagonalMatrix(c)$SquareMatrix(n,EXPR R)  (66) Type: SquareMatrix?(4,Expression(Integer)) fricas eta:=diagonalMatrix(concat(1,[-1 for i in 2..n]))$SquareMatrix(n,EXPR R)
 (67)
Type: SquareMatrix?(4,Expression(Integer))
fricas
-- vector field
vf:=vector b
 (68)
Type: Vector(Expression(Integer))
fricas
-- macros
dV(g) ==> volumeForm(g)$M Type: Void fricas i(X,w) ==> interiorProduct(X,w)$M
Type: Void
fricas
L(X,w) ==> lieDerivative(X,w)$M Type: Void fricas ** w ==> hodgeStar(g,w)$M
Type: Void
fricas
---
w:=x.1*dx.2-x.2*dx.1
 (69)
Type: DeRhamComplex?(Integer,[x[1],x[2],x[3],x[4]])
fricas
res.36 := test(d w = 2*dx.1*dx.2)
 (70)
Type: Boolean
fricas
res.37 := test(w*w = zero()$M)  (71) Type: Boolean fricas res.38 := test(i(vf,w) = x.1*b.2-x.2*b.1)  (72) Type: Boolean fricas res.39 := test(L(vf,w) = d i(vf,w) + i(vf,d w))  (73) Type: Boolean fricas res.40 := test(d i(vf,w) + i(vf,d w) - L(vf,w) = zero()$M)
 (74)
Type: Boolean
fricas
res.41 := test(dot(g,w,w)$M = x.1^2+x.2^2)  (75) Type: Boolean fricas -- div(b) dV res.41 := test(d i(vf,dV(g)) = reduce(_+,[D(b.j,xs.j) for j in 1..n])*dV(g))  (76) Type: Boolean fricas res.42 := test(d (P*one()$M) = reduce(_+,[D(P,xs.j)*dx.j for j in 1..n]))
 (77)
Type: Boolean
fricas
res.43 := test(i(vf,d (P*one()$M))= reduce(_+,[D(P,xs.j)*b.j for j in 1..n])*one()$M)
 (78)
Type: Boolean
fricas
res.44 := test(1/dot(g,w,w)$M*w = w*(1/(x.1^2+x.2^2)))  (79) Type: Boolean fricas res.45 := test(d (1/dot(g,w,w)$M*w) = zero()$M)  (80) Type: Boolean fricas --- s:=zeroForm('s)$M
 (81)
Type: DeRhamComplex?(Integer,[x[1],x[2],x[3],x[4]])
fricas
res.46 := test(d s =  totalDifferential(retract s)$DeRhamComplex(Integer,v))  (82) Type: Boolean fricas res.47 := test(d s = totalDifferential(retract s)$typeOf(s))
 (83)
Type: Boolean
fricas
res.48 := test(d (** s) = 0$typeOf(s))  (84) Type: Boolean fricas res.49 := test(dot(g,** ( d s),w*dx.2*dx.3)$M = x.2*D(retract s, xs.4))
 (85)
Type: Boolean
fricas
res.50 := test(d (** ( d s)) = reduce(_+,[D(retract s,xs.j,2) for j in 1..n])*dV(g))
 (86)
Type: Boolean
fricas
r:=sin(x.1*x.2)*one()$M  (87) Type: DeRhamComplex?(Integer,[x[1],x[2],x[3],x[4]]) fricas res.51 := test(d r = x.1*cos(x.1*x.2)*dx.2+x.2*cos(x.1*x.2)*dx.1)  (88) Type: Boolean fricas res.52 := test(d (** ( d r)) = -(x.1^2+x.2^2)*sin(x.1*x.2)*dV(g))  (89) Type: Boolean fricas res.53 := test(** (d (** ( d r))) = -(x.1^2+x.2^2)*sin(x.1*x.2))  (90) Type: Boolean fricas res.53 := test(** (d (** ( d r)))::EXPR INT = retract (** (d (** ( d r)))))  (91) Type: Boolean fricas res.54 := test(eval(** (d (** ( d r)))::EXPR INT,xs.1=%pi) = (-%pi^2-x.2^2)*sin(%pi*x.2))  (92) Type: Boolean fricas res.55 := test(eval(eval(** (d (** ( d r)))::EXPR INT,xs.1=%pi) ,xs.2=%pi)=-2*%pi^2*sin(%pi^2))  (93) Type: Boolean fricas a(P)*one()$M
 (94)
Type: DeRhamComplex?(Integer,[x[1],x[2],x[3],x[4]])
fricas
-- chain diff
res.56 := test(d (a(P)*one()$M) = eval(D(a(t),'t),t=P)*d (P*one()$M))
 (95)
Type: Boolean
fricas
res.57 := test(** invHodgeStar(g,w)$M = w)  (96) Type: Boolean fricas res.58 := test(invHodgeStar(g,** w)$M = w)
 (97)
Type: Boolean
fricas
res.59 := test(** invHodgeStar(g,** w + dx.1)$M = ** w + dx.1)  (98) Type: Boolean fricas res.60 := test( ** dV(g) = invHodgeStar(g,dV(g))$M)
 (99)
Type: Boolean
fricas
res.61 := test(** dV(h) ~= invHodgeStar(h,dV(g))$M)  (100) Type: Boolean fricas res.62 := test( dot(h,w,w)$M = (c.2*x.2^2+c.1*x.1^2)/(c.1*c.2))
 (101)
Type: Boolean
fricas
res.63 := test( s(g)$M = 1)  (102) Type: Boolean fricas res.64 := test( s(eta)$M = -1)
 (103)
Type: Boolean
fricas
res.65 := test( s(h)$M = 's? )  (104) Type: Boolean fricas -- https://en.wikipedia.org/wiki/Hodge_dual -- Four dimensions res.66 := test( hodgeStar(eta,dx.1)$M = dx.2*dx.3*dx.4)
 (105)
Type: Boolean
fricas
res.67 := test( hodgeStar(eta,dx.2)$M = dx.1*dx.3*dx.4)  (106) Type: Boolean fricas res.68 := test( hodgeStar(eta,dx.3)$M = dx.1*dx.4*dx.2)
 (107)
Type: Boolean
fricas
res.69 := test( hodgeStar(eta,dx.4)$M = dx.1*dx.2*dx.3)  (108) Type: Boolean fricas res.70 := test( hodgeStar(eta,dx.1*dx.2)$M = dx.4*dx.3)
 (109)
Type: Boolean
fricas
res.71 := test( hodgeStar(eta,dx.1*dx.3)$M = dx.2*dx.4)  (110) Type: Boolean fricas res.72 := test( hodgeStar(eta,dx.1*dx.4)$M = dx.3*dx.2)
 (111)
Type: Boolean
fricas
res.73 := test( hodgeStar(eta,dx.2*dx.3)$M = dx.1*dx.4)  (112) Type: Boolean fricas res.74 := test( hodgeStar(eta,dx.2*dx.4)$M = dx.3*dx.1)
 (113)
Type: Boolean
fricas
res.75 := test( hodgeStar(eta,dx.3*dx.4)$M = dx.1*dx.2)  (114) Type: Boolean fricas -- codifferential: (delta=(-)^degree(x)*invHodgeStar(g, d hodgeStar(g,x)) res.76 := test(codifferential(g,s*dx.1)$M = -D(retract s,xs.1)*one()$M)  (115) Type: Boolean fricas res.77 := test(codifferential(g,P*dx.2)$M = -D(P,xs.2)*one()$M)  (116) Type: Boolean fricas res.78 := test(codifferential(g,s*P*dx.1*dx.2)$M = _
(-P*D(retract s,xs.1)-s*D(P,xs.1))*dx.2+_
(P*D(retract s,xs.2)+s*D(P,xs.2))*dx.1)
 (117)
Type: Boolean
fricas
res.79 := test(codifferential(g,P*w)$M = x.2*D(P,xs.1)*one()$M -_
x.1*D(P,xs.2)*one()$M)  (118) Type: Boolean fricas res.80 := test(codifferential(g,P*w)$M = _
(-1)^degree(w)*invHodgeStar(g, d hodgeStar(g,P*w)$M)$M)
 (119)
Type: Boolean
fricas
res.81 := test(codifferential(eta,P*w)$M = _ (-1)^degree(w)*invHodgeStar(eta, d hodgeStar(eta,P*w)$M)$M)  (120) Type: Boolean fricas res.82 := test(codifferential(h,P*w)$M = _
(-1)^degree(w)*invHodgeStar(h, d hodgeStar(h,P*w)$M)$M)
 (121)
Type: Boolean
fricas
res.83 := test(codifferential(h,P*w*dx.3)$M = _ (-1)^degree(w*dx.3)*invHodgeStar(h, d hodgeStar(h,P*w*dx.3)$M)$M)  (122) Type: Boolean fricas -- the codifferential \delta is (sort of) the adjoint to the differential. -- This doesn’t quite hold, but we can show that it does hold “up to homology”. -- We can calculate their difference times the canonical volume form: res.84 := test((dot(g,d w, dx.1*dx.2)$M -_
dot(g,w,codifferential(g,dx.1*dx.2)$M)$M)*dV(g)=
d (w*hodgeStar(g,dx.1*dx.2)$M))  (123) Type: Boolean fricas res.85 := test((dot(eta,d w, dx.1*dx.2)$M -_
dot(eta,w,codifferential(eta,dx.1*dx.2)$M)$M)*dV(eta)=
d (w*hodgeStar(eta,dx.1*dx.2)$M))  (124) Type: Boolean fricas res.86 := test(hodgeLaplacian(g,w*(** w))$M = -4 * dV(g))
 (125)
Type: Boolean
fricas
res.87 := test(hodgeLaplacian(eta,w*(hodgeStar(eta,w)$M))$M = 4 * dV(eta))
 (126)
Type: Boolean
fricas
res.88 := test(hodgeLaplacian(h,w*(hodgeStar(h,w)$M))$M =_
d codifferential(h,w*hodgeStar(h,w)$M)$M)
 (127)
Type: Boolean
fricas
res.89 := test(d(vf*dx) *  (** d(vf*dx))=dot(g,d(vf*dx),d(vf*dx))$M*dV(g))  (128) Type: Boolean fricas -- next is inequality because ** = hodgeStar w.r.t to metric g! res.90 := test(d(vf*dx) * (** d(vf*dx))~=dot(eta,d(vf*dx),d(vf*dx))$M*dV(eta))
 (129)
Type: Boolean
fricas
-- correct is:
res.91 := test(d(vf*dx)*hodgeStar(eta,d(vf*dx))$M=_ dot(eta,d(vf*dx),d(vf*dx))$M*dV(eta))
 (130)
Type: Boolean
fricas
-------------
-- Results --
-------------
fricas
)version
Value = "FriCAS 1.3.4 compiled at Wed Jun 27 14:53:01 UTC 2018"
fricas
)lisp (lisp-implementation-type)
Value = "SBCL"
fricas
)lisp (lisp-implementation-version)
Value = "1.1.1"
res
 (131)
Type: List(Boolean)
fricas
reduce(_and,res)
 (132)
Type: Boolean
fricas
-- dummy statistics
[testEquals("res." string(j),"true") for j in 1..N];
Type: List(Void)
fricas
statistics()
=============================================================================
General WARNINGS:
* do not use ')clear completely' before having used 'statistics()'
It clears the statistics without warning!
* do not forget to pass the arguments of the testXxxx functions as Strings!
Otherwise, the test will fail and statistics() will not notice!
* testLibraryError does not prevent FriCAS from aborting the current block.
Thus, if a block contains other test functions, they will not be executed
and statistics() will not notice!
=============================================================================
Testsuite: dform
failed (total): 0 (1)
=============================================================================
testsuite | testcases: failed (total) | tests: failed (total)
dform                       0     (1)               0    (91)
=============================================================================
File summary.
unexpected failures: 0
expected failures: 0
unexpected passes: 0
total tests: 91
Type: Void

Some changes necessary: use vectors instead of lists, ...

 Subject:   Be Bold !! ( 15 subscribers )