# Using defined function to simplify expression

I have an expression

$$\sqrt{1-6e^{ik}+e^{2ik}}$$

I want to simplify this expression by defining

$$f(k) \equiv 1-6e^{ik}+e^{2ik}$$

So that my output will be

$$\sqrt{f(k)}$$

Thanks

• Try (Full)Simplify with the option TransformationFunctions -> {# /. (1 - 6 E^(i k) + 2^(2 i k) -> f[k]) &, Automatic} – Coolwater Mar 30 '19 at 18:41

Sqrt[1 - 6 Exp[I k] + Exp[2 I k]] /. {1 - 6 Exp[I k] + Exp[2 I k] -> f[k]}