Question: Collect with respect to a specific term


I would like to ask a very basic question. The solution would indeed simplify my life!

I have a function called (eu) :

eu := -2*n^2*B^2+2*n*B^2*p-2*n*B^2*p^2+n*B^2-B^2*p+B^2*p^3+n*c*d

I would like to collect it with respect to two specific terms: (n-p+p^2) and (n-p+p^3), that would give me at the end:

eu := -2*n*B^2*(n-p+p^2)+B^2*(n-p+p^3)+n*c*d

Collect command gives me the following error meesage: "Error, (in collect) cannot collect n-p+p^2".

Would you have a solution for this problem?

Thanks in advance.


Please Wait...