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

Wrong order in diophantine() with syms #20395

Open
boyoungzheng opened this issue Nov 8, 2020 · 2 comments
Open

Wrong order in diophantine() with syms #20395

boyoungzheng opened this issue Nov 8, 2020 · 2 comments

Comments

@boyoungzheng
Copy link

In diophantine.py line 488--490

dict_sym_index = dict(zip(syms, range(len(syms))))
return {tuple([t[dict_sym_index[i]] for i in var])
            for t in diophantine(eq, param, permute=permute)}

I think we should switch syms and var here. We want returns in the order of syms rather than var. Otherwise, it makes no sense to me. So it should be

dict_var_index = dict(zip(var, range(len(var))))
return {tuple([t[dict_var_index[i]] for i in syms])
            for t in diophantine(eq, param, permute=permute)}
@oscarbenjamin
Copy link
Contributor

Can you give examples of how the output from diophantine would be different?

@boyoungzheng
Copy link
Author

>>> diophantine(x1+2*x2+3*x3)
{(t_0, t_0 + 3*t_1, -t_0 - 2*t_1)}
>>> diophantine(x1+2*x2+3*x3, syms=[x3, x1, x2])
{(t_0 + 3*t_1, -t_0 - 2*t_1, t_0)}

After the code modification

>>> diophantine(x1+2*x2+3*x3)
{(t_0, t_0 + 3*t_1, -t_0 - 2*t_1)}
>>> diophantine(x1+2*x2+3*x3, syms=[x3, x1, x2])
{(-t_0 - 2*t_1, t_0, t_0 + 3*t_1)}

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

No branches or pull requests

2 participants