I tried to solve $\int t \sin (t^2) dt$ using partial integration. I tried to solve  $\int t \sin (t^2) dt$ using partial integration. The result is $\frac{-t \cos{(t^2)}}{2} + \frac{\sin{(t^2)}}{4} + C$.
Then I tried to differente that result. Instead of getting $t \sin (t^2)$, I got $t^2 \sin{(t^2)}-\frac{\cos{(t^2)}}{2}+\frac{t\cos{(t^2)}}{2}$.
What's wrong? (I know I can use substitution, just curious to use partial integration.)
Edit: Here is how I get the result:
Using the formula $\int uv' dt = uv-\int u'vdt$.
$ u = t \rightarrow u \frac{d}{dt} = t \frac{d}{dt} \rightarrow u \frac{d}{dt} = 1$, and $v \frac{d}{dt} = \sin{(t^2)} \rightarrow \int {v \frac{d}{dt}} dt = \int{\sin{(t^2)}} dt \rightarrow v = \frac{-\cos {(t^2)}}{2}+C_1$, so
$\begin{align} uv-\int{u'v}dt = \frac{-t \cos{(t^2)}}{2} + tC_1 - \int{\frac{-\cos{(t^2)}}{2}}dt - \int{C_1}dt = \frac{-t \cos{(t^2)} }{2} + tC_1 + \frac{ \sin{(t^2)}}{4} - tC_1 + C_2 = \frac{-t \cos{(t^2)} }{2} + \frac{ \sin{(t^2)}}{4} + C_2. \end{align}$
 A: I’m guessing that you integrated $\sin t^2$ to $-\frac12\cos t^2$ and $\cos t^2$ to $\frac12\sin t^2$, as that would yield the result you give. That’s wrong, as you can see if you differentiate the results.
A: Integrating by parts will yield the following:
$$
\begin{align}
\int \underbrace{t}_u\underbrace{\sin\left(t^2\right)}_{v'}\text{d}t = \underbrace{t}_u \cdot \underbrace{\int \sin\left(t^2\right)\text{d}t}_v - \int \left(\underbrace{1}_{u'} \cdot \underbrace{\int \sin\left(t^2\right)\text{d}t}_v \right)\text{d}t \tag{1}\label{1}
\end{align}
$$
Your mistake lies in the integration of $v'$. Following your statement would mean:
$$ v \frac{\text{d}}{\text{d}t} = - \frac{1}{2}\cos\left(t^2\right) \frac{\text{d}}{\text{d}t} \color{red}{ = \sin\left(t^2\right) = v'}$$
The correct derivative of $-\frac{1}{2}\cos\left(t^2\right)$ would be $t \sin\left(t^2\right)$ (which is what you started with so you accidentally found the correct integral for the initial function). 
The correct integral of $v' = \sin\left(t^2\right)$ would be:
$$
\begin{align}
v = \int \sin\left(t^2\right)\text{d}t &= \frac{1}{4} \left(1 + i\right)\left(-i\operatorname{erf}\left(\frac{1}{2}\left(1-i\right)t\sqrt{\pi}\sqrt{\frac{2}{/pi}}\right)+\operatorname{erf}\left(\frac{1}{2}\left(1+i\right)t\sqrt{\pi}\sqrt{\frac{2}{\pi}}\right)\right)\sqrt{\frac{\pi}{2}}  \\
&= \left(\frac{1}{4}+\frac{i}{4}\right)\sqrt{\frac{\pi}{2}}\left(\operatorname{erf}\left(\frac{\left(1+i\right)t}{\sqrt{2}}\right)-\operatorname{erfi}\left(\frac{\left(1+i\right)t}{\sqrt{2}}\right)\right)
\end{align}
$$
As you can see, this wont integrate nicely and you will need the Error function. Putting this into $\eqref{1}$ and integrating it a second time will eventually get you to the same solution but substitution is obviously the better choice.
