logoalt Hacker News

noosphrtoday at 7:39 AM4 repliesview on HN

More generally it's not at all clear what 'simplify' means.

Is x*x simpler than x^2? Probably? Is sqrt(5)^3 simpler than 5^(3/2)? I don't know.

It entirely depends on what you're going to be doing with the expression later.


Replies

henrikehtoday at 5:20 PM

While some comments do point out the general opaqueness of Mathematica, the goal of Simplify is actually documented in Mathematica and something which can be changed: https://reference.wolfram.com/language/ref/ComplexityFunctio...

The default is a balance between leaf count and number of digits. But the documentation page above gives an example of how to nudge the cost function away from specialised functions.

jmyeettoday at 11:31 AM

I think "simplify" is pretty clear here. For trigonometric functions you would expect a trig function and an inverse trig function to be simplified. We all know what we'd expect if we saw sin(arcsin(x)) (ie x). If we saw cos(arcsin(x)) I'll spoil it for you: it simplifies to sqrt(1-x^2).

Hyperbolic functions aren't used as much but the same principle applies. Here the core identity is cosh^2(x) = sinh^2(x) = 1 so:

      sinh(arccosh(x))
    = sqrt(1 + cosh^2(arccosh(x))
    = sqrt(1 + x^2)
You should absolutely expect that from "simplify".
show 2 replies
nurettintoday at 2:39 PM

In this case, a heuristic like "less parameters, less operators and less function calls" covers all the cases.

show 2 replies