let
@variables q[1:5]
Symbolics.gradient(
sum(q .* log.(q)), collect(q)
)
end
This outputs a vector of zeros: [0, 0, 0, 0, 0], but the correct gradient consists of elements like 1 + log(q[k]):
import sympy as sp
q = sp.symbols("q1:5", real=True)
the_sum = sum(
q_ * sp.log(q_) for q_ in q
)
sp.Matrix([
[the_sum.diff(q_) for q_ in q]
]).T
Output:

┆Issue is synchronized with this Trello card by Unito