Re: NIntegrate with floating point limits
- To: mathgroup at smc.vnet.net
- Subject: [mg28878] Re: [mg28864] NIntegrate with floating point limits
- From: BobHanlon at aol.com
- Date: Thu, 17 May 2001 04:22:49 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Whether x is an exact number or an inexact number is affecting
the order of the evaluation and whether there is an infinite term
in one of the intermediate steps.
Simplify the argument to the first CosIntegral
Clear[x];
((x - u)/x + 1) // Simplify
2 - u/x
x = N[1/4];
NIntegrate[ CosIntegral[2 - u/x] - CosIntegral[u/x], {u, 0, x}]
0.23619958861949253
Or simplify the argument to the second CosIntegral
Clear[x];
(1 - (x -u)/x ) // Simplify
u/x
x = N[1/4];
NIntegrate[CosIntegral[(x - u)/x + 1] - CosIntegral[u/x], {u, 0, x}]
0.23619958861949253
Or simplify them both
Clear[x, f];
f[x_] = Evaluate[
Simplify[CosIntegral[(x - u)/x + 1] - CosIntegral[1 - (x - u)/x]]];
x = N[1/4];
NIntegrate[f[x], {u, 0, x}]
0.23619958861949253
Or avoid evaluating the integrand for u = 0
x = N[1/4];
NIntegrate[CosIntegral[(x - u)/x + 1] - CosIntegral[1 - (x - u)/x],
{u, 10^-15, x}]
0.23619958861946183
Bob Hanlon
In a message dated 2001/5/16 3:38:43 AM, f.h.simons at tue.nl writes:
>Can someone explain why the following integral can only be computed
>numerically with exact limits and not with a floating point limit?
>
>x = 1/4; NIntegrate[ CosIntegral[(x - u)/x + 1] - CosIntegral[1 - (x -
>u)/x], {u, 0, x}]
>
>returns 0.2362;
>
>x = N[1/4]; NIntegrate[ CosIntegral[(x - u)/x + 1] - CosIntegral[1 - (x
>-
>u)/x], {u, 0, x}]
>
>returns some complaints and no result.
>
>In all cases I met so far, floating points limits in numerical integration
>caused no problems.
>