Closed aliang8 closed 7 years ago
This looks great! How hard do you think it would be to also supportsqrt(x,2)^2 => x
? We would just need to add support for expanding sqrt(x,2)^2 => sqrt(x,2)*sqrt(x,2)
and then your code will take it from there.
I was also taking a look at what we do for sqrt(x^2,2)
-- that should really result in abs(x)
not just x
, right?
This might not be super important, but does this work for negative square roots? (i.e. unary minus)?
Great suggestions. Thanks! Regarding the abs(x)
comment, I think that is a valid point. We should make that change in another PR. I will also make the changes for (nthRoot(x,2))^2
in a separate PR since it involves manipulating a different set of files.
This might not be super important, but does this work for negative square roots? (i.e. unary minus)?
You mean something like nthRoot(x, -2) or like nthRoot(-x, 2)? Neither one of these should evaluate. Are you suggesting that I should add checks?
something like nthRoot(x, -2) or like nthRoot(-x, 2)? Neither one of these should evaluate. Are you suggesting that I should add checks?
Yeah we should probably make sure these don't try to get evaluated and throw errors - good catch!
@aliang8 When I mentioned negatives, I actually mean -sqrt(x) sqrt(x), will that get evaluated to -x? Or -sqrt(x) -sqrt(x) = x? I'm still trying to understand how negatives are handled in the code base.
Other than that, I think everything has been addressed, so @evykassirer do you want to approve?
But yeah once those things have been addressed, good to go :) I'll approve and you can merge tomorrow after the fixes!
sqrt(x) * sqrt(x) should simplify to x