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

Simplify the default simplify so that a small fraction needs simplify_fraction #511

Closed
ChrisRackauckas opened this issue Jan 17, 2022 · 2 comments

Comments

@ChrisRackauckas
Copy link
Member

Self-explanatory title, but I'll dig in anyways.

I don't think that the current defaults have worked out for simplification. Users are very confused and it's not a good situation. #507 #494 etc. When almost every issue starts becoming "you're using it wrong", then I would venture to think that something is wrong in the API and how it's being presented to users.

Now the difficulty here is #507 (comment) as @stevengj points out many things are assuming safety: no dividing by zero, etc. And there are good reasons for that, but why is that the default? Maple, Mathematica, etc. all of these systems did not choose that default because it does not give the results people expect, and I don't think simplify_fractions.(simplify.(inv(A) * det(A), expand=true)) is a satisfying answer.

But there is a different way to construct this that would give both safety and convenience. We could do it through the type system because our variables have context, and implicitly this information is about spaces. Right now we have:

@variables a::Real

as the default (though users don't write the ::Real of course), and so everything has been shoved into that type. But we can have different versions:

@variables a::Real # real under the assumption that substitutions are limiting behavior, so `a/a = 1` because it does even as `a->0`
@variables a::SafeReal # real without limiting assumptions
@variables a::SymbolicFloat # only assumptions floating point safe simplifications

and having different rule sets. Under this setup, it would then make sense for a::Real to always simplify fractions in the constructor, which means simplify_fractions would not have to be a separate step because it wouldn't be so slow. It would just be understood that SafeReal is going to be slower, and simplify_fractions would just be folded into simplify by default (with an option to turn it off).

@shashi
Copy link
Member

shashi commented Jan 17, 2022

I just made simplify call simplify_fractions by default JuliaSymbolics/SymbolicUtils.jl#422

#507 (comment)

This is due to a bug which I also fixed in the PR.

@shashi shashi changed the title Simplify the default simplify so that a small fraction needs simplify_fraction Number types with varying levels of safety Jan 17, 2022
@shashi shashi changed the title Number types with varying levels of safety Simplify the default simplify so that a small fraction needs simplify_fraction Jan 17, 2022
@shashi shashi closed this as completed Jan 17, 2022
@shashi
Copy link
Member

shashi commented Jan 17, 2022

The issue described by the title should be fixed. I'll open a new issue with the number type safety stuff.

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

No branches or pull requests

2 participants