       Re: Integrate query

• To: mathgroup at smc.vnet.net
• Subject: [mg23382] Re: [mg23361] Integrate query
• From: Daniel Lichtblau <danl at dragonfly.wolfram.com>
• Date: Fri, 5 May 2000 02:07:15 -0400 (EDT)
• References: <200005040659.CAA17509@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```"A. E. Siegman" wrote:
>
> I have a non-negative analytic function f[x] whose area (integral of
> f[x] from 0 to Infinity) is unity.
>
> I want to find the upper limit such that the integral up to that limit
> will contain a fixed fraction of the total area, i.e. find  a  such that
>
>    Integrate[f[x], {x,0,a}] == f         (f<=1)
>
> The question is, what's the most efficient way to program this, if I
> want to find  a  with fair accuracy, and with a variety of different
> functions f[x]?
>
> Thanks . . .

Not sure this is most efficient, but I'd use a root-finder on an
NIntegrate expression. Here is an example.

In:= f[x_] := 2/Pi * 1/(1+x^2)

In:= Integrate[f[x], {x,0,Infinity}]
Out= 1

In:= cdf[a_] /; 0<=a<1 := FindRoot[NIntegrate[f[x], {x,0,k}]==a,
{k,1,2}]

In:= cdf[.4]
Out= {k -> 0.726543}

I gave FindRoot two points so it would use a secant method, so it would
not issue error messages trying to get a gradient (which I believe
happens because NIntegrate cannot deal with a symbolic upper bound).

Daniel Lichtblau
Wolfram Research

```

• Prev by Date: Re: Integrate query
• Next by Date: Re: Gif file?
• Previous by thread: Integrate query
• Next by thread: Re: Integrate query