[Date Index]
[Thread Index]
[Author Index]
Re: Wrong Integral result for a Piecewise function
*To*: mathgroup at smc.vnet.net
*Subject*: [mg58549] Re: [mg58545] Wrong Integral result for a Piecewise function
*From*: Andrzej Kozlowski <akozlowski at gmail.com>
*Date*: Thu, 7 Jul 2005 05:35:39 -0400 (EDT)
*References*: <200507060711.DAA05291@smc.vnet.net>
*Sender*: owner-wri-mathgroup at wolfram.com
On 6 Jul 2005, at 16:11, Dean Nairn wrote:
> This integral gives gives the wrong result for the interval [2,3]
>
> h[x_] := Integrate[Boole[x - 1 < 2 y + 2 z < x], {y, 0, 1}, {z, 0, 1}]
>
> Plot[h[x],{x,0,5}]
> and
> Plot[Evaluate[h[x]],{x,0,5}]
>
> give different plots, The curve should be smooth and bell shaped from
> 0 to 5, so the first looks correct. The second has a jump
> discontinuity
> at 2 and 3. Also
>
> h[5/2]
> and
> h[x]/.x-> 5/2
>
> give different answers
>
> This is using some new features in Mathematica 5.1. Same result on a
> Mac (10.4) and SunOS (5.9).
>
> Breaking into a difference of two integrals gives the correct answer:
> Integrate[Boole[ 2 y + 2 z < x], {y, 0, 1}, {z, 0, 1}] -
> Integrate[Boole[ 2 y + 2 z < x-1], {y, 0, 1}, {z, 0, 1}]
>
> Finally
> Integrate[h[x], {x, 0, 5}] and NIntegrate[h[x], {x, 0, 5}]
> both give the wrong answer, it should be 1. The triple integral is
> correct
>
> Integrate[Boole[x - 1 < 2 y + 2z < x], {y, 0, 1}, {z, 0, 1}, {x, 0,
> 5}]
>
> Any suggestions on integrating over regions with linear constraints?
> Versions 5.1 has powerful new piecewise functions
>
>
If you try instead
g[x_] = FullSimplify[Integrate[UnitStep[2y + 2z - (x - 1)]*UnitStep[x
- 2y - 2z], {y, 0, 1}, {z, 0, 1}]]
(this takes a while to complete) then
Plot[g[x],{x,0,5}]
looks correct. Also
In[18]:=
NIntegrate[g[x], {x, 0, 5}]
Out[18]=
1.
In[19]:=
Integrate[g[x], {x, 0, 5}]
Out[19]=
1
This, of course, is the pre-Mathematica 5 way of doing these things
which only goes to confirm that progress is not always improvement ;-)
Andrzej Kozlowski
Chiba, Japan
Prev by Date:
**Re: Partial diff equations**
Next by Date:
**Re: Wrong Integral result for a Piecewise function**
Previous by thread:
**Wrong Integral result for a Piecewise function**
Next by thread:
**Re: Wrong Integral result for a Piecewise function**
| |