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

Incomplete simplify #21552

Open
proy87 opened this issue May 31, 2021 · 1 comment
Open

Incomplete simplify #21552

proy87 opened this issue May 31, 2021 · 1 comment
Labels

Comments

@proy87
Copy link

proy87 commented May 31, 2021

simplify(2*((2*x - 3*y**2)*(3*x - (3*x**2 - 2*y)/(2*x - 3*y**2)) + (3*x**2 - 2*y)*(3*y*(3*x**2 - 2*y)/(2*x - 3*y**2) - 1))/(2*x - 3*y**2)**2) returns 2*x*y*(27*x**3 - 54*x*y + 27*y**3 + 8)/(8*x**3 - 36*x**2*y**2 + 54*x*y**4 - 27*y**6).
But 8*x**3 - 36*x**2*y**2 + 54*x*y**4 - 27*y**6 is (2*x - 3*y**2)**3.

@mostlyaman
Copy link
Contributor

mostlyaman commented May 31, 2021

As mentioned in the sympy docs at https://docs.sympy.org/latest/tutorial/simplification.html

But simplify() has a pitfall. It just applies all the major simplification operations in SymPy, and uses heuristics to determine the simplest result. But “simplest” is not a well-defined term.

To get specific simplifications, you can use other simplification methods that specialise for your use. In this case, factor returns a factorised numerator and denominator.

>>> factor(2*((2*x - 3*y**2)*(3*x - (3*x**2 - 2*y)/(2*x - 3*y**2)) + (3*x**2 - 2*y)*(3*y*(3*x**2 - 2*y)/(2*x - 3*y**2) - 1))/(2*x - 3*y**2)**2)
2*x*y*(3*x + 3*y + 2)*(9*x**2 - 9*x*y - 6*x + 9*y**2 - 6*y + 4)/(2*x - 3*y**2)**3

factor does the job but if you are suggesting that simplify should output factorised denominator, then a change may be required.

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

No branches or pull requests

3 participants