MathGroup Archive 2007

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

Search the Archive

Re: FindRoot and NIntegrate

mfedert at wrote:
> Hi all,
> I have what is probably a very simple problem.  I want to find x which
> solves an equation of the form
> \integral f(x,y) dy = 0
> I have tried something along the lines of
> FindRoot[ NIntegrate[ f(x,y) , {y, -inf, inf} ], {x, x_0 } ]
> but it doesn't work ---- my theory being that NIntegrate tries to go
> ahead and do the numerical integration before it knows what x is equal
> to... which blows up  because the integrand is - as a function of x -
> non-numerical... Is there a way around this?  I'm sure there's some
> trivial modification I can make to get things working again.

Here's an example:

In[1]:= integral[a_?NumericQ] := NIntegrate[Exp[a*x], {x, 0, 1}]

In[2]:= FindRoot[integral[x] == 2, {x, 1}]
Out[2]= {x -> 1.2564312086261675}


  • Prev by Date: Re: FindRoot and NIntegrate
  • Next by Date: Solution of a non-linear ODE
  • Previous by thread: Re: FindRoot and NIntegrate
  • Next by thread: Re: FindRoot and NIntegrate