# euclideanDistance -- compute the euclidean distance of two chain complexes

## Synopsis

• Usage:
euclideanDistance(C,D)
• Inputs:
• C, ,
• D, , two chain complexes over RR or QQ
• Outputs:
• ,

## Description

Compute the distance in the L^2-norm of two complexes viewed as a sequence of matrices

 i1 : needsPackage "RandomComplexes" o1 = RandomComplexes o1 : Package i2 : setRandomSeed "a good example"; i3 : h={2,3,5,2} o3 = {2, 3, 5, 2} o3 : List i4 : r={4,3,3} o4 = {4, 3, 3} o4 : List i5 : elapsedTime C=randomChainComplex(h,r,Height=>5,ZeroMean=>true) -- 0.0015922 seconds elapsed 6 10 11 5 o5 = ZZ <-- ZZ <-- ZZ <-- ZZ 0 1 2 3 o5 : ChainComplex i6 : C.dd^2 6 11 o6 = 0 : ZZ <----- ZZ : 2 0 10 5 1 : ZZ <----- ZZ : 3 0 o6 : ChainComplexMap i7 : CR=(C**RR_53) 6 10 11 5 o7 = RR <-- RR <-- RR <-- RR 53 53 53 53 0 1 2 3 o7 : ChainComplex i8 : h=(SVDHomology CR)_0 o8 = HashTable{0 => 2} 1 => 3 2 => 5 3 => 2 o8 : HashTable i9 : D=disturb(C,1e-2,Strategy=>Discrete) 6 10 11 5 o9 = RR <-- RR <-- RR <-- RR 53 53 53 53 0 1 2 3 o9 : ChainComplex i10 : C.dd_1 o10 = | -3 4 -4 -2 0 2 -4 -1 -1 -2 | | -4 4 -3 -1 -2 1 -2 -1 1 -6 | | -1 -4 2 2 0 -2 0 5 -1 -2 | | 2 -2 3 -1 4 1 -1 -3 7 5 | | -5 2 -3 -3 4 3 -9 0 4 -1 | | 2 4 -3 -3 2 3 -2 -5 -1 6 | 6 10 o10 : Matrix ZZ <--- ZZ i11 : D.dd_1 o11 = | -3.03 4.04 -3.96 -2.02 0 2.02 -3.96 -.99 -1.01 -1.98 | | -4.04 4.04 -3.03 -1.01 -1.98 1.01 -1.98 -.99 1.01 -5.94 | | -.99 -4.04 1.98 1.98 0 -2.02 0 4.95 -1.01 -2.02 | | 1.98 -2.02 3.03 -.99 4.04 .99 -1.01 -2.97 6.93 5.05 | | -4.95 2.02 -3.03 -2.97 4.04 2.97 -9.09 0 4.04 -.99 | | 2.02 4.04 -2.97 -3.03 2.02 3.03 -1.98 -4.95 -1.01 5.94 | 6 10 o11 : Matrix RR <--- RR 53 53 i12 : D.dd^2 6 11 o12 = 0 : RR <------------------------------------------------------------------------------------------------- RR : 2 53 | .404 -1.0068 1.5192 1.1538 1.9168 -.96 .463 -.5122 .6336 -2.0516 1.8312 | 53 | .0646 -1.1216 .8444 1.6532 1.8214 -.2892 .4242 -1.2694 -7.10543e-15 -2.2028 1.676 | | -.1616 .2424 -1.3062 -.932 -1.1766 .5156 -.524 .4172 -1.12 2.0808 -.198 | | .4674 -.5608 .3608 -1.2064 -.004 -.7272 .1204 1.2226 1.0408 -.1148 -.3548 | | -1.0218 -.7936 -.4102 -.2552 -.0934 -.1212 -.1192 1.031 -2.0768 1.2952 -.2756 | | -.1818 1.23 1.303 1.7906 .596 .1688 .5644 -1.0064 .3944 -1.2468 -.3224 | 10 5 1 : RR <----------------------------------------------- RR : 3 53 | -.6666 -.2352 -3.0378 .1148 -.2808 | 53 | -4.9212 -3.1936 3.2648 -.5656 -.0446 | | -.948 -.2004 1.4232 -.4356 -1.6118 | | .0082 .7928 -.6338 .6336 -3.4756 | | -.96 -1.0344 -.906 -.5544 1.8058 | | -2.7814 -.6764 1.3226 .358 -3.0424 | | -2.8502 -1.7236 1.2766 -.8808 .2148 | | -1.7776 -.9696 -.6352 -1.2024 1.158 | | -.5156 -.4808 .1528 -.4008 .7854 | | -2.7992 -1.0312 2.1204 .2796 -2.8468 | o12 : ChainComplexMap i13 : C'=projectToComplex(D,h) 6 10 11 5 o13 = RR <-- RR <-- RR <-- RR 53 53 53 53 0 1 2 3 o13 : ChainComplex i14 : C'.dd^2 6 11 o14 = 0 : RR <------------------------------------------------------------------------------------------------------------------------------------------------------ RR : 2 53 | 0 -2.13163e-14 2.13163e-14 -3.55271e-15 1.42109e-14 -2.4869e-14 9.32587e-15 7.10543e-15 1.42109e-14 -1.77636e-14 1.77636e-14 | 53 | 2.84217e-14 -4.26326e-14 3.19744e-14 -3.19744e-14 3.19744e-14 -4.9738e-14 -3.10862e-15 2.13163e-14 4.9738e-14 -3.55271e-14 2.84217e-14 | | 8.88178e-15 1.42109e-14 -2.66454e-14 -3.81917e-14 -1.06581e-14 -1.77636e-15 -2.57572e-14 2.66454e-14 -3.19744e-14 3.64153e-14 -3.19744e-14 | | -2.66454e-14 3.55271e-15 -1.95399e-14 1.77636e-15 -3.55271e-14 3.19744e-14 -1.77636e-15 1.59872e-14 -3.90799e-14 2.84217e-14 -4.61853e-14 | | -3.55271e-15 -1.42109e-14 1.42109e-14 -3.55271e-14 7.10543e-15 -1.42109e-14 -5.32907e-15 3.55271e-14 1.42109e-14 0 -7.10543e-15 | | -2.84217e-14 -7.10543e-15 2.84217e-14 8.88178e-14 -1.77636e-15 2.84217e-14 3.70814e-14 -6.92779e-14 2.84217e-14 -3.55271e-14 4.26326e-14 | 10 5 1 : RR <------------------------------------------------------------------------ RR : 3 53 | -2.78805e-14 -1.77913e-14 1.65146e-15 -1.06581e-14 -9.41469e-14 | 53 | -6.12078e-14 1.82293e-14 -6.85617e-14 2.9976e-14 -7.00967e-14 | | 2.00256e-14 3.05311e-15 9.37445e-15 1.77636e-15 4.9738e-14 | | 4.8541e-14 3.5319e-15 6.62682e-14 -1.42109e-14 1.08358e-13 | | -8.3232e-14 -7.32747e-15 -4.62963e-14 1.77636e-14 -1.3145e-13 | | 1.79023e-15 3.21965e-15 1.06859e-14 1.42109e-14 4.44089e-14 | | -6.44831e-14 3.81639e-16 -4.19213e-14 2.4869e-14 -8.70415e-14 | | -6.38656e-14 7.2789e-15 -8.79678e-14 1.77636e-14 -1.00364e-13 | | -3.43655e-14 -5.58668e-15 -1.349e-14 5.88418e-15 -4.37844e-14 | | 3.17871e-14 1.83742e-14 -1.67019e-14 7.10543e-15 5.15143e-14 | o14 : ChainComplexMap i15 : euclideanDistance(C',D) o15 = .448104803679258 o15 : RR (of precision 53) i16 : euclideanDistance(CR,D) o16 = .320600000000001 o16 : RR (of precision 53) i17 : euclideanDistance(C',CR) o17 = .476857690728905 o17 : RR (of precision 53)