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

Simplifications sometimes fail #1019

Open
jack-t opened this issue Mar 10, 2024 · 1 comment
Open

Simplifications sometimes fail #1019

jack-t opened this issue Mar 10, 2024 · 1 comment

Comments

@jack-t
Copy link

jack-t commented Mar 10, 2024

Description

Simple simplifications sometimes fail. Here are some examples:

Correct:

In[21]:= 4 Sqrt[12] + 5 Sqrt[5] + 105 Sqrt[12]
Out[21]= 5 Sqrt[5] + 218 Sqrt[3]

Should be 50 Sqrt[5] + 218 Sqrt[3]:

In[22]:= 4 Sqrt[12] + 50 Sqrt[5] + 105 Sqrt[12]
Out[22]= 8 Sqrt[3] + 50 Sqrt[5] + 210 Sqrt[3]

How to Reproduce

I just opened a Mathics REPL and typed commands in. I observed the same behavior when I wrote the same commands in a script.

Expected behavior

Choosing relatively prime x and y, I wrote expressions of the form a Sqrt[x] + b Sqrt[y] + c Sqrt[x], varying the coefficients. Depending on some relationship between the radicands, a sufficiently large b (see 5 and 50 in the example) seemed to produce this behavior for lots of values of x and y.

Your Environment

Mathics 6.0.4
on CPython 3.9.6 (default, Jul 26 2021, 11:40:16) 
using SymPy 1.12, mpmath 1.3.0, numpy 1.24.3, cython Not installed
@rocky
Copy link
Member

rocky commented Mar 24, 2024

I just had a chance to look at this. (I will be pretty busy until the beginning of May).

First of all, the result is not wrong. The result just isn't simplified as you expect. I am not seeing anywhere in WMA docs that say that results have to be automatically simplified.

If you surround the result in an explicit Symplify[] call, you do get the results you expect. So that is a workaround.

@mmatera your thoughts?

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