Play with two points on two spheres

Guess conditions that make the scaling constraint impossible to satisfy.
This commit is contained in:
Aaron Fenyes 2024-02-12 22:48:16 -05:00
parent a450f701fb
commit 31d5e7e864
2 changed files with 33 additions and 12 deletions

View File

@ -184,6 +184,8 @@ function realize(ctx::Construction{T}) where T
) )
# add relations to center, orient, and scale the construction # add relations to center, orient, and scale the construction
# [to do] the scaling constraint, as written, can be impossible to satisfy
# when all of the spheres have to go through the origin
if !isempty(ctx.points) if !isempty(ctx.points)
append!(eqns, [sum(pt.coords[k] for pt in ctx.points) for k in 1:3]) append!(eqns, [sum(pt.coords[k] for pt in ctx.points) for k in 1:3])
end end

View File

@ -39,7 +39,7 @@ CoeffType = Rational{Int64}
##freedom = Engine.dimension(ideal_ab_s) ##freedom = Engine.dimension(ideal_ab_s)
##println("Two points on a sphere: $freedom degrees of freedom") ##println("Two points on a sphere: $freedom degrees of freedom")
spheres = [Engine.Sphere{CoeffType}() for _ in 1:3] ##spheres = [Engine.Sphere{CoeffType}() for _ in 1:3]
##tangencies = [ ##tangencies = [
## Engine.AlignsWithBy{CoeffType}( ## Engine.AlignsWithBy{CoeffType}(
## spheres[n], ## spheres[n],
@ -48,26 +48,45 @@ spheres = [Engine.Sphere{CoeffType}() for _ in 1:3]
## ) ## )
## for n in 1:3 ## for n in 1:3
##] ##]
tangencies = [ ##tangencies = [
Engine.AlignsWithBy{CoeffType}(spheres[1], spheres[2], CoeffType(-1)), ##Engine.LiesOn{CoeffType}(points[1], spheres[2]),
Engine.AlignsWithBy{CoeffType}(spheres[2], spheres[3], CoeffType(-1//2)) ##Engine.LiesOn{CoeffType}(points[1], spheres[3]),
] ##Engine.LiesOn{CoeffType}(points[2], spheres[3]),
ctx_tan_sph = Engine.Construction{CoeffType}(elements = Set(spheres), relations = Set(tangencies)) ##Engine.LiesOn{CoeffType}(points[2], spheres[1]),
ideal_tan_sph, eqns_tan_sph = Engine.realize(ctx_tan_sph) ##Engine.LiesOn{CoeffType}(points[3], spheres[1]),
freedom = Engine.dimension(ideal_tan_sph) ##Engine.LiesOn{CoeffType}(points[3], spheres[2])
##]
##ctx_tan_sph = Engine.Construction{CoeffType}(elements = Set(spheres), relations = Set(tangencies))
##ideal_tan_sph, eqns_tan_sph = Engine.realize(ctx_tan_sph)
##freedom = Engine.dimension(ideal_tan_sph)
##println("Three mutually tangent spheres: $freedom degrees of freedom") ##println("Three mutually tangent spheres: $freedom degrees of freedom")
println("Chain of three spheres: $freedom degrees of freedom")
p = Engine.Point{CoeffType}()
q = Engine.Point{CoeffType}()
a = Engine.Sphere{CoeffType}()
b = Engine.Sphere{CoeffType}()
p_on_a = Engine.LiesOn{CoeffType}(p, a)
p_on_b = Engine.LiesOn{CoeffType}(p, b)
q_on_a = Engine.LiesOn{CoeffType}(q, a)
q_on_b = Engine.LiesOn{CoeffType}(q, b)
ctx_joined = Engine.Construction{CoeffType}(
elements = Set([p, q, a, b]),
relations= Set([p_on_a, p_on_b, q_on_a, q_on_b])
)
ideal_joined, eqns_joined = Engine.realize(ctx_joined)
freedom = Engine.dimension(ideal_joined)
println("Two points on two spheres: $freedom degrees of freedom")
# --- test rational cut --- # --- test rational cut ---
coordring = base_ring(ideal_tan_sph) coordring = base_ring(ideal_joined)
vbls = Variable.(symbols(coordring)) vbls = Variable.(symbols(coordring))
# test a random witness set # test a random witness set
system = CompiledSystem(System(eqns_tan_sph, variables = vbls)) system = CompiledSystem(System(eqns_joined, variables = vbls))
norm2 = vec -> real(dot(conj.(vec), vec)) norm2 = vec -> real(dot(conj.(vec), vec))
Random.seed!(6071) Random.seed!(6071)
n_planes = 16 n_planes = 3
samples = [] samples = []
for _ in 1:n_planes for _ in 1:n_planes
real_solns = solution.(Engine.Numerical.real_samples(system, freedom)) real_solns = solution.(Engine.Numerical.real_samples(system, freedom))