Why is Mathematica changing the output display format?

I do a command like

  Table[i^5/(i^5 + 7*i + 1) Sin[x]/E^(3 i x), {i, 1, 5}]


The output shows up as

$$\left\{\frac{1}{9} e^{-3 x} \sin (x),\frac{32}{47} e^{-6 x} \sin (x),\frac{243}{265} e^{-9 x} \sin (x),\frac{1024 e^{-12 x} \sin (x)}{1053},\frac{3125 e^{-15 x} \sin (x)}{3161}\right\}$$

Compare the last two entries to the first three. The issue is that the last two entries are a fraction, while the first 3 have a rational times an expression. This is also true when I copy as $$\LaTeX$$.

Why is Mathematica changing the way it is displaying the output, which is quite annoying as I am manually having to make the last two match the first three? Is there any way to have it produce a consistent output?

I have noticed this on both 12.3 and 13.0 on a Windows 10, x86 machine.

• Please evaluate \$Post and read about it in the docs, if applicable.
– Syed
Dec 20, 2021 at 20:47
• Is the issue that the last two entries are a fraction, while the first 3 have a rational times an expression? And what does manually matching mean? Dec 20, 2021 at 20:51
• t /. Times[r_Rational, p_Power, s_Sin] :> HoldForm[HoldForm[r]*p*s] or t /. Times[r_Rational, rem__] :> HoldForm[HoldForm[r]*rem] Dec 20, 2021 at 21:07
• Try the second form in my comment Dec 20, 2021 at 21:11
• Dec 20, 2021 at 21:16

Is there any way to have it produce a consistent output?

and a truthful answer is uncertain because the way that Mathematica produces output is mostly undocumented and subject to change. With that understood, there are several ways that would tend to produce output that is more consistent depending on how much effort you are willing to expend. In effect, you can construct your own output function that does exactly what you want, but that would duplicate the work that is done by the default output function.

What I suggest here is one simple way that may do what you want in this or similar situations, but it is only cosmetic and the underlying result is different than what it looks. That is, you can not use it for further manipulation unless you remove the wrapper.

Define the function

xx[x_] := Interpretation[x,x]


Apply it to your code as follows

Table[xx[i^5/(i^5 + 7*i + 1)] xx[Sin[x] E^(3 i x)], {i, 1, 5}]


The resulting output is what you would expect but the contents of the second use of xx[] appears inside a pair of parenthesis. This may be enough for your present situation without using more advanced methods.

Another workaround (This is meant just for fun's sake). By breaking the input into 2 Latex parts

toX[s_] := ToString@TeXForm@s;
data = Table[toX[i^5/(i^5 + 7 *i + 1)] <> toX[Sin[x]/E^(3 i x)], {i, 1, 5}]


Movie

To obtain back the Mathematica expression

 ToExpression[data, TeXForm]


Or can use MaTeX

 << MaTeX
MaTeX[data, Magnification -> 2]
`