# Is the gradient of a vector product a row or a column?

I am trying to define the gradient of $x^Ty$ with respect of $x$ where both $x, y$ are column vectors $\in \mathbb{R}^m$.

$\frac{\partial x^Ty}{\partial x} = [\frac{\partial x^Ty}{\partial x_1} , \frac{\partial x^Ty}{\partial x_2} , ... , \frac{\partial x^Ty}{\partial x_m}] = [y_1, y_2, ..., y_m] = y^T$

or is it

= $[\frac{\partial x^Ty}{\partial x_1} , \frac{\partial x^Ty}{\partial x_2} , ... , \frac{\partial x^Ty}{\partial x_m}]^T = [y_1, y_2, ..., y_m]^T = y$

I am quite confused since I haven't been exposed to multivariate calculus before.

• It depends on the definition of the gradient. It is very common to use the gradient as a row vector. Feb 9, 2018 at 11:55
• A gradient adds an index. So it depends on what you want the first index to point on rows or columns in your visualization of the structures you are working with. In general you need to specify indices to do inner or outer product over as soon as you get something with more than 2 indices anyway. Feb 12, 2018 at 5:49