Matrix Calculus


MatrixCalculus provides matrix calculus for everyone. It is an online tool that computes vector and matrix derivatives (matrix calculus).

derivative of
w.r.t.

\({}\)

where

  • {{v.name}} is a
Export functions as
Common subexpressions
{{ctrl.service.error.msg}}
0.5*x'*A*x
A*exp(x)
sin(x)'*y
(y.*v)'*x
a^b
norm2(A*x-y)^2
sum(log(exp(-y.*(X*w)) + vector(1)))
tr(A*X'*B*X*C)
log(det(inv(X)))
+
addition
-
subtraction
*
multiplication
/
division
^
power
.*
element-wise multiplication
./
element-wise division
.^
element-wise power
sin()
sine
cos()
cosine
log()
natural logarithm
exp()
exponential
abs()
element-wise absolute value
sign()
element-wise sign
norm1()
element-wise 1-norm
norm2()
Frobenius norm
tr()
trace
det()
determinant
inv()
inverse
norm1()
1-norm
norm2()
Euclidean norm
vector()
constant vector
matrix()
constant matrix
Only scalars, vectors, and matrices are displayed as output. If the derivative is a higher order tensor it will be computed but not displayed since there is no (good) representation of higher order tensors by matrices. For instance, differentiating the matrix expression X with respect to the matrix X yields the 4th order identity tensor. It will not be displayed.
Cannot display this 2nd order tensor.
Some 2nd order tensors do not have a representation as a matrix. For instance, differentiating the row vector expression x' with respect to the column vector x yields a 2nd order tensor that has no representation as a matrix. In such cases try the transpose of the original input expression. It is a column vector and its derivative can be represented as a matrix.