5
$\begingroup$

I want to simplify $5a\cdot x+5b\cdot y+6 c+c^2$, if possible, given that $e=a\cdot x+b\cdot y+c$.

I don't want to replace $c=e-a\cdot x-b\cdot y$. I want to replace it "cleverly".

So, a nice simplification result can be $5e+c+c^2$.

Is this possible? and how?

$\endgroup$
1
  • 2
    $\begingroup$ Use PolynomialReduce: In[53]:= PolynomialReduce[5*a*x + 5*b*y + 6*c + c^2, a*x + b*y + c - e, {x, y, a, b, c, d, e}][[2]] Out[53]= c + c^2 + 5 e $\endgroup$ Mar 8, 2022 at 19:37

3 Answers 3

9
$\begingroup$

The second argument of FullSimplify can list known conditions, relationships, and assumptions:

FullSimplify[5 a x + 5 b y + 6 c + c^2, e == a x + b y + c]
(*    c + c^2 + 5 e    *)
$\endgroup$
1
  • 1
    $\begingroup$ I get the same result using Simplify, i.e., Simplify[5 a*x + 5 b*y + 6 c + c^2, e == a*x + b*y + c] $\endgroup$
    – Bob Hanlon
    Mar 8, 2022 at 1:23
5
$\begingroup$

Solve with elimination of ax or by or both together at the same time.

Solve[{5 ax + 5 by + 6 c + c^2 == f, e == ax + by + c}, f, {ax}]

(*   {{f -> c + c^2 + 5 e}}   *)
$\endgroup$
3
  • 1
    $\begingroup$ Math representation is not so clear: $a x$ and $b y$ are not one variable but two: $a*x$ $\endgroup$
    – Chameleon
    Mar 7, 2022 at 20:29
  • 2
    $\begingroup$ use $a~x$ to put space $a ~x$ $\endgroup$
    – Rupesh
    Mar 7, 2022 at 20:53
  • 4
    $\begingroup$ @Chameleon Even better would be to post your formulas as code, not (just) as TeX. Makes it easy for others to help you: easier to copy/paste, fewer misinterpretations. $\endgroup$
    – Michael E2
    Mar 8, 2022 at 0:14
3
$\begingroup$
GroebnerBasis[{5*a*x + 5*b*y + 6*c + c^2, a*x + b*y + c - e}, {x, y, 
  a, b, c, d, e}]

{c + c^2 + 5 e, c - e + a x + b y}

$\endgroup$
3
  • 3
    $\begingroup$ The answer depends on the ordering of the variables in the second argument of GroebnerBasis. For this method to work as requested, one would have to try all permutations of the variables and choose the minimal LeafCount: something like MinimalBy[GroebnerBasis[{5*a*x + 5*b*y + 6*c + c^2, a*x + b*y + c - e}, #][[1]] & /@ Permutations[{x, y, a, b, c, d, e}], LeafCount] // DeleteDuplicates. $\endgroup$
    – Roman
    Mar 8, 2022 at 21:00
  • $\begingroup$ @Roman thanks for pointing this out. If you want to make it a fully-fledged answer, I am happy to delete mine $\endgroup$
    – user49048
    Mar 8, 2022 at 21:33
  • 2
    $\begingroup$ @Roman The ordering used above is just fine for the task at hand. The problem is that this does not provide an indication of how the original polynomial transforms. Which is one reason I would instead advocate for using PolynomialReduce. $\endgroup$ Mar 9, 2022 at 14:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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