Skip to main content
1 of 6
R zu
  • 349
  • 1
  • 8

Simplify sum of unnatural conditional functions generated by derivative

I try to use Mathematica to evaluate:

$$\frac{\partial}{\partial A_{abc}} \sum_{j=1}^{J}\sum_{k=1}^{K}\log\left(\sum_{l=1}^{L}A_{jkl}B_{jkl}\right)$$

I get:

$$\sum_{j=1}^J \sum_{k=1}^K \frac{\begin{array}&\begin{cases} B(j,k,c) & a-j=0\land b-k=0 \\ 0 & \text{True} \\ \end{cases} \\ \end{array}}{\sum_{l=1}^L A(j,k,l) B(j,k,l)}$$

Instead of

$$\frac{B_{abc}}{\sum _{l=1}^L A_{jkl} B_{jkl}}$$

How to make Mathematica simplify the sum of conditional functions?

Alternatively, how to avoid the conditional functions in the first place?

Thanks.

$Assumptions = 
  Element[a | b | c, Integers] && 1 <= a <= J && 1 <= b <= K && 
   1 <= c <= L;
expr = Sum[
  Log[Sum[A[j, k, l]*B[j, k, l], {l, 1, L}]], {j, 1, J}, {k, 1, K}]
Simplify[D[expr, A[a, b, c]]]
R zu
  • 349
  • 1
  • 8