Open rjc955 opened 9 months ago
That's a good point. Latex output isn't strictly correct in terms of the math and would benefit from grouping symbols in some places to make it more "correct". We haven't done this since the current output more resembles what people write in the literature. Maybe a ruleset could be made for when grouping symbols increase legibility
In some cases, when an expression contains a summation applied over a product of several terms, the LaTeX representation of that expression may omit necessary brackets. To reproduce this issue, run this demo notebook down to the cells at the end. Here is a screenshot:
A visual check of the string representations of
result_4
andexpected_result
shows that they are the same up to a permutation in the order of the terms in the products, and the notebook runs anassert_expr_equal
that verifies the same. But the LaTeX representation ofresult_4
is misleading in that it appears that, in the numerator for example, the summation $\Sigma{W{1}}{\Sigma{W{2},X,Y}{\Sigma{W{3}}}}$ is applied to all three terms in the product, whereas in fact only $\Sigma{W{1}}$ is applied to all three terms, and $\Sigma{W{2},X,Y}{\Sigma{W{3}}}$ is applied only to the first term. To make this fact clear, the LaTeX representation needs to include the red brackets in the numerator in the screenshot. Similarly, there should be brackets around the entire expression following $\Sigma{Y}{\Sigma{W_{1}}}$ in the denominator.