%*******************************************************************% % % % V 3 T O O L S . T S T % % --------------------- % % v3tools.tst contains test examples for the program v3tools.red. % % To run this test read into the session the files crack.red and % % v3tools.red or load their compiled version before. % % % % Author: Thomas Wolf % % Date: 15. June 2004 % % % % Details about the syntax of v3tools are given in v3tools.tex. % % % % Before reading in this file through % % in "v3tools.tst"$ % % you have to either load % % load crack,v3tools$ % % or to read in % % in "crack.red","v3tools.red"$ % % (with the appropriate directory name in front of the file names) % % or, to speed up the calculation, you compile before with % % faslout "crack"$ % % in "crack.red"$ % % faslend$ % % faslout "v3tools"$ % % in "v3tools.red"$ % % faslend$ % % and then load both with % % load crack,v3tools$ % % % %*******************************************************************% comment ------------------------------------------------------------- The package v3tools involves 3 global variables: V_ : the list of vectors involved GBASE_ : a Groebner basis of the identities satisfied by the vectors V_ HEADS_ : the list of leading terms in GBASE_. The computations to be done in this test file involve only vectors A,B,U,V. For these the global variables V_, GBASE_, HEADS_ are already assigned. If other vectors shall be used, call the procedure VINIT first with the list of vectors to be used, e.g. VINIT({A,B,U,V}) . The following are vector expessions which we will use in the tests below. Identifiers starting with !& are parameters, all others are vector products.; kap:=-aa$ HAMh:=ab*uu-1/2*au*bu+buv$ HAMi:=!&p1*abu$ FI6:=bu**2*((bu*aa-ab*au)**2*uu+2*(bu*aa-ab*au)*(bu*auv-buv*au) -vv*uba**2-(bu*av-bv*au)**2-uu*vv*ab**2-kap*uu*vv*bb)$ FI5:=4*!&p1*bu*((ab*uu*(aa*bu-au*ab)*abu+vv*(ab*bu-au*bb)*abu) +(au*bv-av*bu)*(bv*abu-bu*abv) +bu*uv*(ab*(aa*bu-au*ab)-kap*(ab*bu-au*bb)) -ab*(ab*bu-au*bb)*(2*au*uv-av*uu) +uu*(aa*bu-au*ab)*(bb*av-2*ab*bv))$ FI4:=!&p1**2*(4*((ab*bu-au*bb)*(av*bu+2*ab*uv)-bv*bu*(aa*bu-au*ab) -2*ab*uu*(ab*bv-av*bb))*abu +4*bu*(bu*(aa*bu-au*ab)-au*(ab*bu-au*bb))*abv -8*(ab*bu-au*bb)*(ab*bv-av*bb)*uv +(4*ab**2*au*(ab*bu-au*bb)-4*bu*(2*ab**2-aa*bb)* (aa*bu-ab*au) +4*(ab*bv-av*bb)**2)*uu-4*ab**2*(ab**2-aa*bb)*uu**2)$ FI3:=8*!&p1**3*(aa*bb-ab**2)*(ab*uu*abu+(bb*av-bv*ab)*uu+ (ab*bu-au*bb)*uv)$ FI2:=-4*!&p1**4*(aa*bb-ab**2)*(ab**2*uu-bb*vv)$ comment ------------------------------------------------------------- In order to ensure that the same order of vector names is used for the same products one can convert all to the correct name using the procedure e2s. The following should produce all zeros: ; write"0 = ",e2s (abu - uab); write"0 = ",e2s (abu + aub); write"0 = ",e2s (ba*uu-1/2*ua*ub+vbu - HAMh); comment ------------------------------------------------------------- Just in case the data above which have not been generated by the program have vectors ordered not lexicographically we re-write them again: ; HAMh:=e2s HAMh$ HAMi:=e2s HAMi$ FI6:=e2s FI6$ FI5:=e2s FI5$ FI4:=e2s FI4$ FI3:=e2s FI3$ FI2:=e2s FI2$ comment ------------------------------------------------------------- To convert a vector expression into component form we can use v2c; write"Conversion into component form: 0 = ", v2c(HAMh) - ( a1*b1*u1**2 + 2*a1*b1*u2**2 + 2*a1*b1*u3**2 - a1*b2*u1*u2 - a1*b3*u1*u3 - a2*b1*u1*u2 + 2*a2*b2*u1**2 + a2*b2*u2**2 + 2*a2*b2*u3**2 - a2*b3*u2*u3 - a3*b1*u1*u3 - a3*b2*u2*u3 + 2*a3*b3*u1**2 + 2*a3*b3*u2**2 + a3*b3*u3**2 + 2*b1*u2*v3 - 2*b1*u3*v2 - 2*b2*u1*v3 + 2*b2*u3*v1 + 2*b3*u1*v2 - 2*b3*u2*v1)/2; comment ------------------------------------------------------------- To convert a component form vector expression into standard vector form we can use c2s. $ write"Conversion into vector form: 0 = ", c2s( a1*b1*u1**2 + 2*a1*b1*u2**2 + 2*a1*b1*u3**2 - a1*b2*u1*u2 - a1*b3*u1*u3 - a2*b1*u1*u2 + 2*a2*b2*u1**2 + a2*b2*u2**2 + 2*a2*b2*u3**2 - a2*b3*u2*u3 - a3*b1*u1*u3 - a3*b2*u2*u3 + 2*a3*b3*u1**2 + 2*a3*b3*u2**2 + a3*b3*u3**2 + 2*b1*u2*v3 - 2*b1*u3*v2 - 2*b2*u1*v3 + 2*b2*u3*v1 + 2*b3*u1*v2 - 2*b3*u2*v1)/2 - HAMh; comment ------------------------------------------------------------- The procedure s2e introduces n-products, like abcd for (a,bx(cxd)), in order to compress an expression. (For notation see v3tools.tex). We call this extended vector form. The following computation can take a few minutes. It also needs some memory (10MB) ; s2e(ab*abu*uu*(aa*bb - ab**2))$ comment ------------------------------------------------------------- To test the correctness the following should give zero; write"Conversion into extended vector form: 0 = ",ws - abauuubbaab; comment ------------------------------------------------------------- To convert a extended vector form into standard vector form is an easier task and done by procedure e2s as well. ; write"Conversion into standard vector form: 0 = ",e2s(abauuubbaab) - ab*abu*uu*(aa*bb - ab**2)$ comment ------------------------------------------------------------- Another quick (and absolute safe) test whether two vector expressions are equal is to convert them into component form; write"Conversion into component form: 0 = ",v2c(abauuubbaab) - v2c(ab*abu*uu*(aa*bb - ab**2))$ comment ------------------------------------------------------------- There are a number of identities between vectors. The function s2s generates them and uses them to shorten a given vector expression. ; s2s(aa*bb*vv - aa*bv**2 - ab**2*vv + 2*ab*av*bv)$ comment ------------------------------------------------------------- The new vector expression found should be shorter. To check correctness we do: ; write"Shortening of standard vector form: 0 = ",ws - (abv**2 + av**2*bb); comment ------------------------------------------------------------- The procedure poisson_c computes the poisson bracket of two expressions in component form. We need the Poisson structure matrix which we will assign once as STRUC_CONS and then use repeatedly in a number of examples. Any assignment of identifiers in the structure matrix has to be done in component form before the first call of poisson_c (or poisson_v, see below). The default structure constants used in v3tools.tst are: ; kap:=-a1**2-a2**2-a3**2$ STRUC_CONS:={{U1,U2, U3}, {U2,U3, U1}, {U3,U1, U2}, {U1,V2, V3}, {U2,V3, V1}, {U3,V1, V2}, {U1,V3,-V2}, {U2,V1,-V3}, {U3,V2,-V1}, {V1,V2, kap*U3}, {V2,V3, kap*U1}, {V3,V1, kap*U2}}$ comment : Structure matrices for other Lie-Poisson brackets are given in v3tools.red. The following test shows that FI6 is a 6th degree first integral of the Hamiltonian HAMh. (It needs 40MB memory!); on time$off time$ write"Poisson bracket in components: 0 = ", poisson_c(v2c(HAMh),v2c(FI6),STRUC_CONS); comment ------------------------------------------------------------- One can compute the Poisson bracket also directy in standard vector form. When doing this the first time Poisson brackets for scalar products and triple products have to be worked out automatically which takes a bit more time and which takes the structure constants in component form (and therefore also anything that turns up in the structur constants, like kap, in component form). +++++++++++++++++++++++ The procedure poisson_v needs a list of vectors as third argument. The third of the following tests shows that FI6+FI5+FI4+FI3+FI2 is a 6th degree (inhomogeneous) first integral of the (inhomogeneous) Hamiltonian HAMh+HAMi ! $ on time$off time$ write"Poisson bracket in vector form: 0 = ",poisson_v(HAMh,FI6,STRUC_CONS); on time$off time$ write"Poisson bracket in vector form: 0 = ",poisson_v(HAMh,FI6,STRUC_CONS); on time$off time$ write"Poisson bracket in vector form: 0 = ", poisson_v(HAMh+HAMi,FI6+FI5+FI4+FI3+FI2,STRUC_CONS); on time$off time$ comment ------------------------------------------------------------- The following procedure creates for a given list of vectors a list of all their scalar and triple products. $ write"Generation of vector products: ", if (genpro {a,b,u,v}) = {aa,ab,au,av,bb,bu,bv,uu,uv,vv,abu,abv,auv,buv} then "ok." else "*** wrong! ***"$ comment ------------------------------------------------------------- Procedure genpro_wg generates a list of all scalar and triple products with weight lists for a given vector weight list. $ write"Generation of vector products with weights: ", if genpro_wg {{A,1,0,0},{B,0,1,0},{U,0,0,1},{V,1,0,1}} = {{aa,2,0,0}, {ab,1,1,0}, {au,1,0,1}, {av,2,0,1}, {bb,0,2,0}, {bu,0,1,1}, {bv,1,1,1}, {uu,0,0,2}, {uv,1,0,2}, {vv,2,0,2}, {abu,1,1,1},{abv,2,1,1},{auv,2,0,2},{buv,1,1,2}} then "ok." else "*** wrong! ***"$ comment ------------------------------------------------------------- The following is a longer computation. To show intermediate results simply replace the dollar sign by semicolon signs. The purpose will be to find a first integral FI for the Hamiltonian HAMh. At first we generate an ansatz using the procedure gfi to generate a 4th degree expression in vectors u,v with appropriate homogeneity which then is multiplied with bu**2 as we want the first integral to have this factor. FL will be the list of unknown coefficients. $ hh:= gfi({4,2,4}, % total weights {{A,1,0,0},{B,0,1,0},{U,0,0,1},{V,1,0,1} }, % list of vectors + weights {}, % no restrictions for the % terms to be generated heads_ % apart from avoiding heads_ )$ FI:=bu**2*(first hh)$ FL:=rest hh$ comment ------------------------------------------------------------- Now we compute the Poisson bracket and split it wrt to all occuring scalar and triple products to generate a list of conditions for the unknown coefficients which is solved using solve. $ hh:={poisson_v(HAMh,FI,STRUC_CONS)}$ for each g in genpro {a,b,u,v} do hh:=for each h in hh join coeff(h,g)$ hh:=solve(hh,fl)$ comment ------------------------------------------------------------- The solution for the coefficients is substituted into the ansatz for FI and we check that it is the same as FI6 up to vector identities which we get rid of by transforming into component form. The first of the two tests is sufficient to show that FI is a first integral but to show that it is not any integral but the 6th degree integral FI6 one can use preduce or v2c. The higher the degree the slower v2c becomes compared to preduce. To use s2s in order to shorten an expression and find it to be zero is not reliable due to the non- reliability of shortening of non-linear expressions in CRACK. $ FI:=sub(first hh,FI)$ off nat$ write"Check of a computed first integral: 0 = ",poisson_v(HAMh,FI,STRUC_CONS)$ comment ------------------------------------------------------------- Test that FI ~ FI6 can be done by factorize(preduce(FI,gbase_)-preduce(FI6,gbase_)) to find the value of arbcomplex(1). Assuming arbcomplex(1)=2 we check: $ write"Equivalence check with FI6: 0 = ", preduce(sub(arbcomplex(1)=-1,FI),gbase_) -preduce(FI6 ,gbase_)$ comment ------------------------------------------------------------- Now the same without assuming bu**2 to be a factor of the first integral FI. The following example demonstrates the use of the procedure fnc_dep which can determine any functional dependence of homogeneous vectorial expressions even modulo vector identities. The call of gfi() generates an ansatz for the first integral. From this ansatz terms had been dropped in gfi() such that the resulting polynomial does not contain a functionally depending on AA,AB,BB,UV,-AA*UU+VV,HAMh. $ hh:= gfi({4,4,6}, % total weights {{A,1,0,0},{B,0,1,0},{U,0,0,1},{V,1,0,1}}, % list of vectors + weights {AA,AB,BB, % all constant UV,-AA*UU+VV, % Casimir 1 and 2 HAMh % Hamiltonian }, heads_ )$ FI:=first hh$ FL:=rest hh$ hh:={poisson_v(HAMh,FI,STRUC_CONS)}$ for each g in genpro {a,b,u,v} do hh:=for each h in hh join coeff(h,g)$ hh:=solve(hh,fl)$ FI:=sub(first hh,FI)$ write"Check of a computed first integral: 0 = ", poisson_v(HAMh,FI,STRUC_CONS); if fnc_dep(FI,{aa,ab,bb,uv,uu*aa-vv,HAMh,FI6}, {{A,1,0,0},{B,0,1,0},{U,0,0,1},{V,1,0,1}}) then write"Known first integral." else write"New first integral!"$ clear g,h,hh,FI,FL$ lisp(depl!*:=nil)$ % to delete all dependencies of functions on variables end$