Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Using variety() to solve a trigonometric system of quadratic equations

Following the answers provided in a previous Post https://ask.sagemath.org/question/70614/trigonometric-system-of-quadratic-equations/, I tried to apply the proposed methods to a similar trigonometric system of quadratic equations.

$$ \begin{align} 8 r^2 &=((1+\sqrt(3))\cos(\alpha) r+2\cos(\beta)r-\frac{1}{2})^2 +((1+\sqrt(3))\sin(\alpha)r+2 \sin(\beta) r-\frac{1}{2})^2\\
4 r^2 &= (2(1+\sqrt(3))\cos(\alpha)r+2\cos(\beta)r-1)^2+(2(1+\sqrt(3))\sin(\alpha)r+2\sin(\beta)r)^2\\ 4 r^2 &= (((1+\sqrt(3))\cos(\alpha)r+2\cos(\beta)r+(1+\sqrt(3))\sin(\alpha)r+2\sin(\beta)r)\frac{1}{2}-\frac{1}{2})^2\\ &+((1-(1+\sqrt(3))\cos(\alpha)r-2\cos(\beta)r +(1+\sqrt(3))\sin(\alpha)r+2 \sin(\beta)r)\frac{1}{2}-\frac{1}{2})^2 \end{align
} $$

I am interested in finding the minimal polynomial of the root $r$ between 0 and 1 for which a numerical appriximation is $r \approx 0.1225582838364$.

Below is my (unsuccessfull) attempt to use the variety() function to solve this problem

reset()
from time import time as stime
RR.<x, y, r, s0, c0, s1, c1>=AA[]
Sys2 = [ # a
    -8*r^2+((1+2*AA(cos(pi/6)))*c0*r+2*c1*r-1/2-x)^2+((1+2*AA(cos(pi/6)))*s0*r+2*s1*r-1/2-y)^2,
    # b
    -4*r^2+(2*(1+2*AA(cos(pi/6)))*c0*r+2*c1*r-1-x)^2+(2*(1+2*AA(cos(pi/6)))*s0*r+2*s1*r-y)^2,
    # eq3
    -4*r^2+(((1+2*AA(cos(pi/6)))*c0*r+2*c1*r+(1+2*AA(cos(pi/6)))*s0*r+2*s1*r)/2-1/2)^2+((1-(1+2*AA(cos(pi/6)))*c0*r- 
2*c1*r+(1+2*AA(cos(pi/6)))*s0*r+2*s1*r)/2-1/2)^2,
    # eq4
    -8*r^2+((1+2*AA(cos(pi/6)))*c0*r+2*c1*r-1/2)^2+((1+2*AA(cos(pi/6)))*s0*r+2*s1*r-1/2)^2,
    # eq5
    -4*r^2+(2*(1+2*AA(cos(pi/6)))*c0*r+2*c1*r-1)^2+(2*(1+2*AA(cos(pi/6)))*s0*r+2*s1*r)^2,
    # eq6
    -4*r^2 +(-1/2*(1 + 2*AA(cos(pi/6)) * r * (c0 - s0) + r * s1 + r * c1)^2 +(1/2*(r*(-(1+2*AA(cos(pi/6)))) * (s0 + c0) + 2 * s1 - 
2 * c1) + 1))^2,
    # Basic
    s0^2 + c0^2 - 1,
    s1^2 + c1^2 - 1]
J1 = RR.ideal(Sys2)
print("Solution dimension = ", J1.dimension())
t0 = stime()
Sols = J1.variety()
t1 = stime()
print("Number of solutions = ", len(Sols), ", found in %f6.3 seconds."%(t1-t0))
Errs = [abs(s[r]-0.1225582838364) for s in Sols]
Sol = Sols[Errs.index(min(Errs))]
t2 = stime()
P = Sol[r].minpoly()
t3 = stime()
print("Minimal polynomial (found in %f6.3 seconds) :"%(t3-t2))
print(P)

Unfortunately there seems to be a crash in the Variety() call and no result is returned. It this because this particular system is more complex than in the different post (one more variable)?

In advance, thanks for your help.

kr,

Using variety() to solve a trigonometric system of quadratic equations

Following the answers provided in a previous Post https://ask.sagemath.org/question/70614/trigonometric-system-of-quadratic-equations/, I tried to apply the proposed methods to a similar trigonometric system of quadratic equations.

$$ \begin{align} 8 r^2 &=((1+\sqrt(3))\cos(\alpha) r+2\cos(\beta)r-\frac{1}{2})^2 +((1+\sqrt(3))\sin(\alpha)r+2 \sin(\beta) r-\frac{1}{2})^2\\
4 r^2 &= (2(1+\sqrt(3))\cos(\alpha)r+2\cos(\beta)r-1)^2+(2(1+\sqrt(3))\sin(\alpha)r+2\sin(\beta)r)^2\\ 4 r^2 &= (((1+\sqrt(3))\cos(\alpha)r+2\cos(\beta)r+(1+\sqrt(3))\sin(\alpha)r+2\sin(\beta)r)\frac{1}{2}-\frac{1}{2})^2\\ &+((1-(1+\sqrt(3))\cos(\alpha)r-2\cos(\beta)r +(1+\sqrt(3))\sin(\alpha)r+2 \sin(\beta)r)\frac{1}{2}-\frac{1}{2})^2 \end{align
} $$

I am interested in finding the minimal polynomial of the root $r$ between 0 and 1 for which a numerical appriximation is $r \approx 0.1225582838364$.

Below is my (unsuccessfull) attempt to use the variety() function to solve this problem

reset()
from time import time as stime
RR.<x, y, r, s0, c0, s1, c1>=AA[]
Sys2 = [ # a
    -8*r^2+((1+2*AA(cos(pi/6)))*c0*r+2*c1*r-1/2-x)^2+((1+2*AA(cos(pi/6)))*s0*r+2*s1*r-1/2-y)^2,
    # b
    -4*r^2+(2*(1+2*AA(cos(pi/6)))*c0*r+2*c1*r-1-x)^2+(2*(1+2*AA(cos(pi/6)))*s0*r+2*s1*r-y)^2,
    # eq3
    -4*r^2+(((1+2*AA(cos(pi/6)))*c0*r+2*c1*r+(1+2*AA(cos(pi/6)))*s0*r+2*s1*r)/2-1/2)^2+((1-(1+2*AA(cos(pi/6)))*c0*r- 
2*c1*r+(1+2*AA(cos(pi/6)))*s0*r+2*s1*r)/2-1/2)^2,
    # eq4
    -8*r^2+((1+2*AA(cos(pi/6)))*c0*r+2*c1*r-1/2)^2+((1+2*AA(cos(pi/6)))*s0*r+2*s1*r-1/2)^2,
    # eq5
    -4*r^2+(2*(1+2*AA(cos(pi/6)))*c0*r+2*c1*r-1)^2+(2*(1+2*AA(cos(pi/6)))*s0*r+2*s1*r)^2,
    # eq6
    -4*r^2 +(-1/2*(1 + 2*AA(cos(pi/6)) * r * (c0 - s0) + r * s1 + r * c1)^2 +(1/2*(r*(-(1+2*AA(cos(pi/6)))) * (s0 + c0) + 2 * s1 - 
2 * c1) + 1))^2,
    # Basic
    s0^2 + c0^2 - 1,
    s1^2 + c1^2 - 1]
J1 = RR.ideal(Sys2)
print("Solution dimension = ", J1.dimension())
t0 = stime()
Sols = J1.variety()
t1 = stime()
print("Number of solutions = ", len(Sols), ", found in %f6.3 seconds."%(t1-t0))
Errs = [abs(s[r]-0.1225582838364) for s in Sols]
Sol = Sols[Errs.index(min(Errs))]
t2 = stime()
P = Sol[r].minpoly()
t3 = stime()
print("Minimal polynomial (found in %f6.3 seconds) :"%(t3-t2))
print(P)

