Re: Solving a numerical integration

*To*: mathgroup at smc.vnet.net*Subject*: [mg5476] Re: [mg5440] Solving a numerical integration*From*: fransm at win.tue.nl (Frans Martens)*Date*: Wed, 11 Dec 1996 03:15:57 -0500*Sender*: owner-wri-mathgroup at wolfram.com

Pere Llosas wrote: > I would like to solve an equation of this kind > > NIntegrate[f[n],{n,0,x}]==0 (f[x_]=Sqrt[1+x+x^2...) > where x is the searched value, and f cannot be integrated > analytically. > > NSolve[NIntegrate[f[n],{n,0,x}]==0,x], tries to evaluate > NIntegrate[f[n],{n,0,x}] before assignin a numerical value to x and > returns an error. > > How could this calculation be done without having to write a > program that searches the root? The equation NIntegrate[f[n],{n,0,x}]==0 has root x = 0 and the NSolve function tries to compute the inverse of the function x |-> NIntegrate[f[n],{n,0,x}] . The function FindRoot is more suitable. Here is an example with a second root in the neigbourhood of x = 4.8 . In[25]:= Clear[int,f] int[x_]:=NIntegrate[f[t],{t,0,x}, AccuracyGoal -> 6]; f[x_]:=Sqrt[1+x+x^2]-3; In[28]:= FindRoot[int[x]==0,{x,4.8}, Jacobian -> f[x]] Out[28]= {x -> 4.66231} >>>>> The whole above without messages <<<<<<<<< There are two precautions: 1)The option AccuracyGoal in NIntegrate is set to 6 because the integral int[x] equals zero for the root x. 2)FindRoot uses the method of Newton-Raphson and setting the option Jacobian prevents the symbolic computation of int'[x] . Note that int'[x] equals f[x]. You must have a global idea of the roots of the original equation. Frans Martens Eindhoven The Netherlands