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

                    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[     10460,        308]*)
(*NotebookOutlinePosition[     13918,        418]*)
(*  CellTagsIndexPosition[     13590,        401]*)
(*WindowFrame->Normal*)



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

Cell[TextData[{
  "The ",
  StyleBox["Mathematica", "TI"],
  " function ",
  StyleBox["NIntegrate", "MR"],
  " computes a numerical approximation to a definite integral. However, if \
you want to evaluate the Cauchy principal value of an integral, ",
  StyleBox["NIntegrate", "MR"],
  " cannot be used directly. To find the Cauchy principal value, you should \
use instead ",
  StyleBox["CauchyPrincipalValue", "MR"],
  ". "
}], "Text",
  CellTags->{"S5.78.1", "1.2"}],

Cell[BoxData[
    FormBox[
      StyleBox[
        FrameBox[
          StyleBox[GridBox[{
                {
                  
                  RowBox[{"\<\"\\!\\(\\*StyleBox[\\\"\\\\\\\"\
CauchyPrincipalValue[\\\\\\\"\\\", \\\"MR\\\"]\\)\\!\\(\\*StyleBox[\\\"\\\\\\\
\"f\\\\\\\"\\\", \\\"TI\\\"]\\)\\!\\(\\*StyleBox[\\\"\\\\\\\",\\\\\\\"\\\", \
\\\"MR\\\"]\\) \"\>", 
                    StyleBox["{",
                      
                      "InlineFormula"], \
"\<\"\\!\\(\\*StyleBox[\\\"\\\\\\\"x\\\\\\\"\\\", \
\\\"TI\\\"]\\)\\!\\(\\*StyleBox[\\\"\\\\\\\",\\\\\\\"\\\", \\\"MR\\\"]\\) \\!\
\\(\\*StyleBox[\\\"\\\\\\\"a\\\\\\\"\\\", \
\\\"TI\\\"]\\)\\!\\(\\*StyleBox[\\\"\\\\\\\",\\\\\\\"\\\", \\\"MR\\\"]\\) \
\"\>", 
                    StyleBox["{",
                      
                      "InlineFormula"], \
"\<\"\\!\\(\\*StyleBox[\\\"\\\\\\\"b\\\\\\\"\\\", \\\"TI\\\"]\\)\"\>", 
                    StyleBox["}",
                      
                      "InlineFormula"], \
"\<\"\\!\\(\\*StyleBox[\\\"\\\\\\\",\\\\\\\"\\\", \\\"MR\\\"]\\) \
\\!\\(\\*StyleBox[\\\"\\\\\\\"c\\\\\\\"\\\", \\\"TI\\\"]\\)\"\>", 
                    StyleBox["}",
                      
                      "InlineFormula"], \
"\<\"\\!\\(\\*StyleBox[\\\"\\\\\\\",\\\\\\\"\\\", \\\"MR\\\"]\\) \
\\!\\(\\*StyleBox[\\\"\\\\\\\"options\\\\\\\"\\\", \
\\\"TI\\\"]\\)\\!\\(\\*StyleBox[\\\"\\\\\\\"]\\\\\\\"\\\", \\\"MR\\\"]\\) \
\"\>"}], 
                  
                  RowBox[{"\<\"numerically find the Cauchy principal value of \
the integral \"\>", 
                    StyleBox[\(\[Integral]\_a\%c f \[DifferentialD]x\),
                      
                      "InlineFormula"], "\<\" which has a nonintegrable \
singularity at \"\>", 
                    StyleBox[\(x = b\),
                      "InlineFormula"]}]},
                {
                  
                  RowBox[{"\<\"\\!\\(\\*StyleBox[\\\"\\\\\\\"\
CauchyPrincipalValue[\\\\\\\"\\\", \\\"MR\\\"]\\)\\!\\(\\*StyleBox[\\\"\\\\\\\
\"f\\\\\\\"\\\", \\\"TI\\\"]\\)\\!\\(\\*StyleBox[\\\"\\\\\\\",\\\\\\\"\\\", \
\\\"MR\\\"]\\) \"\>", 
                    StyleBox["{",
                      
                      "InlineFormula"], \
"\<\"\\!\\(\\*StyleBox[\\\"\\\\\\\"x\\\\\\\"\\\", \
\\\"TI\\\"]\\)\\!\\(\\*StyleBox[\\\"\\\\\\\",\\\\\\\"\\\", \\\"MR\\\"]\\) \\!\
\\(\\*StyleBox[\\\"\\\\\\\"a\\\\\\\"\\\", \
\\\"TI\\\"]\\)\\!\\(\\*StyleBox[\\\"\\\\\\\",\\\\\\\"\\\", \\\"MR\\\"]\\) \
\"\>", 
                    StyleBox["{",
                      
                      "InlineFormula"], \
"\<\"\\!\\(\\*StyleBox[\\\"\\\\\\\"b\\\\\\\"\\\", \
\\\"TI\\\"]\\)\\!\\(\\*StyleBox[\\\"\\\\\\\",\\\\\\\"\\\", \\\"MR\\\"]\\) \\!\
\\(\\*StyleBox[\\\"\\\\\\\"eps\\\\\\\"\\\", \\\"TI\\\"]\\)\"\>", 
                    StyleBox["}",
                      
                      "InlineFormula"], \
"\<\"\\!\\(\\*StyleBox[\\\"\\\\\\\",\\\\\\\"\\\", \\\"MR\\\"]\\) \
\\!\\(\\*StyleBox[\\\"\\\\\\\"c\\\\\\\"\\\", \\\"TI\\\"]\\)\"\>", 
                    StyleBox["}",
                      
                      "InlineFormula"], \
"\<\"\\!\\(\\*StyleBox[\\\"\\\\\\\",\\\\\\\"\\\", \\\"MR\\\"]\\) \
\\!\\(\\*StyleBox[\\\"\\\\\\\"options\\\\\\\"\\\", \
\\\"TI\\\"]\\)\\!\\(\\*StyleBox[\\\"\\\\\\\"]\\\\\\\"\\\", \\\"MR\\\"]\\) \
\"\>"}], 
                  
                  RowBox[{"\<\"find the Cauchy principal value by integrating \
from \"\>", 
                    StyleBox["a",
                      "InlineFormula"], "\<\" to \"\>", 
                    StyleBox[\(b - \[Epsilon]\),
                      "InlineFormula"], "\<\" and from \"\>", 
                    StyleBox[\(b + \[Epsilon]\),
                      "InlineFormula"], "\<\" to \"\>", 
                    StyleBox["c",
                      
                      "InlineFormula"], "\<\" and exploiting symmetry on the \
interval from \"\>", 
                    StyleBox[\(b - \[Epsilon]\),
                      "InlineFormula"], "\<\" to \"\>", 
                    StyleBox[\(b + \[Epsilon]\),
                      "InlineFormula"]}]}
                },
              ColumnAlignments->{Right, Left}],
            GridBoxOptions->{RowLines->False}]],
        "2ColumnBox"], TraditionalForm]], "Text",
  CellTags->{"S5.78.1", "1.3"}],

