MathGroup Archive 1998

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

Search the Archive

RE: Integrate vs. NIntegrate


Andreas wrote:
|
|who knows how I can get ride of the following type of problem with
|undefined limits in NIntegrate?
|
|In[1]:=FindRoot[NIntegrate[y,{y,0,x}]==1,{x,0.25}] NIntegrate::"nlim":
|"\!\(y\) = \!\(x\) is not a valid limit of integration."
|NIntegrate::"nlim": "\!\(y\) = \!\(x\) is not a valid limit of
|integration."
|NIntegrate::"nlim": "\!\(y\) = \!\(x\) is not a valid limit of
|integration."
|General::"stop": "Further output of \!\(NIntegrate :: \"nlim\"\) will
be |suppressed during this calculation." Out[1]:={x->1.41421} |
|

You gave FindRoot one starting value, so it will use Newton's method. 
To  use Newton's method FindRoot needs to compute
D[NIntegrate[y,{y,0,x}]-1,x]
In the line below we see Mathematica can do this, but it produces a
message  each time it tries to.

In[1]:=
D[NIntegrate[y,{y,0,x}]-1,x]

NIntegrate::"nlim": "\!\(y\) = \!\(x\) is not a valid limit of
integration."

Out[1]=
x

_______________________________
To prevent this problem you can:

1-  Tell the FindRoot algorithm that the derivative is (x) using the 
Jacobian option.

2- Give FindRoot two starting values.  This way it will use either
Brent's  method or Secant method.  They will not have this problem
because they don't  need to compute the derivative.

3-  Evaluate  Off[NIntegrate::nlim],  and display of the message will be
suppressed.  Then you  can use you initial attempt, and it will work
just  fine.

 -  See the lines below -
_____________________________

In[2]:=
FindRoot[NIntegrate[y,{y,0,x}]==1,{x,0.25},Jacobian->x]

Out[2]=
{x\[Rule]1.41421}


In[3]:=
FindRoot[NIntegrate[y,{y,0,x}]==1,{x,0.25,0.3}]

Out[3]=
{x\[Rule]1.41421}


In[4]:=
Off[NIntegrate::nlim]


In[5]:=
FindRoot[NIntegrate[y,{y,0,x}]==1,{x,0.25}]

Out[5]=
{x\[Rule]1.41421}

___________________________
Ted Ersek



  • Prev by Date: Image Manipulation -- Graphics Question
  • Next by Date: Colors for 3D Curves
  • Previous by thread: Integrate vs. NIntegrate
  • Next by thread: Re: Integrate vs. NIntegrate