Suppose we have a real function $f:mathbb R^2 rightarrow mathbb R$ and we would like to know if this function factorizes into $f(x,y)=f_1(x)f_2(y)$ for some real functions $f_1,f_2$. Is there an easy way of doing this in mathematica ? The program would return a set $f_1,f_2$ that does the job if they exist and would say it is not possible if such $f_1,f_2$ do not exist. I’ve been playing around with the “Collect” command, but I haven’t figured out a way to get what I want.

Example: $f(x,y)=xy^2 – 4y^2 – xy+4y+x-1$ can be factorized into $(x-4)(y^2-y+1)$, so the program would return $f_1(x)=x-4, f_2(y)=y^2-y+1$.