Bug introduced in 10.2.0 or earlier and fixed in 10.4.0
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!
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.
Answer
This is a bug I fixed in 10.4.0. Sorry for the inconvenience! To work around it in earlier versions, evaluate the following block of code:
InactiveDump`assembleInactiveSumProduct[{args_, disp_, interp_, char_,
tag_, tooltip_, fmt_}] :=
TemplateBox[args, tag, DisplayFunction -> Function[disp],
InterpretationFunction -> Function[interp], SyntaxForm -> char]
The SyntaxForm
which specifies precedence for parenthesization was missing before 10.4.0.
Comments
Post a Comment