Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Re: Integrate vs Nintegrate for impulsive functions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg61759] Re: [mg61728] Re: Integrate vs Nintegrate for impulsive functions
  • From: Chris Chiasson <chris.chiasson at gmail.com>
  • Date: Fri, 28 Oct 2005 03:25:44 -0400 (EDT)
  • References: <200510270902.FAA19481@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Pratik,
Based on what Bill Rowe said, I did some more experimentation. I am
now more inclined to believe the original NIntegrate result:

{Cell[CellGroupData[{
Cell[BoxData[
    RowBox[{
      RowBox[{"reps", "[", "1", "]"}], "=",
      RowBox[{"{",
        RowBox[{
          RowBox[{"a", "->",
            RowBox[{"(",
              RowBox[{
                RowBox[{"-", "0.24982234345508192"}], "-",
                RowBox[{"0.0429732983215806", "*", "I"}]}], ")"}]}],
          ",",
          RowBox[{"b", "->",
            RowBox[{"(",
              RowBox[{"3.1734427242687215", "+",
                RowBox[{"0.3295480781081674", "*", "I"}]}], ")"}]}],
          ",",
          RowBox[{"c", "->", "1000."}], ",",
          RowBox[{"d", "->",
            RowBox[{"-", "0.4"}]}]}], "}"}]}]], "Input",
  CellLabel->"In[1]:="],

Cell[BoxData[
    RowBox[{"{",
      RowBox[{
        RowBox[{"a", "\[Rule]",
          RowBox[{
            RowBox[{"-", "0.24982234345508192`"}], "-",
            RowBox[{"0.0429732983215806`", " ", "\[ImaginaryI]"}]}]}],
         ",",
        RowBox[{"b", "\[Rule]",
          RowBox[{
            RowBox[{"3.1734427242687215`", "\[InvisibleSpace]"}], "+",

            RowBox[{"0.3295480781081674`", " ", "\[ImaginaryI]"}]}]}],
         ",",
        RowBox[{"c", "\[Rule]", "1000.`"}], ",",
        RowBox[{"d", "\[Rule]",
          RowBox[{"-", "0.4`"}]}]}], "}"}]], "Output",
  CellLabel->"Out[1]="]
}, Open  ]],

Cell[CellGroupData[{

Cell[BoxData[
    RowBox[{
      RowBox[{"expr", "[", "1", "]"}], "=",
      RowBox[{"a", "*",
        RowBox[{"Sin", "[",
          RowBox[{"b", "*", "x"}], "]"}], "*",
        RowBox[{"(",
          RowBox[{
            RowBox[{"Cosh", "[",
              RowBox[{"c", "*",
                RowBox[{
                  RowBox[{"(",
                    RowBox[{"d", "+", "x"}], ")"}], "^", "2"}]}],
              "]"}], "-",
            RowBox[{"Sinh", "[",
              RowBox[{"c", "*",
                RowBox[{
                  RowBox[{"(",
                    RowBox[{"d", "+", "x"}], ")"}], "^", "2"}]}],
              "]"}]}], ")"}]}]}]], "Input",
  CellLabel->"In[2]:="],

Cell[BoxData[
    RowBox[{"a", " ",
      RowBox[{"Sin", "[",
        RowBox[{"b", " ", "x"}], "]"}], " ",
      RowBox[{"(",
        RowBox[{
          RowBox[{"Cosh", "[",
            RowBox[{"c", " ",
              SuperscriptBox[
                RowBox[{"(",
                  RowBox[{"d", "+", "x"}], ")"}], "2"]}], "]"}], "-",

          RowBox[{"Sinh", "[",
            RowBox[{"c", " ",
              SuperscriptBox[
                RowBox[{"(",
                  RowBox[{"d", "+", "x"}], ")"}], "2"]}], "]"}]}],
        ")"}]}]], "Output",
  CellLabel->"Out[2]="]
}, Open  ]],

Cell[CellGroupData[{

Cell[BoxData[
    RowBox[{
      RowBox[{"expr", "[", "2", "]"}], "=",
      RowBox[{"Integrate", "[",
        RowBox[{
          RowBox[{"expr", "[", "1", "]"}], ",",
          RowBox[{"{",
            RowBox[{"x", ",", "0", ",", "1"}], "}"}]}],
        "]"}]}]], "Input",
  CellLabel->"In[4]:="],

Cell[BoxData[
    RowBox[{
      FractionBox["1",
        RowBox[{"4", " ",
          SqrtBox["c"]}]],
      RowBox[{"(",
        RowBox[{"a", " ",
          SuperscriptBox["\[ExponentialE]",
            RowBox[{"-",
              FractionBox[
                RowBox[{"b", " ",
                  RowBox[{"(",
                    RowBox[{"b", "+",
                      RowBox[{
                      "4", " ", "\[ImaginaryI]", " ", "c", " ",
                        "d"}]}], ")"}]}],
                RowBox[{"4", " ", "c"}]]}]], " ",
          SqrtBox["\[Pi]"], " ",
          RowBox[{"(",
            RowBox[{
              RowBox[{"Erfi", "[",
                FractionBox[
                  RowBox[{"b", "+",
                    RowBox[{
                    "2", " ", "\[ImaginaryI]", " ", "c", " ", "d"}]}],

                  RowBox[{"2", " ",
                    SqrtBox["c"]}]], "]"}], "+",
              RowBox[{
                SuperscriptBox["\[ExponentialE]",
                  RowBox[{
                  "2", " ", "\[ImaginaryI]", " ", "b", " ", "d"}]],
                " ",
                RowBox[{"(",
                  RowBox[{
                    RowBox[{"Erfi", "[",
                      FractionBox[
                        RowBox[{"b", "-",
                          RowBox[{
                          "2", " ", "\[ImaginaryI]", " ", "c", " ",
                            "d"}]}],
                        RowBox[{"2", " ",
                          SqrtBox["c"]}]], "]"}], "-",
                    RowBox[{"Erfi", "[",
                      FractionBox[
                        RowBox[{"b", "-",
                          RowBox[{
                          "2", " ", "\[ImaginaryI]", " ", "c", " ",
                            RowBox[{"(",
                              RowBox[{"1", "+", "d"}], ")"}]}]}],
                        RowBox[{"2", " ",
                          SqrtBox["c"]}]], "]"}]}], ")"}]}], "-",
              RowBox[{"Erfi", "[",
                FractionBox[
                  RowBox[{"b", "+",
                    RowBox[{
                    "2", " ", "\[ImaginaryI]", " ", "c", " ",
                      RowBox[{"(",
                        RowBox[{"1", "+", "d"}], ")"}]}]}],
                  RowBox[{"2", " ",
                    SqrtBox["c"]}]], "]"}]}], ")"}]}],
        ")"}]}]], "Output",
  CellLabel->"Out[4]="]
}, Open  ]],

Cell[CellGroupData[{

Cell[BoxData[
    RowBox[{
      RowBox[{"expr", "[", "3", "]"}], "=",
      RowBox[{
        RowBox[{"expr", "[", "2", "]"}], "/.",
        RowBox[{"reps", "[", "1", "]"}]}]}]], "Input",
  CellLabel->"In[5]:="],

Cell[BoxData[
    RowBox[{
      RowBox[{"-", "0.013361219528374291`"}], "-",
      RowBox[{
      "0.002855508349311957`", " ", "\[ImaginaryI]"}]}]], "Output",
  CellLabel->"Out[5]="]
}, Open  ]],

Cell[CellGroupData[{

Cell[BoxData[
    RowBox[{
      RowBox[{"expr", "[", "4", "]"}], "=",
      RowBox[{"NIntegrate", "[",
        RowBox[{
          RowBox[{"Evaluate", "[",
            RowBox[{
              RowBox[{"expr", "[", "1", "]"}], "/.",
              RowBox[{"reps", "[", "1", "]"}]}], "]"}], ",",
          RowBox[{"{",
            RowBox[{"x", ",", "0", ",", "1"}], "}"}]}],
        "]"}]}]], "Input",
  CellLabel->"In[7]:="],

Cell[BoxData[
    RowBox[{
      RowBox[{"-", "0.013361219516929358`"}], "-",
      RowBox[{
      "0.0028555083468499365`", " ", "\[ImaginaryI]"}]}]], "Output",
  CellLabel->"Out[7]="]
}, Open  ]],

Cell["\<\
I guess they don't agree in their last eight binary digits...\
\>", "Text"],

Cell[CellGroupData[{

Cell[BoxData[
    RowBox[{
      RowBox[{"expr", "[", "3", "]"}], "\[Equal]",
      RowBox[{"expr", "[", "4", "]"}]}]], "Input",
  CellLabel->"In[11]:="],

Cell[BoxData["False"], "Output",
  CellLabel->"Out[11]="]
}, Open  ]],

Cell["Ahh, but these do...", "Text"],

Cell[CellGroupData[{

Cell[BoxData[
    RowBox[{"1`2", "\[Equal]", "0"}]], "Input",
  CellLabel->"In[17]:="],

Cell[BoxData["True"], "Output",
  CellLabel->"Out[17]="]
}, Open  ]]}


