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

Add support for bidirectional limits (dir="real") #8194

Closed
wants to merge 1 commit into from
Closed

Add support for bidirectional limits (dir="real") #8194

wants to merge 1 commit into from

Conversation

skirpichev
Copy link
Contributor

  • Do we need this at all? 1) We don't have specific algorithms for bidirectional limits yet. 2) Not all CAS support this conception, see e.g. Mathematica.
  • Better name for dir value? (variants: "0", "both" or just None); "real" is from the Maple.
  • Raise different errors for discontinuities of different type.

tex = r"\lim_{%s \to %s}" % (self._print(z),
self._print(z0))
tex = r"\lim_{%s \to " % self._print(z)
if str(dir) == "real" or z0 in (S.Infinity, S.NegativeInfinity):
Copy link
Member

Choose a reason for hiding this comment

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

Why are you wrapping dir in str to do the test here and throughout?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

because dir is a Symbol

Copy link
Member

Choose a reason for hiding this comment

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

ok. I missed the sympification of the arg. Would dir.name be better than str(dir)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I find this more cryptic.
On Oct 4, 2014 11:32 PM, "Christopher Smith" notifications@github.com
wrote:

In sympy/printing/latex.py:

@@ -562,8 +562,11 @@ def _print_Integral(self, expr):
def _print_Limit(self, expr):
e, z, z0, dir = expr.args

  •    tex = r"\lim_{%s \to %s}" % (self._print(z),
    
  •                                 self._print(z0))
    
  •    tex = r"\lim_{%s \to " % self._print(z)
    
  •    if str(dir) == "real" or z0 in (S.Infinity, S.NegativeInfinity):
    

ok. I missed the sympification of the arg. Would dir.name be better than
str(dir)?


Reply to this email directly or view it on GitHub
https://github.com/sympy/sympy/pull/8194/files#r18431164.

@skirpichev
Copy link
Contributor Author

rebased on top of #8201

@asmeurer
Copy link
Member

I think it's better just in terms of usability. People expect limit to be bidirectional by default.

@skirpichev
Copy link
Contributor Author

People expect limit to be bidirectional by default.

Maybe (any proofs?). Anyway, are you sure this worth a performance penalty right now?

@asmeurer
Copy link
Member

There have been several issues about it. I do think it would be better if we could make this work on a low level in the Gruntz algorithm to avoid duplicate work.

@skirpichev
Copy link
Contributor Author

On Tue, Oct 28, 2014 at 10:20:20AM -0700, Aaron Meurer wrote:

I do think it would be better if
we could make this work on a low level in the Gruntz algorithm to avoid
duplicate work.

Sure, but it's far from trivial and it will be not the Gruntz algorithm.

@skirpichev skirpichev added the Needs Decision This needs discussion to resolve an undecided issue before further work can be done. label Nov 19, 2014
@skirpichev
Copy link
Contributor Author

Feel free to pick up this work.

@skirpichev skirpichev closed this Jan 16, 2015
@cbm755
Copy link
Contributor

cbm755 commented Jan 24, 2015

@pelegm, @asmeurer I think this should be merged. Performance doesn't strike me as a big deal b/c this PR does not propose making it the default. Can one of you re-open this?

We can file an issue for improving the performance (although I'm not volunteering to do that) and/or making it default.

@moorepants moorepants reopened this Jan 24, 2015
@cbm755
Copy link
Contributor

cbm755 commented Jan 24, 2015

Ok, maybe this is not so easy:

a = limit(sin(1/x**2), x, 0, '-')
# sin(oo)
b = limit(sin(1/x**2), x, 0, '+')
# sin(oo)
(a - b).equals(0)
# True

limit(sin(x), x, oo) should be NaN, or Eq(sin(oo), sin(oo)) should be False, something like that.

But probably there are similar silent failures where the left- and right-hand limit are unevaluated expressions.

@cbm755
Copy link
Contributor

cbm755 commented Jan 24, 2015

sin(oo) thing is #5299.

@amitsaha
Copy link
Contributor

@asmeurer Strictly from a SymPy user's point of view (and writing about it for others to learn), is it possible that the default will be bidirectional in a future release?

@pelegm
Copy link
Contributor

pelegm commented Jan 25, 2015

@amitsaha see discussion here. I personally agree with you.

@skirpichev skirpichev closed this Jan 27, 2015
@skirpichev skirpichev deleted the limit-dir branch March 1, 2015 10:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Decision This needs discussion to resolve an undecided issue before further work can be done. series
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants