Re: CauchyPrincipalValue questions

• To: mathgroup at smc.vnet.net
• Subject: [mg69680] Re: CauchyPrincipalValue questions
• From: dimmechan at yahoo.com
• Date: Wed, 20 Sep 2006 02:44:52 -0400 (EDT)
• References: <eeof5i\$23f\$1@smc.vnet.net>

```Dear Daniel,

As regards my second question I also take notice of the appearance of
these "x" for other functions. What is more strange is that evaluating
by yourself the integral, these "x" do not appear.
Ok it may be a quirck of CauchyPrincipalValue but this package use
Nntegrate (or something I miss).

eps = 10^(-5);
aa = Reap[NIntegrate[1/x, {x, -1, 0 - eps}, EvaluationMonitor :>
Sow[x]] + NIntegrate[1/x, {x, 0 + eps, 2},
EvaluationMonitor :> Sow[x]]];
bb = Block[{Message}, Reap[CauchyPrincipalValue[1/x, {x, -1, {0}, 2},
EvaluationMonitor :> Sow[x]]]];

aa[[1]]
Length[aa[[2,1]]]
Cases[aa[[2,1]], x]
bb[[1]]
Length[bb[[2,1]]]
Cases[bb[[2,1]], x]
0.6931471806032992
506
{}
0.6931471805602387
55
{x, x, x, x, x, x, x, x, x, x, x}

Note also the big difference in the number of sampled points.

As regards my first question, maybe I was not too clear.
I apologised for this.

Let me state it again. First define a list of two functions.

lst = {1/(x - Pi/2), Tan[x]};

Then

NIntegrate[Evaluate[lst], {x, 0, Pi/4}]
{-0.6931471805599468, 0.3465735902799742}

because NIntegrate has the attribute HoldAll (as you know without
Evaluate they appeared the NIntegrate::inum: messages and the integral
returns unevaluated).
However both of the following commands fail (they appeared the
NIntegrate::inum: messages).

CauchyPrincipalValue[lst, {x, 0, {Pi/2}, 3*(Pi/4)}, AccuracyGoal -> 20]
CauchyPrincipalValue[Evaluate[lst], {x, 0, {Pi/2}, 3*(Pi/4)},
AccuracyGoal -> 20]

The question is why.
Do I miss something here?

Regards
Dimitris

Î?/Î? dimmechan at yahoo.com Î­Î³Ï?Î±Ï?Îµ:
> Hello to all.
>
> I have two questions about the CauchyPrincipalValue package.
>
> Needs["NumericalMath`CauchyPrincipalValue`"]
>
> First
>
> lst = {1/Sqrt[x], Sin[x]/x};
> N[Integrate[lst, {x, 0, 10}]]
> {6.324555320336759, 1.658347594218874}
>
> However
>
> NIntegrate[lst, {x, 0, 10}]
> \!\(NIntegrate::"inum" : "Integrand \!\({1\/\@x,
>     Sin[x]\/x}\) is not numerical at \!\({x}\) = {5.`}"\)
> NIntegrate[lst, {x, 0, 10}]
>
> because NIntegrate has the attribute HoldAll
>
> ({#1, Attributes[#1]} & ) /@ {Integrate, NIntegrate}
> {{Integrate, {Protected, ReadProtected}}, {NIntegrate, {HoldAll,
> Protected}}}
>
> As it well known someone must enclose the argument of NIntegrate in
> Evaluate here.
>
> NIntegrate[Evaluate[lst], {x, 0, 10}]
> {6.324555320387874, 1.6583475942188746}
>
> However why the following command fails, since, as the HelpBrowser
> says, CauchyPrincipalValue uses internally the NIntegrate?
>
> lst2 = {1/(x - Pi/2), Tan[x]};
> CauchyPrincipalValue[Evaluate[lst2], {x, 0, {Pi/2}, Pi}]
> NIntegrate::inum : Integrand (the rest of the messages is not
> displayed...)
> CauchyPrincipalValue[{1/Sqrt[x], Sin[x]/x}, {x, 0, {Pi/2}, Pi}]
>
> My query become even bigger considering that
>
> Attributes[CauchyPrincipalValue]
> {Protected}
>
> My second question follows immediately.
>
> Consider the (numerical evaluation) of CPV of 1/x over {x,-1,2}.
>
> aa = Reap[CauchyPrincipalValue[1/x, {x, -1, {0}, 2}, AccuracyGoal ->
> 20,
> WorkingPrecision -> 30, EvaluationMonitor :> Sow[x]]];
>
> This is the value of the integral
>
> aa[[1]]
> 0.69314718055994530942
>
> This the total number of sampled points by NIntegrate
>
> Length[aa[[2,1]]]
> 273
>
> And here are the last 25 sampled points by NIntegrate.
>
> Take[aa[[2,1]], -25]
> {1.492698661756523787149586238081974793655503742219`29.99999998468416,
>   1.382301338243476212850413761918025206344496257781`29.96663056969523,
> 1.465413938559055852040904875211822497115793411141`29.999999992110578,
> 1.409586061440944147959095124788177502884206588859`29.983131270623772,
>   x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x}
>
> >From where appeared all these "x" in the last result?
> It seems that NIntegrate (although the result is not affected
> as it is demonstrated below) fails to sampled the integrand for
> same values of x. Why this happens?
>
> N[Integrate[1/x, {x, -1, 2}, PrincipalValue -> True], 20]
> 0.69314718055994530941723212145817656807`20.
>
> Thanks in advance for any help.

```

• Prev by Date: Re: CauchyPrincipalValue questions
• Next by Date: Re: Re: Why is the negative root?
• Previous by thread: Re: CauchyPrincipalValue questions
• Next by thread: Re: CauchyPrincipalValue questions