separation of variables



Dear all,

I have written a function separable(expr,x,y) that checks if expr is separable into f(x) and g(y) and returns [f,g]. The algorithm is based on Cid (2009), webs.uvigo.es/angelcid/Archivos/Papers/IJMEST.pdf.

But the algorithm sometimes introduces an arbitrary constant, such that it returns [A*f(x),g(y)/A].
Here is an example:

(%i01) expr:exp(x*x+y*y)*(cos(x+y)+cos(x-y));
(%i02) grind(separable(expr,x,y));
[%e^x^2*cos(x),2*%e^y^2*cos(y)]$
(%o02)                               done

(%i03) expr:y/(sin(x+3.5)+5);
(%i04) grind(separable(expr,x,y));
[4.64921677231038/(sin(x+3.5)+5),.2150899923522087*y]$
(%o46)                               done

The first example worked fine, but the second one introduced an arbitrary constant (sin(7/2)+5=4.6492... and 1/(sin(7/2)+5)=0.2150...). 
Is there a maxima way of finding the greatest common constant factor A in two expressions? 
Or is it possible to find the largest subexpression that is independent of x,y? 
At the moment I am thinking of using gcd(Ans[1],1/Ans[2]) and gcd(Ans[2],1/Ans[1]) and take the one that is independent on x,y as my premultiplication factor, but there may be a better way? Also, are there limitations to the input of gcd that make it fail for more general/exotic input expressions?