Unfortunately there seems to be a crash in the Variety() call and no result is returned. It this because this particular system is more complex than in the different post (one more variable)?

In advance, thanks for your help.

kr,

Using variety() to solve a trigonometric system of quadratic equations

Following the answers provided in a previous Post https://ask.sagemath.org/question/70614/trigonometric-system-of-quadratic-equations/, I tried to apply the proposed methods to a similar trigonometric system of quadratic equations.

$$ \begin{align} 8 r^2 &=((1+\sqrt(3))\cos(\alpha) r+2\cos(\beta)r-\frac{1}{2})^2 +((1+\sqrt(3))\sin(\alpha)r+2 \sin(\beta) r-\frac{1}{2})^2\\
4 r^2 &= (2(1+\sqrt(3))\cos(\alpha)r+2\cos(\beta)r-1)^2+(2(1+\sqrt(3))\sin(\alpha)r+2\sin(\beta)r)^2\\ 4 r^2 &= (((1+\sqrt(3))\cos(\alpha)r+2\cos(\beta)r+(1+\sqrt(3))\sin(\alpha)r+2\sin(\beta)r)\frac{1}{2}-\frac{1}{2})^2\\ &+((1-(1+\sqrt(3))\cos(\alpha)r-2\cos(\beta)r +(1+\sqrt(3))\sin(\alpha)r+2 \sin(\beta)r)\frac{1}{2}-\frac{1}{2})^2 \end{align
} $$

I am interested in finding the minimal polynomial of the root $r$ between 0 and 1 for which a numerical appriximation approximation is $r \approx 0.1225582838364$.

Below is my (unsuccessfull) attempt to use the variety() function to solve this problem

reset()
from time import time as stime
RR.<x, y, r, s0, c0, s1, c1>=AA[]
Sys2 = [ # a
    -8*r^2+((1+2*AA(cos(pi/6)))*c0*r+2*c1*r-1/2-x)^2+((1+2*AA(cos(pi/6)))*s0*r+2*s1*r-1/2-y)^2,
    # b
    -4*r^2+(2*(1+2*AA(cos(pi/6)))*c0*r+2*c1*r-1-x)^2+(2*(1+2*AA(cos(pi/6)))*s0*r+2*s1*r-y)^2,
    # eq3
    -4*r^2+(((1+2*AA(cos(pi/6)))*c0*r+2*c1*r+(1+2*AA(cos(pi/6)))*s0*r+2*s1*r)/2-1/2)^2+((1-(1+2*AA(cos(pi/6)))*c0*r- 
2*c1*r+(1+2*AA(cos(pi/6)))*s0*r+2*s1*r)/2-1/2)^2,
    # eq4
    -8*r^2+((1+2*AA(cos(pi/6)))*c0*r+2*c1*r-1/2)^2+((1+2*AA(cos(pi/6)))*s0*r+2*s1*r-1/2)^2,
    # eq5
    -4*r^2+(2*(1+2*AA(cos(pi/6)))*c0*r+2*c1*r-1)^2+(2*(1+2*AA(cos(pi/6)))*s0*r+2*s1*r)^2,
    # eq6
    -4*r^2 +(-1/2*(1 + 2*AA(cos(pi/6)) * r * (c0 - s0) + r * s1 + r * c1)^2 +(1/2*(r*(-(1+2*AA(cos(pi/6)))) * (s0 + c0) + 2 * s1 - 
2 * c1) + 1))^2,
    # Basic
    s0^2 + c0^2 - 1,
    s1^2 + c1^2 - 1]
J1 = RR.ideal(Sys2)
print("Solution dimension = ", J1.dimension())
t0 = stime()
Sols = J1.variety()
t1 = stime()
print("Number of solutions = ", len(Sols), ", found in %f6.3 seconds."%(t1-t0))
Errs = [abs(s[r]-0.1225582838364) for s in Sols]
Sol = Sols[Errs.index(min(Errs))]
t2 = stime()
P = Sol[r].minpoly()
t3 = stime()
print("Minimal polynomial (found in %f6.3 seconds) :"%(t3-t2))
print(P)

Unfortunately there seems to be a crash in the Variety() call and no result is returned. It this because this particular system is more complex than in the different post (one more variable)?

In advance, thanks for your help.

kr,

Using variety() to solve a trigonometric system of quadratic equations

Following the answers provided in a previous Post https://ask.sagemath.org/question/70614/trigonometric-system-of-quadratic-equations/, I tried to apply the proposed methods to a similar trigonometric system of quadratic equations.

$$ \begin{align} 8 r^2 &=((1+\sqrt(3))\cos(\alpha) r+2\cos(\beta)r-\frac{1}{2})^2 +((1+\sqrt(3))\sin(\alpha)r+2 \sin(\beta) r-\frac{1}{2})^2\\
4 r^2 &= (2(1+\sqrt(3))\cos(\alpha)r+2\cos(\beta)r-1)^2+(2(1+\sqrt(3))\sin(\alpha)r+2\sin(\beta)r)^2\\ 4 r^2 &= (((1+\sqrt(3))\cos(\alpha)r+2\cos(\beta)r+(1+\sqrt(3))\sin(\alpha)r+2\sin(\beta)r)\frac{1}{2}-\frac{1}{2})^2\\ &+((1-(1+\sqrt(3))\cos(\alpha)r-2\cos(\beta)r +(1+\sqrt(3))\sin(\alpha)r+2 \sin(\beta)r)\frac{1}{2}-\frac{1}{2})^2 \end{align
} $$

I am interested in finding the minimal polynomial of the root $r$ between 0 and 1 for which a numerical approximation is $r \approx 0.1225582838364$.

Below is my (unsuccessfull) attempt to use the variety() function to solve this problem

reset()
from time import time as stime
RR.<x, y, r, s0, c0, s1, c1>=AA[]
Sys2 = [ # a
    -8*r^2+((1+2*AA(cos(pi/6)))*c0*r+2*c1*r-1/2-x)^2+((1+2*AA(cos(pi/6)))*s0*r+2*s1*r-1/2-y)^2,
    # b
    -4*r^2+(2*(1+2*AA(cos(pi/6)))*c0*r+2*c1*r-1-x)^2+(2*(1+2*AA(cos(pi/6)))*s0*r+2*s1*r-y)^2,
    # eq3
    -4*r^2+(((1+2*AA(cos(pi/6)))*c0*r+2*c1*r+(1+2*AA(cos(pi/6)))*s0*r+2*s1*r)/2-1/2)^2+((1-(1+2*AA(cos(pi/6)))*c0*r- 
2*c1*r+(1+2*AA(cos(pi/6)))*s0*r+2*s1*r)/2-1/2)^2,
    # eq4
    -8*r^2+((1+2*AA(cos(pi/6)))*c0*r+2*c1*r-1/2)^2+((1+2*AA(cos(pi/6)))*s0*r+2*s1*r-1/2)^2,
    # eq5
    -4*r^2+(2*(1+2*AA(cos(pi/6)))*c0*r+2*c1*r-1)^2+(2*(1+2*AA(cos(pi/6)))*s0*r+2*s1*r)^2,
    # eq6
    -4*r^2 +(-1/2*(1 + 2*AA(cos(pi/6)) * r * (c0 - s0) + r * s1 + r * c1)^2 +(1/2*(r*(-(1+2*AA(cos(pi/6)))) * (s0 + c0) + 2 * s1 - 
2 * c1) + 1))^2,
    # Basic
    s0^2 + c0^2 - 1,
    s1^2 + c1^2 - 1]
J1 = RR.ideal(Sys2)
print("Solution dimension = ", J1.dimension())
t0 = stime()
Sols = J1.variety()
t1 = stime()
print("Number of solutions = ", len(Sols), ", found in %f6.3 seconds."%(t1-t0))
Errs = [abs(s[r]-0.1225582838364) for s in Sols]
Sol = Sols[Errs.index(min(Errs))]
t2 = stime()
P = Sol[r].minpoly()
t3 = stime()
print("Minimal polynomial (found in %f6.3 seconds) :"%(t3-t2))
print(P)

