nerdamer
nerdamer copied to clipboard
Problems with nerdamer.simplify and {expr}.simplify with square roots
Review the following code examples:
nerdamer('sqrt(2)').simplify().toString() -> 'sqrt(2)'
nerdamer('sqrt(a)/a').simplify().toString() -> 'a^(-1/2)'
nerdamer('sqrt(2*a)/a').simplify().toString() -> 'a^(-1)*sqrt(2)*sqrt(a)' // should be sqrt(2/a)
nerdamer.simplify('sqrt(2)').toString() -> '131836323/93222358'
nerdamer.simplify('sqrt(a)/a').toString() -> 'sqrt(a)^(-1)'
nerdamer.simplify('sqrt(2*a)/a').toString() -> 'sqrt((131836323/93222358)*a)^(-1)' // this is wrong sqrt(sqrt(2)*a)^(-1) is not equal to sqrt(2*a)^(-1)
So I've found three problems:
- .simplify() does not simplify
sqrt(n*a)/a
tosqrt(n/a)
- nerdamer.simplify converts irrational numbers into confusing fractional approximations.
- nerdamer.simplify makes a mistake in my specific example in converting
sqrt(sqrt(2)*a)
notsqrt(2*a)
To your second point, it is not simplify() that does that, it is simply how Nerdamer represents numbers internally. .text("decimals") or simply .text() is your friend if that is what you want, instead of .toString(). As for the rest, yeah, I have given up on simplify(). Perhaps one of use should take the time to debug that, as a community contribution.
Also, if you want functions like sqrt(2) evaluated, you need to say "evaluate()". I agree with the concept of keeping things symbolic as long as one can.