1

I always meet the HeavisideTheta[0] = 1 during my work, every time I need to use the function Replace[] to finish the job, which has been harassing me. So I want to know if there's a method to set HeavisideTheta[0] = 1 permanently, or copy the definition of HeavisideTheta to a new file and rewrite it to a new package(.m or .wl file) meeting my will. In the post Add a global rule for HeavisideTheta[0], Mauricio Fernández proposed a global assumption method, but it is not convenient because I have to call the Simplify everytime. Thank you!

likehust
  • 693
  • 3
  • 8
  • 2
    Have you tried Unprotect[HeavisideTheta], HeavisideTheta[0]=1, Protect[HeavisideTheta] as suggested in one of the comments in the linked question? That would be the usual way to do this, if you had to. Beware that it might break things, though. – Carl Lange Apr 17 '19 at 09:48
  • 4
    The question arises: what for? – user64494 Apr 17 '19 at 09:50
  • Maybe use UnitStep instead? – Greg Hurst Apr 17 '19 at 12:34
  • @user64494 @Chip Hurst, I use the HeavisideTheta to control boundary condition during symbolic formula derivation and the final numerical calculation, which involving Heaviside's derivative and HeavisideTheta[0], so Unitstep doesn't meet the situation. – likehust Apr 17 '19 at 15:19
  • @Carl Lange, thanks, the method you talked about is feasible, can you tell me how to write this code fragment into init.m file and make every .nb file load them automatically every time? – likehust Apr 17 '19 at 15:30
  • Unfortunately, I can't. I've never done that, and I also think it may not be very safe to do! You should be able to find some example on this site or in the documentation, though. – Carl Lange Apr 17 '19 at 15:44
  • @Carl Lange, I have write the code fragment into the init.m in the directory of C:\ProgramData\Mathematica\Kernel, and realized what I wanted. In the end, I want to know, what is "Beware that it might break things" you talked? Can you provide me with some detail information or live example? Thank you. – likehust Apr 18 '19 at 00:45
  • Unfortunately, I don't have any real details - I am personally worried about changing parts of the internal WL system without really knowing what they might do. – Carl Lange Apr 18 '19 at 07:12

1 Answers1

4

As discussed in the comments, you can set this by Unprotecting the symbol, like so:

Unprotect[HeavisideTheta]
HeavisideTheta[0]=1
Protect[HeavisideTheta]

Note that this may cause some issues with functions that expect HeavisideTheta[0] to be 0.

Carl Lange
  • 13,065
  • 1
  • 36
  • 70
  • 1
    Thank you, I have taken your solution, write Unprotect[HeavisideTheta]; HeavisideTheta[0]=1;HeavisideTheta[0.0]=1; Protect[HeavisideTheta]; into the init.m in the directory of C:\ProgramData\Mathematica\Kernel, and realized what I wanted. – likehust Apr 18 '19 at 07:43