Unfortunately there seems to be a crash in the Variety() call and no result is returned. It this because this particular system is more complex than in the different one in the previous post (one more variable)?

In advance, thanks for your help.

kr,

Using variety() to solve a trigonometric system of quadratic equations

Following the answers provided in a previous Post https://ask.sagemath.org/question/70614/trigonometric-system-of-quadratic-equations/, I tried to apply the proposed methods to a similar trigonometric system of quadratic equations.

$$ \begin{align} 8 r^2 &=((1+\sqrt(3))\cos(\alpha) r+2\cos(\beta)r-\frac{1}{2})^2 +((1+\sqrt(3))\sin(\alpha)r+2 \sin(\beta) r-\frac{1}{2})^2\\
4 r^2 &= (2(1+\sqrt(3))\cos(\alpha)r+2\cos(\beta)r-1)^2+(2(1+\sqrt(3))\sin(\alpha)r+2\sin(\beta)r)^2\\ 4 r^2 &= (((1+\sqrt(3))\cos(\alpha)r+2\cos(\beta)r+(1+\sqrt(3))\sin(\alpha)r+2\sin(\beta)r)\frac{1}{2}-\frac{1}{2})^2\\ &+((1-(1+\sqrt(3))\cos(\alpha)r-2\cos(\beta)r +(1+\sqrt(3))\sin(\alpha)r+2 \sin(\beta)r)\frac{1}{2}-\frac{1}{2})^2 \end{align
} $$

I am interested in finding the minimal polynomial of the root $r$ between 0 and 1 for which a numerical approximation is $r \approx 0.1225582838364$.0.1225582838364$, $\alpha \approx 0.174507496606164$ and $\beta \approx 0.417629154722126$.

Below is my (unsuccessfull) attempt to use the variety() function to solve this problem

reset()
from time import time as stime
RR.<x, y, r, s0, c0, s1, c1>=AA[]
Sys2 = [ # a
    -8*r^2+((1+2*AA(cos(pi/6)))*c0*r+2*c1*r-1/2-x)^2+((1+2*AA(cos(pi/6)))*s0*r+2*s1*r-1/2-y)^2,
    # b
    -4*r^2+(2*(1+2*AA(cos(pi/6)))*c0*r+2*c1*r-1-x)^2+(2*(1+2*AA(cos(pi/6)))*s0*r+2*s1*r-y)^2,
    # eq3
    -4*r^2+(((1+2*AA(cos(pi/6)))*c0*r+2*c1*r+(1+2*AA(cos(pi/6)))*s0*r+2*s1*r)/2-1/2)^2+((1-(1+2*AA(cos(pi/6)))*c0*r- 
2*c1*r+(1+2*AA(cos(pi/6)))*s0*r+2*s1*r)/2-1/2)^2,
    # eq4
    -8*r^2+((1+2*AA(cos(pi/6)))*c0*r+2*c1*r-1/2)^2+((1+2*AA(cos(pi/6)))*s0*r+2*s1*r-1/2)^2,
    # eq5
    -4*r^2+(2*(1+2*AA(cos(pi/6)))*c0*r+2*c1*r-1)^2+(2*(1+2*AA(cos(pi/6)))*s0*r+2*s1*r)^2,
    # eq6
    -4*r^2 +(-1/2*(1 + 2*AA(cos(pi/6)) * r * (c0 - s0) + r * s1 + r * c1)^2 +(1/2*(r*(-(1+2*AA(cos(pi/6)))) * (s0 + c0) + 2 * s1 - 
2 * c1) + 1))^2,
    # Basic
    s0^2 + c0^2 - 1,
    s1^2 + c1^2 - 1]
J1 = RR.ideal(Sys2)
print("Solution dimension = ", J1.dimension())
t0 = stime()
Sols = J1.variety()
t1 = stime()
print("Number of solutions = ", len(Sols), ", found in %f6.3 seconds."%(t1-t0))
Errs = [abs(s[r]-0.1225582838364) for s in Sols]
Sol = Sols[Errs.index(min(Errs))]
t2 = stime()
P = Sol[r].minpoly()
t3 = stime()
print("Minimal polynomial (found in %f6.3 seconds) :"%(t3-t2))
print(P)

Unfortunately there seems to be a crash in the Variety() call and no result is returned. It this because this particular system is more complex than in the one in the previous post (one more variable)?

In advance, thanks for your help.

kr,

Using variety() to solve a trigonometric system of quadratic equations

Following the answers provided in a previous Post https://ask.sagemath.org/question/70614/trigonometric-system-of-quadratic-equations/, I tried to apply the proposed methods to a similar trigonometric system of quadratic equations.

$$ \begin{align} 8 r^2 &=((1+\sqrt(3))\cos(\alpha) r+2\cos(\beta)r-\frac{1}{2})^2 +((1+\sqrt(3))\sin(\alpha)r+2 \sin(\beta) r-\frac{1}{2})^2\\
4 r^2 &= (2(1+\sqrt(3))\cos(\alpha)r+2\cos(\beta)r-1)^2+(2(1+\sqrt(3))\sin(\alpha)r+2\sin(\beta)r)^2\\ 4 r^2 &= (((1+\sqrt(3))\cos(\alpha)r+2\cos(\beta)r+(1+\sqrt(3))\sin(\alpha)r+2\sin(\beta)r)\frac{1}{2}-\frac{1}{2})^2\\ &+((1-(1+\sqrt(3))\cos(\alpha)r-2\cos(\beta)r +(1+\sqrt(3))\sin(\alpha)r+2 \sin(\beta)r)\frac{1}{2}-\frac{1}{2})^2 \end{align
} $$

I am interested in finding the minimal polynomial of the root $r$ between 0 and 1 for which a numerical approximation is $r \approx 0.1225582838364$, $\alpha \approx 0.174507496606164$ and $\beta \approx 0.417629154722126$.

Below is my (unsuccessfull) attempt to use the variety() function to solve this problem

reset()
from time import time as stime
RR.<x, y, r, s0, c0, s1, c1>=AA[]
Sys2 = [ # a
    -8*r^2+((1+2*AA(cos(pi/6)))*c0*r+2*c1*r-1/2-x)^2+((1+2*AA(cos(pi/6)))*s0*r+2*s1*r-1/2-y)^2,
    # b
    -4*r^2+(2*(1+2*AA(cos(pi/6)))*c0*r+2*c1*r-1-x)^2+(2*(1+2*AA(cos(pi/6)))*s0*r+2*s1*r-y)^2,
    # eq3
    -4*r^2+(((1+2*AA(cos(pi/6)))*c0*r+2*c1*r+(1+2*AA(cos(pi/6)))*s0*r+2*s1*r)/2-1/2)^2+((1-(1+2*AA(cos(pi/6)))*c0*r- 
2*c1*r+(1+2*AA(cos(pi/6)))*s0*r+2*s1*r)/2-1/2)^2,
    # eq4
    -8*r^2+((1+2*AA(cos(pi/6)))*c0*r+2*c1*r-1/2)^2+((1+2*AA(cos(pi/6)))*s0*r+2*s1*r-1/2)^2,
    # eq5
    -4*r^2+(2*(1+2*AA(cos(pi/6)))*c0*r+2*c1*r-1)^2+(2*(1+2*AA(cos(pi/6)))*s0*r+2*s1*r)^2,
    # eq6
    -4*r^2 +(-1/2*(1 + 2*AA(cos(pi/6)) * r * (c0 - s0) + r * s1 + r * c1)^2 +(1/2*(r*(-(1+2*AA(cos(pi/6)))) * (s0 + c0) + 2 * s1 - 
2 * c1) + 1))^2,
    # Basic
    s0^2 + c0^2 - 1,
    s1^2 + c1^2 - 1]
