Skip to content

Domain of validity of simplifications? #2391

@gwhitney

Description

@gwhitney

Now that there are some slightly non-trivial array simplifications (and mathjs is veering ever-closer to a full-blown CAS), I think it really raises the issue for simplify as to the domain over which the simplifications should be valid. For example, if I am working with matrix formulas and call simplify on them, I will find that all of my (fairly common) terms like X*M*X^(-1) are turned into just M which will totally destroy my results. Or in another vein, to fulfill #927, it might seem reasonable to add something like sqrt(x^2) -> abs(x) but this is only valid over real numbers, not complex numbers (one can find many other such examples). How should mathjs and simplify handle this sort of thing?

I guess the null possibility is to just declare that simplify performs simplifications valid over [domain X] and document and stick with that. (Seems like it somewhat curtails the potential utility of simplify, though.)

Another possibility that comes to mind is to add a new allowed key to the "options" argument called something like 'domain', with canned possible values like 'real', 'complex', 'matrices', etc.

Or there is already an internal options parameter called "context" that specifies such things as whether multiplication is commutative, etc. So simplify could just include a "context" key in the "options" parameter so that a client could specify whichever properties are true of the operations over the domain the client is considering. (We might need some additional context possibilities, though, to cover differences between reals and complex numbers that are not captured just by what laws the basic operations satisfy.)

Or there may be other possibilities. If you're still interested in a PR for #927, some guidance on this question would be very helpful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions