# Using Collect with equations

Is it possible to somehow use the expression that Mathematica has collected once the Collect command has been used?

What I mean is, I have an expression like this (this is imaginary example)

(a[x,y]+b[x,y]+c[x,y]^2) z^5+a[x,y]^3 z^4+(b[x,y]+c[x,y]^4) z^3


That I got after I made Collect[expression,z,Simplify].

What I'd like to do is to have command that will, for instance, give me the term that goes along z^5 (the (a[x,y]+b[x,y]+c[x,y]^2))?

I didn't find any examples of it, and Collect in help has no such examples.

EDIT:

Can this be done with the help of Coefficient command?

• Perhaps Coefficient can be of help? As in Coefficient[expr,z,5] – Peltio Nov 15 '13 at 12:07
• That's it. I knew there had to be some way :) Thanks! – dingo_d Nov 15 '13 at 12:48

## 1 Answer

This is one way:

 ex = (a[x, y] + b[x, y] + c[x, y]^2) z^5 +
a[x, y]^3 z^4 + (b[x, y] + c[x, y]^4) z^3;

Coefficient[ex, z^5]

(* a[x, y] + b[x, y] + c[x, y]^2 *)


This is another, if you do not like the first one:

    Plus @@ (List @@ ex[[Position[List @@ ex, z^5][[1, 1]], 2]])

(*  a[x, y] + b[x, y] + c[x, y]^2  *)

• Yup that works, just like Peltio suggested :) – dingo_d Nov 15 '13 at 12:49