Cell["Finding the Cauchy principal value of an integral. ", "Caption",
  CellTags->"S5.78.1"],

Cell[TextData[{
  StyleBox["CauchyPrincipalValue", "MR"],
  " works by using ",
  StyleBox["NIntegrate", "MR"],
  " directly on those regions where there is no difficulty and by pairing \
values symmetrically about the specified singularities in order to take \
advantage of the cancellation of the positive and negative values. Thus ",
  StyleBox["CauchyPrincipalValue[f[x],{x,", "MR"],
  " ",
  StyleBox["a,", "MR"],
  " ",
  StyleBox["{b,", "MR"],
  " ",
  StyleBox["eps},", "MR"],
  " ",
  StyleBox["c}]", "MR"],
  " is evaluated as "
}], "Text",
  CellTags->{"S5.78.1", "1.4"}],

Cell[BoxData[
    \(TraditionalForm\`\[Integral]\_a\%\(b - \[Epsilon]\)f \((x)\) \
\[DifferentialD]x + \[Integral]\_0\%\[Epsilon]\((f \((b + t)\) + 
          f \((b - 
              t)\))\) \[DifferentialD]t + \[Integral]\_\(b + \[Epsilon]\)\%c 
      f \((x)\) \[DifferentialD]x\)], "DisplayFormula",
  CellTags->{"S5.78.1", "1.5"}],

Cell[TextData[{
  "where each of the integrals is evaluated using ",
  StyleBox["NIntegrate", "MR"],
  ". If ",
  Cell[BoxData[
      \(TraditionalForm\`\[Epsilon]\)], "InlineFormula"],
  " is not given explicitly, a value is chosen based upon the differences ",
  Cell[BoxData[
      \(TraditionalForm\`b - a\)], "InlineFormula"],
  " and ",
  Cell[BoxData[
      \(TraditionalForm\`c - b\)], "InlineFormula"],
  ". The options to ",
  StyleBox["CauchyPrincipalValue", "MR"],
  " are simply passed directly to ",
  StyleBox["NIntegrate", "MR"],
  "; ",
  StyleBox["CauchyPrincipalValue", "MR"],
  " itself does not make any use of them. "
}], "Text",
  CellTags->{"S5.78.1", "1.6"}],

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

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

Cell[TextData[{
  "This finds the Cauchy principal value of ",
  Cell[BoxData[
      \(TraditionalForm\`\[Integral]\_\(\(-1\)/2\)\%1\( 
            1\/\(x + x\^2\)\) \[DifferentialD]x\)], "InlineFormula"],
  ". "
}], "MathCaption",
  CellTags->{"S5.78.1", "1.8"}],

Cell[CellGroupData[{

Cell["\<\
CauchyPrincipalValue[1/(x+x^2), {x, -1/2,
 {0}, 1}]\
\>", "Input",
  CellLabel->"In[2]:= ",
  CellTags->"S5.78.1"],

Cell[BoxData[
    \(\(-0.6931471805596516`\)\)], "Output",
  CellLabel->"Out[2]= ",
  CellTags->"S5.78.1"]
}, Open  ]],

