Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1998
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1998

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

Search the Archive

Re: Integrate vs. NIntegrate

  • To: mathgroup at smc.vnet.net
  • Subject: [mg12809] Re: Integrate vs. NIntegrate
  • From: Carl Woll <carlw at fermi.phys.washington.edu>
  • Date: Fri, 12 Jun 1998 04:05:40 -0400
  • Organization: University of Washington
  • References: <6llb9f$dcc@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Hi Andreas,

The simplest way to get NIntegrate and FindRoot to work together is to
give FindRoot two starting points so that it uses the Secant method
instead of Newton's method. The reason for your error message is that
when using Newton's method, Mathematica tries to evaluate the
derivative of your function. Thus,

FindRoot[NIntegrate[y,{y,0,x}]==1,{x,0.25,0.5}]

returns

{x -> 1.41421}

However, since Newton's method is usually preferable if possible, there
is a way to get Mathematica to use Newton's method. The trick is to
override Mathematica's calculation of the Jacobian as follows.

Define your function with NumericQ

f[x_?NumericQ] := NIntegrate[y,{y,0,x}] - 1

so that Mathematica is never tempted to evaluate the NIntegrate with a
symbolic limit. Then define the derivative

f /: D[f[x_],x_] := x

Now you can use FindRoot:

FindRoot[ f[x]==0, {x,0.25} ]

returns

{x -> 1.41421}

Carl Woll
Dept of Physics
U of Washington

On 10 Jun 1998, Andreas Kull wrote:

> Hello all,
> 
> 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}
> 
> It would be nice to have the above example working like Integrate, i.e.
> In[2]:=FindRoot[Integrate[y,{y,0,x}]==1,{x,0.25}] Out[2]:={x->1.41421}
> 
> thanks,
> Andreas
> 
> 
> 



  • Prev by Date: Re: Complex Conjugation
  • Next by Date: Re: Exporting lists from Mathematica 3.0 to Excel
  • Previous by thread: RE: Integrate vs. NIntegrate
  • Next by thread: Re: Integrate vs. NIntegrate