RE: Incorrect integral
- To: mathgroup at smc.vnet.net
- Subject: [mg43640] RE: [mg43623] Incorrect integral
- From: "Rasmusson, Lars" <larsr at exch.hpl.hp.com>
- Date: Sat, 27 Sep 2003 04:58:01 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Thank you for help. It seems to work. However, Mathematica does not seem to be working correctly when the integration boundaries are given symbolicly. Is there a way to handle that as well? To see that it is incorrect, compare the result of In[1]:= InputForm[f[p_] = Integrate[UnitStep[k-a*p]*(k-a*p), {k,K0,K1}, {a,A0,A1}, Assumptions->0<p<1]] ; In[2]:= f[0.1]/.{K0|A0->0,K1|A1->1} Out[2]= 0.453333 with the correct value 0.451667. Again, I'm very grateful for your good response to my question. Best regards, Lars Rasmusson -----Original Message----- From: Daniel Lichtblau [mailto:danl at wolfram.com] To: mathgroup at smc.vnet.net Subject: [mg43640] Re: [mg43623] Incorrect integral 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