Consider the following operation M * x where A is a matrix and x a vector. I want to know if we can do the following using the Symbolics package.
- Calculate the Jacobian of M * x with respect to M, M, \dots .
- Use the symbolic expression from one and evaluate it using arbitrary values.
- (Optional) can I compile the function to be equivalent to a normal Julia function. I am mainly interested in speed here.
Here is what I thought should work, but didn’t.
@variables M[1:3, 1:3], x[1:3] Symbolics.jacobian(M*x, reshape(M, 9)) # Does not work Symbolics.jacobian(M*x, [M[1,1], M[1,2]]) # Does not work
I managed to get a working version but it’s the API does not feel intuitive.
@variables M[1:3, 1:3], x[1:3] c = reshape(M, 3, 3) * reshape(x, 3, 1) Symbolics.jacobian(reshape(c, 3), reshape(M, 9))