Wrestling with substitution rules

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite












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?










share|improve this question























  • You mean: "One to rule them all"? ;)
    – Henrik Schumacher
    1 hour ago











  • 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
    – Daniel Lichtblau
    46 mins ago






  • 1




    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.
    – Bob Hanlon
    23 mins ago














up vote
1
down vote

favorite












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?










share|improve this question























  • You mean: "One to rule them all"? ;)
    – Henrik Schumacher
    1 hour ago











  • 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
    – Daniel Lichtblau
    46 mins ago






  • 1




    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.
    – Bob Hanlon
    23 mins ago












up vote
1
down vote

favorite









up vote
1
down vote

favorite











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?










share|improve this question















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?







replacement rule






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 1 hour ago









Henrik Schumacher

43.9k263129




43.9k263129










asked 1 hour ago









dantopa

46928




46928











  • You mean: "One to rule them all"? ;)
    – Henrik Schumacher
    1 hour ago











  • 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
    – Daniel Lichtblau
    46 mins ago






  • 1




    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.
    – Bob Hanlon
    23 mins ago
















  • You mean: "One to rule them all"? ;)
    – Henrik Schumacher
    1 hour ago











  • 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
    – Daniel Lichtblau
    46 mins ago






  • 1




    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.
    – Bob Hanlon
    23 mins ago















You mean: "One to rule them all"? ;)
– Henrik Schumacher
1 hour ago





You mean: "One to rule them all"? ;)
– Henrik Schumacher
1 hour ago













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
– Daniel Lichtblau
46 mins ago




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
– Daniel Lichtblau
46 mins ago




1




1




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.
– Bob Hanlon
23 mins ago




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.
– Bob Hanlon
23 mins ago










2 Answers
2






active

oldest

votes

















up vote
3
down vote













a + 2 b + 1, -a - b, 2 a + 2 b, a^2 + 2 a b + b^2 /. a -> α - b // Simplify



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







share|improve this answer



























    up vote
    2
    down vote













    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







    share|improve this answer




















      Your Answer





      StackExchange.ifUsing("editor", function ()
      return StackExchange.using("mathjaxEditing", function ()
      StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
      StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
      );
      );
      , "mathjax-editing");

      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "387"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      convertImagesToLinks: false,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













       

      draft saved


      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f185287%2fwrestling-with-substitution-rules%23new-answer', 'question_page');

      );

      Post as a guest






























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      3
      down vote













      a + 2 b + 1, -a - b, 2 a + 2 b, a^2 + 2 a b + b^2 /. a -> α - b // Simplify



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







      share|improve this answer
























        up vote
        3
        down vote













        a + 2 b + 1, -a - b, 2 a + 2 b, a^2 + 2 a b + b^2 /. a -> α - b // Simplify



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







        share|improve this answer






















          up vote
          3
          down vote










          up vote
          3
          down vote









          a + 2 b + 1, -a - b, 2 a + 2 b, a^2 + 2 a b + b^2 /. a -> α - b // Simplify



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







          share|improve this answer












          a + 2 b + 1, -a - b, 2 a + 2 b, a^2 + 2 a b + b^2 /. a -> α - b // Simplify



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








          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 1 hour ago









          Henrik Schumacher

          43.9k263129




          43.9k263129




















              up vote
              2
              down vote













              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







              share|improve this answer
























                up vote
                2
                down vote













                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







                share|improve this answer






















                  up vote
                  2
                  down vote










                  up vote
                  2
                  down vote









                  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







                  share|improve this answer












                  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








                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered 43 mins ago









                  kglr

                  169k8192396




                  169k8192396



























                       

                      draft saved


                      draft discarded















































                       


                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f185287%2fwrestling-with-substitution-rules%23new-answer', 'question_page');

                      );

                      Post as a guest













































































                      Comments

                      Popular posts from this blog

                      Long meetings (6-7 hours a day): Being “babysat” by supervisor

                      Is the Concept of Multiple Fantasy Races Scientifically Flawed? [closed]

                      Confectionery