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

Issue 3223:degree((x+1)**10000) takes too long #1793

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Issue 3223 fixed
  • Loading branch information
hargup committed Feb 16, 2013
commit 45224436396751a619e5b52720de16f0bc75f3d4
16 changes: 14 additions & 2 deletions sympy/polys/polytools.py
Original file line number Diff line number Diff line change
Expand Up @@ -1692,7 +1692,7 @@ def degree(f, gen=0):

"""
j = f._gen_to_level(gen)

if hasattr(f.rep, 'degree'):
return f.rep.degree(j)
else: # pragma: no cover
Expand Down Expand Up @@ -3953,8 +3953,20 @@ def degree(f, *gens, **args):
1

"""
options.allowed_flags(args, ['gen', 'polys'])
if len(gens)==0:
gens_present=False
else:
gens_present=True

if f.is_polynomial():
for sym in f.free_symbols:
if gens_present:
if sym==gens[0]:
return -f.subs(sym,1/sym).leadterm(sym)[1]
else:
return -f.subs(sym,1/sym).leadterm(sym)[1]

options.allowed_flags(args, ['gen', 'polys'])
try:
F, opt = poly_from_expr(f, *gens, **args)
except PolificationFailed, exc:
Expand Down