Re: Incorrect integral
- To: mathgroup at smc.vnet.net
- Subject: [mg43639] Re: [mg43623] Incorrect integral
- From: Daniel Lichtblau <danl at wolfram.com>
- Date: Sat, 27 Sep 2003 04:57:59 -0400 (EDT)
- References: <200309260845.EAA03978@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Lars Rasmusson wrote:
>
> Hi, it seems like Integrate is not handling the Max[ ] function properly, or
> am I mistaken?
> Compare the two outputs
> In[1]:=
>
> fa[p_] := NIntegrate[Max[0, k - a p], {k, 0, 1}, {a, 0, 1}]
> fb[p_] := Integrate[Max[0, k - a p], {k, 0, 1}, {a, 0, 1}]
> fa[0.1]
> fb[0.1]
>
> Out[3]=
> 0.451667
> Out[4]=
> 1.66667
>
> The outputs differ. NIntegrate returns the correct value.
>
> In[5]:= $Version
> Out[5]= 5.0 for Microsoft Windows (June 11, 2003)
>
> Is there any way to get a correct behavior from Mathematica? I would be
> happy to receive the symbolic solution (to a more complicated integral of
> this kind).
>
> Thanks,
>
> Lars
One method that Integrate can handle is to reformulate using UnitStep
instead of Max.
In[9]:= InputForm[f[p_] = Integrate[UnitStep[k-a*p]*(k-a*p),
{k,0,1}, {a,0,1}, Assumptions->0<p<1]]
Out[9]//InputForm= (3 - 3*p + p^2)/6
In[11]:= f[.1]
Out[11]= 0.451667
Daniel Lichtblau
Wolfram Research
- References:
- Incorrect integral
- From: "Lars Rasmusson" <Lars.Rasmusson@hp.com>
- Incorrect integral