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

                    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[     10071,        292]*)
(*NotebookOutlinePosition[     14092,        418]*)
(*  CellTagsIndexPosition[     13740,        400]*)
(*WindowFrame->Normal*)



Notebook[{
Cell[TextData[{
  "NumericalMath",
  StyleBox["`", "MB"],
  "NewtonCotes",
  StyleBox["`", "MB"]
}], "Subsection",
  CellTags->{"S5.89.1", "1.1"}],

Cell[TextData[{
  "As one of its methods, the ",
  StyleBox["Mathematica", "TI"],
  " function ",
  StyleBox["NIntegrate", "MR"],
  " uses a fairly sophisticated Gauss\[Hyphen]Kronrod based algorithm. Other \
types of quadrature formulas exist, each with their own advantages. For \
example, Gaussian quadrature uses values of the integrand at oddly spaced \
abscissas. If you want to integrate a function presented in tabular form at \
equally spaced abscissas, it won't work very well. An alternative is to use \
Newton\[Hyphen]Cotes quadrature. \nThe basic idea behind Newton\[Hyphen]Cotes \
quadrature is to approximate the value of an integral as a linear combination \
of values of the integrand evaluated at equally spaced points: "
}], "Text",
  CellTags->{"S5.89.1", "1.2"}],

Cell[BoxData[
    FormBox[
      RowBox[{\(\[Integral]\_a\%b\), "f", \((x)\), "\[DifferentialD]", "x", 
        "=", 
        UnderoverscriptBox["\[Sum]", \(i = 1\), "n",
          LimitsPositioning->False], \(w\_i\), "f", \((x\_i)\)}], 
      TraditionalForm]], "DisplayFormula",
  CellTags->{"S5.89.1", "1.3"}],

Cell[TextData[{
  "In addition, there is the question of whether or not to include the end \
points in the sum. If they are included, the quadrature formula is referred \
to as a closed formula. If not, it is an open formula. If the formula is open \
there is some ambiguity as to where the first abscissa is to be placed. The \
open formulas given in this package have the first abscissa one half step \
from the lower end point. \nSince there are ",
  Cell[BoxData[
      \(TraditionalForm\`n\)], "InlineFormula"],
  " free parameters to be chosen (the weights) and since both integration and \
the sum are linear operations, you can expect to be able to make the formula \
correct for all polynomials of degree less than about ",
  Cell[BoxData[
      \(TraditionalForm\`n\)], "InlineFormula"],
  ". In addition to knowing what the weights are, it is often desirable to \
know how large the error in the approximation will be. This package allows \
you to answer both of these questions. "
}], "Text",
  CellTags->{"S5.89.1", "1.4"}],

Cell[BoxData[
    FormBox[
      StyleBox[
        FrameBox[
          StyleBox[GridBox[{
                {"\<\"\\!\\(\\*StyleBox[\\\"\\\\\\\"NewtonCotesWeights[\\\\\\\
\"\\\", \\\"MR\\\"]\\)\\!\\(\\*StyleBox[\\\"\\\\\\\"n\\\\\\\"\\\", \
\\\"TI\\\"]\\)\\!\\(\\*StyleBox[\\\"\\\\\\\",\\\\\\\"\\\", \\\"MR\\\"]\\) \\!\
\\(\\*StyleBox[\\\"\\\\\\\"a\\\\\\\"\\\", \
\\\"TI\\\"]\\)\\!\\(\\*StyleBox[\\\"\\\\\\\",\\\\\\\"\\\", \\\"MR\\\"]\\) \\!\
\\(\\*StyleBox[\\\"\\\\\\\"b\\\\\\\"\\\", \
\\\"TI\\\"]\\)\\!\\(\\*StyleBox[\\\"\\\\\\\"]\\\\\\\"\\\", \\\"MR\\\"]\\) \
\"\>", 
                  RowBox[{"\<\"give a list of the \"\>", 
                    StyleBox["n",
                      "InlineFormula"], "\<\" pairs \"\>", 
                    StyleBox[\((w\_i, x\_i)\),
                      
                      "InlineFormula"], "\<\" for quadrature on the interval \
\\!\\(\\*StyleBox[\\\"\\\\\\\"a\\\\\\\"\\\", \\\"TI\\\"]\\) to \
\\!\\(\\*StyleBox[\\\"\\\\\\\"b\\\\\\\"\\\", \\\"TI\\\"]\\)\"\>"}]},
                {"\<\"\\!\\(\\*StyleBox[\\\"\\\\\\\"NewtonCotesError[\\\\\\\"\
\\\", \\\"MR\\\"]\\)\\!\\(\\*StyleBox[\\\"\\\\\\\"n\\\\\\\"\\\", \
\\\"TI\\\"]\\)\\!\\(\\*StyleBox[\\\"\\\\\\\",\\\\\\\"\\\", \\\"MR\\\"]\\) \\!\
\\(\\*StyleBox[\\\"\\\\\\\"f\\\\\\\"\\\", \
\\\"TI\\\"]\\)\\!\\(\\*StyleBox[\\\"\\\\\\\",\\\\\\\"\\\", \\\"MR\\\"]\\) \\!\
\\(\\*StyleBox[\\\"\\\\\\\"a\\\\\\\"\\\", \
\\\"TI\\\"]\\)\\!\\(\\*StyleBox[\\\"\\\\\\\",\\\\\\\"\\\", \\\"MR\\\"]\\) \\!\
\\(\\*StyleBox[\\\"\\\\\\\"b\\\\\\\"\\\", \
\\\"TI\\\"]\\)\\!\\(\\*StyleBox[\\\"\\\\\\\"]\\\\\\\"\\\", \\\"MR\\\"]\\) \
\"\>", "\<\"give the error in the formula\"\>"}
                },
              ColumnAlignments->{Right, Left}],
            GridBoxOptions->{RowLines->False}]],
        "2ColumnBox"], TraditionalForm]], "Text",
  CellTags->{"S5.89.1", "1.5"}],

Cell["Finding formulas for Newton\[Hyphen]Cotes quadrature. ", "Caption",
  CellTags->"S5.89.1"],

Cell[BoxData[
    FormBox[
      StyleBox[
        FrameBox[
          StyleBox[GridBox[{
                {"\<\"\\!\\(\\*StyleBox[\\\"\\\\\\\"option name\\\\\\\"\\\", \
\\\"TI\\\"]\\) \"\>", "\<\"\\!\\(\\*StyleBox[\\\"\\\\\\\"default \
value\\\\\\\"\\\", \\\"TI\\\"]\\) \"\>", "\[Null]"},
                {"\<\"\\!\\(\\*StyleBox[\\\"\\\\\\\"QuadratureType\\\\\\\"\\\"\
, \\\"MR\\\"]\\) \"\>", \
"\<\"\\!\\(\\*StyleBox[\\\"\\\\\\\"Closed\\\\\\\"\\\", \\\"MR\\\"]\\) \"\>", \
"\<\"the type of quadrature, \\!\\(\\*StyleBox[\\\"\\\\\\\"Open\\\\\\\"\\\", \
\\\"MR\\\"]\\) or \\!\\(\\*StyleBox[\\\"\\\\\\\"Closed\\\\\\\"\\\", \
\\\"MR\\\"]\\)\"\>"}
                },
              ColumnAlignments->{Left}],
            GridBoxOptions->{RowLines->True}]],
        "3ColumnBox"], TraditionalForm]], "Text",
  CellTags->{"S5.89.1", "1.6"}],

Cell[TextData[{
  "Option for ",
  StyleBox["NewtonCotesWeights", "MR"],
  " and ",
  StyleBox["NewtonCotesError", "MR"],
  "."
}], "Caption",
  CellTags->"S5.89.1"],

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

Cell["<<NumericalMath`NewtonCotes`", "Input",
  CellLabel->"In[1]:= ",
  CellTags->"S5.89.1"],

Cell[TextData[{
  "Here are the weights and abscissas for the five\[Hyphen]point closed \
Newton\[Hyphen]Cotes quadrature formula on the interval ",
  Cell[BoxData[
      \(TraditionalForm\`\((\(-3\), 7)\)\)], "InlineFormula"],
  ". "
}], "MathCaption",
  CellTags->{"S5.89.1", "1.8"}],

Cell[CellGroupData[{

Cell["NewtonCotesWeights[5, -3, 7]", "Input",
  CellLabel->"In[2]:= ",
  CellTags->"S5.89.1"],

Cell[BoxData[
    \({{\(-3\), 7\/9}, {\(-\(1\/2\)\), 32\/9}, {2, 4\/3}, {9\/2, 32\/9}, {7, 
        7\/9}}\)], "Output",
  CellLabel->"Out[2]= ",
  CellTags->"S5.89.1"]
}, Open  ]],

Cell[TextData[{
  "Here is the error in that formula. Unfortunately it involves the sixth \
derivative of ",
  Cell[BoxData[
      \(TraditionalForm\`f\)], "InlineFormula"],
  " at an unknown point so you don't really know what the error itself is. "
}], "MathCaption",
  CellTags->{"S5.89.1", "1.9"}],

Cell[CellGroupData[{

Cell["NewtonCotesError[5, f, -3, 7]", "Input",
  CellLabel->"In[3]:= ",
  CellTags->"S5.89.1"],

Cell[BoxData[
    FractionBox[
      RowBox[{"15625", " ", 
        SuperscriptBox["f", 
          TagBox[\((6)\),
            Derivative],
          MultilineFunction->None]}], "3024"]], "Output",
  CellLabel->"Out[3]= ",
  CellTags->"S5.89.1"]
}, Open  ]],

Cell["\<\
You can see that the error decreases rapidly with the length of the \
interval. \
\>", "MathCaption",
  CellTags->{"S5.89.1", "1.10"}],

Cell[CellGroupData[{

Cell["NewtonCotesError[5, f, a, a+h]", "Input",
  CellLabel->"In[4]:= ",
  CellTags->"S5.89.1"],

Cell[BoxData[
    FractionBox[
      RowBox[{\(h\^7\), " ", 
        SuperscriptBox["f", 
          TagBox[\((6)\),
            Derivative],
          MultilineFunction->None]}], "1935360"]], "Output",
  CellLabel->"Out[4]= ",
  CellTags->"S5.89.1"]
}, Open  ]],

Cell[TextData[{
  "This gives the weights and abscissas for the five\[Hyphen]point open \
Newton\[Hyphen]Cotes quadrature formula on the interval (",
  Cell[BoxData[
      \(TraditionalForm\`-\)], "InlineFormula"],
  "3, 7). "
}], "MathCaption",
  CellTags->{"S5.89.1", "1.11"}],

Cell[CellGroupData[{

Cell["NewtonCotesWeights[5, -3, 7, QuadratureType -> Open]", "Input",
  CellLabel->"In[5]:= ",
  CellTags->"S5.89.1"],

Cell[BoxData[
    \({{\(-2\), 1375\/576}, {0, 125\/144}, {2, 335\/96}, {4, 125\/144}, {6, 
        1375\/576}}\)], "Output",
  CellLabel->"Out[5]= ",
  CellTags->"S5.89.1"]
}, Open  ]],

Cell["Here is the error in that formula. ", "MathCaption",
  CellTags->{"S5.89.1", "1.12"}],

Cell[CellGroupData[{

Cell["NewtonCotesError[5, f, -3, 7, QuadratureType -> Open]", "Input",
  CellLabel->"In[6]:= ",
  CellTags->"S5.89.1"],

Cell[BoxData[
    RowBox[{"-", 
      FractionBox[
        RowBox[{"5575", " ", 
          SuperscriptBox["f", 
            TagBox[\((6)\),
              Derivative],
            MultilineFunction->None]}], "1512"]}]], "Output",
  CellLabel->"Out[6]= ",
  CellTags->"S5.89.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.89.1"->{
    Cell[1717, 49, 146, 6, 70, "Subsection",
      CellTags->{"S5.89.1", "1.1"}],
    Cell[1866, 57, 783, 14, 70, "Text",
      CellTags->{"S5.89.1", "1.2"}],
    Cell[2652, 73, 312, 7, 70, "DisplayFormula",
      CellTags->{"S5.89.1", "1.3"}],
    Cell[2967, 82, 1036, 18, 70, "Text",
      CellTags->{"S5.89.1", "1.4"}],
    Cell[4006, 102, 1839, 35, 70, "Text",
      CellTags->{"S5.89.1", "1.5"}],
    Cell[5848, 139, 96, 1, 70, "Caption",
      CellTags->"S5.89.1"],
    Cell[5947, 142, 833, 18, 70, "Text",
      CellTags->{"S5.89.1", "1.6"}],
    Cell[6783, 162, 165, 7, 70, "Caption",
      CellTags->"S5.89.1"],
    Cell[6951, 171, 79, 1, 70, "MathCaption",
      CellTags->{"S5.89.1", "1.7"}],
    Cell[7033, 174, 93, 2, 70, "Input",
      CellTags->"S5.89.1"],
    Cell[7129, 178, 285, 7, 70, "MathCaption",
      CellTags->{"S5.89.1", "1.8"}],
    Cell[7439, 189, 93, 2, 70, "Input",
      CellTags->"S5.89.1"],
    Cell[7535, 193, 168, 4, 70, "Output",
      CellTags->"S5.89.1"],
    Cell[7718, 200, 301, 7, 70, "MathCaption",
      CellTags->{"S5.89.1", "1.9"}],
    Cell[8044, 211, 94, 2, 70, "Input",
      CellTags->"S5.89.1"],
    Cell[8141, 215, 245, 8, 70, "Output",
      CellTags->"S5.89.1"],
    Cell[8401, 226, 144, 4, 70, "MathCaption",
      CellTags->{"S5.89.1", "1.10"}],
    Cell[8570, 234, 95, 2, 70, "Input",
      CellTags->"S5.89.1"],
    Cell[8668, 238, 249, 8, 70, "Output",
      CellTags->"S5.89.1"],
    Cell[8932, 249, 278, 7, 70, "MathCaption",
      CellTags->{"S5.89.1", "1.11"}],
    Cell[9235, 260, 117, 2, 70, "Input",
      CellTags->"S5.89.1"],
    Cell[9355, 264, 172, 4, 70, "Output",
      CellTags->"S5.89.1"],
    Cell[9542, 271, 91, 1, 70, "MathCaption",
      CellTags->{"S5.89.1", "1.12"}],
    Cell[9658, 276, 118, 2, 70, "Input",
      CellTags->"S5.89.1"],
    Cell[9779, 280, 276, 9, 70, "Output",
      CellTags->"S5.89.1"]},
  "1.1"->{
    Cell[1717, 49, 146, 6, 70, "Subsection",
      CellTags->{"S5.89.1", "1.1"}]},
  "1.2"->{
    Cell[1866, 57, 783, 14, 70, "Text",
      CellTags->{"S5.89.1", "1.2"}]},
  "1.3"->{
    Cell[2652, 73, 312, 7, 70, "DisplayFormula",
      CellTags->{"S5.89.1", "1.3"}]},
  "1.4"->{
    Cell[2967, 82, 1036, 18, 70, "Text",
      CellTags->{"S5.89.1", "1.4"}]},
  "1.5"->{
    Cell[4006, 102, 1839, 35, 70, "Text",
      CellTags->{"S5.89.1", "1.5"}]},
  "1.6"->{
    Cell[5947, 142, 833, 18, 70, "Text",
      CellTags->{"S5.89.1", "1.6"}]},
  "1.7"->{
    Cell[6951, 171, 79, 1, 70, "MathCaption",
      CellTags->{"S5.89.1", "1.7"}]},
  "1.8"->{
    Cell[7129, 178, 285, 7, 70, "MathCaption",
      CellTags->{"S5.89.1", "1.8"}]},
  "1.9"->{
    Cell[7718, 200, 301, 7, 70, "MathCaption",
      CellTags->{"S5.89.1", "1.9"}]},
  "1.10"->{
    Cell[8401, 226, 144, 4, 70, "MathCaption",
      CellTags->{"S5.89.1", "1.10"}]},
  "1.11"->{
    Cell[8932, 249, 278, 7, 70, "MathCaption",
      CellTags->{"S5.89.1", "1.11"}]},
  "1.12"->{
    Cell[9542, 271, 91, 1, 70, "MathCaption",
      CellTags->{"S5.89.1", "1.12"}]}
  }
*)

(*CellTagsIndex
CellTagsIndex->{
  {"S5.89.1", 10696, 309},
  {"1.1", 12594, 360},
  {"1.2", 12688, 363},
  {"1.3", 12777, 366},
  {"1.4", 12875, 369},
  {"1.5", 12965, 372},
  {"1.6", 13056, 375},
  {"1.7", 13146, 378},
  {"1.8", 13241, 381},
  {"1.9", 13337, 384},
  {"1.10", 13434, 387},
  {"1.11", 13532, 390},
  {"1.12", 13630, 393}
  }
*)

(*NotebookFileOutline
Notebook[{
Cell[1717, 49, 146, 6, 70, "Subsection",
  CellTags->{"S5.89.1", "1.1"}],
Cell[1866, 57, 783, 14, 70, "Text",
  CellTags->{"S5.89.1", "1.2"}],
Cell[2652, 73, 312, 7, 70, "DisplayFormula",
  CellTags->{"S5.89.1", "1.3"}],
Cell[2967, 82, 1036, 18, 70, "Text",
  CellTags->{"S5.89.1", "1.4"}],
Cell[4006, 102, 1839, 35, 70, "Text",
  CellTags->{"S5.89.1", "1.5"}],
Cell[5848, 139, 96, 1, 70, "Caption",
  CellTags->"S5.89.1"],
Cell[5947, 142, 833, 18, 70, "Text",
  CellTags->{"S5.89.1", "1.6"}],
Cell[6783, 162, 165, 7, 70, "Caption",
  CellTags->"S5.89.1"],
Cell[6951, 171, 79, 1, 70, "MathCaption",
  CellTags->{"S5.89.1", "1.7"}],
Cell[7033, 174, 93, 2, 70, "Input",
  CellTags->"S5.89.1"],
Cell[7129, 178, 285, 7, 70, "MathCaption",
  CellTags->{"S5.89.1", "1.8"}],

Cell[CellGroupData[{
Cell[7439, 189, 93, 2, 70, "Input",
  CellTags->"S5.89.1"],
Cell[7535, 193, 168, 4, 70, "Output",
  CellTags->"S5.89.1"]
}, Open  ]],
Cell[7718, 200, 301, 7, 70, "MathCaption",
  CellTags->{"S5.89.1", "1.9"}],

Cell[CellGroupData[{
Cell[8044, 211, 94, 2, 70, "Input",
  CellTags->"S5.89.1"],
Cell[8141, 215, 245, 8, 70, "Output",
  CellTags->"S5.89.1"]
}, Open  ]],
Cell[8401, 226, 144, 4, 70, "MathCaption",
  CellTags->{"S5.89.1", "1.10"}],

Cell[CellGroupData[{
Cell[8570, 234, 95, 2, 70, "Input",
  CellTags->"S5.89.1"],
Cell[8668, 238, 249, 8, 70, "Output",
  CellTags->"S5.89.1"]
}, Open  ]],
Cell[8932, 249, 278, 7, 70, "MathCaption",
  CellTags->{"S5.89.1", "1.11"}],

Cell[CellGroupData[{
Cell[9235, 260, 117, 2, 70, "Input",
  CellTags->"S5.89.1"],
Cell[9355, 264, 172, 4, 70, "Output",
  CellTags->"S5.89.1"]
}, Open  ]],
Cell[9542, 271, 91, 1, 70, "MathCaption",
  CellTags->{"S5.89.1", "1.12"}],

Cell[CellGroupData[{
Cell[9658, 276, 118, 2, 70, "Input",
  CellTags->"S5.89.1"],
Cell[9779, 280, 276, 9, 70, "Output",
  CellTags->"S5.89.1"]
}, Open  ]]
}
]
*)




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

