Skip to main content
1 of 3
Lawton
  • 287
  • 1
  • 7

How do I improve simplification in Wolfram Engine for expressions with poles and cancellable square roots?

The responses to my previous question "Are there any tips/tricks to improve simplification..." were very helpful, but I've now encountered expressions that aren't being meaningfully simplified by Wolfram Engine even when using the commands suggested in those answers, but which I am still able to manually simplify.

As an example, Wolfram Engine spit out the 2,285-character, 1,317-leaf expression

(r*(4*(4*(24*Sqrt[10 - 4*Sqrt[2] + (6 - 4*Sqrt[2])*U^2] + 
34*Sqrt[5 - 2*Sqrt[2] + (3 - 2*Sqrt[2])*U^2] - 5*Sqrt[8*(7 + 4*Sqrt[2]) - 
16*(-3 + Sqrt[2])*U^2 + (70 - 48*Sqrt[2])*U^4 + (34 - 24*Sqrt[2])*U^6] - 
7*Sqrt[4*(7 + 4*Sqrt[2]) - 8*(-3 + Sqrt[2])*U^2 + (35 - 24*Sqrt[2])*U^4 + 
(17 - 12*Sqrt[2])*U^6]) + 4*U^2*(3*Sqrt[10 - 4*Sqrt[2] + (6 - 4*Sqrt[2])*U^2] + 
8*Sqrt[5 - 2*Sqrt[2] + (3 - 2*Sqrt[2])*U^2] - Sqrt[8*(7 + 4*Sqrt[2]) - 
16*(-3 + Sqrt[2])*U^2 + (70 - 48*Sqrt[2])*U^4 + (34 - 24*Sqrt[2])*U^6] - 
Sqrt[4*(7 + 4*Sqrt[2]) - 8*(-3 + Sqrt[2])*U^2 + (35 - 24*Sqrt[2])*U^4 + 
(17 - 12*Sqrt[2])*U^6]) + U^4*(-32*Sqrt[10 - 4*Sqrt[2] + (6 - 4*Sqrt[2])*U^2] + 
46*Sqrt[5 - 2*Sqrt[2] + (3 - 2*Sqrt[2])*U^2] + U^2*(86 - 61*Sqrt[2] + 
(41 - 29*Sqrt[2])*U^2)*Sqrt[5 - 2*Sqrt[2] + (3 - 2*Sqrt[2])*U^2] - 
Sqrt[8*(7 + 4*Sqrt[2]) - 16*(-3 + Sqrt[2])*U^2 + (70 - 48*Sqrt[2])*U^4 + 
(34 - 24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+ Sqrt[2])*U^2 + (70 - 48*Sqrt[2])*U^4 + 
(34 - 24*Sqrt[2])*U^6] + 8*Sqrt[4*(7 + 4*Sqrt[2]) - 8*(-3 + Sqrt[2])*U^2 + 
(35 - 24*Sqrt[2])*U^4 + (17 - 12*Sqrt[2])*U^6]))))/(2*Sqrt[15 - 6*Sqrt[2] + 
(9 - 6*Sqrt[2])*U^2]*(-8*(22 + 15*Sqrt[2]) - 4*(22 + 5*Sqrt[2])*U^2 + 
6*(-18 + 11*Sqrt[2])*U^4 + (-138 + 97*Sqrt[2])*U^6 + (-58 + 41*Sqrt[2])*U^8))

which I was able to rework down to the 65-character, 41-leaf expression

r*Sqrt[2/3]*(1 - (4 + c*(2 + Sqrt[2]))/(4 + (6 - 4*Sqrt[2])*U^2))

for almost a 97.2% reduction in length and almost a 96.88% reduction in leaf count. Wolfram Engine seems to be getting caught up in the square-roots-of-sub-experssions and failing to recognize that they cancel out, even when I specify that $U$ is a real number and use options like Extension and TransformationFunctions to extend the search space and try to get it to factor them out. Several of my attempted commands on the long expression also apparently failed because it has a pole and thus is not a pure polynomial.

Are there any tricks that will make Wolfram Engine reliably find such drastically-shorter equivalent forms when dealing with expressions with poles and cancellable square roots?

Lawton
  • 287
  • 1
  • 7