Message Boards Message Boards

2
|
1590 Views
|
19 Replies
|
15 Total Likes
View groups...
Share
Share this post:

A numerical integration high precision calculation problem

Posted 3 months ago

I tried many times but couldn't get a high precision calculation

enter image description here

Attachments:
POSTED BY: HuaXing Ma
19 Replies

Using a Evaluating integrals over the positive real axis:

S = IntegrateChangeVariables[Inactive[Integrate][Abs[Sin[x^4]]/(Sqrt[x] + x^2), {x, 0, Infinity}], t, t == x^4];

int = LaplaceTransform[Numerator[S[[1]]], t, x]*InverseLaplaceTransform[1/Denominator[S[[1]]], t, x]

(* (x^(1/4) Coth[(\[Pi] x)/2] MittagLefflerE[3/8, 5/4, -x^(3/8)])/(4 (1 + x^2)) *)

NIntegrate[int, {x, 0, Infinity}, Method -> "GlobalAdaptive", WorkingPrecision -> 50, PrecisionGoal -> 25, MaxRecursion -> 25]

(* 0.61822293775804867431044812335205529689707962742130 *)

Regards M.I.

POSTED BY: Mariusz Iwaniuk

Nice!

POSTED BY: Michael Rogers

Using the method "DoubleExponentialOscillatory" works, at least to a point, but it is slow:

AbsoluteTiming@
 NIntegrate[Abs[Sin[x^4]]/(Sqrt[x] + x^2), {x, 0, \[Infinity]}, 
  Method -> {"DoubleExponentialOscillatory", 
    Method -> {"GlobalAdaptive", "MaxErrorIncreases" -> 10^6}, 
    "SymbolicProcessing" -> 0}, PrecisionGoal -> 4, 
  MaxRecursion -> 40]
NIntegrate::slwcon: Numerical integration converging too slowly; suspect one of the following: singularity, value of the integration is 0, highly oscillatory integrand, or WorkingPrecision too small.

NIntegrate::eincr: The global error of the strategy GlobalAdaptive has increased more than 1000000 times. The global error is expected to decrease monotonically after a number of integrand evaluations. Suspect one of the following: the working precision is insufficient for the specified precision goal; the integrand is highly oscillatory or it is not a (piecewise) smooth function; or the true value of the integral is 0. Increasing the value of the GlobalAdaptive option MaxErrorIncreases might lead to a convergent numerical integration. NIntegrate obtained 0.6184623212443172` and 0.0007604000503125842` for the integral and error estimates.

{117.819, 0.618462}
In[1]:= AbsoluteTiming@
 NIntegrate[Abs[Sin[x^4]]/(Sqrt[x] + x^2), {x, 0, \[Infinity]}, 
  Method -> {"DoubleExponentialOscillatory", 
    Method -> {"GlobalAdaptive", "MaxErrorIncreases" -> 10^6}, 
    "SymbolicProcessing" -> 0}, PrecisionGoal -> 4, 
  MaxRecursion -> 40, WorkingPrecision -> 30]
DynamicNIntegrate::slwcon: Numerical integration converging too slowly; suspect one of the following: singularity, value of the integration is 0, highly oscillatory integrand, or WorkingPrecision too small.Dynamic

DynamicNIntegrate::eincr: The global error of the strategy GlobalAdaptive has increased more than 1000000 times. The global error is expected to decrease monotonically after a number of integrand evaluations. Suspect one of the following: the working precision is insufficient for the specified precision goal; the integrand is highly oscillatory or it is not a (piecewise) smooth function; or the true value of the integral is 0. Increasing the value of the GlobalAdaptive option MaxErrorIncreases might lead to a convergent numerical integration. NIntegrate obtained 0.618315690550426459312705456807`30. and 0.00046796568836866222451442302407`30. for the integral and error estimates.Dynamic

{6215.76, 0.618315690550426459312705456807}

From the messages it seems that we can trust the first three significant digits, 0.618, and those results agree with the earlier posted results.

POSTED BY: Anton Antonov
Posted 3 months ago

