On 8/09/2012 7:41 AM, nijso beishuizen wrote:
> 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)
>
There is a function separable in share/diffequations/ode2.mac. It
solves separable first order odes. As part of that, it determines if
the expression is separable. You could compare it to your approach.
Have you considered splitting the expression into (constant
terms)*f(x)*g(y). You can then choose what to do with the (constant
terms) later.