Differentiate the product of some terms
As stated in my comment, the hard thing here is, that Mathematica cannot expand your Product
for an unknown k
. What you know is, that $1\leq j \leq k$ but I don't how I could help Mathematica, that it expands your Product with this knowledge. What we want to do is the following:
$$\prod_{i=1}^k (1+\lambda_i)e^{\lambda_i} \rightarrow \\\left(\prod_{i=1}^{j-1} (1+\lambda_i)e^{\lambda_i}\right) \cdot \left((1+\lambda_j)e^{\lambda_j}\right)\cdot \left(\prod_{i=j+1}^k (1+\lambda_i)e^{\lambda_i}\right)$$
Let's try to do this small part manually
expr = Product[(1 + l[i]) Exp[l[i]], {i, k}];
exprExpanded = expr /. Product[f_, {i_, k_}] :>
Product[f, {i, 1, j - 1}]*(f /. i :> j)*Product[f, {i, j + 1, k}]
$$e^{l[j]} (1+l[j]) \left(\prod _{i=1}^{-1+j} e^{l[i]} (1+l[i])\right) \prod _{i=1+j}^k e^{l[i]} (1+l[i])$$
In this form we can derive the expression with D
because everything which depends on l[j]
is extracted
dexpr = D[exprExpanded, l[j]]
$$e^{l[j]} \left(\prod _{i=1}^{-1+j} e^{l[i]} (1+l[i])\right) \prod _{i=1+j}^k e^{l[i]} (1+l[i])+e^{l[j]} (1+l[j]) \left(\prod _{i=1}^{-1+j} e^{l[i]} (1+l[i])\right) \prod _{i=1+j}^k e^{l[i]} (1+l[i])$$
This is the general analytic form of your derivative. Now you can check whether it is equivalent to calculated derivative when you insert special values for j
and k
(dexpr /. {j :> 3, k :> 5}) == D[Product[(1 + l[i]) Exp[l[i]], {i, 5}], l[3]]
(*
True
*)