Hi all, I got stuck on computing the partial derivatives of a multivariate polynomial.
The following is my code:
using TypedPolynomials
using LinearAlgebra
@polyvar p1 p2 p3 p4 p5 p6 p11 p12 p13 p21 p22 p23 p31 p32 p33
A = [p1 p2 p3]
AT = transpose(A)
B = [p4 p5 p6]
BT = transpose(B)
P = AT*A + BT*B
M=copy(P)
M[1,1] = 2*M[1,1]
M[2,2] = 2*M[2,2]
M[3,3] = 2*M[3,3]
differentiate(det(M), P[1,1])
Here, matrix P is like:
p1² + p4² p1p2 + p4p5 p1p3 + p4p6
p1p2 + p4p5 p2² + p5² p2p3 + p5p6
p1p3 + p4p6 p2p3 + p5p6 p3² + p6²
I want to compute the partial derivative of det(M) with respect to P[1,1], i.e. p1² + p4². But I still couldn’t find a way to compute it. There’s always an error, which is shown below:
ERROR: MethodError: no method matching iterate(::Polynomial{Int64,Term{Int64,Monomial{(p1, p2, p3, p4, p5, p6),6}},Array{Term{Int64,Monomial{(p1, p2, p3, p4, p5, p6),6}},1}})
Is there a package that can be used to solve this problem? Really appreciate!