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("(x^2)^0.5") should be "abs(x)" #3329

Open
paulftw opened this issue Nov 29, 2024 · 2 comments
Open

simplify("(x^2)^0.5") should be "abs(x)" #3329

paulftw opened this issue Nov 29, 2024 · 2 comments

Comments

@paulftw
Copy link
Contributor

paulftw commented Nov 29, 2024

While there are genuine use cases when returning "x" would be better (that's what most humans would expect), strictly speaking it is incorrect.

To reproduce in the mathnotepad:

derivative("(x^2)^0.5", "x").evaluate({x:-3})
    1

derivative("(x^2)^0.5", "x", {simplify:false}).evaluate({x:-3})
    -1

Here I evaluate the same derivative at the same point x=-3 but get two different results.
Same problem for x^4 and I assume all other even powers.

@josdejong
Copy link
Owner

Thanks that is a very good and valid point.

Anyone able to improve simplify? Help would be welcome.

@gwhitney
Copy link
Collaborator

gwhitney commented Jan 3, 2025

Well, the relation (x^2)^0.5 = abs(x) is not an identity for complex numbers, e.g, (i^2)^0.5 = i but abs(i) = 1. But I completely agree that (x^2)^0.5 = x is not an identity in general either, for example with negative numbers as Paul points out. I think the only tenable approach is to further restrict use of such an identity, or eliminate it altogether from simplify, rather than replacing it with (x^2)^0.5 = abs(x); or possibly having both with different restrictions (e.g., if x is known to be a real number, then I guess (x^2)^0.5 = abs(x) is OK.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants