Skip to main content
1 of 4
Hosein Rahnama
  • 1.7k
  • 1
  • 17
  • 31

Problems with Displaying Output for Summation

Consider the following code.

ClearAll["Global`*"]
InactSum = Inactive[Sum]
InactInt = Inactive[Integrate]
A = InactInt[
    Subscript[\[Phi], j][x] InactSum[
    Subscript[a, i] Subscript[\[Phi], i][x], {i, 1, n}] , {x, a, b}]
B = InactInt[
    InactSum[Subscript[a, i]
    Subscript[\[Phi], i][x] Subscript[\[Phi], j][x], {i, 1, n}] , {x,
    a, b}]
Interchange = InactInt[InactSum[p_, q_], r_] -> InactSum[InactInt[p, r], q];
A /. Interchange
B /. Interchange

I have introduced two expressions

$$\begin{align} A &= \int_{a}^{b} \phi_{j}(x) \left( \sum_{i=1}^{n} a_i \phi_{i}(x) \right) dx \\ B &= \int_{a}^{b} \left( \sum_{i=1}^{n} a_i \phi_{i}(x) \phi_{j}(x)\right) dx \end{align}$$

where in $A$, $\phi_{j}$ is outside the summation while in $B$ it is inside the summation. Technically, these are both the same. But when I was trying to write a transformation rule that interchanges the integration and summation, then I noticed that it just applies to $B$ and not to $A$. So, I understood that Mathematica understands the little difference between these two but

The Standard Output for Both is the Same!

enter image description here

This prevents user from understanding the difference and it just shows itself when you want to apply the transformation rule.

I think this is a bug. In my opinion, the standard output for these two should be different. I would be happy to see what you think.

Hosein Rahnama
  • 1.7k
  • 1
  • 17
  • 31