[Date Index]
[Thread Index]
[Author Index]
Re: Integrate vs NIntegrate
*To*: mathgroup at smc.vnet.net
*Subject*: [mg46882] Re: [mg46868] Integrate vs NIntegrate
*From*: Anton Antonov <antonov at wolfram.com>
*Date*: Fri, 12 Mar 2004 23:39:32 -0500 (EST)
*References*: <200403120702.CAA25536@smc.vnet.net>
*Sender*: owner-wri-mathgroup at wolfram.com
Mukhtar Bekkali wrote:
>I am confused why NIntegrate misbehaves on such a simple function as mine.
>
>Here is what I have:
>
>In:
>
>f=D[1/(1+(1+(a-b)^2)),a];
>g=Integrate[f*b*(1-b)^2,{b,0,1},Assumptions->0<a<1];
>FindRoot[g==0,{a,0,1}]
>
>Out:
>
>a->0.397207
>
>However, since Integrate takes long, I tried to use NIntegrate instead and
>this is what I get
>
>In:
>
>f=D[1/(1+(1+(a-b)^2)),a];
>g:=NIntegrate[f*b*(1-b)^2,{b,0,1}];
>FindRoot[g==0,{a,0,1}]
>
>Out:
>
>a->1
>
>or, FindRoot+NIntegrate give me the upper boundary of a. If I abandon the
>secant method and turn to Newton, i.e. use
>FindRoot[g==0,{a,0.5}] instead then I get the message that Jacobian is
>singular at a=0.5 and get no solution. Perturbing the starting value of a
>does not help.
>
>What is going on here?
>
>
Your NIntegrate input evaluates with the messages saying the computation
has failed:
In[1]:= f = D[1/(1 + (1 + (a - b)^2)), a];
In[2]:= g := NIntegrate[f*b*(1 - b)^2, {b, 0, 1}];
In[3]:= FindRoot[g == 0, {a, 0, 1}]
2
NIntegrate::inum: Integrand f b (1 - b) is not numerical at {b} = {0.5}.
FindRoot::cvmit:
Failed to converge to the requested accuracy or precision within 100
iterations.
Out[3]= {a -> 1.}
The Integrate and NIntegrate results coincide if we can rewrite the code
above as
In[4]:= Clear[f, g]
In[5]:=f[(a_)?NumberQ] := Evaluate[D[1/(1 + (1 + (a - b)^2)), a]];
In[6]:=g[(a_)?NumberQ] := NIntegrate[f[a]*b*(1 - b)^2,{b, 0, 1}];
In[7]:=FindRoot[g[a] == 0, {a, 0, 1}]
NIntegrate::ploss:
Numerical integration stopping due to loss of precision. Achieved neither
the requested PrecisionGoal nor AccuracyGoal; suspect one of the
following: highly oscillatory integrand or the true value of the
integral
is 0. If your integrand is oscillatory try using the option
Method->Oscillatory in NIntegrate.
NIntegrate::ploss:
Numerical integration stopping due to loss of precision. Achieved neither
the requested PrecisionGoal nor AccuracyGoal; suspect one of the
following: highly oscillatory integrand or the true value of the
integral
is 0. If your integrand is oscillatory try using the option
Method->Oscillatory in NIntegrate.
Out[7]= {a -> 0.397861}
You can further refer to the technical documentation explaining the
evaluation of the arguments by the numerical functions
http://support.wolfram.com/mathematica/mathematics/numerics/nsumerror.html
--
Anton Antonov
Wolfram Research, Inc.
Prev by Date:
**RE: Undiscovered Bug?**
Next by Date:
**Re: Creating a symmetric matrix**
Previous by thread:
**Integrate vs NIntegrate**
Next by thread:
**Re: Integrate vs NIntegrate**
| |