0

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

enter image description here

user64494
  • 26,149
  • 4
  • 27
  • 56
likehust
  • 693
  • 3
  • 8
  • which version are you using? on V 14 on windows 10., I do not see this. Timing is very close. Here is screen shot. Mathematica graphics also you should really be using RepeatedTiming – Nasser Jan 19 '24 at 13:50
  • These integrals make no sense in traditional math (for example, see Wiki and Encyclopedia of Mathematics). – user64494 Jan 19 '24 at 14:29
  • @Nasser,Thanks for your response. 1. You run these codes, maybe get a new consuming time near the time in my figure. 2. the lower limit of integration from 0 to 0.0 gives a result not we want, how to deal with it? – likehust Jan 19 '24 at 14:34
  • @user64494, Thanks for your answer. When we solve the question in a half space, the stress on the surface of a body is 0, the situation will appear. The snippet codes are parts of my full program. Can you give a solution to deal with the problem? Thank you. – likehust Jan 19 '24 at 14:41
  • @likehust For your application it is completely sufficient to assume symmtrical diracdelta, in which case we have HeavisideTheta[0]==1/2 – Ulrich Neumann Jan 19 '24 at 14:58
  • @Ulrich Neumann, Thanks. 1. We need the HeavisideTheta[0]=0 when defining the boundary condition; 2. DiracDelta faces the same problems of consuming too much time in [0,infinity), and giving fault result at the point z=0.0. – likehust Jan 19 '24 at 15:12
  • @likehust Please give an idea of the boundary condition you try to solve. – Ulrich Neumann Jan 19 '24 at 15:46
  • @likehust: Can you provide an example when the time of evaluation really matters? Because it the case of examples you provided it does not really matter whether it takes 0.01 seconds or 0.02 seconds. – azerbajdzan Jan 19 '24 at 15:50
  • @Ulrich Neumann, Please refer to the website: https://www.sciencedirect.com/science/article/abs/pii/0165212587900448 – likehust Jan 19 '24 at 16:12
  • @azerbajdzan, Thanks. The integration as described is a very small part. If all the elements of a big matrix are similar to it or more complex than it, or the integration is in a big For function, the time of evaluation will really matter. – likehust Jan 19 '24 at 16:18
  • @likehust: So then use a replacement HeavisideTheta[0.] -> 1. on the output and you get what you want for Integrate[D[HeavisideTheta[z], z], {z, 0., Infinity}]. – azerbajdzan Jan 19 '24 at 16:28

0 Answers0