Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
simplify coefficients automatically and use the faster algorithm per …
Browse files Browse the repository at this point in the history
…default
  • Loading branch information
dkrenn committed Nov 4, 2015
1 parent 2a0815d commit e93ce46
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/sage/rings/asymptotic/asymptotic_expansion_generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,14 +273,17 @@ def Binomial_kn_over_n(var, k, precision=None, skip_constant_factor=False,
TESTS::
sage: asymptotic_expansions.Binomial_kn_over_n(
....: 'n', k=2, precision=5, algorithm='log')
sage: asymptotic_expansions.Binomial_kn_over_n(
....: 'n', k=3, precision=5, algorithm='log')
sage: all( # long time
....: asymptotic_expansions.Binomial_kn_over_n('n', k=k,
....: precision=5, algorithm='direct').has_same_summands(
....: asymptotic_expansions.Binomial_kn_over_n('n', k=k,
....: precision=5, algorithm='log'))
....: for k in (2, 4))
True
"""
if algorithm is None:
algorithm = 'direct'
algorithm = 'log' # 'log' seems to be faster, so we use it
# as a default.

from sage.symbolic.ring import SR
SCR = SR.subring(no_variables=True)
Expand Down Expand Up @@ -315,7 +318,8 @@ def Binomial_kn_over_n(var, k, precision=None, skip_constant_factor=False,
if not skip_constant_factor:
result /= (2*SCR('pi')).sqrt()

return result
return result.map_coefficients(
lambda c: c.canonicalize_radical())

else:
raise ValueError('Unknown algorithm %s.' % (algorithm,))
Expand Down

0 comments on commit e93ce46

Please sign in to comment.