The problem is described in the following figure. Mathematica version 14.0, OS windows 10 LTSC.
The integration interval is [0,infinity), and the value of HeavisideTheta in the point 0 is 0. we can see, getting the result r1 of expression 1 took time 0.0097771, but the time consumed in the expression 2 is 0.02, almost the twice of expression 1. Why is this strange situation happening?
In order to reduce the integrating time, the expression 1 is always used instead of expression 2, because they can provide the same result. However, the integration interval in real physical scenes is [0,infinity).
Based on the book, Power programming with Mathematica, Changing the lower limit of integration from 0 to 0.0 should improve the integrate performance. In fact, the time was reduced as the expression 3 which gave the result r3 consuming time 0.012, but the result is not one we want, because the result is 0 when HeavisideTheta[0.0] = 0. How to revise the expression 3?
Can you provide a solution? thank you.
The codes in the case as the following
Integrate[
D[HeavisideTheta[z], z], {z, -Infinity,
Infinity}] // AbsoluteTiming
Integrate[
D[HeavisideTheta[z], z], {z, 0, Infinity}] // AbsoluteTiming
Integrate[
D[HeavisideTheta[z], z], {z, 0., Infinity}] // AbsoluteTiming

RepeatedTiming– Nasser Jan 19 '24 at 13:50HeavisideTheta[0]==1/2– Ulrich Neumann Jan 19 '24 at 14:580.01seconds or0.02seconds. – azerbajdzan Jan 19 '24 at 15:50HeavisideTheta[0.] -> 1.on the output and you get what you want forIntegrate[D[HeavisideTheta[z], z], {z, 0., Infinity}]. – azerbajdzan Jan 19 '24 at 16:28