I'd like to do something like:
integrate(1/(1 + Heaviside(x)),x)
It just returns Integral(1/(Heaviside(x) + 1), x)
unevaluated.
The problem is that Heaviside(0)
, is not defined. In Mathematica, for example, there is the UnitStep
function, which is like the Heaviside
, except that UnitStep(0)
is equal to 1. Can I mimic this in sympy?
I've tried Heaviside(x,1) and it doesn't work.
I don't think the problem is Heaviside(0)
. It's just that sympy doesn't have the code to handle this particular case in the integration routines. You can help it along by rewriting the Heaviside as a Piecewise:
In [36]: Integral(1/(Heaviside(x) + 1), x).rewrite(Piecewise).doit()
Out[36]:
⎧x for x < 0
⎪
⎨x
⎪─ otherwise
⎩2