|
|
last edited 11 years ago by test1 |
1 2 3 4 5 6 7 8 9 10 11 12 | ||
Editor: Bill Page
Time: 2008/08/26 13:49:28 GMT-7 |
||
Note: associativity |
http://en.wikipedia.org/wiki/Tensor_productA tensor product is "the most general bilinear operation" available in a specified domain of computation, satisfying:
\begin{equation} \label{eq1} (v_1+v_2)\otimes w - (v_1\otimes w+v_2\otimes w) = 0 \end{equation} \begin{equation} \label{eq2} v\otimes (w_1+w_2) - (v\otimes w_1+v\otimes w_2) = 0 \end{equation} \begin{equation} \label{eq3} cv\otimes w=v\otimes cw=c(v\otimes w) \end{equation}
We can use the domain constructor
Sum
[SandBoxSum] \begin{axiom} )lib SUM \end{axiom}First we can define some recursive operations on the polynomials \begin{axiom} scanPoly(p,n) == _ (p=0 => 0; mapMonomial(leadingMonomial(p),n)+scanPoly(reductum p,n)) mapMonomial(p,n) == monomial(coefficient(p,degree p),scanIndex(degree(p),n))$SMP(Integer,Sum(Symbol,Symbol)) scanIndex(p,n) == (zero? p => 0$IndexedExponents(Sum(Symbol,Symbol)); monomial(leadingCoefficient(p), if n=1 then in1(leadingSupport(p))$Sum(Symbol,Symbol) else in2(leadingSupport(p))$Sum(Symbol,Symbol) )$IndexedExponents(Sum(Symbol,Symbol))+ _ scanIndex(reductum(p),n)) \end{axiom} For example: \begin{axiom} -- functions are first compiled here -- scanPoly(x,1) \end{axiom} injects the polynomial
x
in to the tensor product. So now the full tensor product is just: \begin{axiom} tensorPoly(p,q) == _ scanPoly(p,1)*scanPoly(q,2) \end{axiom}For example: \begin{axiom} p:=2x^2+3 q:=5xy+7y+11 r:=tensorPoly(p,q) monomials(r) \end{axiom}
Demonstrating the axioms (1) (2) and (3) of the tensor product: \begin{axiom} w:= 13y^2+17y+19 test( tensorPoly(p+q,w) = (tensorPoly(p,w) + tensorPoly(q,w)) ) test( tensorPoly(p,q+w) = (tensorPoly(p,q) + tensorPoly(p,w)) ) test( tensorPoly(p,23w) = 23tensorPoly(p,w) ) test( tensorPoly(23p,w) = 23tensorPoly(p,w) ) \end{axiom} I suppose that we could give an inductive proof that this implementation of the tensor product of polynomials is correct ... but for now lets take this demonstration as reassurance.
Re-coding the interpreter functions as library package. \begin{spad} )abbrev package TPROD TensorProduct macro IE == IndexedExponents(VAR) macro IEP == IndexedExponents(Sum(VAR,VAR)) macro SMP == SparseMultivariatePolynomial(R,Sum(VAR,VAR))
TensorProduct(R:Ring, VAR: OrderedSet, P:PolynomialCategory(R,IE,VAR)): with \/: (P,P) -> SMP == add scanIndex(x:IE,n:Integer):IEP == zero? x => 0 monomial(leadingCoefficient(x), if n=1 then in1(leadingSupport(x))$Sum(VAR,VAR) else in2(leadingSupport(x))$Sum(VAR,VAR) _ ) + scanIndex(reductum(x),n) mapMonomial(p:P,n:Integer):SMP == monomial(coefficient(p,degree p),scanIndex(degree(p),n))$SMP scanPoly(p:P,n:Integer):SMP == p=0 => 0 mapMonomial(leadingMonomial(p),n)+scanPoly(reductum p,n)
(p:P \/ q:P):SMP == scanPoly(p,1)*scanPoly(q,2) \end{spad}
\begin{axiom} test( p\/q = r ) test( (p+q) \/ w = (p\/w) + (q\/w) ) test( p \/ (q+w) = (p\/q) + (p\/w) ) test( p \/ (23w) = 23(p\/w) ) test( (23p) \/ w = 23(p\/w) ) \end{axiom}
Here's another way to write this - maybe better this way as first step to express associativity of the tensor product. \begin{spad} )abbrev package TPROD2 TensorProduct2 macro IE1 == IndexedExponents(VAR1) macro IE2 == IndexedExponents(VAR2) macro S == Sum(VAR1,VAR2) macro IEP == IndexedExponents(S) macro SMP == SparseMultivariatePolynomial(R,S)
TensorProduct2(R:Ring, VAR1: OrderedSet, VAR2: OrderedSet, P:PolynomialCategory(R,IE1,VAR1), Q:PolynomialCategory(R,IE2,VAR2)): with \/: (P,Q) -> SMP == add scanIndex1(x:IE1):IEP == zero? x => 0 monomial(leadingCoefficient(x), in1(leadingSupport(x))$S) + scanIndex1(reductum(x)) scanIndex2(x:IE2):IEP == zero? x => 0 monomial(leadingCoefficient(x), in2(leadingSupport(x))$S) + scanIndex2(reductum(x)) mapMonomial1(p:P):SMP == monomial(coefficient(p,degree p),scanIndex1(degree(p)))$SMP mapMonomial2(q:Q):SMP == monomial(coefficient(q,degree q),scanIndex2(degree(q)))$SMP scanPoly1(p:P):SMP == p=0 => 0 mapMonomial1(leadingMonomial(p))+scanPoly1(reductum p) scanPoly2(q:Q):SMP == q=0 => 0 mapMonomial2(leadingMonomial(q))+scanPoly2(reductum q)
(p:P \/ q:Q):SMP == scanPoly1(p)*scanPoly2(q) \end{spad}
\begin{axiom} test( p\/q = r ) test( (p+q) \/ w = (p\/w) + (q\/w) ) test( p \/ (q+w) = (p\/q) + (p\/w) ) test( p \/ (23w) = 23(p\/w) ) test( (23p) \/ w = 23(p\/w) ) \end{axiom}
Associativity of the tensor product means these two expressions should be identical: \begin{axiom} (p\/q)\/w p\/(q\/w) \end{axiom}
Some or all expressions may not have rendered properly, because Axiom returned the following error:Error: export AXIOM=/usr/local/lib/open-axiom/x86_64-unknown-linux/1.3.0-2009-01-05; export ALDORROOT=/usr/local/aldor/linux/1.1.0; export PATH=$ALDORROOT/bin:$PATH; export HOME=/var/zope2/var/LatexWiki; ulimit -t 240; $AXIOM/bin/AXIOMsys < /var/zope2/var/LatexWiki/6578669110478838235-25px.axm Segmentation faultGCL (GNU Common Lisp) 2.6.7 CLtL1 Oct 29 2006 20:31:33 Source License: LGPL(gcl,gmp), GPL(unexec,bfd,xgcl) Binary License: GPL due to GPL'ed components: (XGCL READLINE BFD UNEXEC) Modifications of this banner must retain notice of a compatible license Dedicated to the memory of W. Schelter
Use (help) to get some basic information on how to use GCL. Temporary directory for compiler files set to /tmp/ OpenAxiom: The Open Scientific Computation Platform Version: OpenAxiom 1.3.0-2009-01-05 Built on Wednesday January 7, 2009 at 17:48:30 ----------------------------------------------------------------------------- Issue )copyright to view copyright notices. Issue )summary for a summary of useful system commands. Issue )quit to leave OpenAxiom and return to shell. -----------------------------------------------------------------------------
(1) -> (1) -> (1) -> (1) -> (1) -> )lib SUM
Sum is now explicitly exposed in frame initial Sum will be automatically loaded when needed from /var/zope2/var/LatexWiki/SUM.NRLIB/code.o (1) -> scanPoly(p,n) == _ (p=0 => 0; mapMonomial(leadingMonomial(p),n)+scanPoly(reductum p,n))
Type: Void mapMonomial(p,n) == _ monomial(coefficient(p,degree p),scanIndex(degree(p),n))$SMP(Integer,Sum(Symbol,Symbol))
Type: Void scanIndex(p,n) == (zero? p => 0$IndexedExponents(Sum(Symbol,Symbol)); monomial(leadingCoefficient(p), if n=1 then in1(leadingSupport(p))$Sum(Symbol,Symbol) else in2(leadingSupport(p))$Sum(Symbol,Symbol) )$IndexedExponents(Sum(Symbol,Symbol))+ scanIndex(reductum(p),n))
Type: Void (4) -> -- functions are first compiled here -- scanPoly(x,1)
! Missing $ inserted. <inserted text> $ l.120 \/: (P,P) -> SMP Missing $ inserted. <inserted text> $ l.125 ...hen in1(leadingSupport(x))$Sum(VAR,VAR) _Missing $ inserted. <inserted text> $ l.126 ...lse in2(leadingSupport(x))$Sum(VAR,VAR) _
Overfull \hbox (127.90825pt too wide) in paragraph at lines 119--133 \OML/cmm/m/it/12 Integer\OT1/cmr/m/n/12 ) : \OML/cmm/m/it/12 IEP \OT1/cmr/m/n/1 2 == \OML/cmm/m/it/12 zero\OT1/cmr/m/n/12 ?\OML/cmm/m/it/12 x \OT1/cmr/m/n/12 = \OML/cmm/m/it/12 > \OT1/cmr/m/n/12 0\OML/cmm/m/it/12 monomial\OT1/cmr/m/n/12 (\ OML/cmm/m/it/12 leadingCoefficient\OT1/cmr/m/n/12 (\OML/cmm/m/it/12 x\OT1/cmr/m /n/12 )\OML/cmm/m/it/12 ;[] fn \OT1/cmr/m/n/12 = 1\OML/cmm/m/it/12 thenin\OT1/c mr/m/n/12 1(\OML/cmm/m/it/12 leadingSupport\OT1/cmr/m/n/12 (\OML/cmm/m/it/12 x\ OT1/cmr/m/n/12 ))$Sum(VAR,VAR) $[]\OML/cmm/m/it/12 lsein\OT1/cmr/m/n/12 2(\OML/ cmm/m/it/12 leadingSupport\OT1/cmr/m/n/12 (\OML/cmm/m/it/12 x\OT1/cmr/m/n/12 )) $Sum(VAR,VAR)
Overfull \hbox (8.49167pt too wide) in paragraph at lines 119--133 [] \OT1/cmr/m/n/12 + \OML/cmm/m/it/12 scanIndex\OT1/cmr/m/n/12 (\OML/cmm/m/it/1 2 reductum\OT1/cmr/m/n/12 (\OML/cmm/m/it/12 x\OT1/cmr/m/n/12 )\OML/cmm/m/it/12 ; n\OT1/cmr/m/n/12 )\OML/cmm/m/it/12 mapMonomial\OT1/cmr/m/n/12 (\OML/cmm/m/it/ 12 p \OT1/cmr/m/n/12 : \OML/cmm/m/it/12 P; n \OT1/cmr/m/n/12 : \OML/cmm/m/it/12 Integer\OT1/cmr/m/n/12 ) : \OML/cmm/m/it/12 SMP \OT1/cmr/m/n/12 == \OML/cmm/m/ it/12 monomial\OT1/cmr/m/n/12 (\OML/cmm/m/it/12 coefficient\OT1/cmr/m/n/12 (\OM L/cmm/m/it/12 p; degreep\OT1/cmr/m/n/12 )\OML/cmm/m/it/12 ; scanIndex\OT1/cmr/m /n/12 (\OML/cmm/m/it/12 degree\OT1/cmr/m/n/12 (\OML/cmm/m/it/12 p\OT1/cmr/m/n/1 2 )\OML/cmm/m/it/12 ; n\OT1/cmr/m/n/12 ))$SMP [4]
LaTeX Warning: Characters dropped after `\end{axiom}' on input line 142.
Missing $ inserted. <inserted text> $ l.152 \/: (P,Q) -> SMP Missing $ inserted. <inserted text> $ l.170
Overfull \hbox (22.17155pt too wide) in paragraph at lines 151--170 []\OT1/cmr/m/n/12 TensorProduct2(R:Ring, VAR1: Or-dered-Set, VAR2: Or-dered-Set , P:PolynomialCategory(R,IE1,VAR1), Q:PolynomialCategory(R,IE2,VAR2)):
Overfull \hbox (0.20291pt too wide) in paragraph at lines 151--170 \OT1/cmr/m/n/12 with $[]\OML/cmm/m/it/12 = \OT1/cmr/m/n/12 : (\OML/cmm/m/it/12 P; Q\OT1/cmr/m/n/12 )\OMS/cmsy/m/n/12 ^^@ \OML/cmm/m/it/12 > SMP \OT1/cmr/m/n/1 2 == \OML/cmm/m/it/12 addscanIndex\OT1/cmr/m/n/12 1(\OML/cmm/m/it/12 x \OT1/cmr /m/n/12 : \OML/cmm/m/it/12 IE\OT1/cmr/m/n/12 1) : \OML/cmm/m/it/12 IEP \OT1/cmr /m/n/12 == \OML/cmm/m/it/12 zero\OT1/cmr/m/n/12 ?\OML/cmm/m/it/12 x \OT1/cmr/m/ n/12 =\OML/cmm/m/it/12 > \OT1/cmr/m/n/12 0\OML/cmm/m/it/12 monomial\OT1/cmr/m/n /12 (\OML/cmm/m/it/12 leadingCoefficient\OT1/cmr/m/n/12 (\OML/cmm/m/it/12 x\OT1 /cmr/m/n/12 )\OML/cmm/m/it/12 ; in\OT1/cmr/m/n/12 1(\OML/cmm/m/it/12 leadingSup port\OT1/cmr/m/n/12 (\OML/cmm/m/it/12 x\OT1/cmr/m/n/12 ))$S)
Overfull \hbox (171.6808pt too wide) in paragraph at lines 151--170 \OT1/cmr/m/n/12 + scanIn-dex1(reductum(x)) scanIn-dex2(x:IE2):IEP == zero?