J1 = RR.ideal(Sys2)
print("Solution dimension = ", J1.dimension())
t0 = stime()
Sols = J1.variety()
t1 = stime()
print("Number of solutions = ", len(Sols), ", found in %f6.3 seconds."%(t1-t0))
Errs = [abs(s[r]-0.1225582838364) for s in Sols]
Sol = Sols[Errs.index(min(Errs))]
t2 = stime()
P = Sol[r].minpoly()
t3 = stime()
print("Minimal polynomial (found in %f6.3 seconds) :"%(t3-t2))
print(P)

Unfortunately there seems to be a crash in the Variety() call and no result is returned. It this because this particular system is more complex than in the one in the previous post (one more variable)?

In advance, thanks for your help.

kr,

Using variety() to solve Finding the minimal polynomial for a solution of a trigonometric system of quadratic equations

Following the answers provided in a previous Post https://ask.sagemath.org/question/70614/trigonometric-system-of-quadratic-equations/, I tried to apply the proposed methods to a similar trigonometric system of quadratic equations.

$$ \begin{align} $ 8 r^2 &=((1+\sqrt(3))\cos(\alpha) =((1+\sqrt(3))\cos(\alpha) r+2\cos(\beta)r-\frac{1}{2})^2 +((1+\sqrt(3))\sin(\alpha)r+2 \sin(\beta) r-\frac{1}{2})^2\\
r-\frac{1}{2})^2 $

$ 4 r^2 &= = (2(1+\sqrt(3))\cos(\alpha)r+2\cos(\beta)r-1)^2+(2(1+\sqrt(3))\sin(\alpha)r+2\sin(\beta)r)^2\\ $

