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
Prev Previous commit
Next Next commit
Errors in previous commit fixed.
  • Loading branch information
hargup committed Feb 16, 2013
commit 7fee1c06da95bf2a83be35c95c23ee1a592eea77
16 changes: 8 additions & 8 deletions sympy/polys/polytools.py
Original file line number Diff line number Diff line change
Expand Up @@ -1692,7 +1692,6 @@ 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,18 +3952,19 @@ def degree(f, *gens, **args):
1

"""
if len(gens)==0:
gens_present=False
if len(gens) == 0:
gens_present = False
else:
gens_present=True
gens_present = True

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

options.allowed_flags(args, ['gen', 'polys'])
try:
Expand Down