-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
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
find singularities for any expression #2925
Conversation
singularity in the following even though it is not in the domain of | ||
the expression (which is {x | x < 1}). | ||
|
||
>>> singularities(log(1 - x)/(x - 2)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why you won't count x=1
as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
x=1 is not in log's domain
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's a branch point for log(1-x), right?
>>> from sympy import Symbol | ||
>>> x = Symbol('x', real=True) | ||
>>> from sympy import Symbol, log | ||
>>> from sympy.abc import x |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we always prefer from sympy.abc import x
over x = Symbol('x')
? Does it have any particular advantage?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
importing from abc is pretty common and a good visual reminder that you are getting vanilla symbols when you do so
@smichr We had a more general implementation of singularities at #2723 but then we decided to stick to rational functions because the current solve is not reliable enough. We were using There are a lot of comments in that PR and many of them might not be useful to you. You can see this #2723 (comment) and subsequent comments. I also branched out that implementation of |
On Tue, Feb 18, 2014 at 08:56:18AM -0800, Harsh Gupta wrote:
The problem was not in the solve, but in this "more general |
>>> singularities(1/(1/x - 1), strict=True) | ||
(0, 1) | ||
|
||
If `poles` is Truen then points at which functions are undefined will |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
@hargup do you think you can support and perhaps work from the changes I have made here? (This PR has been updated since your last comment.) Note, too, that something like the following can help with finding poles:
But I think the thing that needs to be done is for all functions to define their poles since I think it's conceivable that finding where the 1/derivative = 0 may lead to a function that can't be solved, e.g. Note that setting check to False can help in finding solutions from solve:
|
If `poles` is True and the function is not rational, an error will be raised; if False, all values of `sym` that set any denominator to zero are returned. If `strict` is False (default) then removable singularities are not reported: 1/(1/x - 1) is not defined for x in (0, 1) but only 1 is returned with the default setting for `strict`.
Yes, that was suggested in #2723 (comment). I think - (1) branch points and (2) essential singularities should be defined on a per-function basis. For (3) poles - we can use solve (and, probably, cache this information and represent it as a property of the function). |
@skirpichev , the default behavior is as it was before. There is now an option to get singularities of non-rational functions and to return removable singularities. Does this look ok now? |
for d in denoms(expr, [sym]): | ||
rv.update(solve(d, sym)) | ||
# XXX add in poles | ||
if poles and not expr.is_rational_function(sym): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should move this up.
Good points, @skirpichev . @hargup is probably a better one to make these changes, so feel free to modify and use at will. Regarding the use of together: yes, that is a good way to handle rational functions. |
Yes I'm willing to work on it in future, but for now I want to work on making |
poles
was added as a keyword; when False it allows the singularites of non-rational expressions to be returned.together, rather than simplify, is now used and solve is applied only on extracted denominators