Is there a simple way to apply a function to the RHS of a substitution?Assign the Background rule in Grid (the positions can be described by a integer function)ReplaceAll performance problem: packed arrays on the LHS are unpacked when the RHS is too longHow to select the value of a substitution rule for a particular variable?replace RHS of ruleWhy won't the Rule work? And how to apply it to a combination of variables?How does one unpack the contents of a list while using rules to substitute values for each variable?Why does syntax highlighting in `Set` and `Rule` not color pattern names on the RHS?What is the function of OrderedQ in these expressions?Make Mathematica apply the same rule exhaustively in simplification

DIY inkjet transparency film or photopaper

Is the net charge on a capacitor zero? If yes, then why?

Can the President be impeached twice?

Sorting marbles based on weightings

Does 'hacer alguien matar' mean to make somebody kill or to get sb killed?

How to pair a xrightarrow with text on the top) to a sort of xleftarrow (with text on the bottom)?

Undesired blank space between some words

Reference book or websites on how Mac OS works

Is a datagram from an upper network layer converted 1:1 to one of the lower layer?

Is it safe to wear earplugs in flight?

one list minus another

What's the greatest number of hands I can have to annoy my mother-in-law with?

Pass on your radiation

Secure Implementation of Password Database

Why is wired Ethernet losing its speed advantage over wireless?

How does a religion based around destroying the world attract followers

What are the disadvantages of using a Zener diode over a linear voltage regulator?

Who started calling the matrix multiplication "multiplication"?

How to deal with this fundamental problem with the advice: "Don't trust obscure PHP libraries that nobody uses!"?

Did a man complain that his Pontiac wouldn't start whenever the ice cream he picked up was vanilla?

Do photons have kinetic energy?

Will the same JavaScript fetched by HTTP and HTTPS be cached separately by the browser?

Acid-catalysed isomerisation of phenyl epoxide to aldehyde

Avoid long walking when changing between Tokyo subway lines



Is there a simple way to apply a function to the RHS of a substitution?


Assign the Background rule in Grid (the positions can be described by a integer function)ReplaceAll performance problem: packed arrays on the LHS are unpacked when the RHS is too longHow to select the value of a substitution rule for a particular variable?replace RHS of ruleWhy won't the Rule work? And how to apply it to a combination of variables?How does one unpack the contents of a list while using rules to substitute values for each variable?Why does syntax highlighting in `Set` and `Rule` not color pattern names on the RHS?What is the function of OrderedQ in these expressions?Make Mathematica apply the same rule exhaustively in simplification






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;

.everyonelovesstackoverflowposition:absolute;height:1px;width:1px;opacity:0;top:0;left:0;pointer-events:none;








6















$begingroup$


Suppose I have solved a system of equations, resulting in a solution of the form:



sol = f[a1] -> SomeComplicatedFunction[x, a1], f[a2] -> SomeComplicatedFunction[x, a2], f[a3] -> SomeComplicatedFunction[x, a3]


I want to use the list of substitutions sol later on, but first I want to apply some method myFunction to the rhs of the substitution. I.e., the desired output is



sol = f[a1] -> myFunction[SomeComplicatedFunction[x, a1]], f[a2] -> myFunction[SomeComplicatedFunction[x, a2]], f[a3] -> myFunction[SomeComplicatedFunction[x, a3]]


I have tried extracting all the RHSs from sol, applying myFunction to the list, then setting this back to the original f[]s, but this seems to be very inefficient. Is there some canonical Mathematica way of applying rules to solutions while keeping the solutions intact?










share|improve this question









