2
$\begingroup$

Summary

I am struggling with substitution rules.

Example

Here are several cases which are problematic:

Clear[a,α];
{a + 2 b + 1, -a - b, 2 a + 2 b, a^2 + 2 a b + b^2} /. {a + b -> α}

Actual result:

{1 + a + 2 b, -a - b, 2 a + 2 b, a^2 + 2 a b + b^2}

Desired result:

{1 + α +  b, -α, 2 α, α^2}

Question

Currently, the rule is permuted for every case, e.g.

2 a + 2 b -> 2α

Can the alpha substitution rule be generalized That, is there a single rule to handle all cases?

$\endgroup$
3
  • 3
    $\begingroup$ You mean: "One to rule them all"? ;) $\endgroup$ Nov 4, 2018 at 18:38
  • 1
    $\begingroup$ Use PolynomialReduce to obtain algebraic "substitutions". In[208]:= PolynomialReduce[{a + 2 b + 1, -a - b, 2 a + 2 b, a^2 + 2 a b + b^2}, a + b - alpha, {a, b}][[All, 2]] Out[208]= {1 + alpha + b, -alpha, 2 alpha, alpha^2} $\endgroup$ Nov 4, 2018 at 19:14
  • 1
    $\begingroup$ Generally, to apply a relationship broadly, write the corresponding rule such that the LHS of the rule is as simple as possible, e.g., solution posted by @HenrikSchumacher. Since rules are applied to the structure of the internal (FullForm) representation, this will result in the highest number of matches with the LHS. $\endgroup$
    – Bob Hanlon
    Nov 4, 2018 at 19:38

2 Answers 2

6
$\begingroup$
{a + 2 b + 1, -a - b, 2 a + 2 b, a^2 + 2 a b + b^2} /. {a -> α - b} // Simplify

{1 + b + α, -α, 2 α, α^2}

$\endgroup$
5
$\begingroup$

Also

Simplify[{a + 2 b + 1, -a - b, 2 a + 2 b,  a^2 + 2 a b + b^2}, {a + b == α}]

{1 + b + α, -α, 2 α, α^2}

$\endgroup$

Your Answer

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

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