This sort of integrals can probably be evaluated correctly by using double exponential quadratures, see, for example, Ooura and Mori, "The double exponential formula for oscillatory functions over the half infinite interval", J. Comput. Appl. Math. 38(1991)353-360. However, my attempts to use double exponential quadratures in MATHEMATICA were not successful. L.B.

POSTED BY: Leslaw Bieniasz

However, my attempts to use double exponential quadratures in MATHEMATICA were not successful.

In your attempts, did you use the methods "DoubleExponential" or "DoubleExponentialOscillatory"? Over this integral or (also) others?

POSTED BY: Anton Antonov
Posted 3 months ago

I don't remember now. It was a few years ago. But I wanted to integrate a non-oscillatory integrand with a hard singularity at x=0, and I finally succeeded by not using double exponential formulae. L.B.

POSTED BY: Leslaw Bieniasz
Posted 3 months ago

After a change of variables, maybe integrate several cycles and then replace sine by its average. The change of variables may not be important, but I did it early in searching for a solution to make it easier (for my brain) to locate the singularities.

integrand = 
 Abs[Sin[x^4]]/(Sqrt[x] + x^2) Dt[x, u] /. x -> (Pi*u)^(1/4) // 
  Simplify[#, u > 0] &
avgSine = Integrate[Sin[\[Pi]  u], {u, 0, 1}];

(*  (\[Pi]^(1/8) Abs[Sin[\[Pi] u]])/((4 + 4 \[Pi]^(3/8) u^(3/8)) u^(7/8))  *)

Block[{n = 10000},
 NIntegrate[integrand, Evaluate@Flatten@{u, Range[0, n]}] + 
  avgSine*Integrate[ (\[Pi]^(1/8))/((4 + 4 \[Pi]^(3/8) u^(3/8)) u^(7/8)), {u, n, Infinity}]
 ]

(*  0.6182229377606695`  *)

The solution with n = 100000, which differs from the above in around the 11th digit:

(*  0.618222937758045`  *)
POSTED BY: Updating Name
Posted 3 months ago

Thank you for your reply. I really feel helpless about the problem

POSTED BY: HuaXing Ma

POSTED BY: Michael Rogers
Posted 3 months ago

Your answer gave me a lot of help, thank you very much!

POSTED BY: HuaXing Ma

Very nice! This should be a separate Community post.

POSTED BY: Anton Antonov

I tried a change of variables:

IntegrateChangeVariables[
 Inactive[Integrate][Abs[Sin[x^4]]/(Sqrt[x] + x^2),
  {x, 0, \[Infinity]}],
 t, t == x^4]

The decay at infinity is 1/t^(5/4), rather slow. Integrating by part will make the decay faster, but the Abs forces to divide into intervals.

POSTED BY: Gianluca Gorni
Posted 3 months ago

Yes, I tried for a long time, but the problem is still there. I don't have enough knowledge to solve it

POSTED BY: HuaXing Ma
Posted 3 months ago

I used the following combination of methods for rapidly oscillating functions:

Method -> {"ExtrapolatingOscillatory", Method -> "Trapezoidal"} 

And the next result is silently within a second:

In: NIntegrate[Abs[Sin[x^4]]/(Sqrt[x] + x^2), {x, 0, \[Infinity]}, 
 Method -> {"ExtrapolatingOscillatory", Method -> "Trapezoidal"}, 
 MaxRecursion -> 100, WorkingPrecision -> 10] 
Out: 0.5988992624

But when I try to increase WorkingPrecision to 11 everything hangs ((

POSTED BY: Denis Ivanov

I strongly suspect your are confusing WorkingPrecision with PrecisionGoal.

POSTED BY: Anton Antonov
Posted 3 months ago

In fact, I've already tried....

POSTED BY: HuaXing Ma
Posted 3 months ago

I tried to copy the learning document method, but it didn't work, so I would like to ask you to try. (I also tried Maple, but the results were disappointing)

POSTED BY: HuaXing Ma

Maple solution see here

POSTED BY: Mariusz Iwaniuk
Posted 3 months ago

thanks

POSTED BY: HuaXing Ma
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract