# FullSimplify doesn't simplify enough

In 12.1.0 for Microsoft Windows (64-bit) (March 14, 2020), writing:

num = 7 (3764 + 3673 Sqrt[2]) x^4 - 12 (19302 + 10727 Sqrt[2]) x^3 y + 756 (-44 + 31 Sqrt[2]) x^2 y^2 + 864 (37 + 51 Sqrt[2]) x y^3 - 5184 (2 + Sqrt[2]) y^4;
den = ((7 + 10 Sqrt[2]) x - 6 y) ((9 + 32 Sqrt[2]) x + 12 (1 + Sqrt[2]) y);
FullSimplify[num/den^2]
FullSimplify[num/den]/den

I get:

where it's evident that the second expression is more compact than the first. Is there a way to get it automatically? Thanks!

MinimalBy[z /. Simplify@First@Solve[Reduce[z==num/den^2, #], z] & /@ {x, y}, LeafCount]

$$\frac{\left(6-5 \sqrt{2}\right) x-12 \left(\sqrt{2}-2\right) y}{\left(23 \sqrt{2}-55\right) x-12 y}$$

Another way

Factor[num/den^2, Extension -> Automatic]
With[{expr = (a x + b y)/(c x + d y)},
expr /. RootReduce@SolveAlways[% == expr, {x, y}]] // FullSimplify
• Cool +1. Any idea how to reduce the coefficients I got? Simplifying the difference of our answers yields zero, but gosh my numbers are huge. Dec 21 '20 at 7:00
• I had found the above simplification using the computer software of the TI-Nspire CX CAS calculator, but it would never have crossed my mind that it could be further simplified, at least in this way! Now I'll have to figure out "what" this code does, really cool, thanks!
– TeM
Dec 21 '20 at 7:29
• Btw v. 11.3 gives a longer result. Dec 21 '20 at 7:32

By default FullSimplify and Simplify avoid large numbers through the default complexity function. Use LeafCount instead if you don’t mind the large numbers:

FullSimplify[num/den^2, ComplexityFunction->LeafCount]
(*
(6432772386615749160*x + 4548621517377519337*Sqrt[2]*x - 42218157353358559728*y -
29852856498186887412*Sqrt[2]*y) /
(134971395315929658167*x +
95439426336007826330*Sqrt[2]*x + 72071013851545447140*y +
50961935174866167276*Sqrt[2]*y)
*)
• Thanks to you too, I always learn new things, great!
– TeM
Dec 21 '20 at 7:25

This way it simlifies even more (or less)

num/den^2 // Apart // FullSimplify // Factor // FullSimplify

$$\frac{7 \left(124944256776+87864579823 \sqrt{2}\right) x-12 \left(476402576068+337753093375 \sqrt{2}\right) y}{\left(691401+441484 \sqrt{2}\right) \left(\left(13669487+10004398 \sqrt{2}\right) x+12 \left(616179+439573 \sqrt{2}\right) y\right)}$$

• Thanks to you too, have a nice day!
– TeM
Dec 21 '20 at 7:25