I've done $$-\frac13\int \sin 3t\tan 3t\,dt=-\frac19\ln(\sec 3t+\tan 3t)+\frac19\sin 3t$$ using standard procedures in Calculus II. However, Matlab returns $$-\frac13\int \sin 3t\tan 3t\,dt=\frac19\sin 3t-\frac29\tanh^{-1}\left(\tan\frac{3t}{2}\right)$$ Now, I've done a detailed proof that these two answers are the same using some difficult trigonometry. However, I am wondering what approach will lead directly to Matlab's answer. What substitution is being performed on $(-1/3)\int \sin 3t\tan 3t\,dt$ that leads directly to Matlab's answer?
Thanks.
Hint:
Let $e^{2m}=\sec 2y+\tan2u=\dfrac{(1+\tan u)^2}{1-\tan^2u}$ using
https://www.cut-the-knot.org/arithmetic/algebra/WeierstrassSubstitution.shtml
$\tanh(m)=\dfrac{e^m-e^{-m}}{e^m+e^{-m}}=\tan u$
$m=?$