-
Notifications
You must be signed in to change notification settings - Fork 0
/
teaser.m2
63 lines (55 loc) · 2.19 KB
/
teaser.m2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
--teaser example
restart
needs "main.m2"
setRandomSeed 0
dom = domain(3, 1)
Map = diffEuclideanSigMap dom
H = witnessHomotopy(dom, Map)
elapsedTime W = runMonodromy H
(fix, slice) := (fixedParams W, sliceParams W);
chartInds := (numcols fix -3..numcols fix-1);
(coef, chart) := (submatrix'(fix, chartInds), submatrix(fix, chartInds));
slicen := slice + matrix{{0_CC, 0_CC, 1}};
w' := witnessCollect(coef, W, SliceParameters => slice, ChartParameters => chart);
preimage w'
)
)
verticalSweep = (W, n) -> (
(fix, slice) := (fixedParams W, sliceParams W);
chartInds := (numcols fix -3..numcols fix-1);
(coef, chart) := (submatrix'(fix, chartInds), submatrix(fix, chartInds));
apply(n, i -> (
slicen := slice + matrix{{0_CC, 0_CC, i}};
w' := witnessCollect(coef, W, SliceParameters => slicen, ChartParameters => chart);
preimage w'
)
)
)
n=3
netList verticalSweep(W, 3)
peek W
R = QQ[x,y,z]
f=homogenize(8*x^3 - (20*x)*y + 2*y^2 + 5*x - 10,z)
W0 = witnessCollect(f,W)
-- intersect our signature curve with the blue line
-- notice in the output that we can't distinguish two points in the image due to rounding error
L0 = sub(matrix{{-100,60,-3}},CC)
W0 = witnessCollect(f, W,SliceParameters=>L0,Verbose=>true)
-- take slices parallel to L0 and run the trace test
-- we compare the result using 47 vs 48 points
L1 = L0 + transpose foldVert for i from 1 to 1 list (matrix 0_(CC^2)||matrix{{1_CC}})
L2 = L0 + transpose(matrix 0_(CC^2)||matrix{{-1_CC}})
W1 = witnessCollect(f, W0,SliceParameters=>L1)
W2 = witnessCollect(f, W1,SliceParameters=>L2)
imSums = {W0,W1,W2}/(w->sum(matrix \ points image w))
r1=imSums#0-imSums#1
r2=imSums#0-imSums#2
-- iffy as to whether or not the actual trace varies linearly based on our approximations to the points in the image (it does not)
min first SVD(r1||r2)
-- now try with 48
imSumIngredients = {W0,W1,W2}/(w->apply(preimage w, x -> evaluate(map H,point fixedParams w,x)))
imSumIngredients/first
imSums = imSumIngredients/sum
r1=imSums#0-imSums#1
r2=imSums#0-imSums#2
min first SVD(r1||r2) -- our measure of linearity decreases by 3 orders of magnitude