Laws of trigonometry 1

3370 days ago by Kris.Coolsaet

In this example we investigate the consequences of the laws of cosines using Gröbner basis techniques. $a,b,c$ represent the sides of a triangle, $A,B,C$ correspond to the angles in the following way:

\[A = \tan \alpha/2, B = \tan \beta/2, C = \tan \gamma/2\]

When constructing the polynomial ring $R$ below, we need to choose a monomial order (here: the purely lexicographical order lex) and an ordering of the variables. This will influence the result of the computations. 

R = PolynomialRing (QQ, 'a,b,c,A,B,C', order='lex') a,b,c,A,B,C = R.gens() 
       

To verify the monomial order, we evaluate a simple polynomial expression.

(a+b+1)^2 
       

                                
                            

                                

Every law must be represented as a polynomial which is expected to be zero. (Gröbner bases work only with polynomials.)

coslawa = (1+A^2)*(b^2+c^2-a^2) - 2*b*c*(1-A^2) coslawb = (1+B^2)*(c^2+a^2-b^2) - 2*c*a*(1-B^2) coslawc = (1+C^2)*(a^2+b^2-c^2) - 2*a*b*(1-C^2) 
       

Do not worry about the word ideal in the next statement. For now you can simply regard an ideal as some intermediate object we need to do our computations.

Icos = Ideal (coslawa,coslawb,coslawc) 
       

We compute the Gröbner basis with the std command from the program Singular.

Gcos = Icos.groebner_basis('libsingular:std') 
       

This yields a list of polynomials. We first check how many there are

len(Gcos) 
       

                                
                            

                                

Using lexicographical ordering as a monomial order indeed tends to produce large bases (and is often quite slow).

However, one of the advantages of lexicographical ordering is that it can be used to eliminate variables. The last polynomials in the basis have fewer variables than the first. We can see this in the following two statements.

[f.degree(a) for f in Gcos] 
       

                                
                            

                                
[f.degree(b) for f in Gcos] 
       

                                
                            

                                

It is therefore often quite useful to have a look at the last polynomial(s) in the list.

Splitting the polynomial into factors is always a good idea.

Gcos[-1].factor() 
       

                                
                            

                                

Note that $AB+AC+BC=1$ if and only if $\alpha+\beta+\gamma=\pi$. (The other three factors correspond to negative angles.)

Another interesting result is the following:

Gcos[-5].factor() 
       

                                
                            

                                

from which you can derive the 'new' law

\[\frac{b-c}{b+c} \tan^2 \alpha/2 = \tan(\beta+\gamma)/2\tan(\beta-\gamma)/2\]

We simplify the basis by adding the condition $AB+AC+BC=1$

Icos2 = Ideal(coslawa,coslawb,coslawc,A*B+A*C+B*C - 1) Gcos2 = Icos2.groebner_basis("libsingular:std") len (Gcos2) 
       

                                
                            

                                

Not only is this new basis shorter, but also the polynomials have lower degree, as witnessed by the next two commands

[f.degree() for f in Gcos] 
       

                                
                            

                                
[f.degree() for f in Gcos2] 
       

                                
                            

                                

Again we find an interesting result

Gcos2[-2].factor() 
       

                                
                            

                                

The last factor can be rewritten as

\[bC (B^2+1) = cB (C^2+1)\]

which is the same as

\[\frac{B}{b(B^2+1)} = \frac{C}{c(C^2+1)}\]

or $\frac{\sin \beta}b = \frac{\sin \gamma}c$. We rediscovered the law of sines!