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

ImageSet now supports multiple sets #14145

Merged
merged 2 commits into from Feb 11, 2018
Merged

Conversation

Upabjojr
Copy link
Contributor

Additionally, imageset has been remapped to use multipledispatching.


@dispatch(FunctionUnion, Intersection)
def function_sets(f, x):
return Intersection(imageset(f, arg) for arg in x.args)
Copy link
Member

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.

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 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?

Copy link
Contributor Author

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.

Copy link
Member

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
):
Copy link
Contributor Author

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?

Copy link
Member

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.

@Upabjojr Upabjojr merged commit af4f447 into sympy:master Feb 11, 2018
@Upabjojr Upabjojr deleted the imageset_manysets branch April 20, 2019 08:45
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.

None yet

2 participants