# How can I guide FullSimplify to do a better job?

I encountered an expression which manual simplification is manageable, where the results are nicely in terms of generalized mean (power mean).

To avoid making this post too long, I created a post on Math StackExchange to display the kind of algebra I'm talking about.${}^1$

How can I formulate perhaps ComplexityFunction or adopt some good practice to use with FullSimplify to arrive at an outcome that is "close enough"?

The math itself is rather standard calculus (2nd derivative), and I anticipate similar but more tedious calculations as one moves up the order (of derivatives). Therefore it would be nice to establish a reliable approach.

The codes below show what I'm trying to do.

(* quick and dirty *)
ClearAll[x, y, u, k, f, target, goal, myM, myAss];
myAss = x > y > 1 && k >= 1;
f = (Sqrt[1/(u + y)] - Sqrt[1/(u + x)]) Sqrt[2 (u + k)];
target = Divide[D[f, {u, 2}],
D[f, u]] /. {u -> 0} (* just take a look *)
target //FullSimplify[#, myAss]&
myM[p_] := If[p == 0, Sqrt[x y], (x^p + y^p)^(1/p)]
goal =
(-1/2 ) (1/k + 3(1/x + 1/y + 1/G + (M - G + (M G)/k)^(-1))) /.
{G -> myM @ 0, M -> myM[-1/2]};
goal - target //Simplify[#, myAss]&
(* verifies an equivalent form of the target expression *)


Having things in terms of generalized mean is not just for the aesthetics. Analytically it is helpful for estimation.

For example,${}^2$ here we have $\min = y < H < M < G < A < x = max$, in the order of generalized mean of powers $\{ -\infty,\, -1,\, \frac{-1}2,\, 0,\, 1,\, \infty \}$

I tried a bit manually forcing the change of variables like /.{Sqrt[x y] -> G} and friends, but it's a total mess. There are many posts here regarding simplification and algebraic manipulation, and I'm still wading through.

I've had some experience of algebraic manipulation with MMA, and I know that one has to nudge it constantly to achieve a workable result. I guess what I'm asking is a guide for me to guide MMA for this particular type of task.

Footnote 1

The linked Math StackExchange post deals with only partially what the MMA code here contains. In manual simplification, it is trivial to first pull out the $1/k$, but not so much programmatically.

Footnote 2

Here $G$ is the geometric mean, $H$ is the harmonic mean, and $M$ is the mean with $\text{power}= \frac{-1}2$ (see the linked post). The arithmetic mean $A$ doesn't really appear in the final expression; included just for perspectives. The factors of averaging ($\frac1{\sqrt2}$ and $\frac12$) at various places are omitted here, since I'm just sketching an argument for the merit of such expressions.

FullSimplify[target /. {x -> 1/v, y -> 1/w, k -> 1/m}, v < w < 1 && m <= 1]

Also, this is the natural course to take and adopt the notions of p-norms (instead of the generalized means); one just have to give up on unifying $\sqrt{xy} = \sqrt{v w}$ formally.