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/706..., 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,
EDIT
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)
Again, your polynomial expressions bear no visible relation to your original problem. How do you derive them ?
FWIW, on Sage 10.1.rc0,
.variety()
didn't return in more than 2 hours, but didn't raise an error either...What did you edit ? I worked on the initial version of yur question, no longer available...
Regarding my last edit, I only added numerical approximations for $\alpha$ and $\beta$, as I previously only gave the approximation for $r$.
As you suggested, I did compare the original equations to the polynomial expressions in the sage program. Indeed, there were differences and I am pretty sure x and y variables are not needed in this case. I gave it another try and now I am pretty sure the polynomial expressions agree with the initial system of equations. Hoever it still does not produces a result.. After the variety() call nothing is displayed. .