I've looked in the Matlab R2015a change log but can't seem to find any information. Has the heaviside() function changed such integration results in the following answer:
>> int(heaviside(t),t)
ans =
(t*(sign(t) + 1))/2
This is not the same answer you would get in R2014a. This also affects answers to ODE which use heaviside(). I don't doubt the answer is correct; it's just more complicated in my mind than the R2014a result which returns:
>> int(heaviside(t),t)
ans =
t*heaviside(t)
Thanks!
The two forms are different for complex-valued inputs. Additionally, the sym/sign
function is a direct call to MuPAD's sign
, while sym/heaviside
is not directly based on MuPAD's heaviside
, but does several manipulations and calls the lower-level undocumented HeavisideAtOrigin
function (type edit heaviside
in your Command Window to see the code).
It seems like your actual question is why the new version with sign
doesn't work in other code that you didn't show. One workaround is to use the rewrite
function to turn the output from int
back into an expression in terms of the Heaviside function:
syms t
H = int(heaviside(t),t)
rewrite(H, 'heaviside')
which returns the expected t*heaviside(t)
.
I don't know why this change was made, but I'd guess that it might be because there is no numeric floating-point version of heaviside
while there is for sign
. This might facilitate the conversion back and forth to symbolic math internally and for users unfamiliar with the Heaviside function.