$endgroup$





















    6















    $begingroup$


    Suppose I have solved a system of equations, resulting in a solution of the form:



    sol = f[a1] -> SomeComplicatedFunction[x, a1], f[a2] -> SomeComplicatedFunction[x, a2], f[a3] -> SomeComplicatedFunction[x, a3]


    I want to use the list of substitutions sol later on, but first I want to apply some method myFunction to the rhs of the substitution. I.e., the desired output is



    sol = f[a1] -> myFunction[SomeComplicatedFunction[x, a1]], f[a2] -> myFunction[SomeComplicatedFunction[x, a2]], f[a3] -> myFunction[SomeComplicatedFunction[x, a3]]


    I have tried extracting all the RHSs from sol, applying myFunction to the list, then setting this back to the original f[]s, but this seems to be very inefficient. Is there some canonical Mathematica way of applying rules to solutions while keeping the solutions intact?










    share|improve this question









    $endgroup$

















      6













      6









      6


      1



      $begingroup$


      Suppose I have solved a system of equations, resulting in a solution of the form:



      sol = f[a1] -> SomeComplicatedFunction[x, a1], f[a2] -> SomeComplicatedFunction[x, a2], f[a3] -> SomeComplicatedFunction[x, a3]


      I want to use the list of substitutions sol later on, but first I want to apply some method myFunction to the rhs of the substitution. I.e., the desired output is



      sol = f[a1] -> myFunction[SomeComplicatedFunction[x, a1]], f[a2] -> myFunction[SomeComplicatedFunction[x, a2]], f[a3] -> myFunction[SomeComplicatedFunction[x, a3]]


      I have tried extracting all the RHSs from sol, applying myFunction to the list, then setting this back to the original f[]s, but this seems to be very inefficient. Is there some canonical Mathematica way of applying rules to solutions while keeping the solutions intact?










      share|improve this question









      $endgroup$




      Suppose I have solved a system of equations, resulting in a solution of the form:



      sol = f[a1] -> SomeComplicatedFunction[x, a1], f[a2] -> SomeComplicatedFunction[x, a2], f[a3] -> SomeComplicatedFunction[x, a3]


      I want to use the list of substitutions sol later on, but first I want to apply some method myFunction to the rhs of the substitution. I.e., the desired output is



      sol = f[a1] -> myFunction[SomeComplicatedFunction[x, a1]], f[a2] -> myFunction[SomeComplicatedFunction[x, a2]], f[a3] -> myFunction[SomeComplicatedFunction[x, a3]]


      I have tried extracting all the RHSs from sol, applying myFunction to the list, then setting this back to the original f[]s, but this seems to be very inefficient. Is there some canonical Mathematica way of applying rules to solutions while keeping the solutions intact?







      rule






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Oct 1 at 0:13









      user366202user366202

      1475 bronze badges




      1475 bronze badges























          2 Answers
          2






          active

          oldest

          votes


















          7

















          $begingroup$

          sol = 
          f[a1] -> SomeComplicatedFunction[x, a1],
          f[a2] -> SomeComplicatedFunction[x, a2],
          f[a3] -> SomeComplicatedFunction[x, a3];

          sol2 = sol /. Rule[lhs_, rhs_] :> Rule[lhs, myFunction[rhs]]

          (* f[a1] -> myFunction[SomeComplicatedFunction[x, a1]], f[a2] ->
          myFunction[SomeComplicatedFunction[x, a2]], f[a3] ->
          myFunction[SomeComplicatedFunction[x, a3]] *)





          share|improve this answer










          $endgroup$





















            7

















            $begingroup$

            Additional alternatives:



            You can use MapAt to map myFunction at positions All, -1, -1:



            sol3 = MapAt[myFunction, sol, All, -1, -1]



            f[a1] -> myFunction[SomeComplicatedFunction[x, a1]],

            f[a2] ->
            myFunction[SomeComplicatedFunction[x, a2]],

            f[a3] ->
            myFunction[SomeComplicatedFunction[x, a3]]




            You can assign new values at desired positions using Part assignment:



            sol4 = sol;
            sol4[[All, -1, -1]] = myFunction /@ sol4[[All, -1, -1]];
            sol4



            same result







            share|improve this answer










            $endgroup$















              Your Answer








              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',
              autoActivateHeartbeat: false,
              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/4.0/"u003ecc by-sa 4.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%2f207134%2fis-there-a-simple-way-to-apply-a-function-to-the-rhs-of-a-substitution%23new-answer', 'question_page');

              );

              Post as a guest















              Required, but never shown


























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              7

















              $begingroup$

              sol = 
              f[a1] -> SomeComplicatedFunction[x, a1],
              f[a2] -> SomeComplicatedFunction[x, a2],
              f[a3] -> SomeComplicatedFunction[x, a3];

              sol2 = sol /. Rule[lhs_, rhs_] :> Rule[lhs, myFunction[rhs]]

              (* f[a1] -> myFunction[SomeComplicatedFunction[x, a1]], f[a2] ->
              myFunction[SomeComplicatedFunction[x, a2]], f[a3] ->
              myFunction[SomeComplicatedFunction[x, a3]] *)





              share|improve this answer










              $endgroup$


















                7

















                $begingroup$

                sol = 
                f[a1] -> SomeComplicatedFunction[x, a1],
                f[a2] -> SomeComplicatedFunction[x, a2],
                f[a3] -> SomeComplicatedFunction[x, a3];

                sol2 = sol /. Rule[lhs_, rhs_] :> Rule[lhs, myFunction[rhs]]

                (* f[a1] -> myFunction[SomeComplicatedFunction[x, a1]], f[a2] ->
                myFunction[SomeComplicatedFunction[x, a2]], f[a3] ->
                myFunction[SomeComplicatedFunction[x, a3]] *)





                share|improve this answer










                $endgroup$
















                  7















                  7











                  7







                  $begingroup$

                  sol = 
                  f[a1] -> SomeComplicatedFunction[x, a1],
                  f[a2] -> SomeComplicatedFunction[x, a2],
                  f[a3] -> SomeComplicatedFunction[x, a3];

                  sol2 = sol /. Rule[lhs_, rhs_] :> Rule[lhs, myFunction[rhs]]

                  (* f[a1] -> myFunction[SomeComplicatedFunction[x, a1]], f[a2] ->
                  myFunction[SomeComplicatedFunction[x, a2]], f[a3] ->
                  myFunction[SomeComplicatedFunction[x, a3]] *)





                  share|improve this answer










                  $endgroup$



                  sol = 
                  f[a1] -> SomeComplicatedFunction[x, a1],
                  f[a2] -> SomeComplicatedFunction[x, a2],
                  f[a3] -> SomeComplicatedFunction[x, a3];

                  sol2 = sol /. Rule[lhs_, rhs_] :> Rule[lhs, myFunction[rhs]]

                  (* f[a1] -> myFunction[SomeComplicatedFunction[x, a1]], f[a2] ->
                  myFunction[SomeComplicatedFunction[x, a2]], f[a3] ->
                  myFunction[SomeComplicatedFunction[x, a3]] *)






                  share|improve this answer













                  share|improve this answer




                  share|improve this answer










                  answered Oct 1 at 0:19









                  Bob HanlonBob Hanlon

                  70.4k3 gold badges40 silver badges110 bronze badges




                  70.4k3 gold badges40 silver badges110 bronze badges


























                      7

















                      $begingroup$

                      Additional alternatives:



                      You can use MapAt to map myFunction at positions All, -1, -1:



                      sol3 = MapAt[myFunction, sol, All, -1, -1]



                      f[a1] -> myFunction[SomeComplicatedFunction[x, a1]],

                      f[a2] ->
                      myFunction[SomeComplicatedFunction[x, a2]],

                      f[a3] ->
                      myFunction[SomeComplicatedFunction[x, a3]]




                      You can assign new values at desired positions using Part assignment:



                      sol4 = sol;
                      sol4[[All, -1, -1]] = myFunction /@ sol4[[All, -1, -1]];
                      sol4



                      same result







                      share|improve this answer










                      $endgroup$


















                        7

















                        $begingroup$

                        Additional alternatives:



                        You can use MapAt to map myFunction at positions All, -1, -1:



                        sol3 = MapAt[myFunction, sol, All, -1, -1]



                        f[a1] -> myFunction[SomeComplicatedFunction[x, a1]],

                        f[a2] ->
                        myFunction[SomeComplicatedFunction[x, a2]],

                        f[a3] ->
                        myFunction[SomeComplicatedFunction[x, a3]]




                        You can assign new values at desired positions using Part assignment:



                        sol4 = sol;
                        sol4[[All, -1, -1]] = myFunction /@ sol4[[All, -1, -1]];
                        sol4



                        same result







                        share|improve this answer










                        $endgroup$
















                          7















                          7











                          7







                          $begingroup$

                          Additional alternatives:



                          You can use MapAt to map myFunction at positions All, -1, -1:



                          sol3 = MapAt[myFunction, sol, All, -1, -1]



                          f[a1] -> myFunction[SomeComplicatedFunction[x, a1]],

                          f[a2] ->
                          myFunction[SomeComplicatedFunction[x, a2]],

                          f[a3] ->
                          myFunction[SomeComplicatedFunction[x, a3]]




                          You can assign new values at desired positions using Part assignment:



                          sol4 = sol;
                          sol4[[All, -1, -1]] = myFunction /@ sol4[[All, -1, -1]];
                          sol4



                          same result







                          share|improve this answer










                          $endgroup$



                          Additional alternatives:



                          You can use MapAt to map myFunction at positions All, -1, -1:



                          sol3 = MapAt[myFunction, sol, All, -1, -1]



                          f[a1] -> myFunction[SomeComplicatedFunction[x, a1]],

                          f[a2] ->
                          myFunction[SomeComplicatedFunction[x, a2]],

                          f[a3] ->
                          myFunction[SomeComplicatedFunction[x, a3]]




                          You can assign new values at desired positions using Part assignment:



                          sol4 = sol;
                          sol4[[All, -1, -1]] = myFunction /@ sol4[[All, -1, -1]];
                          sol4



                          same result








                          share|improve this answer













                          share|improve this answer




                          share|improve this answer










                          answered Oct 1 at 1:04









                          kglrkglr

                          229k10 gold badges259 silver badges522 bronze badges




                          229k10 gold badges259 silver badges522 bronze badges































                              draft saved

                              draft discarded















































                              Thanks for contributing an answer to Mathematica Stack Exchange!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid


                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.

                              Use MathJax to format equations. MathJax reference.


                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function ()
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f207134%2fis-there-a-simple-way-to-apply-a-function-to-the-rhs-of-a-substitution%23new-answer', 'question_page');

                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown









                              Popular posts from this blog

                              Tamil (spriik) Luke uk diar | Nawigatjuun

                              Align equal signs while including text over equalitiesAMS align: left aligned text/math plus multicolumn alignmentMultiple alignmentsAligning equations in multiple placesNumbering and aligning an equation with multiple columnsHow to align one equation with another multline equationUsing \ in environments inside the begintabularxNumber equations and preserving alignment of equal signsHow can I align equations to the left and to the right?Double equation alignment problem within align enviromentAligned within align: Why are they right-aligned?

                              Where does the image of a data connector as a sharp metal spike originate from?Where does the concept of infected people turning into zombies only after death originate from?Where does the motif of a reanimated human head originate?Where did the notion that Dragons could speak originate?Where does the archetypal image of the 'Grey' alien come from?Where did the suffix '-Man' originate?Where does the notion of being injured or killed by an illusion originate?Where did the term “sophont” originate?Where does the trope of magic spells being driven by advanced technology originate from?Where did the term “the living impaired” originate?