Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LaTeX representations of complex expressions involving summations should sometimes include brackets but do not #208

Open
rjc955 opened this issue Feb 4, 2024 · 1 comment

Comments

@rjc955
Copy link
Contributor

rjc955 commented Feb 4, 2024

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:

Summation_Representation_Issue

A visual check of the string representations of result_4 and expected_result shows that they are the same up to a permutation in the order of the terms in the products, and the notebook runs an assert_expr_equal that verifies the same. But the LaTeX representation of result_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.

@cthoyt
Copy link
Member

cthoyt commented Feb 4, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants