Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have a very long expression like a + b x/y + f + c y/x + d (x z)/y + ... where a , b, c, f ... are coefficients and x,y,z,... are variables. I need to pick up the terms without variables which are a , f here how can I do this?

Or even collection of the zero order terms will be helpful.

share|improve this question
    
Try the Coefficient function with the 3rd argument as 0. –  Jonie Aug 5 '13 at 13:44
    
@Nasser, Would you explain how this works? The coefficient a, b,... are themselves complicated functions of other variables then what should i put in MemberQ[{...} ? –  richard Aug 5 '13 at 13:44
    
@Jonie, and what for second argument? –  richard Aug 5 '13 at 13:49
1  
@Nasser, suppose zero order terms are complicated functions of other parameters a=f(i,j,k), ... –  richard Aug 5 '13 at 13:51

2 Answers 2

up vote 4 down vote accepted

In this case you can pick all expression at the first level which are free of any of your variables

Cases[a + b x/y + f + c y/x + d (x z)/y, _?(FreeQ[#, x | y | z] &)]

Equivalently you can use Select

Select[List @@ (a + b x/y + f + c y/x + d (x z)/y), FreeQ[#, x | y | z] &]
share|improve this answer

In case there are terms like $\frac{(x-1) (x+1)}{x^2-1}$ you may try to simplify the expression and then follow halirutan's solution.

Another approach is to use Series.

Series[a + b x/y + f + c y/x + d (x z)/y, {x, 0, 0}, {y, 0, 0}, {z, 0,
0}] // Normal
(* a + f *)
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.