How is the following multiplication performed for this (cost) function:
$J=\frac{1}{2}\int_0^T{[y(t)-\hat{\pmb{x}}^T\pmb{h}(t)]^T[y(t)-\hat{\pmb{x}}^T\pmb{h}(t)]dt}$$=\frac{1}{2}\int_0^T{[y(t)]^2dt}-[\int_0^T{[y(t)\pmb{h}^T(t)dt}]\hat{\pmb{x}}+\frac{1}{2}\hat{\pmb{x}}^T[\int_0^T{[\pmb{h}(t)\pmb{h}^T(t)dt}]\hat{\pmb{x}}$
I can't see how we get the second term. Also, the third term implies that, only for this case, AB=BA, where A and B are matrices, right?
EDIT: $\pmb{h}(t)$ is a column vector of functions of $t$ and $\pmb{\hat{x}}$ is a column vector of numbers.