Alternative: Maybe you could provide your function with an additional (possibly) optional argument that specifies
where the first factor takes on the value 1; for example
separable(2*x*y,x=1) --> [x, 2*y]
separable(2*x*y,x=c) --> [x/c, 2*y*c]
--Barton
________________________________
From: maxima-bounces at math.utexas.edu [maxima-bounces at math.utexas.edu] on behalf of nijso beishuizen [nijso at hotmail.com]
Sent: Friday, September 07, 2012 16:41
To: maxima at math.utexas.edu
Subject: find shared constant in two expressions
Hello,
I have written a simple function separable(expr,x,y) to test if expr is separable, i.e. expr can be written as f(x)*g(y).
However, the algorithm sometimes leads to the introduction of constants like f(x)/C and C*g(x).
example:
(%i2) L:separable(x*log(x)*g(y),x,y);
x log(x) 2
(%o2)/R/ [---------, 4 g(y) log (2)]
2
4 log (2)
so even though xlog(x)*g(y) is separated correctly into xlog(x) and g(y), it introduces the constant 4*log^2(2).
Is there a simple way to find out if two expressions have a shared constant factor so I can eliminate the constant C?