On 10/27/05, Bill Rowe <readnewsciv at earthlink.net> wrote:
> On 10/26/05 at 2:44 AM, chris.chiasson at gmail.com (Chris Chiasson)
> wrote:
>
> >My computer gives the same answer as yours for NIntegrate, but it
> >thought for a long while on Integrate and then spit out:
> >Complex[-4.4073414839228176`*^145,6.238877585945074`*^146] Bug??
> >Version Number: 5.2.0.0
> >Platform: Windows
>
> Using version 5.2 on MacOS 10.4.2, for Integrate I get
>
> Out[2]=
> 4.651767835491884*^136 + 1.162941958872971*^136*I
>
> and for NItegrate, I get the same result reported by Pratik Desai.
>
> The function being integrated is specified with machine precision coefficients. I strongly suspect this is the root of the problem.
>
> Integrate will first get a symbolic answer then compute the final answer by substituting the end points into the symbolic answer. It is entirely possible this leads to problems even when the orginal function being integrated has reasonable values over the range of integration.
>
> So, I would be inclined to accept the answer given by NIntegrate as valid and reject the answer given by Integrate. But I would not consider this to be a bug. Instead, I would chalk this up as one of the issues with doing machine precision computations.
> --
> To reply via email subtract one hundred and four
>
>


--
http://chrischiasson.com/contact/chris_chiasson


  • Prev by Date: Re: Re: MLPutRealList vs. sequence of MLPutDouble
  • Next by Date: Re: Re: Integrate vs Nintegrate for impulsive functions
  • Previous by thread: Re: Re: Integrate vs Nintegrate for impulsive functions<> got it !!!!
  • Next by thread: Re: Re: Integrate vs Nintegrate for impulsive functions