Suppose I have an expression like
1/8 + 1/8 Sqrt[1 - 28 (2/(3 (Sqrt[4197] - 9)))^(1/3) + 2 (2/3)^(2/3) (Sqrt[4197] - 9)^(1/3)]
- 1/2 Sqrt[1/8 - (1/2 (Sqrt[4197] - 9))^(1/3)/(4 3^(2/3)) + 7/(2 2^(2/3) (3 (Sqrt[4197] - 9))^(1/3))
- 7/(8 Sqrt[1 - 28 (2/(3 (Sqrt[4197] - 9)))^(1/3) + 2 (2/3)^(2/3) (Sqrt[4197] - 9)^(1/3)])]
which contains repeated common subexpressions. I am interested in an algorithm that can decompose it into parts of the minimal (or close to minimal) total complexity. The expected output should be something like this:
(1 + α - Sqrt[3 - β - 14/α]) / 8
/. α -> Sqrt[β]
/. β -> 1 + 2 γ - 56/(3 γ)
/. γ -> (4 Sqrt[4197]/9 - 4)^(1/3)
(if you ever worked with Maple, this is similar to how it formats complex output expressions)
FullSimplify
looks like it does a better job. $\endgroup$Experimental`OptimizeExpression
? Although it's meant for numerical applications, its job is indeed CSE. $\endgroup$Experimental`OptimizeExpression[]
; would you happen to remember it? $\endgroup$