$ 4 r^2 &= (((1+\sqrt(3))\cos(\alpha)r+2\cos(\beta)r+(1+\sqrt(3))\sin(\alpha)r+2\sin(\beta)r)\frac{1}{2}-\frac{1}{2})^2\\ &+((1-(1+\sqrt(3))\cos(\alpha)r-2\cos(\beta)r = (((1+\sqrt(3))\cos(\alpha)r+2\cos(\beta)r +(1+\sqrt(3))\sin(\alpha)r+2\sin(\beta)r)\frac{1}{2} -\frac{1}{2})^2+((1-(1+\sqrt(3))\cos(\alpha)r-2\cos(\beta)r +(1+\sqrt(3))\sin(\alpha)r+2 \sin(\beta)r)\frac{1}{2}-\frac{1}{2})^2 \end{align} $$$

I am interested in finding the minimal polynomial of the root $r$ between 0 and 1 for which a numerical approximation is $r \approx 0.1225582838364$, $\alpha \approx 0.174507496606164$ and $\beta \approx 0.417629154722126$.

Below is my (unsuccessfull) attempt to use the variety() function to solve this problem

reset()
from time import time as stime
RR.<x, y, r, s0, c0, s1, c1>=AA[]
Sys2 = [ # a
    -8*r^2+((1+2*AA(cos(pi/6)))*c0*r+2*c1*r-1/2-x)^2+((1+2*AA(cos(pi/6)))*s0*r+2*s1*r-1/2-y)^2,
    # b
    -4*r^2+(2*(1+2*AA(cos(pi/6)))*c0*r+2*c1*r-1-x)^2+(2*(1+2*AA(cos(pi/6)))*s0*r+2*s1*r-y)^2,
    # eq3
    -4*r^2+(((1+2*AA(cos(pi/6)))*c0*r+2*c1*r+(1+2*AA(cos(pi/6)))*s0*r+2*s1*r)/2-1/2)^2+((1-(1+2*AA(cos(pi/6)))*c0*r- 
2*c1*r+(1+2*AA(cos(pi/6)))*s0*r+2*s1*r)/2-1/2)^2,
    # eq4
    -8*r^2+((1+2*AA(cos(pi/6)))*c0*r+2*c1*r-1/2)^2+((1+2*AA(cos(pi/6)))*s0*r+2*s1*r-1/2)^2,
    # eq5
    -4*r^2+(2*(1+2*AA(cos(pi/6)))*c0*r+2*c1*r-1)^2+(2*(1+2*AA(cos(pi/6)))*s0*r+2*s1*r)^2,
    # eq6
    -4*r^2 +(-1/2*(1 + 2*AA(cos(pi/6)) * r * (c0 - s0) + r * s1 + r * c1)^2 +(1/2*(r*(-(1+2*AA(cos(pi/6)))) * (s0 + c0) + 2 * s1 - 
2 * c1) + 1))^2,
    # Basic
    s0^2 + c0^2 - 1,
    s1^2 + c1^2 - 1]
J1 = RR.ideal(Sys2)
print("Solution dimension = ", J1.dimension())
t0 = stime()
Sols = J1.variety()
t1 = stime()
print("Number of solutions = ", len(Sols), ", found in %f6.3 seconds."%(t1-t0))
Errs = [abs(s[r]-0.1225582838364) for s in Sols]
Sol = Sols[Errs.index(min(Errs))]
t2 = stime()
P = Sol[r].minpoly()
t3 = stime()
print("Minimal polynomial (found in %f6.3 seconds) :"%(t3-t2))
print(P)

Unfortunately there seems to be a crash in the Variety() call and no result is returned. It this because this particular system is more complex than in the one in the previous post (one more variable)?

In advance, thanks for your help.

kr,

Finding the minimal polynomial for a solution of a trigonometric system of quadratic equations

Following the answers provided in a previous Post https://ask.sagemath.org/question/70614/trigonometric-system-of-quadratic-equations/, I tried to apply the proposed methods to a similar trigonometric system of quadratic equations.

$ 8 r^2 =((1+\sqrt(3))\cos(\alpha) r+2\cos(\beta)r-\frac{1}{2})^2 +((1+\sqrt(3))\sin(\alpha)r+2 \sin(\beta) r-\frac{1}{2})^2 $

$ 4 r^2 = (2(1+\sqrt(3))\cos(\alpha)r+2\cos(\beta)r-1)^2+(2(1+\sqrt(3))\sin(\alpha)r+2\sin(\beta)r)^2\\ (2(1+\sqrt(3))\cos(\alpha)r+2\cos(\beta)r-1)^2+(2(1+\sqrt(3))\sin(\alpha)r+2\sin(\beta)r)^2 $

$ 4 r^2 = (((1+\sqrt(3))\cos(\alpha)r+2\cos(\beta)r +(1+\sqrt(3))\sin(\alpha)r+2\sin(\beta)r)\frac{1}{2} +(1+\sqrt(3))\sin(\alpha)r+2\sin(\beta)r)\frac{1}{2}\\ -\frac{1}{2})^2+((1-(1+\sqrt(3))\cos(\alpha)r-2\cos(\beta)r +(1+\sqrt(3))\sin(\alpha)r+2 \sin(\beta)r)\frac{1}{2}-\frac{1}{2})^2 $

I am interested in finding the minimal polynomial of the root $r$ between 0 and 1 for which a numerical approximation is $r \approx 0.1225582838364$, $\alpha \approx 0.174507496606164$ and $\beta \approx 0.417629154722126$.

Below is my (unsuccessfull) attempt to use the variety() function to solve this problem

reset()
from time import time as stime
RR.<x, y, r, s0, c0, s1, c1>=AA[]
Sys2 = [ # a
    -8*r^2+((1+2*AA(cos(pi/6)))*c0*r+2*c1*r-1/2-x)^2+((1+2*AA(cos(pi/6)))*s0*r+2*s1*r-1/2-y)^2,
    # b
    -4*r^2+(2*(1+2*AA(cos(pi/6)))*c0*r+2*c1*r-1-x)^2+(2*(1+2*AA(cos(pi/6)))*s0*r+2*s1*r-y)^2,
    # eq3
    -4*r^2+(((1+2*AA(cos(pi/6)))*c0*r+2*c1*r+(1+2*AA(cos(pi/6)))*s0*r+2*s1*r)/2-1/2)^2+((1-(1+2*AA(cos(pi/6)))*c0*r- 
2*c1*r+(1+2*AA(cos(pi/6)))*s0*r+2*s1*r)/2-1/2)^2,
    # eq4
    -8*r^2+((1+2*AA(cos(pi/6)))*c0*r+2*c1*r-1/2)^2+((1+2*AA(cos(pi/6)))*s0*r+2*s1*r-1/2)^2,
    # eq5
    -4*r^2+(2*(1+2*AA(cos(pi/6)))*c0*r+2*c1*r-1)^2+(2*(1+2*AA(cos(pi/6)))*s0*r+2*s1*r)^2,
    # eq6
    -4*r^2 +(-1/2*(1 + 2*AA(cos(pi/6)) * r * (c0 - s0) + r * s1 + r * c1)^2 +(1/2*(r*(-(1+2*AA(cos(pi/6)))) * (s0 + c0) + 2 * s1 - 
2 * c1) + 1))^2,
    # Basic
    s0^2 + c0^2 - 1,
    s1^2 + c1^2 - 1]
J1 = RR.ideal(Sys2)
print("Solution dimension = ", J1.dimension())
t0 = stime()
Sols = J1.variety()
t1 = stime()
print("Number of solutions = ", len(Sols), ", found in %f6.3 seconds."%(t1-t0))
Errs = [abs(s[r]-0.1225582838364) for s in Sols]
Sol = Sols[Errs.index(min(Errs))]
t2 = stime()
P = Sol[r].minpoly()
t3 = stime()
print("Minimal polynomial (found in %f6.3 seconds) :"%(t3-t2))
print(P)

Unfortunately there seems to be a crash in the Variety() call and no result is returned. It this because this particular system is more complex than in the one in the previous post (one more variable)?

In advance, thanks for your help.

kr,

Finding the minimal polynomial for a solution of a trigonometric system of quadratic equations

Following the answers provided in a previous Post https://ask.sagemath.org/question/70614/trigonometric-system-of-quadratic-equations/, I tried to apply the proposed methods to a similar trigonometric system of quadratic equations.

$ 8 r^2 =((1+\sqrt(3))\cos(\alpha) =((1+\sqrt{3})\cos(\alpha) r+2\cos(\beta)r-\frac{1}{2})^2 +((1+\sqrt(3))\sin(\alpha)r+2 +((1+\sqrt{3})\sin(\alpha)r+2 \sin(\beta) r-\frac{1}{2})^2 $

$ 4 r^2 = (2(1+\sqrt(3))\cos(\alpha)r+2\cos(\beta)r-1)^2+(2(1+\sqrt(3))\sin(\alpha)r+2\sin(\beta)r)^2 (2(1+\sqrt{3})\cos(\alpha)r+2\cos(\beta)r-1)^2+(2(1+\sqrt(3))\sin(\alpha)r+2\sin(\beta)r)^2 $

$ 4 r^2 = (((1+\sqrt(3))\cos(\alpha)r+2\cos(\beta)r +(1+\sqrt(3))\sin(\alpha)r+2\sin(\beta)r)\frac{1}{2}\\ -\frac{1}{2})^2+((1-(1+\sqrt(3))\cos(\alpha)r-2\cos(\beta)r +(1+\sqrt(3))\sin(\alpha)r+2 (((1+\sqrt{3})\cos(\alpha)r+2\cos(\beta)r +(1+\sqrt{3})\sin(\alpha)r+2\sin(\beta)r)\frac{1}{2}-\frac{1}{2})^2\\ \qquad+((1-(1+\sqrt{3})\cos(\alpha)r-2\cos(\beta)r +(1+\sqrt{3})\sin(\alpha)r+2 \sin(\beta)r)\frac{1}{2}-\frac{1}{2})^2 $

I am interested in finding the minimal polynomial of the root $r$ between 0 and 1 for which a numerical approximation is $r \approx 0.1225582838364$, $\alpha \approx 0.174507496606164$ and $\beta \approx 0.417629154722126$.

Below is my (unsuccessfull) attempt to use the variety() function to solve this problem

reset()
from time import time as stime
RR.<x, y, r, s0, c0, s1, c1>=AA[]
Sys2 = [ # a
    -8*r^2+((1+2*AA(cos(pi/6)))*c0*r+2*c1*r-1/2-x)^2+((1+2*AA(cos(pi/6)))*s0*r+2*s1*r-1/2-y)^2,
    # b
    -4*r^2+(2*(1+2*AA(cos(pi/6)))*c0*r+2*c1*r-1-x)^2+(2*(1+2*AA(cos(pi/6)))*s0*r+2*s1*r-y)^2,
    # eq3
    -4*r^2+(((1+2*AA(cos(pi/6)))*c0*r+2*c1*r+(1+2*AA(cos(pi/6)))*s0*r+2*s1*r)/2-1/2)^2+((1-(1+2*AA(cos(pi/6)))*c0*r- 
2*c1*r+(1+2*AA(cos(pi/6)))*s0*r+2*s1*r)/2-1/2)^2,
    # eq4
    -8*r^2+((1+2*AA(cos(pi/6)))*c0*r+2*c1*r-1/2)^2+((1+2*AA(cos(pi/6)))*s0*r+2*s1*r-1/2)^2,
    # eq5
    -4*r^2+(2*(1+2*AA(cos(pi/6)))*c0*r+2*c1*r-1)^2+(2*(1+2*AA(cos(pi/6)))*s0*r+2*s1*r)^2,
    # eq6
    -4*r^2 +(-1/2*(1 + 2*AA(cos(pi/6)) * r * (c0 - s0) + r * s1 + r * c1)^2 +(1/2*(r*(-(1+2*AA(cos(pi/6)))) * (s0 + c0) + 2 * s1 - 
2 * c1) + 1))^2,
    # Basic
    s0^2 + c0^2 - 1,
    s1^2 + c1^2 - 1]
J1 = RR.ideal(Sys2)
print("Solution dimension = ", J1.dimension())
t0 = stime()
Sols = J1.variety()
t1 = stime()
print("Number of solutions = ", len(Sols), ", found in %f6.3 seconds."%(t1-t0))
Errs = [abs(s[r]-0.1225582838364) for s in Sols]
Sol = Sols[Errs.index(min(Errs))]
t2 = stime()
P = Sol[r].minpoly()
t3 = stime()
print("Minimal polynomial (found in %f6.3 seconds) :"%(t3-t2))
print(P)

Unfortunately there seems to be a crash in the Variety() call and no result is returned. It this because this particular system is more complex than in the one in the previous post (one more variable)?

In advance, thanks for your help.

kr,

Finding the minimal polynomial for a solution of a trigonometric system of quadratic equations

Following the answers provided in a previous Post https://ask.sagemath.org/question/70614/trigonometric-system-of-quadratic-equations/, I tried to apply the proposed methods to a similar trigonometric system of quadratic equations.

$ 8 r^2 =((1+\sqrt{3})\cos(\alpha) r+2\cos(\beta)r-\frac{1}{2})^2 +((1+\sqrt{3})\sin(\alpha)r+2 \sin(\beta) r-\frac{1}{2})^2 $

$ 4 r^2 = (2(1+\sqrt{3})\cos(\alpha)r+2\cos(\beta)r-1)^2+(2(1+\sqrt(3))\sin(\alpha)r+2\sin(\beta)r)^2 (2(1+\sqrt{3})\cos(\alpha)r+2\cos(\beta)r-1)^2 +(2(1+\sqrt{3})\sin(\alpha)r+2\sin(\beta)r)^2 $

$ 4 r^2 = (((1+\sqrt{3})\cos(\alpha)r+2\cos(\beta)r +(1+\sqrt{3})\sin(\alpha)r+2\sin(\beta)r)\frac{1}{2}-\frac{1}{2})^2\\ \qquad+((1-(1+\sqrt{3})\cos(\alpha)r-2\cos(\beta)r +(1+\sqrt{3})\sin(\alpha)r+2 \sin(\beta)r)\frac{1}{2}-\frac{1}{2})^2 $

I am interested in finding the minimal polynomial of the root $r$ between 0 and 1 for which a numerical approximation is $r \approx 0.1225582838364$, $\alpha \approx 0.174507496606164$ and $\beta \approx 0.417629154722126$.

Below is my (unsuccessfull) attempt to use the variety() function to solve this problem

reset()
from time import time as stime
RR.<x, y, r, s0, c0, s1, c1>=AA[]
Sys2 = [ # a
    -8*r^2+((1+2*AA(cos(pi/6)))*c0*r+2*c1*r-1/2-x)^2+((1+2*AA(cos(pi/6)))*s0*r+2*s1*r-1/2-y)^2,
    # b
    -4*r^2+(2*(1+2*AA(cos(pi/6)))*c0*r+2*c1*r-1-x)^2+(2*(1+2*AA(cos(pi/6)))*s0*r+2*s1*r-y)^2,
    # eq3
    -4*r^2+(((1+2*AA(cos(pi/6)))*c0*r+2*c1*r+(1+2*AA(cos(pi/6)))*s0*r+2*s1*r)/2-1/2)^2+((1-(1+2*AA(cos(pi/6)))*c0*r- 
2*c1*r+(1+2*AA(cos(pi/6)))*s0*r+2*s1*r)/2-1/2)^2,
    # eq4
    -8*r^2+((1+2*AA(cos(pi/6)))*c0*r+2*c1*r-1/2)^2+((1+2*AA(cos(pi/6)))*s0*r+2*s1*r-1/2)^2,
    # eq5
    -4*r^2+(2*(1+2*AA(cos(pi/6)))*c0*r+2*c1*r-1)^2+(2*(1+2*AA(cos(pi/6)))*s0*r+2*s1*r)^2,
    # eq6
    -4*r^2 +(-1/2*(1 + 2*AA(cos(pi/6)) * r * (c0 - s0) + r * s1 + r * c1)^2 +(1/2*(r*(-(1+2*AA(cos(pi/6)))) * (s0 + c0) + 2 * s1 - 
2 * c1) + 1))^2,
    # Basic
    s0^2 + c0^2 - 1,
    s1^2 + c1^2 - 1]
J1 = RR.ideal(Sys2)
print("Solution dimension = ", J1.dimension())
t0 = stime()
Sols = J1.variety()
t1 = stime()
print("Number of solutions = ", len(Sols), ", found in %f6.3 seconds."%(t1-t0))
Errs = [abs(s[r]-0.1225582838364) for s in Sols]
Sol = Sols[Errs.index(min(Errs))]
t2 = stime()
P = Sol[r].minpoly()
t3 = stime()
print("Minimal polynomial (found in %f6.3 seconds) :"%(t3-t2))
print(P)

Unfortunately there seems to be a crash in the Variety() call and no result is returned. It this because this particular system is more complex than in the one in the previous post (one more variable)?

In advance, thanks for your help.

kr,

Finding the minimal polynomial for a solution of a trigonometric system of quadratic equations

Following the answers provided in a previous Post https://ask.sagemath.org/question/70614/trigonometric-system-of-quadratic-equations/, I tried to apply the proposed methods to a similar trigonometric system of quadratic equations.

$ 8 r^2 =((1+\sqrt{3})\cos(\alpha) r+2\cos(\beta)r-\frac{1}{2})^2 +((1+\sqrt{3})\sin(\alpha)r+2 \sin(\beta) r-\frac{1}{2})^2 $

$ 4 r^2 = (2(1+\sqrt{3})\cos(\alpha)r+2\cos(\beta)r-1)^2 +(2(1+\sqrt{3})\sin(\alpha)r+2\sin(\beta)r)^2 $

$ 4 r^2 = (((1+\sqrt{3})\cos(\alpha)r+2\cos(\beta)r +(1+\sqrt{3})\sin(\alpha)r+2\sin(\beta)r)\frac{1}{2}-\frac{1}{2})^2\\ \qquad+((1-(1+\sqrt{3})\cos(\alpha)r-2\cos(\beta)r +(1+\sqrt{3})\sin(\alpha)r+2 \sin(\beta)r)\frac{1}{2}-\frac{1}{2})^2 $

I am interested in finding the minimal polynomial of the root $r$ between 0 and 1 for which a numerical approximation is $r \approx 0.1225582838364$, $\alpha \approx 0.174507496606164$ and $\beta \approx 0.417629154722126$.

Below is my (unsuccessfull) attempt to use the variety() function to solve this problem

reset()
from time import time as stime
RR.<x, y, r, s0, c0, s1, c1>=AA[]
Sys2 = [ # a
    -8*r^2+((1+2*AA(cos(pi/6)))*c0*r+2*c1*r-1/2-x)^2+((1+2*AA(cos(pi/6)))*s0*r+2*s1*r-1/2-y)^2,
    # b
    -4*r^2+(2*(1+2*AA(cos(pi/6)))*c0*r+2*c1*r-1-x)^2+(2*(1+2*AA(cos(pi/6)))*s0*r+2*s1*r-y)^2,
    # eq3
    -4*r^2+(((1+2*AA(cos(pi/6)))*c0*r+2*c1*r+(1+2*AA(cos(pi/6)))*s0*r+2*s1*r)/2-1/2)^2+((1-(1+2*AA(cos(pi/6)))*c0*r- 
2*c1*r+(1+2*AA(cos(pi/6)))*s0*r+2*s1*r)/2-1/2)^2,
    # eq4
    -8*r^2+((1+2*AA(cos(pi/6)))*c0*r+2*c1*r-1/2)^2+((1+2*AA(cos(pi/6)))*s0*r+2*s1*r-1/2)^2,
    # eq5
    -4*r^2+(2*(1+2*AA(cos(pi/6)))*c0*r+2*c1*r-1)^2+(2*(1+2*AA(cos(pi/6)))*s0*r+2*s1*r)^2,
    # eq6
    -4*r^2 +(-1/2*(1 + 2*AA(cos(pi/6)) * r * (c0 - s0) + r * s1 + r * c1)^2 +(1/2*(r*(-(1+2*AA(cos(pi/6)))) * (s0 + c0) + 2 * s1 - 
2 * c1) + 1))^2,
    # Basic
    s0^2 + c0^2 - 1,
    s1^2 + c1^2 - 1]
J1 = RR.ideal(Sys2)
print("Solution dimension = ", J1.dimension())
t0 = stime()
Sols = J1.variety()
t1 = stime()
print("Number of solutions = ", len(Sols), ", found in %f6.3 seconds."%(t1-t0))
Errs = [abs(s[r]-0.1225582838364) for s in Sols]
Sol = Sols[Errs.index(min(Errs))]
t2 = stime()
P = Sol[r].minpoly()
t3 = stime()
print("Minimal polynomial (found in %f6.3 seconds) :"%(t3-t2))
print(P)

Unfortunately there seems to be a crash in the Variety() call and no result is returned. It this because this particular system is more complex than in the one in the previous post (one more variable)?

In advance, thanks for your help.

kr,

EDT

After checking the 3 equations again I am pretty sure we dont need x and y variables so I gave it another try, but still not working...

r = 0.1225582838364
a = 0.1745074966061
b = 0.4176291547221

eq1 = -8*r^2+((1+sqrt(3))*cos(a)*r+2*cos(b)*r-1/2)^2 +((1+sqrt(3))*sin(a)*r+2*sin(b)*r-1/2)^2
eq2 = -4*r^2+(2*(1+sqrt(3))*cos(a)*r+2*cos(b)*r-1)^2+(2*(1+sqrt(3))*sin(a)*r+2*sin(b)*r)^2
eq3 = -4*r^2+(((1+sqrt(3))*cos(a)*r+2*cos(b)*r+(1+sqrt(3))*sin(a)*r+2*sin(b)*r)/2-1/2)^2+((1-(1+sqrt(3))*cos(a)*r- 
2*cos(b)*r+(1+sqrt(3))*sin(a)*r+2*sin(b)*r)/2-1/2)^2

show(eq1.numerical_approx())
show(eq2.numerical_approx())
show(eq3.numerical_approx())


reset()
from time import time as stime
RR.<r, s0, c0, s1, c1>=AA[]
Sys2 = [ # eq1
    -8*r^2+((1+2*AA(cos(pi/6)))*c0*r+2*c1*r-1/2)^2 +((1+AA(cos(-7*pi/12)))*s0*r+2*s1*r-1/2)^2,
    # eq2
    -4*r^2+(2*(1+2*AA(cos(pi/6)))*c0*r+2*c1*r-1)^2+(2*(1+2*AA(cos(pi/6)))*s0*r+2*s1*r)^2,
    # eq3
    -4*r^2+(((1+2*AA(cos(pi/6)))*c0*r+2*c1*r+(1+2*AA(cos(pi/6)))*s0*r+2*s1*r)/2-1/2)^2+((1-

(1+2AA(cos(pi/6)))c0r-2c1r+(1+2AA(cos(pi/6)))s0r+2s1r)/2-1/2)^2, # Basic s0^2 + c0^2 - 1, s1^2 + c1^2 -1 ] J1 = RR.ideal(Sys2) print("Solution dimension = ", J1.dimension()) t0 = stime() Sols = J1.variety() t1 = stime() print("Number of solutions = ", len(Sols), ", found in %f6.3 seconds."%(t1-t0)) Errs = [abs(s[r]-0.1225582838364) for s in Sols] Sol = Sols[Errs.index(min(Errs))] t2 = stime() P = Sol[r].minpoly() t3 = stime() print("Minimal polynomial (found in %f6.3 seconds) :"%(t3-t2)) print(P)

Finding the minimal polynomial for a solution of a trigonometric system of quadratic equations

Following the answers provided in a previous Post https://ask.sagemath.org/question/70614/trigonometric-system-of-quadratic-equations/, I tried to apply the proposed methods to a similar trigonometric system of quadratic equations.

$ 8 r^2 =((1+\sqrt{3})\cos(\alpha) r+2\cos(\beta)r-\frac{1}{2})^2 +((1+\sqrt{3})\sin(\alpha)r+2 \sin(\beta) r-\frac{1}{2})^2 $

$ 4 r^2 = (2(1+\sqrt{3})\cos(\alpha)r+2\cos(\beta)r-1)^2 +(2(1+\sqrt{3})\sin(\alpha)r+2\sin(\beta)r)^2 $

$ 4 r^2 = (((1+\sqrt{3})\cos(\alpha)r+2\cos(\beta)r +(1+\sqrt{3})\sin(\alpha)r+2\sin(\beta)r)\frac{1}{2}-\frac{1}{2})^2\\ \qquad+((1-(1+\sqrt{3})\cos(\alpha)r-2\cos(\beta)r +(1+\sqrt{3})\sin(\alpha)r+2 \sin(\beta)r)\frac{1}{2}-\frac{1}{2})^2 $

I am interested in finding the minimal polynomial of the root $r$ between 0 and 1 for which a numerical approximation is $r \approx 0.1225582838364$, $\alpha \approx 0.174507496606164$ and $\beta \approx 0.417629154722126$.

Below is my (unsuccessfull) attempt to use the variety() function to solve this problem

reset()
from time import time as stime
RR.<x, y, r, s0, c0, s1, c1>=AA[]
Sys2 = [ # a
    -8*r^2+((1+2*AA(cos(pi/6)))*c0*r+2*c1*r-1/2-x)^2+((1+2*AA(cos(pi/6)))*s0*r+2*s1*r-1/2-y)^2,
    # b
    -4*r^2+(2*(1+2*AA(cos(pi/6)))*c0*r+2*c1*r-1-x)^2+(2*(1+2*AA(cos(pi/6)))*s0*r+2*s1*r-y)^2,
    # eq3
    -4*r^2+(((1+2*AA(cos(pi/6)))*c0*r+2*c1*r+(1+2*AA(cos(pi/6)))*s0*r+2*s1*r)/2-1/2)^2+((1-(1+2*AA(cos(pi/6)))*c0*r- 
2*c1*r+(1+2*AA(cos(pi/6)))*s0*r+2*s1*r)/2-1/2)^2,
    # eq4
    -8*r^2+((1+2*AA(cos(pi/6)))*c0*r+2*c1*r-1/2)^2+((1+2*AA(cos(pi/6)))*s0*r+2*s1*r-1/2)^2,
    # eq5
    -4*r^2+(2*(1+2*AA(cos(pi/6)))*c0*r+2*c1*r-1)^2+(2*(1+2*AA(cos(pi/6)))*s0*r+2*s1*r)^2,
    # eq6
    -4*r^2 +(-1/2*(1 + 2*AA(cos(pi/6)) * r * (c0 - s0) + r * s1 + r * c1)^2 +(1/2*(r*(-(1+2*AA(cos(pi/6)))) * (s0 + c0) + 2 * s1 - 
2 * c1) + 1))^2,
    # Basic
    s0^2 + c0^2 - 1,
    s1^2 + c1^2 - 1]
J1 = RR.ideal(Sys2)
print("Solution dimension = ", J1.dimension())
t0 = stime()
Sols = J1.variety()
t1 = stime()
print("Number of solutions = ", len(Sols), ", found in %f6.3 seconds."%(t1-t0))
Errs = [abs(s[r]-0.1225582838364) for s in Sols]
Sol = Sols[Errs.index(min(Errs))]
t2 = stime()
P = Sol[r].minpoly()
t3 = stime()
print("Minimal polynomial (found in %f6.3 seconds) :"%(t3-t2))
print(P)

Unfortunately there seems to be a crash in the Variety() call and no result is returned. It this because this particular system is more complex than in the one in the previous post (one more variable)?

In advance, thanks for your help.

kr,

EDT

After checking the 3 equations again I am pretty sure we dont need x and y variables so I gave it another try, but still not working...

r = 0.1225582838364
a = 0.1745074966061
b = 0.4176291547221

eq1 = -8*r^2+((1+sqrt(3))*cos(a)*r+2*cos(b)*r-1/2)^2 +((1+sqrt(3))*sin(a)*r+2*sin(b)*r-1/2)^2
eq2 = -4*r^2+(2*(1+sqrt(3))*cos(a)*r+2*cos(b)*r-1)^2+(2*(1+sqrt(3))*sin(a)*r+2*sin(b)*r)^2
eq3 = -4*r^2+(((1+sqrt(3))*cos(a)*r+2*cos(b)*r+(1+sqrt(3))*sin(a)*r+2*sin(b)*r)/2-1/2)^2+((1-(1+sqrt(3))*cos(a)*r- 
2*cos(b)*r+(1+sqrt(3))*sin(a)*r+2*sin(b)*r)/2-1/2)^2

show(eq1.numerical_approx())
show(eq2.numerical_approx())
show(eq3.numerical_approx())


reset()
from time import time as stime
RR.<r, s0, c0, s1, c1>=AA[]
Sys2 = [ # eq1
    -8*r^2+((1+2*AA(cos(pi/6)))*c0*r+2*c1*r-1/2)^2 +((1+AA(cos(-7*pi/12)))*s0*r+2*s1*r-1/2)^2,
    # eq2
    -4*r^2+(2*(1+2*AA(cos(pi/6)))*c0*r+2*c1*r-1)^2+(2*(1+2*AA(cos(pi/6)))*s0*r+2*s1*r)^2,
    # eq3
    -4*r^2+(((1+2*AA(cos(pi/6)))*c0*r+2*c1*r+(1+2*AA(cos(pi/6)))*s0*r+2*s1*r)/2-1/2)^2+((1-

(1+2AA(cos(pi/6)))c0r-2c1r+(1+2AA(cos(pi/6)))s0r+2s1r)/2-1/2)^2, -4*r^2+(((1+2*AA(cos(pi/6)))*c0*r+2*c1*r+(1+2*AA(cos(pi/6)))*s0*r+2*s1*r)/2-1/2)^2+((1- (1+2*AA(cos(pi/6)))*c0*r-2*c1*r+(1+2*AA(cos(pi/6)))*s0*r+2*s1*r)/2-1/2)^2, # Basic s0^2 + c0^2 - 1, s1^2 + c1^2 -1 ] J1 = RR.ideal(Sys2) print("Solution dimension = ", J1.dimension()) t0 = stime() Sols = J1.variety() t1 = stime() print("Number of solutions = ", len(Sols), ", found in %f6.3 seconds."%(t1-t0)) Errs = [abs(s[r]-0.1225582838364) for s in Sols] Sol = Sols[Errs.index(min(Errs))] t2 = stime() P = Sol[r].minpoly() t3 = stime() print("Minimal polynomial (found in %f6.3 seconds) :"%(t3-t2)) print(P)

print(P)

Finding the minimal polynomial for a solution of a trigonometric system of quadratic equations

Following the answers provided in a previous Post https://ask.sagemath.org/question/70614/trigonometric-system-of-quadratic-equations/, I tried to apply the proposed methods to a similar trigonometric system of quadratic equations.

$ 8 r^2 =((1+\sqrt{3})\cos(\alpha) r+2\cos(\beta)r-\frac{1}{2})^2 +((1+\sqrt{3})\sin(\alpha)r+2 \sin(\beta) r-\frac{1}{2})^2 $

$ 4 r^2 = (2(1+\sqrt{3})\cos(\alpha)r+2\cos(\beta)r-1)^2 +(2(1+\sqrt{3})\sin(\alpha)r+2\sin(\beta)r)^2 $

$ 4 r^2 = (((1+\sqrt{3})\cos(\alpha)r+2\cos(\beta)r +(1+\sqrt{3})\sin(\alpha)r+2\sin(\beta)r)\frac{1}{2}-\frac{1}{2})^2\\ \qquad+((1-(1+\sqrt{3})\cos(\alpha)r-2\cos(\beta)r +(1+\sqrt{3})\sin(\alpha)r+2 \sin(\beta)r)\frac{1}{2}-\frac{1}{2})^2 $

I am interested in finding the minimal polynomial of the root $r$ between 0 and 1 for which a numerical approximation is $r \approx 0.1225582838364$, $\alpha \approx 0.174507496606164$ and $\beta \approx 0.417629154722126$.

Below is my (unsuccessfull) attempt to use the variety() function to solve this problem

reset()
from time import time as stime
RR.<x, y, r, s0, c0, s1, c1>=AA[]
Sys2 = [ # a
    -8*r^2+((1+2*AA(cos(pi/6)))*c0*r+2*c1*r-1/2-x)^2+((1+2*AA(cos(pi/6)))*s0*r+2*s1*r-1/2-y)^2,
    # b
    -4*r^2+(2*(1+2*AA(cos(pi/6)))*c0*r+2*c1*r-1-x)^2+(2*(1+2*AA(cos(pi/6)))*s0*r+2*s1*r-y)^2,
    # eq3
    -4*r^2+(((1+2*AA(cos(pi/6)))*c0*r+2*c1*r+(1+2*AA(cos(pi/6)))*s0*r+2*s1*r)/2-1/2)^2+((1-(1+2*AA(cos(pi/6)))*c0*r- 
2*c1*r+(1+2*AA(cos(pi/6)))*s0*r+2*s1*r)/2-1/2)^2,
    # eq4
    -8*r^2+((1+2*AA(cos(pi/6)))*c0*r+2*c1*r-1/2)^2+((1+2*AA(cos(pi/6)))*s0*r+2*s1*r-1/2)^2,
    # eq5
    -4*r^2+(2*(1+2*AA(cos(pi/6)))*c0*r+2*c1*r-1)^2+(2*(1+2*AA(cos(pi/6)))*s0*r+2*s1*r)^2,
    # eq6
    -4*r^2 +(-1/2*(1 + 2*AA(cos(pi/6)) * r * (c0 - s0) + r * s1 + r * c1)^2 +(1/2*(r*(-(1+2*AA(cos(pi/6)))) * (s0 + c0) + 2 * s1 - 
2 * c1) + 1))^2,
    # Basic
    s0^2 + c0^2 - 1,
    s1^2 + c1^2 - 1]
J1 = RR.ideal(Sys2)
print("Solution dimension = ", J1.dimension())
t0 = stime()
Sols = J1.variety()
t1 = stime()
print("Number of solutions = ", len(Sols), ", found in %f6.3 seconds."%(t1-t0))
Errs = [abs(s[r]-0.1225582838364) for s in Sols]
Sol = Sols[Errs.index(min(Errs))]
t2 = stime()
P = Sol[r].minpoly()
t3 = stime()
print("Minimal polynomial (found in %f6.3 seconds) :"%(t3-t2))
print(P)

Unfortunately there seems to be a crash in the Variety() call and no result is returned. It this because this particular system is more complex than in the one in the previous post (one more variable)?

In advance, thanks for your help.

kr,

EDTEDIT

After checking the 3 equations again I am pretty sure we dont need x and y variables so I gave it another try, but still not working...

r = 0.1225582838364
a = 0.1745074966061
b = 0.4176291547221

eq1 = -8*r^2+((1+sqrt(3))*cos(a)*r+2*cos(b)*r-1/2)^2 +((1+sqrt(3))*sin(a)*r+2*sin(b)*r-1/2)^2
eq2 = -4*r^2+(2*(1+sqrt(3))*cos(a)*r+2*cos(b)*r-1)^2+(2*(1+sqrt(3))*sin(a)*r+2*sin(b)*r)^2
eq3 = -4*r^2+(((1+sqrt(3))*cos(a)*r+2*cos(b)*r+(1+sqrt(3))*sin(a)*r+2*sin(b)*r)/2-1/2)^2+((1-(1+sqrt(3))*cos(a)*r- 
2*cos(b)*r+(1+sqrt(3))*sin(a)*r+2*sin(b)*r)/2-1/2)^2

show(eq1.numerical_approx())
show(eq2.numerical_approx())
show(eq3.numerical_approx())


reset()
from time import time as stime
RR.<r, s0, c0, s1, c1>=AA[]
Sys2 = [ # eq1
    -8*r^2+((1+2*AA(cos(pi/6)))*c0*r+2*c1*r-1/2)^2 +((1+AA(cos(-7*pi/12)))*s0*r+2*s1*r-1/2)^2,
    # eq2
    -4*r^2+(2*(1+2*AA(cos(pi/6)))*c0*r+2*c1*r-1)^2+(2*(1+2*AA(cos(pi/6)))*s0*r+2*s1*r)^2,
    # eq3
    -4*r^2+(((1+2*AA(cos(pi/6)))*c0*r+2*c1*r+(1+2*AA(cos(pi/6)))*s0*r+2*s1*r)/2-1/2)^2+((1- 
    (1+2*AA(cos(pi/6)))*c0*r-2*c1*r+(1+2*AA(cos(pi/6)))*s0*r+2*s1*r)/2-1/2)^2,
    # Basic
    s0^2 + c0^2 - 1,
    s1^2 + c1^2 -1 ]
J1 = RR.ideal(Sys2)
print("Solution dimension = ", J1.dimension())
t0 = stime()
Sols = J1.variety()
t1 = stime()
print("Number of solutions = ", len(Sols), ", found in %f6.3 seconds."%(t1-t0))
Errs = [abs(s[r]-0.1225582838364) for s in Sols]
Sol = Sols[Errs.index(min(Errs))]
t2 = stime()
P = Sol[r].minpoly()
t3 = stime()
print("Minimal polynomial (found in %f6.3 seconds) :"%(t3-t2))
print(P)