|
|
last edited 6 years ago by pagani |
1 | ||
Editor: pagani
Time: 2018/07/16 21:49:28 GMT+0 |
||
Note: |
changed: - \begin{spad} )abbrev package DFORM DifferentialForms ++ Author: Kurt Pagani <nilqed@gmail.com> ++ Date Created: October 2014 ++ Revised: Sat Sep 17 17:10:00 CET 2016 ++ License: FriCAS/BSD ++ 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. Implementation == add -- 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 a:=leadingBasisTerm(x) if degree(a)=p then leadingCoefficient(x)*a + proj(p, reductum x) 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) x ~= leadingBasisTerm(x) => error(err5) 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 leadingCoefficient(x)*intProdBasisTerm(w,leadingBasisTerm(x)) + _ interiorProduct(w, reductum(x)) lieDerivative(w:Vector X,x:DRC):DRC == a := exteriorDifferential(interiorProduct(w,x)) b := interiorProduct(w, exteriorDifferential(x)) a+b eps(x:DRC):X == leadingCoefficient(x*conjBasisTerm(x)) 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 y:DRC:=leadingBasisTerm(x) k:X:=coerce(degree y)$X c:X:=s(g)*(-1)^(k*(coerce(n)$X-k)) leadingCoefficient(x)*hodgeStarBT(g,c*y) + _ 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) \end{spad} Test flavours \begin{axiom} -- ======================================= -- 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 )set break resume )expose UnittestCount UnittestAux Unittest )expose DFORM ----------------- testsuite "dform" testcase "all" ----------------- ----------- -- Setup -- ----------- n:=7 -- dim of base space (n>=2 !), may change in course N:=91 -- number of tests O ==> OutputForm -- HodgeStar package for DERHAM(R,v) R:=Integer -- Ring v:=[subscript(x,[j::OutputForm]) for j in 1..n] -- (x_1,..,x_n) M:=DFORM(R,v) -- basis 1-forms and coordinate vector dx:=baseForms()$M -- [dx[1],...,dx[n]] x:=coordVector()$M -- [x[1],...,x[n]] xs:=coordSymbols()$M -- as above but as List Symbol (for differentiate, D) -- operator, vector field, scalar field, symbol a:=operator 'a -- operator b:=vectorField(b)$M -- generic vector field [b1(x1..xn),...,bn(x1..xn)] c:=vectorField(c)$M P:=scalarField(P)$M -- scalar field P(x1,..,xn) -- (pseudo-) random form & zeroForm rd:=reduce(_*,[dx.j for j in 1..random(n)$NNI+1]) nf:=zeroForm(nf)$M -- metric g:=diagonalMatrix([1 for i in 1..n])$SquareMatrix(n,EXPR R) -- Euclidean h:=diagonalMatrix(c)$SquareMatrix(n,EXPR R) -- vector field vf:=vector b -- Result list res:List(Boolean):=[false for j in 1..N] -- res.1 := test (dx.1=d(x.1*one()$M)) res.2 := test (#dx = n) res.3 := test (#x = n) res.4 := test (a x = a(x)) res.5 := test (#b = n) -- null Form (i.e. degree 0) res.6 := test (zeroForm('a)$M = a(x)*one()$M) res.7 := test (d zeroForm('a)$M = reduce(_+,[D(a(x),xs.i)*dx.i for i in 1..n])) -- products (à la Flanders, vector forms) res.8 := test ( x*dx = reduce(_+,[x.i*dx.i for i in 1..n])) res.9 := test ( dx * dx = 0) res.10 := test ( (x*dx)*dx = -dx*(x*dx)) -- (co-)vector field res.11 := test (vectorField(W)$M * dx = dx * vectorField(W)$M) res.12 := test (typeOf(vectorField(S)$M)::O=List(Expression(R))::O) res.13 := test (typeOf(covectorField(K)$M)::O=List(DERHAM(R,v))::O) res.14 := test (typeOf(vectorField(W)$M * covectorField(K)$M)::O=DERHAM(R,v)::O) -- dot products w.r.t. g res.15 := reduce(_and,[test ( dot(g,dx.j,dx.j)$M = 1) for j in 1..n]) res.16 := reduce(_and,[test ( dot(g,dx.j,dx.(j+1))$M = 0) for j in 1..n-1]) res.17 := reduce(_and,[test ( dot(g,dx.1*dx.j,dx.1*dx.j)$M = 1) for j in 2..n]) res.18 := reduce(_and,[test ( dot(h,dx.j,dx.j)$M = 1/c.j) for j in 1..n]) res.19 := reduce(_and,[test ( dot(h,dx.j,dx.(j+1))$M = 0) for j in 1..n-1]) 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]) -- Hodge star res.21 := test (one()$M*hodgeStar(g,1)$M = dot(g,1,1)$M * volumeForm(g)$M) res.22 := test (rd*hodgeStar(g,rd)$M = dot(g,rd,rd)$M * volumeForm(g)$M) res.23 := test (degree(hodgeStar(g,dx.n)$M) = n-1) res.24 := test (one()$M*hodgeStar(h,1)$M = dot(h,1,1)$M * volumeForm(h)$M) res.25 := test (rd*hodgeStar(h,rd)$M = dot(h,rd,rd)$M * volumeForm(h)$M) res.26 := test (degree(hodgeStar(h,dx.n)$M) = n-1) -- Projections res.27 := test (proj(0,nf+b*dx+d(b*dx))$M = nf) res.28 := test (proj(1,nf+b*dx+d(b*dx))$M = b*dx) res.29 := test (proj(2,nf+b*dx+d(b*dx))$M = d(b*dx)) res.30 := test (proj(n,volumeForm(g)$M)$M = volumeForm(g)$M) res.31 := test (proj(random(n)$NNI,volumeForm(g)$M)$M = 0) -- Interior product res.32 := test (interiorProduct(vf,dx.1)$M = b.1) res.33 := test (interiorProduct(vf,dx.n)$M = b.n) res.34 := test (d interiorProduct(vf, volumeForm(g)$M)$M = _ reduce(_+,[D(b.j,xs.j) for j in 1..n])*volumeForm(g)$M) -- Lie derivative res.35 := test ( d interiorProduct(vf,b*dx)$M + _ interiorProduct(vf,d(b*dx))$M = lieDerivative(vf,b*dx)$M) -- Version 1.2 )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 !) O ==> OutputForm -- HodgeStar package for DERHAM(R,v) R:=Integer -- Ring v:=[subscript(x,[j::OutputForm]) for j in 1..n] -- (x_1,..,x_n) M:=DFORM(R,v) -- basis 1-forms and coordinate vector dx:=baseForms()$M -- [dx[1],...,dx[n]] x:=coordVector()$M -- [x[1],...,x[n]] xs:=coordSymbols()$M -- as above but as List Symbol (for differentiate, D) -- operator, vector field, scalar field, symbol a:=operator 'a -- operator b:=vectorField(b)$M -- generic vector field [b1(x1..xn),...,bn(x1..xn)] c:=vectorField(c)$M P:=scalarField(P)$M -- scalar field P(x1,..,xn) -- metric g:=diagonalMatrix([1 for i in 1..n])$SquareMatrix(n,EXPR R) -- Euclidean h:=diagonalMatrix(c)$SquareMatrix(n,EXPR R) eta:=diagonalMatrix(concat(1,[-1 for i in 2..n]))$SquareMatrix(n,EXPR R) -- vector field vf:=vector b -- macros dV(g) ==> volumeForm(g)$M i(X,w) ==> interiorProduct(X,w)$M L(X,w) ==> lieDerivative(X,w)$M ** w ==> hodgeStar(g,w)$M --- w:=x.1*dx.2-x.2*dx.1 res.36 := test(d w = 2*dx.1*dx.2) res.37 := test(w*w = zero()$M) res.38 := test(i(vf,w) = x.1*b.2-x.2*b.1) res.39 := test(L(vf,w) = d i(vf,w) + i(vf,d w)) res.40 := test(d i(vf,w) + i(vf,d w) - L(vf,w) = zero()$M) res.41 := test(dot(g,w,w)$M = x.1^2+x.2^2) -- div(b) dV res.41 := test(d i(vf,dV(g)) = reduce(_+,[D(b.j,xs.j) for j in 1..n])*dV(g)) res.42 := test(d (P*one()$M) = reduce(_+,[D(P,xs.j)*dx.j for j in 1..n])) res.43 := test(i(vf,d (P*one()$M))= reduce(_+,[D(P,xs.j)*b.j for j in 1..n])*one()$M) res.44 := test(1/dot(g,w,w)$M*w = w*(1/(x.1^2+x.2^2))) res.45 := test(d (1/dot(g,w,w)$M*w) = zero()$M) --- s:=zeroForm('s)$M res.46 := test(d s = totalDifferential(retract s)$DeRhamComplex(Integer,v)) res.47 := test(d s = totalDifferential(retract s)$typeOf(s)) res.48 := test(d (** s) = 0$typeOf(s)) res.49 := test(dot(g,** ( d s),w*dx.2*dx.3)$M = x.2*D(retract s, xs.4)) res.50 := test(d (** ( d s)) = reduce(_+,[D(retract s,xs.j,2) for j in 1..n])*dV(g)) r:=sin(x.1*x.2)*one()$M res.51 := test(d r = x.1*cos(x.1*x.2)*dx.2+x.2*cos(x.1*x.2)*dx.1) res.52 := test(d (** ( d r)) = -(x.1^2+x.2^2)*sin(x.1*x.2)*dV(g)) res.53 := test(** (d (** ( d r))) = -(x.1^2+x.2^2)*sin(x.1*x.2)) res.53 := test(** (d (** ( d r)))::EXPR INT = retract (** (d (** ( d r))))) res.54 := test(eval(** (d (** ( d r)))::EXPR INT,xs.1=%pi) = (-%pi^2-x.2^2)*sin(%pi*x.2)) res.55 := test(eval(eval(** (d (** ( d r)))::EXPR INT,xs.1=%pi) ,xs.2=%pi)=-2*%pi^2*sin(%pi^2)) a(P)*one()$M -- chain diff res.56 := test(d (a(P)*one()$M) = eval(D(a(t),'t),t=P)*d (P*one()$M)) res.57 := test(** invHodgeStar(g,w)$M = w) res.58 := test(invHodgeStar(g,** w)$M = w) res.59 := test(** invHodgeStar(g,** w + dx.1)$M = ** w + dx.1) res.60 := test( ** dV(g) = invHodgeStar(g,dV(g))$M) res.61 := test(** dV(h) ~= invHodgeStar(h,dV(g))$M) res.62 := test( dot(h,w,w)$M = (c.2*x.2^2+c.1*x.1^2)/(c.1*c.2)) res.63 := test( s(g)$M = 1) res.64 := test( s(eta)$M = -1) res.65 := test( s(h)$M = 's? ) -- https://en.wikipedia.org/wiki/Hodge_dual -- Four dimensions res.66 := test( hodgeStar(eta,dx.1)$M = dx.2*dx.3*dx.4) res.67 := test( hodgeStar(eta,dx.2)$M = dx.1*dx.3*dx.4) res.68 := test( hodgeStar(eta,dx.3)$M = dx.1*dx.4*dx.2) res.69 := test( hodgeStar(eta,dx.4)$M = dx.1*dx.2*dx.3) res.70 := test( hodgeStar(eta,dx.1*dx.2)$M = dx.4*dx.3) res.71 := test( hodgeStar(eta,dx.1*dx.3)$M = dx.2*dx.4) res.72 := test( hodgeStar(eta,dx.1*dx.4)$M = dx.3*dx.2) res.73 := test( hodgeStar(eta,dx.2*dx.3)$M = dx.1*dx.4) res.74 := test( hodgeStar(eta,dx.2*dx.4)$M = dx.3*dx.1) res.75 := test( hodgeStar(eta,dx.3*dx.4)$M = dx.1*dx.2) -- 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) res.77 := test(codifferential(g,P*dx.2)$M = -D(P,xs.2)*one()$M) 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) res.79 := test(codifferential(g,P*w)$M = x.2*D(P,xs.1)*one()$M -_ x.1*D(P,xs.2)*one()$M) res.80 := test(codifferential(g,P*w)$M = _ (-1)^degree(w)*invHodgeStar(g, d hodgeStar(g,P*w)$M)$M) res.81 := test(codifferential(eta,P*w)$M = _ (-1)^degree(w)*invHodgeStar(eta, d hodgeStar(eta,P*w)$M)$M) res.82 := test(codifferential(h,P*w)$M = _ (-1)^degree(w)*invHodgeStar(h, d hodgeStar(h,P*w)$M)$M) 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) -- 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)) 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)) res.86 := test(hodgeLaplacian(g,w*(** w))$M = -4 * dV(g)) res.87 := test(hodgeLaplacian(eta,w*(hodgeStar(eta,w)$M))$M = 4 * dV(eta)) res.88 := test(hodgeLaplacian(h,w*(hodgeStar(h,w)$M))$M =_ d codifferential(h,w*hodgeStar(h,w)$M)$M) res.89 := test(d(vf*dx) * (** d(vf*dx))=dot(g,d(vf*dx),d(vf*dx))$M*dV(g)) -- 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)) -- 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)) ------------- -- Results -- ------------- )version )lisp (lisp-implementation-type) )lisp (lisp-implementation-version) res reduce(_and,res) -- dummy statistics [testEquals("res." string(j),"true") for j in 1..N]; statistics() \end{axiom} Some changes necessary: use vectors instead of lists, ...
(1) -> <spad>
)abbrev package DFORM DifferentialForms ++ Author: Kurt Pagani <nilqed@gmail.com> ++ Date Created: October 2014 ++ Revised: Sat Sep 17 17:10:00 CET 2016 ++ License: FriCAS/BSD ++ 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.
Implementation == add
-- 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 a:=leadingBasisTerm(x) if degree(a)=p then leadingCoefficient(x)*a + proj(p, reductum x) 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) x ~= leadingBasisTerm(x) => error(err5) 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 leadingCoefficient(x)*intProdBasisTerm(w, leadingBasisTerm(x)) + _ interiorProduct(w, reductum(x))
lieDerivative(w:Vector X,x:DRC):DRC == a := exteriorDifferential(interiorProduct(w, x)) b := interiorProduct(w, exteriorDifferential(x)) a+b
eps(x:DRC):X == leadingCoefficient(x*conjBasisTerm(x))
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 y:DRC:=leadingBasisTerm(x) k:X:=coerce(degree y)$X c:X:=s(g)*(-1)^(k*(coerce(n)$X-k)) leadingCoefficient(x)*hodgeStarBT(g, c*y) + _ 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.01 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 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 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.01 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 SEC.
compiling exported * : (List Expression R,List DeRhamComplex(R, v)) -> DeRhamComplex(R, v) Time: 0.01 SEC.
compiling exported * : (List DeRhamComplex(R,v), List DeRhamComplex(R, v)) -> DeRhamComplex(R, v) Time: 0.02 SEC.
compiling exported volumeForm : SquareMatrix(# v,Expression R) -> DeRhamComplex(R, v) Time: 0.03 SEC.
compiling exported monomials : NonNegativeInteger -> List DeRhamComplex(R,v) Time: 0 SEC.
compiling local flip : ExtAlgBasis -> ExtAlgBasis Time: 0 SEC.
compiling local pos : (ExtAlgBasis,Integer) -> List Integer Time: 0 SEC.
compiling local dot1 : (SquareMatrix(# v,Expression R), Record(k: ExtAlgBasis, c: Expression R), Record(k: ExtAlgBasis, c: Expression R)) -> Expression R Time: 0.14 SEC.
compiling local dot2 : (SquareMatrix(# v,Expression R), Record(k: ExtAlgBasis, c: Expression R), Record(k: ExtAlgBasis, c: Expression R)) -> Expression R Time: 0.35 SEC.
compiling exported dot : (SquareMatrix(# v,Expression R), DeRhamComplex(R, v), DeRhamComplex(R, v)) -> Expression R Time: 0 SEC.
compiling exported proj : (NonNegativeInteger,DeRhamComplex(R, v)) -> DeRhamComplex(R, v) Time: 0 SEC.
compiling exported conjBasisTerm : DeRhamComplex(R,v) -> DeRhamComplex(R, v) Time: 0.01 SEC.
compiling exported atomizeBasisTerm : DeRhamComplex(R,v) -> List DeRhamComplex(R, v) Time: 0 SEC.
compiling local intProdBasisTerm : (Vector Expression R,DeRhamComplex(R, v)) -> DeRhamComplex(R, v) Time: 0.03 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 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.03 SEC.
compiling exported hodgeStar : (SquareMatrix(# v,Expression R), DeRhamComplex(R, v)) -> DeRhamComplex(R, v) Time: 0 SEC.
compiling exported s : SquareMatrix(# v,Expression R) -> Expression R Time: 0.02 SEC.
compiling exported invHodgeStar : (SquareMatrix(# v,Expression R), DeRhamComplex(R, v)) -> DeRhamComplex(R, v) Time: 0.09 SEC.
compiling exported codifferential : (SquareMatrix(# v,Expression R), DeRhamComplex(R, v)) -> DeRhamComplex(R, v) Time: 0.40 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: 1.24 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 "Return the complement of a basis term \\spad{w}.\\spad{r}.\\spad{t}. volumeForm" --------(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 "List of all monomials of degree \\spad{p} (\\spad{p} in 1..\\spad{n}). This is a basis for Lambda(\\spad{n}, {}\\spad{p})." --------(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 "computes the inner product of two differential forms \\spad{w}.\\spad{r}.\\spad{t}. \\spad{g}" --------(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 "\\spad{s(g)} determines the sign of determinant(\\spad{g}) and is related to the signature of \\spad{g} (n=p+q, {}\\spad{t=p}-\\spad{q}, {}\\spad{s=}(-)^(\\spad{n}-\\spad{t})\\spad{/2} \\spad{=>} \\spad{s=}(-)\\spad{^q}." --------(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 07 OCT 2024 05:50:13 PM):
; wrote /var/aw/var/LatexWiki/DFORM.NRLIB/DFORM.fasl ; compilation finished in 0:00:00.120 ------------------------------------------------------------------------ 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
-- =======================================
)set break resume
)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
)expose DFORM
DifferentialForms is already explicitly exposed in frame initial
----------------- testsuite "dform"
All user variables and function definitions have been cleared.
testcase "all"
All user variables and function definitions have been cleared.
-----------------
----------- -- Setup -- -----------
n:=7 -- dim of base space (n>=2 !),may change in course
(1) |
N:=91 -- number of tests
(2) |
O ==> OutputForm
-- HodgeStar package for DERHAM(R,v) R:=Integer -- Ring
(3) |
v:=[subscript(x,[j::OutputForm]) for j in 1..n] -- (x_1, .., x_n)
(4) |
M:=DFORM(R,v)
(5) |
-- basis 1-forms and coordinate vector dx:=baseForms()$M -- [dx[1],..., dx[n]]
(6) |
x:=coordVector()$M -- [x[1],..., x[n]]
(7) |
xs:=coordSymbols()$M -- as above but as List Symbol (for differentiate,D)
(8) |
-- operator,vector field, scalar field, symbol a:=operator 'a -- operator
(9) |
b:=vectorField(b)$M -- generic vector field [b1(x1..xn),..., bn(x1..xn)]
(10) |
c:=vectorField(c)$M
(11) |
P:=scalarField(P)$M -- scalar field P(x1,.., xn)
(12) |
-- (pseudo-) random form & zeroForm rd:=reduce(_*,[dx.j for j in 1..random(n)$NNI+1])
(13) |
nf:=zeroForm(nf)$M
(14) |
-- metric g:=diagonalMatrix([1 for i in 1..n])$SquareMatrix(n,EXPR R) -- Euclidean
(15) |
h:=diagonalMatrix(c)$SquareMatrix(n,EXPR R)
(16) |
-- vector field vf:=vector b
(17) |
-- Result list res:List(Boolean):=[false for j in 1..N]
(18) |
-- res.1 := test (dx.1=d(x.1*one()$M))
(19) |
res.2 := test (#dx = n)
(20) |
res.3 := test (#x = n)
(21) |
res.4 := test (a x = a(x))
(22) |
res.5 := test (#b = n)
(23) |
-- null Form (i.e. degree 0) res.6 := test (zeroForm('a)$M = a(x)*one()$M)
(24) |
res.7 := test (d zeroForm('a)$M = reduce(_+,[D(a(x), xs.i)*dx.i for i in 1..n]))
(25) |
-- products (à la Flanders,vector forms) res.8 := test ( x*dx = reduce(_+, [x.i*dx.i for i in 1..n]))
(26) |
res.9 := test ( dx * dx = 0)
(27) |
res.10 := test ( (x*dx)*dx = -dx*(x*dx))
(28) |
-- (co-)vector field res.11 := test (vectorField(W)$M * dx = dx * vectorField(W)$M)
(29) |
res.12 := test (typeOf(vectorField(S)$M)::O=List(Expression(R))::O)
(30) |
res.13 := test (typeOf(covectorField(K)$M)::O=List(DERHAM(R,v))::O)
(31) |
res.14 := test (typeOf(vectorField(W)$M * covectorField(K)$M)::O=DERHAM(R,v)::O)
(32) |
-- 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) |
res.16 := reduce(_and,[test ( dot(g, dx.j, dx.(j+1))$M = 0) for j in 1..n-1])
(34) |
res.17 := reduce(_and,[test ( dot(g, dx.1*dx.j, dx.1*dx.j)$M = 1) for j in 2..n])
(35) |
res.18 := reduce(_and,[test ( dot(h, dx.j, dx.j)$M = 1/c.j) for j in 1..n])
(36) |
res.19 := reduce(_and,[test ( dot(h, dx.j, dx.(j+1))$M = 0) for j in 1..n-1])
(37) |
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) |
-- Hodge star res.21 := test (one()$M*hodgeStar(g,1)$M = dot(g, 1, 1)$M * volumeForm(g)$M)
(39) |
res.22 := test (rd*hodgeStar(g,rd)$M = dot(g, rd, rd)$M * volumeForm(g)$M)
(40) |
res.23 := test (degree(hodgeStar(g,dx.n)$M) = n-1)
(41) |
res.24 := test (one()$M*hodgeStar(h,1)$M = dot(h, 1, 1)$M * volumeForm(h)$M)
(42) |
res.25 := test (rd*hodgeStar(h,rd)$M = dot(h, rd, rd)$M * volumeForm(h)$M)
(43) |
res.26 := test (degree(hodgeStar(h,dx.n)$M) = n-1)
(44) |
-- Projections res.27 := test (proj(0,nf+b*dx+d(b*dx))$M = nf)
(45) |
res.28 := test (proj(1,nf+b*dx+d(b*dx))$M = b*dx)
(46) |
res.29 := test (proj(2,nf+b*dx+d(b*dx))$M = d(b*dx))
(47) |
res.30 := test (proj(n,volumeForm(g)$M)$M = volumeForm(g)$M)
(48) |
res.31 := test (proj(random(n)$NNI,volumeForm(g)$M)$M = 0)
(49) |
-- Interior product res.32 := test (interiorProduct(vf,dx.1)$M = b.1)
(50) |
res.33 := test (interiorProduct(vf,dx.n)$M = b.n)
(51) |
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) |
-- Lie derivative res.35 := test ( d interiorProduct(vf,b*dx)$M + _ interiorProduct(vf, d(b*dx))$M = lieDerivative(vf, b*dx)$M)
(53) |
-- Version 1.2
)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) |
O ==> OutputForm
-- HodgeStar package for DERHAM(R,v) R:=Integer -- Ring
(55) |
v:=[subscript(x,[j::OutputForm]) for j in 1..n] -- (x_1, .., x_n)
(56) |
M:=DFORM(R,v)
(57) |
-- basis 1-forms and coordinate vector dx:=baseForms()$M -- [dx[1],..., dx[n]]
(58) |
x:=coordVector()$M -- [x[1],..., x[n]]
(59) |
xs:=coordSymbols()$M -- as above but as List Symbol (for differentiate,D)
(60) |
-- operator,vector field, scalar field, symbol a:=operator 'a -- operator
(61) |
b:=vectorField(b)$M -- generic vector field [b1(x1..xn),..., bn(x1..xn)]
(62) |
c:=vectorField(c)$M
(63) |
P:=scalarField(P)$M -- scalar field P(x1,.., xn)
(64) |
-- metric g:=diagonalMatrix([1 for i in 1..n])$SquareMatrix(n,EXPR R) -- Euclidean
(65) |
h:=diagonalMatrix(c)$SquareMatrix(n,EXPR R)
(66) |
eta:=diagonalMatrix(concat(1,[-1 for i in 2..n]))$SquareMatrix(n, EXPR R)
(67) |
-- vector field vf:=vector b
(68) |
-- macros dV(g) ==> volumeForm(g)$M
i(X,w) ==> interiorProduct(X, w)$M
L(X,w) ==> lieDerivative(X, w)$M
** w ==> hodgeStar(g,w)$M
---
w:=x.1*dx.2-x.2*dx.1
(69) |
res.36 := test(d w = 2*dx.1*dx.2)
(70) |
res.37 := test(w*w = zero()$M)
(71) |
res.38 := test(i(vf,w) = x.1*b.2-x.2*b.1)
(72) |
res.39 := test(L(vf,w) = d i(vf, w) + i(vf, d w))
(73) |
res.40 := test(d i(vf,w) + i(vf, d w) - L(vf, w) = zero()$M)
(74) |
res.41 := test(dot(g,w, w)$M = x.1^2+x.2^2)
(75) |
-- 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) |
res.42 := test(d (P*one()$M) = reduce(_+,[D(P, xs.j)*dx.j for j in 1..n]))
(77) |
res.43 := test(i(vf,d (P*one()$M))= reduce(_+, [D(P, xs.j)*b.j for j in 1..n])*one()$M)
(78) |
res.44 := test(1/dot(g,w, w)$M*w = w*(1/(x.1^2+x.2^2)))
(79) |
res.45 := test(d (1/dot(g,w, w)$M*w) = zero()$M)
(80) |
--- s:=zeroForm('s)$M
(81) |
res.46 := test(d s = totalDifferential(retract s)$DeRhamComplex(Integer,v))
(82) |
res.47 := test(d s = totalDifferential(retract s)$typeOf(s))
(83) |
res.48 := test(d (** s) = 0$typeOf(s))
(84) |
res.49 := test(dot(g,** ( d s), w*dx.2*dx.3)$M = x.2*D(retract s, xs.4))
(85) |
res.50 := test(d (** ( d s)) = reduce(_+,[D(retract s, xs.j, 2) for j in 1..n])*dV(g))
(86) |
r:=sin(x.1*x.2)*one()$M
(87) |
res.51 := test(d r = x.1*cos(x.1*x.2)*dx.2+x.2*cos(x.1*x.2)*dx.1)
(88) |
res.52 := test(d (** ( d r)) = -(x.1^2+x.2^2)*sin(x.1*x.2)*dV(g))
(89) |
res.53 := test(** (d (** ( d r))) = -(x.1^2+x.2^2)*sin(x.1*x.2))
(90) |
res.53 := test(** (d (** ( d r)))::EXPR INT = retract (** (d (** ( d r)))))
(91) |
res.54 := test(eval(** (d (** ( d r)))::EXPR INT,xs.1=%pi) = (-%pi^2-x.2^2)*sin(%pi*x.2))
(92) |
res.55 := test(eval(eval(** (d (** ( d r)))::EXPR INT,xs.1=%pi) , xs.2=%pi)=-2*%pi^2*sin(%pi^2))
(93) |
a(P)*one()$M
(94) |
-- chain diff res.56 := test(d (a(P)*one()$M) = eval(D(a(t),'t), t=P)*d (P*one()$M))
(95) |
res.57 := test(** invHodgeStar(g,w)$M = w)
(96) |
res.58 := test(invHodgeStar(g,** w)$M = w)
(97) |
res.59 := test(** invHodgeStar(g,** w + dx.1)$M = ** w + dx.1)
(98) |
res.60 := test( ** dV(g) = invHodgeStar(g,dV(g))$M)
(99) |
res.61 := test(** dV(h) ~= invHodgeStar(h,dV(g))$M)
(100) |
res.62 := test( dot(h,w, w)$M = (c.2*x.2^2+c.1*x.1^2)/(c.1*c.2))
(101) |
res.63 := test( s(g)$M = 1)
(102) |
res.64 := test( s(eta)$M = -1)
(103) |
res.65 := test( s(h)$M = 's? )
(104) |
-- https://en.wikipedia.org/wiki/Hodge_dual -- Four dimensions
res.66 := test( hodgeStar(eta,dx.1)$M = dx.2*dx.3*dx.4)
(105) |
res.67 := test( hodgeStar(eta,dx.2)$M = dx.1*dx.3*dx.4)
(106) |
res.68 := test( hodgeStar(eta,dx.3)$M = dx.1*dx.4*dx.2)
(107) |
res.69 := test( hodgeStar(eta,dx.4)$M = dx.1*dx.2*dx.3)
(108) |
res.70 := test( hodgeStar(eta,dx.1*dx.2)$M = dx.4*dx.3)
(109) |
res.71 := test( hodgeStar(eta,dx.1*dx.3)$M = dx.2*dx.4)
(110) |
res.72 := test( hodgeStar(eta,dx.1*dx.4)$M = dx.3*dx.2)
(111) |
res.73 := test( hodgeStar(eta,dx.2*dx.3)$M = dx.1*dx.4)
(112) |
res.74 := test( hodgeStar(eta,dx.2*dx.4)$M = dx.3*dx.1)
(113) |
res.75 := test( hodgeStar(eta,dx.3*dx.4)$M = dx.1*dx.2)
(114) |
-- 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) |
res.77 := test(codifferential(g,P*dx.2)$M = -D(P, xs.2)*one()$M)
(116) |
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) |
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) |
res.80 := test(codifferential(g,P*w)$M = _ (-1)^degree(w)*invHodgeStar(g, d hodgeStar(g, P*w)$M)$M)
(119) |
res.81 := test(codifferential(eta,P*w)$M = _ (-1)^degree(w)*invHodgeStar(eta, d hodgeStar(eta, P*w)$M)$M)
(120) |
res.82 := test(codifferential(h,P*w)$M = _ (-1)^degree(w)*invHodgeStar(h, d hodgeStar(h, P*w)$M)$M)
(121) |
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) |
-- 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) |
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) |
res.86 := test(hodgeLaplacian(g,w*(** w))$M = -4 * dV(g))
(125) |
res.87 := test(hodgeLaplacian(eta,w*(hodgeStar(eta, w)$M))$M = 4 * dV(eta))
(126) |
res.88 := test(hodgeLaplacian(h,w*(hodgeStar(h, w)$M))$M =_ d codifferential(h, w*hodgeStar(h, w)$M)$M)
(127) |
res.89 := test(d(vf*dx) * (** d(vf*dx))=dot(g,d(vf*dx), d(vf*dx))$M*dV(g))
(128) |
-- 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) |
-- 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) |
------------- -- Results -- -------------
)version
"FriCAS 1.3.10 compiled at Wed 10 Jan 02:19:45 CET 2024"
)lisp (lisp-implementation-type)
Your user access level is compiler and this command is therefore not available. See the )set userlevel command for more information.
)lisp (lisp-implementation-version)
Your user access level is compiler and this command is therefore not available. See the )set userlevel command for more information.
res
(131) |
reduce(_and,res)
(132) |
-- dummy statistics [testEquals("res." string(j),"true") for j in 1..N];
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!
============================================================================= 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
Some changes necessary: use vectors instead of lists, ...