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
ImageSet now supports multiple sets #14145
Conversation
sympy/sets/dispatchers.py
Outdated
|
||
@dispatch(FunctionUnion, Intersection) | ||
def function_sets(f, x): | ||
return Intersection(imageset(f, arg) for arg in x.args) |
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.
Intersection of image sets may contain elements that are not in the image of the intersection. Compare the intersection of f([-1, 0])
and f([0, 1])
with the image of the intersection f({0})
when f(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.
I see. This code was just copied from the _eval_imageset
method of Intersection. It is supposed to be called when the intersection cannot be calculated.
Shall we leave the imageset unevaluated for this case?
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.
Bijective functions may be treated separately.
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.
Shall we leave the imageset unevaluated for this case?
I guess that is what has to be done.
# TODO: find a better condition for invertible functions: | ||
if ((f in (exp, log)) # functions known to be invertible | ||
or (fdiff > 0) == True or (fdiff < 0) == True # monotonous funcs | ||
): |
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.
@jksuom I put these conditions of invertibility. solveset
needs this mapping to solve equations with Abs
and similar. It does not look that clean.
Do we have a better way to test the invertibility of functions?
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.
We probably should have a method for testing invertibility in a set such as the union of x.args
.
Additionally,
imageset
has been remapped to use multipledispatching.