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

is_polynomial right for wrong reasons (and sometimes wrong) #22583

Closed
Tracked by #1047
smichr opened this issue Dec 1, 2021 · 2 comments · Fixed by #22539
Closed
Tracked by #1047

is_polynomial right for wrong reasons (and sometimes wrong) #22583

smichr opened this issue Dec 1, 2021 · 2 comments · Fixed by #22539
Labels

Comments

@smichr
Copy link
Member

smichr commented Dec 1, 2021

>>> (f(x) + 1).is_polynomial(f(x))
True

That is right for the same reason that (x + 1).is_polynomial(y) -> True: because the expression is perceived as being independent of the "symbol" provided. This can be seen by considering a case known to be false:

>>> (1/x+1).is_polynomial(x)
False
>>> (1/f(x)+1).is_polynomial(f(x))
True

This is addressed by #22539

@smichr
Copy link
Member Author

smichr commented Dec 1, 2021

/!\ Things become significantly more complicated when we allow non-symbols generators to stay in place while doing operations on expressions in terms of generators (e.g. solving, integrating, etc...). The problem is that you have to start being more precise and more careful when determining how you can treat an expression. e.g. Although (x**2 + x + 1).has(x + 1) is True this doesn't mean that you can separate the expressions into parts that have and don't have 1 + x because they are dependent on each other, both x**2 and 1 + x sharing symbol x. This is where the generator idea is more helpful: it will not identify x as a generator in f(x), nor will it identify x + 1 as one in x**2 + x + 1.

And if routines need to check generators at the outset to make sure they are the right type, then those routines might as well make life easier by just replacing them with a Symbol right from the start.

@MishraAditya12126
Copy link

Well you can't define a polynomial in terms of its output symbol i guess
like
x = x*(x+2)
Note this is not a incremenation
you are treating this as a function

skirpichev added a commit to skirpichev/diofant that referenced this issue Mar 1, 2022
Closes sympy/sympy#22583

Note, that (as in the SymPy right now):
In [4]: x.is_polynomial((x + 1)**2)
Out[4]: True
skirpichev added a commit to skirpichev/diofant that referenced this issue Mar 2, 2022
Closes sympy/sympy#22583

Note, that (as in the SymPy right now):
In [4]: x.is_polynomial((x + 1)**2)
Out[4]: True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants