Question: extract coefficients from general (non-polynomial) expression

Hi!

 

I have an expression that involves an unknown function, say g:

expr:=a*x[1]+b*x[2]+cx[3]+g(x[1],x[2],x[3]);

where a, b and c are the coefficients I'm actually interested in. These coefficients are not constants but usually expressions in some constant parameters. The function g is an expression involving derivatives of some more fundamental function (in my problem).

Example:

expr:=(q/r-sqrt(2))*x[1] + x[2] - (w*r+4)*x[3] + D(G)(x[1]) - D(G)(x[3]);

Because g is not a polynomial, it's impossible to use coeff directly. Anyone any ideas how to get the coefficients? Thanks a lot!

 

- Fred.

Please Wait...