[Acknowledged as a bug persisting in V12.2]
Integrate[SquareWave[t], t] // InputForm
Gives as output
Piecewise[{{-t, Inequality[1/2, LessEqual, Mod[t, 1], Less, 1]}}, t]
I don't understand how this can be the right answer. For example, substituting in
% /. t->19/2
gives -19/2, whereas
NIntegrate[SquareWave[t], {t, 0, 19/2}]
gives 0.5
Edited:
As made clear in the comments below (very informative thank you), there are unavoidable ambiguities in indefinite integrals for functions with branch cuts in the complex plane.
However, as explicitly stated in the documentation, SquareWave
is only defined for real numbers. In this case, the result returned by Mathematica seems perverse. Wouldn't a more appropriate result be
TriangleWave[t + 3/4]/4
SquareWave[t] // PiecewiseExpand
$\endgroup$Integrate[SquareWave[t], t] - Integrate[PiecewiseExpand[SquareWave[t], 0 < t < 19/2], t]
$\endgroup$