(****************************************************************************) (* Tiny Forms Calculator Version 0.4.8 *) (****************************************************************************) Print[" -- Tiny Forms Calculator -- William L. Burke"] Print[" 0.4.8 1995/02/20 "] (****************************************************************************) (* Rules for Differential Forms *) (****************************************************************************) (* Make forms antisymmetric by sorting the arguments *) (* invoke these rules occasionally to kill the zero terms *) (* these should be included in any operation that destroys normal order *) FSimp := { Form[ a__] :> Signature[ Form[a]] Sort[Form[a]], TForm[ a__] :> Signature[ TForm[a]] Sort[TForm[a]] } Form[] := 1 Form[ f___, n_ /; NumberQ[n], g___] := 0 (****************************************************************************) (* Rules for Duality of Forms and Vectors, the angle operator *) (****************************************************************************) angle[ a_, b_ + c_] := angle[a,b] + angle[a,c] angle[ a_ + b_, c_] := angle[a,c] + angle[b,c] angle[ a_, Times[b___, c_Plus, d___] ] := angle[a, Expand[Times[b,c,d]]] angle[ Times[b___, c_Plus, d___] , a_] := angle[ Expand[Times[b,c,d]], a] angle[ a_ b_Vector, c_] := a angle[b,c] angle[ a_Vector, b_ c_Form] := b angle[a,c] angle[ Vector[ u_], Form[ v___, u_, w___]] := -(-1)^(Position[Form[v,u,w], u][[1,1]]) Form[v, w] angle[ a_Vector, 0] := 0 angle[ 0, a_] := 0 angle[a_Vector, b_Form] := 0 (* no match above *) (****************************************************************************) (* Rules for Wedge Product of Diffential Forms *) (* Important to leave answers properly sorted *) (****************************************************************************) wedge[] := 1 wedge[ n_ ] := n wedge[z___, a_ + b_, y___ ] := wedge[z, a, y] + wedge[z, b, y] wedge[ z___, a_ b_Form, y___ ] := a wedge[ z, b, y ] wedge[a___, Times[b___, c_Plus, d___] , e___] := wedge[ a, Expand[Times[b,c,d]], e] wedge[ Form[a__], Form[ b__]] := Form[ a, b] /. FSimp wedge[ a_, b_, c__] := wedge[ wedge[a,b], c] (* Treat the cases where entry is a 0-form; fall through to here *) wedge[ f___, n_ /; Position[n, Form]=={}, g___] := n wedge[ f, g ] (****************************************************************************) (* Rules for Exterior Derivatives of Differential Forms *) (****************************************************************************) d[ f_ ] := Dt2form[ Dt[f]] d[ a_ + b_] := d[ a] + d[ b] d[ Times[ b___, c_Plus, e___ ] ] := d[ Expand[Times[b,c,e]]] d[ f_ Form[a___]] := wedge[Dt2form[ Dt[f]], Form[ a]] Dt2form[x_] := x /. Dt -> Dtttt /. Dtttt[y_] -> Form[y] (* I don't know why you can't do this directly, without Dtttt *) d[ a_Form ] := 0 (****************************************************************************) (* Rules for Lie Bracket of Vectors *) (****************************************************************************) Lie[ Times[ b___, c_Plus, e___ ], f_] := Lie[ Expand[Times[b,c,e]], f] Lie[ f_, Times[ b___, c_Plus, e___ ]] := Lie[ f, Expand[Times[b,c,e]]] Lie[f_ Vector[ x_], g_ Vector[ y_]] := f D[g,x] Vector[ y ] - g D[f,y] Vector[ x ] Lie[Vector[ x_], g_ Vector[ y_]] := D[g,x] Vector[ y ] Lie[f_ Vector[ x_], Vector[ y_]] := - D[f,y] Vector[ x ] Lie[Vector[ x_], Vector[ y_]] := 0 (****************************************************************************) (* Rules for Lie Derivatives of Differential Forms *) (****************************************************************************) Lie[v_+u_, w_] := Lie[v,w] + Lie[u,w] Lie[v_, w_ + m_] := Lie[v,w] + Lie[v,m] Lie[f_ Vector[ x_], g_ Form[ w__]] := f D[g,x] Form[w] + g wedge[ d[f], angle[ Vector[x], Form[w]]] Lie[f_ Vector[ x_], w_Form] := wedge[ d[f], angle[ Vector[x], w]] Lie[ x_Vector, g_ Form[ w__]] := D[g,x] Form[w] Lie[f_ Vector[ x_], g_ ] := f D[g,x] Lie[ Vector[ x_], g_ ] := D[g,x] (****************************************************************************) (* Rules for Reducing Pullback *) (****************************************************************************) Pullback[ Times[b___, c_Plus, d___], pc_] := Pullback[ Expand[b c d], pc] Pullback[f_ + g__, pc_] := Pullback[f,pc] + Pullback[g, pc] Pullback[ f_ g_Form, pc_ ] := (f /. pc) Pullback[ g, pc] Pullback[f_Form, pc_] := wedge @@ d /@ (f /. pc) (****************************************************************************) (* Rules for Hodge Star, use right hand rule to eliminate twisted forms *) (****************************************************************************) << estar3.m (****************************************************************************) (* Shorthand for basis forms in three euclidean dimensions *) (****************************************************************************) << euclid3.m