(***********************************************************************

                    Mathematica-Compatible Notebook

This notebook can be used on any computer system with Mathematica 4.0,
MathReader 4.0, or any compatible application. The data for the notebook 
starts with the line containing stars above.

To get the notebook into a Mathematica-compatible application, do one of 
the following:

* Save the data starting with the line of stars above into a file
  with a name ending in .nb, then open the file inside the application;

* Copy the data starting with the line of stars above to the
  clipboard, then use the Paste menu command inside the application.

Data for notebooks contains only printable 7-bit ASCII and can be
sent directly in email or through ftp in text mode.  Newlines can be
CR, LF or CRLF (Unix, Macintosh or MS-DOS style).

NOTE: If you modify the data for this notebook not in a Mathematica-
compatible application, you must delete the line below containing the 
word CacheID, otherwise Mathematica-compatible applications may try to 
use invalid cache data.

For more information on notebooks and Mathematica-compatible 
applications, contact Wolfram Research:
  web: http://www.wolfram.com
  email: info@wolfram.com
  phone: +1-217-398-0700 (U.S.)

Notebook reader applications are available free of charge from 
Wolfram Research.
***********************************************************************)

(*CacheID: 232*)


(*NotebookFileLineBreakTest
NotebookFileLineBreakTest*)
(*NotebookOptionsPosition[     11485,        373]*)
(*NotebookOutlinePosition[     15084,        487]*)
(*  CellTagsIndexPosition[     14781,        471]*)
(*WindowFrame->Normal*)



