A program computing the Canonical Form.

We use the package Implicit Plot to plot all three Conics. We abbreviate the commands Coefficient and FS.

In[24]:=

<<Graphics`ImplicitPlot` ; Co[x_, y_] := Coefficient[x, y] ; FS[x_] := FullSimplify[x] ;

We define the symmetric matrix A of degree 2 coefficients for a generic degree 2 polynomial f in the variables x, y.

In[27]:=

Mat[f_] := Do[e := Expand[f] ; a11 := Co[e, x^2] ;   a12 := Co[e, x * y]/2 ; ... 12}, {a12, a22}} ; <br />        traceofA := a11 + a22 ;]

Defining colors, titles and comments.

Colors. We select the color for the original version of the Conic, for the rotated version, for the canonical version.

In[28]:=

RowBox[{        , RowBox[{OriginalColor  &nb ... p;    , CanonicalColor      = RGBColor[1, 0, 0] ;}]}]

Bold Characters. We define a function changing a text to be printed to boldface.

In[31]:=

BoldFace[s_] := StyleForm[s, FontWeight->"Bold"] ;

We may now print into boldface a string s just by the command Print[s//BoldFace].

Titles. We define, for each section of the program, a macro printing the title of the section.
The first title introduces the original Conic.

In[32]:=

Title[1] := Print[StyleForm["\n 1. The Original Conic \n", FontSize->18] //BoldFace] ;

The second title introduces the rotation.

In[33]:=

Title[2] := Print[StyleForm["\n 2. Rotating the Conic \n", FontSize->18]//BoldFace] ;

The third title introduce the translation (the canonical form).

In[34]:=

Title[3] := Print[StyleForm["\n 3.  Translating the Conic: the canonical form \n", FontSize->18]//BoldFace] ;

The forth title introduces the graphics of the three Conics, and the color for each conic: for the original one, the rotated one, the canonical one.

In[35]:=

Title[4] := Print[<br />StyleForm["\n 4. Grafico delle Coniche \n", FontSize->18] ... <br />StyleForm[ "\t 3. The Canonical Form", FontColor->CanonicalColor ]//BoldFace] ;

Comments. We introduce a few comments to be introduced in each section. The first comment introduces the matrix A.

In[36]:=

Comment["A"] := Print["\t Symmetric matrix A out of degree 2 coefficients: \n"  //BoldFace] ;

Here is a comment telling which kind of conic we have, according to the value of det(A).

In[37]:=

Comment["kind", detA_] := If[detA>0, <br />      &n ... nic is an", StyleForm[" Hyperbola. \n", FontColor->OriginalColor]//BoldFace]]] ;

This comment introduces Eigenvalues and Eigenvectors.

In[38]:=

Comment["Eigenvalues"] := Print["\t Eigenvalues of A: \n"// BoldFace] ;

In[39]:=

Comment["Eigenvectors"] := Print["\t Eigenvectors of A: \n"// BoldFace] ;

Here is another comment, telling how many degrees we rotate the original Conic. The rotation is  (x,y) |-> (xP_1 - yP_2,  xP_1+ yP_2), hence the angle of rotation is ArcCos(P_1).

In[40]:=

Comment["sos1"] := <br />    Print["\t We apply the rotatio ... sp;     N[ArcCos[P[[1]]]/ Degree], " degrees: \n" //BoldFace] ;

  Yet another comment, telling how far we translate the rotated Conic. The translation is (x,y)|->(x-a,y-b), therefore the distance is (a^2 + b^2)^(1/2).

In[41]:=

Comment["sos2"] := <br />    Print["\t We apply the translation of "//BoldFace, N[ (a^2 + b^2)^(1/2)], " units \n"// BoldFace] ;

This comment introduces the equation of the rotated Conic.

In[42]:=

Comment["h"] := <br />    Print["\t Equation of the rotated conic: \n"//BoldFace] ;

This comment introduces the equation of the canonical form.

In[43]:=

Comment["k"] := Print["\t Canonical form (after rotating and translating): \n"//BoldFace] ;

Defining the program "Conic[f]".


Created by Mathematica  (August 4, 2004)