       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:=
Clear[int,f]
int[x_]:=NIntegrate[f[t],{t,0,x},
AccuracyGoal -> 6];
f[x_]:=Sqrt[1+x+x^2]-3;
In:=
FindRoot[int[x]==0,{x,4.8},
Jacobian -> f[x]]
Out=
{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

```

• Prev by Date: Re: FindRoot question
• Next by Date: UTM-Lat/Long conversion
• Previous by thread: Solving a numerical integration
• Next by thread: Re: Re: Solving a numerical integration