Notebook[{
Cell[TextData[{
  "Algebra",
  StyleBox["`", "MB"],
  "PolynomialExtendedGCD",
  StyleBox["`", "MB"]
}], "Subsection",
  CellTags->{"S5.5.1", "1.1"}],

Cell[TextData[{
  StyleBox["PolynomialExtendedGCD", "MR"],
  " gives the extended greatest common divisor for two univariate \
polynomials. The ",
  StyleBox["Mathematica", "TI"],
  " kernel has the functions ",
  StyleBox["GCD", "MR"],
  " and ",
  StyleBox["ExtendedGCD", "MR"],
  " for integers, and the function ",
  StyleBox["PolynomialGCD", "MR"],
  " for multivariate polynomials over the rationals. The function defined in \
this package works not only for polynomials over the rationals, but also for \
polynomials over the integers mod prime ",
  Cell[BoxData[
      \(TraditionalForm\`p\)], "InlineFormula"],
  ", and for polynomials with coefficients in a finite field defined by the \
package ",
  StyleBox["Algebra`FiniteFields`", "MR"],
  ". \nIn a Euclidean domain, such as addition and multiplication on the \
integers, or addition and multiplication on univariate polynomials with \
coefficients in some field, it is possible to write the gcd of two elements \
as a linear combination of the two elements. The extended gcd gives the \
coefficients of the linear combination. ",
  StyleBox["PolynomialExtendedGCD[", "MR"],
  Cell[BoxData[
      FormBox[
        SubscriptBox["\<\"\\!\\(\\*StyleBox[\\\"\\\\\\\"poly\\\\\\\"\\\", \
\\\"TI\\\"]\\)\"\>", "1"], TraditionalForm]], "InlineFormula"],
  StyleBox[",", "MR"],
  " ",
  Cell[BoxData[
      FormBox[
        SubscriptBox["\<\"\\!\\(\\*StyleBox[\\\"\\\\\\\"poly\\\\\\\"\\\", \
\\\"TI\\\"]\\)\"\>", "2"], TraditionalForm]], "InlineFormula"],
  StyleBox["]", "MR"],
  " gives the list ",
  Cell[BoxData[
      \(TraditionalForm\`{\)], "InlineFormula"],
  StyleBox["gcd", "TI"],
  StyleBox[",", "MR"],
  " ",
  Cell[BoxData[
      \(TraditionalForm\`{\)], "InlineFormula"],
  StyleBox["r", "TI"],
  StyleBox[",", "MR"],
  " ",
  StyleBox["s", "TI"],
  Cell[BoxData[
      \(TraditionalForm\`}\)], "InlineFormula"],
  Cell[BoxData[
      \(TraditionalForm\`}\)], "InlineFormula"],
  " where ",
  Cell[BoxData[
      \(TraditionalForm\`g  c  d\)], "InlineFormula"],
  " is the greatest common divisor of ",
  Cell[BoxData[
      FormBox[
        SubscriptBox["\<\"\\!\\(\\*StyleBox[\\\"\\\\\\\"poly\\\\\\\"\\\", \
\\\"TI\\\"]\\)\"\>", "1"], TraditionalForm]], "InlineFormula"],
  " and ",
  Cell[BoxData[
      FormBox[
        SubscriptBox["\<\"\\!\\(\\*StyleBox[\\\"\\\\\\\"poly\\\\\\\"\\\", \
\\\"TI\\\"]\\)\"\>", "2"], TraditionalForm]], "InlineFormula"],
  ", and ",
  Cell[BoxData[
      \(TraditionalForm\`r\)], "InlineFormula"],
  " and ",
  Cell[BoxData[
      \(TraditionalForm\`s\)], "InlineFormula"],
  " are polynomials such that ",
  StyleBox["r", "TI"],
  " ",
  Cell[BoxData[
      FormBox[
        SubscriptBox["\<\"\\!\\(\\*StyleBox[\\\"\\\\\\\"poly\\\\\\\"\\\", \
\\\"TI\\\"]\\)\"\>", "1"], TraditionalForm]], "InlineFormula"],
  " ",
  StyleBox["+", "MR"],
  " ",
  StyleBox["s", "TI"],
  " ",
  Cell[BoxData[
      FormBox[
        SubscriptBox["\<\"\\!\\(\\*StyleBox[\\\"\\\\\\\"poly\\\\\\\"\\\", \
\\\"TI\\\"]\\)\"\>", "2"], TraditionalForm]], "InlineFormula"],
  " ",
  StyleBox["=", "MR"],
  " ",
  StyleBox["gcd", "TI"],
  ". "
}], "Text",
  CellTags->{"S5.5.1", "1.2"}],

Cell[BoxData[
    FormBox[
      StyleBox[
        FrameBox[
          StyleBox[GridBox[{
                {
                  
                  RowBox[{"\<\"\\!\\(\\*StyleBox[\\\"\\\\\\\"\
PolynomialExtendedGCD[\\\\\\\"\\\", \\\"MR\\\"]\\)\"\>", 
                    StyleBox[
                      
                      SubscriptBox["\<\"\\!\\(\\*StyleBox[\\\"\\\\\\\"poly\\\\\
\\\"\\\", \\\"TI\\\"]\\)\"\>", "1"],
                      
                      "InlineFormula"], \
"\<\"\\!\\(\\*StyleBox[\\\"\\\\\\\",\\\\\\\"\\\", \\\"MR\\\"]\\) \"\>", 
                    StyleBox[
                      
                      SubscriptBox["\<\"\\!\\(\\*StyleBox[\\\"\\\\\\\"poly\\\\\
\\\"\\\", \\\"TI\\\"]\\)\"\>", "2"],
                      
                      "InlineFormula"], \
"\<\"\\!\\(\\*StyleBox[\\\"\\\\\\\"]\\\\\\\"\\\", \\\"MR\\\"]\\) \"\>"}], 
                  
                  RowBox[{"\<\"give the extended gcd of the two univariate \
polynomials \"\>", 
                    StyleBox[
                      
                      SubscriptBox["\<\"\\!\\(\\*StyleBox[\\\"\\\\\\\"poly\\\\\
\\\"\\\", \\\"TI\\\"]\\)\"\>", "1"],
                      "InlineFormula"], "\<\" and \"\>", 
                    StyleBox[
                      
                      SubscriptBox["\<\"\\!\\(\\*StyleBox[\\\"\\\\\\\"poly\\\\\
\\\"\\\", \\\"TI\\\"]\\)\"\>", "2"],
                      
                      "InlineFormula"], "\<\" over the rationals, gaussian \
rationals, or finite fields\"\>"}]},
                {
                  
                  RowBox[{"\<\"\\!\\(\\*StyleBox[\\\"\\\\\\\"\
PolynomialExtendedGCD[\\\\\\\"\\\", \\\"MR\\\"]\\)\"\>", 
                    StyleBox[
                      
                      SubscriptBox["\<\"\\!\\(\\*StyleBox[\\\"\\\\\\\"poly\\\\\
\\\"\\\", \\\"TI\\\"]\\)\"\>", "1"],
                      
                      "InlineFormula"], \
"\<\"\\!\\(\\*StyleBox[\\\"\\\\\\\",\\\\\\\"\\\", \\\"MR\\\"]\\) \"\>", 
                    StyleBox[
                      
                      SubscriptBox["\<\"\\!\\(\\*StyleBox[\\\"\\\\\\\"poly\\\\\
\\\"\\\", \\\"TI\\\"]\\)\"\>", "2"],
                      
                      "InlineFormula"], \
"\<\"\\!\\(\\*StyleBox[\\\"\\\\\\\",\\\\\\\"\\\", \\\"MR\\\"]\\) \
\\!\\(\\*StyleBox[\\\"\\\\\\\"Modulus->\\\\\\\"\\\", \
\\\"MR\\\"]\\)\\!\\(\\*StyleBox[\\\"\\\\\\\"p\\\\\\\"\\\", \
\\\"TI\\\"]\\)\\!\\(\\*StyleBox[\\\"\\\\\\\"]\\\\\\\"\\\", \\\"MR\\\"]\\) \
\"\>"}], 
                  
                  RowBox[{"\<\"give the extended gcd of two univariate \
polynomials over the integers mod prime \"\>", 
                    StyleBox["p",
                      "InlineFormula"]}]}
                },
              ColumnAlignments->{Right, Left}],
            GridBoxOptions->{RowLines->False}]],
        "2ColumnBox"], TraditionalForm]], "Text",
  CellTags->{"S5.5.1", "1.3"}],

Cell["Polynomial greatest common divisor.", "Caption",
  CellTags->"S5.5.1"],

Cell["This loads the package. ", "MathCaption",
  CellTags->{"S5.5.1", "1.4"}],

Cell["<<Algebra`PolynomialExtendedGCD`", "Input",
  CellLabel->"In[1]:= ",
  CellTags->"S5.5.1"],

Cell["Here is an example over the integers mod 7. ", "MathCaption",
  CellTags->{"S5.5.1", "1.5"}],

Cell[CellGroupData[{

Cell["\<\
PolynomialExtendedGCD[x^2 + 2 x + 1,
 Expand[(x + 1)(x + 2)], Modulus->7]\
\>", "Input",
  CellLabel->"In[2]:= ",
  CellTags->"S5.5.1"],

Cell[BoxData[
    \({1 + x, {6, 1}}\)], "Output",
  CellLabel->"Out[2]= ",
  CellTags->"S5.5.1"]
}, Open  ]],

Cell["Here is the same example over the rationals. ", "MathCaption",
  CellTags->{"S5.5.1", "1.6"}],

Cell[CellGroupData[{

Cell["\<\
PolynomialExtendedGCD[x^2 + 2 x + 1,
 Expand[(x + 1)(x + 2)]]\
\>", "Input",
  CellLabel->"In[3]:= ",
  CellTags->"S5.5.1"],

Cell[BoxData[
    \({1 + x, {\(-1\), 1}}\)], "Output",
  CellLabel->"Out[3]= ",
  CellTags->"S5.5.1"]
}, Open  ]],

Cell[TextData[{
  "Load the ",
  StyleBox["Algebra`FiniteFields`", "MR"],
  " package. "
}], "MathCaption",
  CellTags->{"S5.5.1", "1.7"}],

Cell["<<Algebra`FiniteFields`", "Input",
  CellLabel->"In[4]:= ",
  CellTags->"S5.5.1"],

Cell[TextData[{
  "Here is the example over the field ",
  StyleBox["GF[7]", "MR"],
  ". "
}], "MathCaption",
  CellTags->{"S5.5.1", "1.8"}],

Cell[CellGroupData[{

Cell["\<\
PolynomialExtendedGCD[
 x^2 + GF[7][{2}] x + GF[7][{1}],
 Expand[(x + GF[7][{1}])(x + GF[7][{2}])]]\
\>", "Input",
  CellLabel->"In[5]:= ",
  CellTags->"S5.5.1"],

Cell[BoxData[
    RowBox[{"{", 
      RowBox[{
        RowBox[{
          InterpretationBox[\({1}\_7\),
            Subscripted[ 
              {1}[ 7]],
            Editable->False], "+", 
          RowBox[{"x", " ", 
            InterpretationBox[\({1}\_7\),
              Subscripted[ 
                {1}[ 7]],
              Editable->False]}]}], ",", 
        RowBox[{"{", 
          RowBox[{
            InterpretationBox[\({6}\_7\),
              Subscripted[ 
                {6}[ 7]],
              Editable->False], ",", 
            InterpretationBox[\({1}\_7\),
              Subscripted[ 
                {1}[ 7]],
              Editable->False]}], "}"}]}], "}"}]], "Output",
  CellLabel->"Out[5]= ",
  CellTags->"S5.5.1"]
}, Open  ]],

Cell[TextData[{
  "Note that the kernel function ",
  StyleBox["PolynomialGCD", "MR"],
  " does not work for polynomials over finite fields. Apply ",
  StyleBox["First", "MR"],
  " to the result of ",
  StyleBox["PolynomialExtendedGCD", "MR"],
  " instead. "
}], "MathCaption",
  CellTags->{"S5.5.1", "1.9"}],

Cell[CellGroupData[{

Cell["\<\
PolynomialGCD[x^2 + GF[7][{2}] x + GF[7][{1}],
 Expand[(x + GF[7][{1}])(x + GF[7][{2}])]]\
\>", "Input",
  CellLabel->"In[6]:= ",
  CellTags->"S5.5.1"],

Cell[BoxData[
    \(1\)], "Output",
  CellLabel->"Out[6]= ",
  CellTags->"S5.5.1"]
}, Open  ]],

Cell["Here the polynomial coefficients are Gaussian integers. ", "MathCaption",
  CellTags->{"S5.5.1", "1.10"}],

Cell[CellGroupData[{

Cell["\<\
PolynomialExtendedGCD[
  Expand[ ((12+I) z^2 + 7 z + I) (I z + 3)],
  Expand[ ((9+2I) z + (3+I)) ((3I)z + 9)]
]\
\>", "Input",
  CellLabel->"In[7]:= ",
  CellTags->"S5.5.1"],

Cell[BoxData[
    \({\(-3\)\ \[ImaginaryI] + 
        z, {\(-\(1672\/3469\)\) + \(1489\ \[ImaginaryI]\)\/3469, \((89\/3469 \
- \(688\ \[ImaginaryI]\)\/10407)\) + \((1901\/10407 - \(2222\ \[ImaginaryI]\)\
\/10407)\)\ z}}\)], "Output",
  CellLabel->"Out[7]= ",
  CellTags->"S5.5.1"]
}, Open  ]]
},
FrontEndVersion->"4.0 for X",
ScreenRectangle->{{0, 800}, {0, 600}},
WindowSize->{520, 455},
WindowMargins->{{140, Automatic}, {Automatic, 72}},
StyleDefinitions -> "HelpBrowser.nb"
]


(***********************************************************************
Cached data follows.  If you edit this Notebook file directly, not using
Mathematica, you must remove the line containing CacheID at the top of 
the file.  The cache data will then be recreated when you save this file 
from within Mathematica.
***********************************************************************)

(*CellTagsOutline
CellTagsIndex->{
  "S5.5.1"->{
    Cell[1717, 49, 149, 6, 70, "Subsection",
      CellTags->{"S5.5.1", "1.1"}],
    Cell[1869, 57, 3162, 93, 70, "Text",
      CellTags->{"S5.5.1", "1.2"}],
    Cell[5034, 152, 2899, 69, 70, "Text",
      CellTags->{"S5.5.1", "1.3"}],
    Cell[7936, 223, 76, 1, 70, "Caption",
      CellTags->"S5.5.1"],
    Cell[8015, 226, 78, 1, 70, "MathCaption",
      CellTags->{"S5.5.1", "1.4"}],
    Cell[8096, 229, 96, 2, 70, "Input",
      CellTags->"S5.5.1"],
    Cell[8195, 233, 98, 1, 70, "MathCaption",
      CellTags->{"S5.5.1", "1.5"}],
    Cell[8318, 238, 145, 5, 70, "Input",
      CellTags->"S5.5.1"],
    Cell[8466, 245, 96, 3, 70, "Output",
      CellTags->"S5.5.1"],
    Cell[8577, 251, 99, 1, 70, "MathCaption",
      CellTags->{"S5.5.1", "1.6"}],
    Cell[8701, 256, 133, 5, 70, "Input",
      CellTags->"S5.5.1"],
    Cell[8837, 263, 101, 3, 70, "Output",
      CellTags->"S5.5.1"],
    Cell[8953, 269, 138, 5, 70, "MathCaption",
      CellTags->{"S5.5.1", "1.7"}],
    Cell[9094, 276, 87, 2, 70, "Input",
      CellTags->"S5.5.1"],
    Cell[9184, 280, 140, 5, 70, "MathCaption",
      CellTags->{"S5.5.1", "1.8"}],
    Cell[9349, 289, 171, 6, 70, "Input",
      CellTags->"S5.5.1"],
    Cell[9523, 297, 735, 24, 70, "Output",
      CellTags->"S5.5.1"],
    Cell[10273, 324, 308, 9, 70, "MathCaption",
      CellTags->{"S5.5.1", "1.9"}],
    Cell[10606, 337, 161, 5, 70, "Input",
      CellTags->"S5.5.1"],
    Cell[10770, 344, 82, 3, 70, "Output",
      CellTags->"S5.5.1"],
    Cell[10867, 350, 111, 1, 70, "MathCaption",
      CellTags->{"S5.5.1", "1.10"}],
    Cell[11003, 355, 183, 7, 70, "Input",
      CellTags->"S5.5.1"],
    Cell[11189, 364, 280, 6, 70, "Output",
      CellTags->"S5.5.1"]},
  "1.1"->{
    Cell[1717, 49, 149, 6, 70, "Subsection",
      CellTags->{"S5.5.1", "1.1"}]},
  "1.2"->{
    Cell[1869, 57, 3162, 93, 70, "Text",
      CellTags->{"S5.5.1", "1.2"}]},
  "1.3"->{
    Cell[5034, 152, 2899, 69, 70, "Text",
      CellTags->{"S5.5.1", "1.3"}]},
  "1.4"->{
    Cell[8015, 226, 78, 1, 70, "MathCaption",
      CellTags->{"S5.5.1", "1.4"}]},
  "1.5"->{
    Cell[8195, 233, 98, 1, 70, "MathCaption",
      CellTags->{"S5.5.1", "1.5"}]},
  "1.6"->{
    Cell[8577, 251, 99, 1, 70, "MathCaption",
      CellTags->{"S5.5.1", "1.6"}]},
  "1.7"->{
    Cell[8953, 269, 138, 5, 70, "MathCaption",
      CellTags->{"S5.5.1", "1.7"}]},
  "1.8"->{
    Cell[9184, 280, 140, 5, 70, "MathCaption",
      CellTags->{"S5.5.1", "1.8"}]},
  "1.9"->{
    Cell[10273, 324, 308, 9, 70, "MathCaption",
      CellTags->{"S5.5.1", "1.9"}]},
  "1.10"->{
    Cell[10867, 350, 111, 1, 70, "MathCaption",
      CellTags->{"S5.5.1", "1.10"}]}
  }
*)

(*CellTagsIndex
CellTagsIndex->{
  {"S5.5.1", 12109, 390},
  {"1.1", 13829, 437},
  {"1.2", 13922, 440},
  {"1.3", 14011, 443},
  {"1.4", 14101, 446},
  {"1.5", 14195, 449},
  {"1.6", 14289, 452},
  {"1.7", 14383, 455},
  {"1.8", 14478, 458},
  {"1.9", 14573, 461},
  {"1.10", 14670, 464}
  }
*)

(*NotebookFileOutline
Notebook[{
Cell[1717, 49, 149, 6, 70, "Subsection",
  CellTags->{"S5.5.1", "1.1"}],
Cell[1869, 57, 3162, 93, 70, "Text",
  CellTags->{"S5.5.1", "1.2"}],
Cell[5034, 152, 2899, 69, 70, "Text",
  CellTags->{"S5.5.1", "1.3"}],
Cell[7936, 223, 76, 1, 70, "Caption",
  CellTags->"S5.5.1"],
Cell[8015, 226, 78, 1, 70, "MathCaption",
  CellTags->{"S5.5.1", "1.4"}],
Cell[8096, 229, 96, 2, 70, "Input",
  CellTags->"S5.5.1"],
Cell[8195, 233, 98, 1, 70, "MathCaption",
  CellTags->{"S5.5.1", "1.5"}],

Cell[CellGroupData[{
Cell[8318, 238, 145, 5, 70, "Input",
  CellTags->"S5.5.1"],
Cell[8466, 245, 96, 3, 70, "Output",
  CellTags->"S5.5.1"]
}, Open  ]],
Cell[8577, 251, 99, 1, 70, "MathCaption",
  CellTags->{"S5.5.1", "1.6"}],

Cell[CellGroupData[{
Cell[8701, 256, 133, 5, 70, "Input",
  CellTags->"S5.5.1"],
Cell[8837, 263, 101, 3, 70, "Output",
  CellTags->"S5.5.1"]
}, Open  ]],
Cell[8953, 269, 138, 5, 70, "MathCaption",
  CellTags->{"S5.5.1", "1.7"}],
Cell[9094, 276, 87, 2, 70, "Input",
  CellTags->"S5.5.1"],
Cell[9184, 280, 140, 5, 70, "MathCaption",
  CellTags->{"S5.5.1", "1.8"}],

Cell[CellGroupData[{
Cell[9349, 289, 171, 6, 70, "Input",
  CellTags->"S5.5.1"],
Cell[9523, 297, 735, 24, 70, "Output",
  CellTags->"S5.5.1"]
}, Open  ]],
Cell[10273, 324, 308, 9, 70, "MathCaption",
  CellTags->{"S5.5.1", "1.9"}],

Cell[CellGroupData[{
Cell[10606, 337, 161, 5, 70, "Input",
  CellTags->"S5.5.1"],
Cell[10770, 344, 82, 3, 70, "Output",
  CellTags->"S5.5.1"]
}, Open  ]],
Cell[10867, 350, 111, 1, 70, "MathCaption",
  CellTags->{"S5.5.1", "1.10"}],

Cell[CellGroupData[{
Cell[11003, 355, 183, 7, 70, "Input",
  CellTags->"S5.5.1"],
Cell[11189, 364, 280, 6, 70, "Output",
  CellTags->"S5.5.1"]
}, Open  ]]
}
]
*)




(***********************************************************************
End of Mathematica Notebook file.
***********************************************************************)

