Trying to perform system identification in the following state-space model $$ \begin{bmatrix} x_{1}(n)\\ x_{2}(n) \\ x_{3}(n)\end{bmatrix}=\begin{bmatrix} a_{11} && a_{12} && a_{13} \\ a_{21} && a_{22} && a_{23} \\ a_{31} && a_{32} && a_{33} \end{bmatrix} \begin{bmatrix} x_{1}(n-1)\\ x_{2}(n-1) \\ x_{3}(n-1)\end{bmatrix} +\begin{bmatrix} b_{11} && b_{12} \\ b_{21} && b_{22} \\ b_{32} && b_{23}\end{bmatrix} \begin{bmatrix} u(n) \\ u(n-1) \end{bmatrix} $$
$$ y(n) = \begin{bmatrix} c_{1} && c_{2} && c_{3}\end{bmatrix}\begin{bmatrix} x_{1}(n)\\ x_{2}(n) \\ x_{3}(n)\end{bmatrix} $$
$u$ in the input sequence and $y$ is the output sequence. If $p$ is any parameter in the model the following 'LMS rule' is used for estimating the parameter.
It is seen that the gradient of the output with respect to the parameter $p$ is needed. It is possible to compute these gradients with the expressions found in e.g. enter link description here. Experimentally I have verified that it works. So far so good.
All the parameters in the model I'm considering are computed from 6 underlying parameters $\theta_1, \theta_2, \theta_3, \theta_4, \theta_5, \theta_6$ which are the parameters that really need to be estimated/identified.
In a synthetic setup I'm keeping $\theta_3, \theta_4, \theta_5, \theta_6$ constant (pretending they are known) and only trying to estimate $\theta_1, \theta_2$. Both $a_{11}$ and $a_{12}$ depend on $\theta_1, \theta_2$. So I can write $a_{11}(\theta_1, \theta_2)$ and $a_{12}(\theta_1, \theta_2)$. Other parameters in the model also depend on $\theta_1, \theta_2$. My question is why I can't compute the gradients $\frac{\partial y(n)}{\partial \theta_1}$ and $\frac{\partial y(n)}{\partial \theta_2}$ by
$$ \begin{bmatrix} \frac{\partial y(n)}{\partial \theta_1}\\ \frac{\partial y(n)}{\partial \theta_2} \end{bmatrix} = \begin{bmatrix} \frac{\partial a_{11}(\theta_1, \theta_2)}{\partial \theta_1} && \frac{\partial a_{12}(\theta_1, \theta_2)}{\partial \theta_1} \\ \frac{\partial a_{11}(\theta_1, \theta_2)}{\partial \theta_2} && \frac{\partial a_{12}(\theta_1, \theta_2)}{\partial \theta_2} \end{bmatrix} \begin{bmatrix} \frac{\partial y(n)}{\partial a_{11}}\\ \frac{\partial y(n)}{\partial a_{12}} \end{bmatrix} $$
It may be a stupid bug but after serious debugging I'm starting to wonder if the above approach is fundamentally flawed, I just don't quite understand why it shouldn't work.
