# Is there any way I can substitute a combination of variables.

I know this is a long short but I was wondering whether it is possible to substitute a combination of variables by something else. Let me explain it with an example.

Let $f(x,y,z) = f(x) \sqrt{x^2+y^2+z^2} + f(y) \sqrt{x^2+y^2+z^2} + f(z) \sqrt{x^2+y^2+z^2}$

As we can see the combination $\sqrt{x^2+y^2+z^2}$ occurs very often. Is there a way I call this combination some other variable, say, w. I cannot use substitute in this case as I want to leave $x$,$y$ and $z$ alone if they dont come in this specific combination $\sqrt{x^2+y^2+z^2}$. If it were a string I could have used find and replace. But I want to use the expression as a input later on in the notebook.

Edit: I came across a sympy command which is very close to what I want to do but not quite. There is a command cse in the module simplify. However, it identifies the subexpresssion by itself. As far as I could see it does not offer the flexibility for the users to identify the subexpression. Also for some reason sage expressions cannot be converted to sympy using `f._sympy_()`

if there are "i"'s in the expression.

Thanks in advance.