I wrote this code to calculate the gradient of the matrix, but I got the wrong answer
W = matrix(SR, 2, var(','.join([f'w{i}' for i in range(4)]), domain=RR))
x = vector(SR, 2, var('x1,x2', domain=RR))
y = sum(W*x)
f(x) = y.diff(x)
W.apply_map(f)
output:
[0 0]
[0 0]
what I expect is
[x1 x2]
[x1 x2]