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

Missing Parentheses in Complex Number Operations with SymPy #224

Open
limka1200 opened this issue Dec 3, 2024 · 0 comments
Open

Missing Parentheses in Complex Number Operations with SymPy #224

limka1200 opened this issue Dec 3, 2024 · 0 comments

Comments

@limka1200
Copy link

limka1200 commented Dec 3, 2024

I noticed a potential issue when using SymPy in combination with handcalcs. When performing operations involving complex numbers, parentheses are not added around terms during subtraction or multiplication. This could lead to confusion, especially when negative parts of complex numbers are involved, as the expressions might appear mathematically incorrect.
Here’s an example to illustrate:

from sympy import I
import handcalcs.render
%%render
z1 = 3 + I*4
z2 = -4 + I*3

z01 = z1*z2
z02 = z1-z2

The rendered output in LaTeX might look like this
image

Expected Behavior

Parentheses should be automatically placed around subtracted or multiplied terms to clarify the operations:
z01 = (3 + 4i)(-4 + 3i) = -24 - 7i
z02 = 3 + 4i - (-4 + 3i) = 7 + i

Version: 1.9.0

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

1 participant