about derivative of a matrix and trace I have checked it up the following derivation of a formula:"

The question that I have is why the author uses the trace in the third part; supposedly it uses a formula derived from the properties of the trace that states that:

 A: This is an awfully complicated way of deriving the derivative or gradient.
It is simpler to show that $\|J(\theta+h)-J(\theta) - (X \theta-y)^T X h\|$ is bounded above by $\|X^TX\| \|h\|^2$ from which we see that
 $DJ(\theta)(h) = (X \theta-y)^T X h = 
\langle X^T (X\theta -y), h \rangle$, where
$\langle \cdot,\cdot \rangle $ is the usual inner product in $\mathbb{R}^n$.
It follows from this that
$\nabla_\theta J(\theta) = X^T (X\theta -y)$.
Alternatively:
We have $J(\theta) = (X \theta-y)^T (X \theta -y) = 
\operatorname{tr} ( (X \theta-y)^T (X \theta -y)  )$, since the quantity is 
a scalar.
Expanding the terms in brackets leads to a constant term, terms linear in $\theta$ and a term that is quadratic in $\theta$.
The derivative of the constant term is zero, the linear terms are straightforward, only the quadratic term needs some attention.
The quadratic term takes the general form $L(X)$, where we let $L(X)= \operatorname{tr} (X^T B X C)$, then
$L(X+H)-L(X) = \operatorname{tr}(X^T B H C+H^T B X C+H^T B H C)$. Since trace
is linear we have $\operatorname{tr}(H^T B H C) \le M \|H\|^2$ for some $M$, and so $DL(X)(H) = \operatorname{tr}(X^T B H C+H^T B X C) = \operatorname{tr}(CX^T B H +C^T X^T B^T H)$, where the latter uses
the properties $\operatorname{tr}(AB) = \operatorname{tr}(BA)$ and
$\operatorname{tr} (A) = \operatorname{tr} (A^T)$.
This gives $DL(X)(H) = \langle BXC+B^TXC^T, H \rangle$, from which we
have $\nabla_X L(X) = BXC+B^TXC^T$. This is using the inner product induced
by the Frobenius norm. If $X$  (and $H$, of course) is in $\mathbb{R}^n$, this
reduces to the usual inner product,
which gives the above result.
