Differentiating a function with respect to a vector I need to differentiate the function $u$ shown below with respect to a vector $\psi$: ($a, c$ and $f$ are constants)
$$u(\psi) =\left[\begin{array}{cccc}
a & f & 0 & 0\\
c & a & f & 0\\
0 & c & a & f\\
0 & 0 & c & a
\end{array}\right]\left[\begin{array}{c}
\psi^{1}\\
\psi^{2}\\
\psi^{3}\\
\psi^{4}
\end{array}\right]$$
I'm thinking that the answer would be: 
$\left[\begin{array}{cccc}
a & f & 0 & 0\\
c & a & f & 0\\
0 & c & a & f\\
0 & 0 & c & a
\end{array}\right]$ by working out the derivative of each term of the matrix with respect to its corresponding $\psi$. But I was hesitant that the function could be written as:
$u=\left[\begin{array}{c}
a\psi^{1}+f\psi^{2}\\
c\psi^{1}+a\psi^{2}+f\psi^{3}\\
c\psi^{2}+a\psi^{3}+f\psi^{4}\\
c\psi^{3}+a\psi^{4}
\end{array}\right]$
and hence its derivative will just be: $\left[\begin{array}{c}
a\\
a\\
a\\
a
\end{array}\right]$, if the rows were differentiated with respect to only the corresponding $\psi$. Please let me know which is correct. I think the first one, but need to be sure.
 A: The answer does depend on what you mean by "derivative".  Your function $u$ appears to be a nice linear function $u:\mathbb{R}^4 \rightarrow \mathbb{R}^4$.  Most of the time when one says they want to take "the derivative" of a function, $f: \mathbb{R}^n \rightarrow \mathbb{R}^m$ at $\vec{x} = \vec{a} $ they mean they want the linear function $Df_{\vec{a}}: \mathbb{R}^n \rightarrow \mathbb{R}^m$ that satisfies the condition:
$$\lim_{\vec{x} \rightarrow \vec{a}} \frac{|f(\vec{x}) - f(\vec{a})-Df_{\vec{a}}(\vec{x})|}{|\vec{x} - \vec{a}|} = 0 $$
Assuming such a $Df$ exists it turns out to be given by the matrix with rows equal to the gradients of the components of $f$.  So  in your case, $u= (a \psi^1 + f \psi^2, c \psi^1 + a \psi^2 + f \psi^3,c \psi^2 + a \psi^3 + f \psi^4, c \psi^3 + a \psi^4) = (u_1,u_2,u_3,u_4)$ the derivative $Du$ is given by: 
$$\left(
  \begin{array}{c}
    \nabla u_1\\
    \nabla u_2 \\
      \nabla u_3 \\
     \nabla u_4
  \end{array}
\right)
%
=\left(
  \begin{array}{cccc}
    a & f & 0 & 0 \\
    c &  a & f & 0 \\
     0 & c & a & f \\
    0 & 0 & c & a \\
  \end{array}
\right)
$$
Which was your first instinct! Go withyour gut!
A: You have
$$u_i(\psi)=\sum_jA_{ij}\psi_j$$
and so
$$\partial_{\psi_k}u_i(\psi)=\sum_jA_{ij}\delta_{jk}=A_{ik}$$
that is your original matrix.
