Question: How can I find if an expression is linear in one of its indeterminate ?

Hi,

I would like to determine if some lengthy expression F is linear in one of its inderteminates X.
 I use to use type(F, linear(X)) to do this but I've just found that if F is piiecewise defined, then type(F, linear(X)) returns false even if E is linear in X...
For instance, let  F := a*X+piecewise(Y<0, X, b)
then type(F, X) returns false.

I do not pretend it is a bug: at first sight I would say that F is linear with respect to X but maybe the notion of linearity with respect to an indeterlinate must be interpretated as "linear on each branch" ?

For the moment I've circumvented the problem by doing this :
dF := diff(F, X):
has(dF, X):
# returns {\emptyset} if F is linear in X
 

But, as I said, F can be a rather lengthy expression invoking a lot of piecewise constructors, and I don't think that computing dF is an efficient way to do the job.

Do you have a better idea to proceed?

Thanks in advance

Please Wait...