Cell[TextData[{
  "Here is the Cauchy principal value of ",
  Cell[BoxData[
      \(TraditionalForm\`\[Integral]\_\(-2\)\%1\( 
            1\/\(x + x\^2\)\) \[DifferentialD]x\)], "InlineFormula"],
  ". Note that there are two singularities that need to be specified. "
}], "MathCaption",
  CellTags->{"S5.78.1", "1.9"}],

Cell[CellGroupData[{

Cell["\<\
CauchyPrincipalValue[1/(x+x^2), {x, -2, {-1},
 {0}, 1}]\
\>", "Input",
  CellLabel->"In[3]:= ",
  CellTags->"S5.78.1"],

Cell[BoxData[
    \(\(-1.386294361119086`\)\)], "Output",
  CellLabel->"Out[3]= ",
  CellTags->"S5.78.1"]
}, Open  ]],

Cell["\<\
This checks the value. The result would be 0 if everything were \
done exactly. \
\>", "MathCaption",
  CellTags->{"S5.78.1", "1.10"}],

Cell[CellGroupData[{

Cell["% + 2 Log[2.]", "Input",
  CellLabel->"In[4]:= ",
  CellTags->"S5.78.1"],

Cell[BoxData[
    \(8.044676036433884`*^-13\)], "Output",
  CellLabel->"Out[4]= ",
  CellTags->"S5.78.1"]
}, Open  ]],

Cell[TextData[{
  "It should be noted that the singularities must be located exactly. Because \
the points on both sides of the singularity are paired together in the \
algorithm, if the singularity is slightly mislocated the cancellation will \
not be sufficiently good near the pole and the result can be significantly in \
error if ",
  StyleBox["NIntegrate", "MR"],
  " converges at all. "
}], "Text",
  CellTags->{"S5.78.1", "1.11"}]
},
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.78.1"->{
    Cell[1717, 49, 155, 6, 70, "Subsection",
      CellTags->{"S5.78.1", "1.1"}],
    Cell[1875, 57, 468, 13, 70, "Text",
      CellTags->{"S5.78.1", "1.2"}],
    Cell[2346, 72, 4277, 97, 70, "Text",
      CellTags->{"S5.78.1", "1.3"}],
    Cell[6626, 171, 93, 1, 70, "Caption",
      CellTags->"S5.78.1"],
    Cell[6722, 174, 582, 18, 70, "Text",
      CellTags->{"S5.78.1", "1.4"}],
    Cell[7307, 194, 334, 6, 70, "DisplayFormula",
      CellTags->{"S5.78.1", "1.5"}],
    Cell[7644, 202, 683, 20, 70, "Text",
      CellTags->{"S5.78.1", "1.6"}],
    Cell[8330, 224, 79, 1, 70, "MathCaption",
      CellTags->{"S5.78.1", "1.7"}],
    Cell[8412, 227, 102, 2, 70, "Input",
      CellTags->"S5.78.1"],
    Cell[8517, 231, 263, 7, 70, "MathCaption",
      CellTags->{"S5.78.1", "1.8"}],
    Cell[8805, 242, 124, 5, 70, "Input",
      CellTags->"S5.78.1"],
    Cell[8932, 249, 106, 3, 70, "Output",
      CellTags->"S5.78.1"],
    Cell[9053, 255, 319, 7, 70, "MathCaption",
      CellTags->{"S5.78.1", "1.9"}],
    Cell[9397, 266, 128, 5, 70, "Input",
      CellTags->"S5.78.1"],
    Cell[9528, 273, 105, 3, 70, "Output",
      CellTags->"S5.78.1"],
    Cell[9648, 279, 144, 4, 70, "MathCaption",
      CellTags->{"S5.78.1", "1.10"}],
    Cell[9817, 287, 78, 2, 70, "Input",
      CellTags->"S5.78.1"],
    Cell[9898, 291, 105, 3, 70, "Output",
      CellTags->"S5.78.1"],
    Cell[10018, 297, 438, 9, 70, "Text",
      CellTags->{"S5.78.1", "1.11"}]},
  "1.1"->{
    Cell[1717, 49, 155, 6, 70, "Subsection",
      CellTags->{"S5.78.1", "1.1"}]},
  "1.2"->{
    Cell[1875, 57, 468, 13, 70, "Text",
      CellTags->{"S5.78.1", "1.2"}]},
  "1.3"->{
    Cell[2346, 72, 4277, 97, 70, "Text",
      CellTags->{"S5.78.1", "1.3"}]},
  "1.4"->{
    Cell[6722, 174, 582, 18, 70, "Text",
      CellTags->{"S5.78.1", "1.4"}]},
  "1.5"->{
    Cell[7307, 194, 334, 6, 70, "DisplayFormula",
      CellTags->{"S5.78.1", "1.5"}]},
  "1.6"->{
    Cell[7644, 202, 683, 20, 70, "Text",
      CellTags->{"S5.78.1", "1.6"}]},
  "1.7"->{
    Cell[8330, 224, 79, 1, 70, "MathCaption",
      CellTags->{"S5.78.1", "1.7"}]},
  "1.8"->{
    Cell[8517, 231, 263, 7, 70, "MathCaption",
      CellTags->{"S5.78.1", "1.8"}]},
  "1.9"->{
    Cell[9053, 255, 319, 7, 70, "MathCaption",
      CellTags->{"S5.78.1", "1.9"}]},
  "1.10"->{
    Cell[9648, 279, 144, 4, 70, "MathCaption",
      CellTags->{"S5.78.1", "1.10"}]},
  "1.11"->{
    Cell[10018, 297, 438, 9, 70, "Text",
      CellTags->{"S5.78.1", "1.11"}]}
  }
*)

(*CellTagsIndex
CellTagsIndex->{
  {"S5.78.1", 11085, 325},
  {"1.1", 12547, 364},
  {"1.2", 12641, 367},
  {"1.3", 12730, 370},
  {"1.4", 12820, 373},
  {"1.5", 12910, 376},
  {"1.6", 13009, 379},
  {"1.7", 13099, 382},
  {"1.8", 13194, 385},
  {"1.9", 13290, 388},
  {"1.10", 13387, 391},
  {"1.11", 13485, 394}
  }
*)

(*NotebookFileOutline
Notebook[{
Cell[1717, 49, 155, 6, 70, "Subsection",
  CellTags->{"S5.78.1", "1.1"}],
Cell[1875, 57, 468, 13, 70, "Text",
  CellTags->{"S5.78.1", "1.2"}],
Cell[2346, 72, 4277, 97, 70, "Text",
  CellTags->{"S5.78.1", "1.3"}],
Cell[6626, 171, 93, 1, 70, "Caption",
  CellTags->"S5.78.1"],
Cell[6722, 174, 582, 18, 70, "Text",
  CellTags->{"S5.78.1", "1.4"}],
Cell[7307, 194, 334, 6, 70, "DisplayFormula",
  CellTags->{"S5.78.1", "1.5"}],
Cell[7644, 202, 683, 20, 70, "Text",
  CellTags->{"S5.78.1", "1.6"}],
Cell[8330, 224, 79, 1, 70, "MathCaption",
  CellTags->{"S5.78.1", "1.7"}],
Cell[8412, 227, 102, 2, 70, "Input",
  CellTags->"S5.78.1"],
Cell[8517, 231, 263, 7, 70, "MathCaption",
  CellTags->{"S5.78.1", "1.8"}],

Cell[CellGroupData[{
Cell[8805, 242, 124, 5, 70, "Input",
  CellTags->"S5.78.1"],
Cell[8932, 249, 106, 3, 70, "Output",
  CellTags->"S5.78.1"]
}, Open  ]],
Cell[9053, 255, 319, 7, 70, "MathCaption",
  CellTags->{"S5.78.1", "1.9"}],

Cell[CellGroupData[{
Cell[9397, 266, 128, 5, 70, "Input",
  CellTags->"S5.78.1"],
Cell[9528, 273, 105, 3, 70, "Output",
  CellTags->"S5.78.1"]
}, Open  ]],
Cell[9648, 279, 144, 4, 70, "MathCaption",
  CellTags->{"S5.78.1", "1.10"}],

Cell[CellGroupData[{
Cell[9817, 287, 78, 2, 70, "Input",
  CellTags->"S5.78.1"],
Cell[9898, 291, 105, 3, 70, "Output",
  CellTags->"S5.78.1"]
}, Open  ]],
Cell[10018, 297, 438, 9, 70, "Text",
  CellTags->{"S5.78.1", "1.11"}]
}
]
*)




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

