|
|
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 |
removed: -p\/q\/w added: Associativity of the tensor product means these two expressions should be identical: \begin{axiom} (p\/q)\/w p\/(q\/w) \end{axiom}
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.2.0-2008-05-25; 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
! Missing $ inserted. <inserted text> $ l.128 \/: (P,P) -> SMP Missing $ inserted. <inserted text> $ l.133 ...hen in1(leadingSupport(x))$Sum(VAR,VAR) _Missing $ inserted. <inserted text> $ l.134 ...lse in2(leadingSupport(x))$Sum(VAR,VAR) _
Overfull \hbox (30.44293pt too wide) in paragraph at lines 127--141 []\OT1/cmr/m/n/12 TensorProduct(R:Ring, VAR: Or-dered-Set, P:PolynomialCategory (R,IE,VAR)):
Overfull \hbox (127.18265pt too wide) in paragraph at lines 127--141 \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/c mm/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/cmr/m/ n/12 1(\OML/cmm/m/it/12 leadingSupport\OT1/cmr/m/n/12 (\OML/cmm/m/it/12 x\OT1/c mr/m/n/12 ))$Sum(VAR,VAR)
Overfull \hbox (89.29578pt too wide) in paragraph at lines 127--141 []\OML/cmm/m/it/12 lsein\OT1/cmr/m/n/12 2(\OML/cmm/m/it/12 leadingSupport\OT1/c mr/m/n/12 (\OML/cmm/m/it/12 x\OT1/cmr/m/n/12 ))$Sum(VAR,VAR) $[] + \OML/cmm/m/i t/12 scanIndex\OT1/cmr/m/n/12 (\OML/cmm/m/it/12 reductum\OT1/cmr/m/n/12 (\OML/c mm/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 :
Overfull \hbox (87.85938pt too wide) in paragraph at lines 127--141 \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 (\OML/cmm/m/it/12 p; degree p\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/12 )\OML/cmm/m/it/12 ; n \OT1/cmr/m/n/12 ))$SMP
Overfull \hbox (135.91133pt too wide) in paragraph at lines 127--141 \OT1/cmr/m/n/12 scan-Poly(p:P,n:Integer):SMP == p=0 => 0 map-Mono-mial(leadingM onomial(p),n)+scanPoly(reductum [10] [11] Overfull \hbox (53.30666pt too wide) in paragraph at lines 154--160 \OT1/cmr/m/n/12 nents(VAR1) macro IE2 == In-dexed-Ex-po-nents(VAR2) macro S == Sum(VAR1,VAR2)
Overfull \hbox (6.8212pt too wide) in paragraph at lines 154--160 \OT1/cmr/m/n/12 macro IEP == In-dexed-Ex-po-nents(S) macro SMP == Sparse-Mul-ti -vari-atePoly- Missing $ inserted. <inserted text> $ l.162 \/: (P,Q) -> SMP Missing $ inserted. <inserted text> $ l.180
Overfull \hbox (154.23055pt too wide) in paragraph at lines 161--180 []\OT1/cmr/m/n/12 TensorProduct2(R:Ring, VAR1: Or-dered-Set, VAR2: Or-dered-Set , P:PolynomialCategory(R,IE1,VAR1),
Overfull \hbox (65.84291pt too wide) in paragraph at lines 161--180 \OT1/cmr/m/n/12 Q:PolynomialCategory(R,IE2,VAR2)): 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 ^^@ \O ML/cmm/m/it/12 > SMP \OT1/cmr/m/n/12 == \OML/cmm/m/it/12 addscanIndex\OT1/cmr/m /n/12 1(\OML/cmm/m/it/12 x \OT1/cmr/m/n/12 :
Overfull \hbox (76.06493pt too wide) in paragraph at lines 161--180 \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 ?