# Simplifying polynomials with conditions on variables

I'm working with polynomials of 5 variables $a,b,p,q,r$ which have a condition $a+b=p+q+r$. I'd like to minimize the number of variables in the answer. However, FullSimplify can't handle even simple example:

pol=p+q+r-b;
FullSimplify[pol, Assumptions -> a + b == p + q + r]


returns

-b + p + q + r


instead of a. Is there a way to do it?

• That ain't how assumptions work. Here's a possibility: do you prefer expressing in terms of $a,b$, or $p,q,r$? May 8, 2016 at 17:05
• Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! May 8, 2016 at 18:46
• Are your examples all linear? That could simplify matters if so. May 8, 2016 at 21:27
• @DanielLichtblau In general, I need to decompose homogeneous polynomials of degree n-1 which variables satisfy equation $a+b=p_1+...+p_n$ (at least for n=4,5,6). The polynomial I actually needed to simplify was 2*b*(-b+p+q+r). I'm thinking of introducing additional variable $d=a+b=p_1+...+p_n$, substitute sums for $d$, then substitute expressions of the type $d-p$. May 9, 2016 at 9:38

The equality may be used to eliminate one variable of your choice. It may be done by the way used in the @happy fish answer, or by a direct substitution:

 pol = p + q + r - b;
pol /. b -> p + q + r - a

(*  a  *)


Have fun!

You can use

Solve[pol == p + q + r - b && a + b == p + q + r, pol, {b, q, p, r}]


or

Eliminate[pol == p + q + r - b && a + b == p + q + r, {b, q, p, r}]