### Documentation

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

Valid input examples are:
• 0.5*x'*A*x
• A*exp(x)
• (y.*v)'*x
• a^b
• norm1(A*x-y)
• norm2(A*x-y)^2
• sum(log(exp(-y.*(X*w)) + vector(1)))
• tr(A*X'*B*X*C)
• log(det(inv(X)))

By default:
• a, b, ..., g are scalars,
• h, i, ..., z are vectors, and
• A, B, ..., Z are matrices.

Output:
• $$\odot$$ - element-wise multiply
• $$\oslash$$ - element-wise divide
• $$\mathbb{I}$$ - identity matrix
• $$\mathrm{diag}$$ - diagonal matrix
• $$\mathrm{inv}$$ - inverse matrix
• $$\mathrm{adj}$$ - adjugate matrix

Valid input operators are:
• +, -, *, /, ^
• .*, ./, .^ - element-wise operations
• sin, cos, exp, log, abs, sign - element-wise operations (not matrix exponentials, etc.!)
• sum - sum of all entries of a vector or matrix
• norm1 - 1-norm of a vector or element-wise 1-norm of a matrix
• norm2 - Euclidean norm of a vector or Frobenius norm of a matrix
• tr, det, logdet, inv
• vector, matrix

Common error messages:
• Cannot display this 3rd/4th order tensor.

• 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.