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

cancel consistently handles exprs #12786

Closed
wants to merge 22 commits into from
Closed

cancel consistently handles exprs #12786

wants to merge 22 commits into from

Conversation

smichr
Copy link
Member

@smichr smichr commented Jun 22, 2017

>>> cancel((Poly(x),Poly(y)))
(1, Poly(x, x, y, domain='ZZ'), Poly(y, x, y, domain='ZZ'))
>>> cancel((Poly(x),Poly(y)), tuple=False)
x/y
>>> cancel(x/2+1)
(x + 2)/2
>>> cancel(x/2+1, tuple=True)
(1/2, x + 2, 1)
  • when the output is not a tuple, it will always be a fraction or an expression with numerator of 1,
    unevaluate if necessary
  • passing a tuple of length other than 2 is disabled
  • the handling of expressions and numerator/denominator tuples is separated

closes #12787
closes #11506

@smichr smichr changed the title cancel recognizes non-symbol gens cancel recognizes non-symbol gens and consistently handles exprs Jun 22, 2017
@smichr smichr force-pushed the cancel branch 5 times, most recently from 7b02128 to 897805a Compare June 25, 2017 03:47
@smichr smichr changed the title cancel recognizes non-symbol gens and consistently handles exprs cancel consistently handles exprs Jun 25, 2017
p, q = F
rv = c, n, d = _cancel_pq(p, q, *gens, **args)
if not as_tuple:
rv = _keep_coeff(c, nd)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nd->n, d and test this

smichr added 21 commits July 3, 2017 21:25
The generators are recognized in the order given.

The return type is now consistently a Tuple.
A conequence of being consistent is that an expression like this:

exp(1 + log(_p)/_p)

formerly returned as this

E*exp(log(_p)/_p)

but now comes back as this:

exp((_p + log(_p))/_p)

The latter result is consistent with how the original cancel
gave cancel(exp(1 + x/y)) -> exp((y + x)/y).

Because of this change, expansion is now used in calculate_series.

A consequence of the expansion is that a former test that gave
sign(y)*I*oo now gives y*I*oo ... and that seems ok. The expanded
t in calculate_series for gruntz(y*3*sin(I)*x, x, oo) is now

-3*I*y*exp(-1)/(2*_w) +3*E*I*y/(2*_w)

while it was formerly

(-3*I*y + 3*I*y*exp(2))*exp(-1)/(2*_w)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cancel should recognize non-Symbol generators cancel on expressions with exponentials
1 participant