How to “split” a function with two separate arguments of the form F[X][Y]?












4












$begingroup$


I recently stumbled upon a function F[X][Y] that has two separate arguments X,Y. Note that it is not of the form F[X, Y]!



So for F[X][Y], first F acts on X and then F[X] acts on Y. Now for the purposes of my work I need to split the function F = F1 + F2, but I can't successfully feed the second argument Y neither F1[X] nor F2[X] in the end.



Here's my description in code:



F[X][Y]
% /. F -> (F1[#] + F2[#] &)


this gives as an output



(F1[X] + F2[X])[Y]


but what I need as a desired output is



F1[X][Y] + F2[X][Y]


So my question is:



How can one start from F[X][Y] so that one ends up with the desired output F1[X][Y] + F2[X][Y]?



Bonus question.



Can the above happen by only changing the head of F?, i.e., modifying the rule /. F -> (F1[#] + F2[#] &) somehow?










share|improve this question









New contributor




Viktor Gakis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$








  • 7




    $begingroup$
    % /. F -> (F1[#] + F2[#] &) // Through
    $endgroup$
    – Coolwater
    10 hours ago








  • 4




    $begingroup$
    % /. F[x_][y_] -> F1[x][y] + F2[x][y]
    $endgroup$
    – Roman
    10 hours ago










  • $begingroup$
    Thank you both a lot for your fast answers, both of them work perfectly.
    $endgroup$
    – Viktor Gakis
    9 hours ago
















4












$begingroup$


I recently stumbled upon a function F[X][Y] that has two separate arguments X,Y. Note that it is not of the form F[X, Y]!



So for F[X][Y], first F acts on X and then F[X] acts on Y. Now for the purposes of my work I need to split the function F = F1 + F2, but I can't successfully feed the second argument Y neither F1[X] nor F2[X] in the end.



Here's my description in code:



F[X][Y]
% /. F -> (F1[#] + F2[#] &)


this gives as an output



(F1[X] + F2[X])[Y]


but what I need as a desired output is



F1[X][Y] + F2[X][Y]


So my question is:



How can one start from F[X][Y] so that one ends up with the desired output F1[X][Y] + F2[X][Y]?



Bonus question.



Can the above happen by only changing the head of F?, i.e., modifying the rule /. F -> (F1[#] + F2[#] &) somehow?










share|improve this question









New contributor




Viktor Gakis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$








  • 7




    $begingroup$
    % /. F -> (F1[#] + F2[#] &) // Through
    $endgroup$
    – Coolwater
    10 hours ago








  • 4




    $begingroup$
    % /. F[x_][y_] -> F1[x][y] + F2[x][y]
    $endgroup$
    – Roman
    10 hours ago










  • $begingroup$
    Thank you both a lot for your fast answers, both of them work perfectly.
    $endgroup$
    – Viktor Gakis
    9 hours ago














4












4








4





$begingroup$


I recently stumbled upon a function F[X][Y] that has two separate arguments X,Y. Note that it is not of the form F[X, Y]!



So for F[X][Y], first F acts on X and then F[X] acts on Y. Now for the purposes of my work I need to split the function F = F1 + F2, but I can't successfully feed the second argument Y neither F1[X] nor F2[X] in the end.



Here's my description in code:



F[X][Y]
% /. F -> (F1[#] + F2[#] &)


this gives as an output



(F1[X] + F2[X])[Y]


but what I need as a desired output is



F1[X][Y] + F2[X][Y]


So my question is:



How can one start from F[X][Y] so that one ends up with the desired output F1[X][Y] + F2[X][Y]?



Bonus question.



Can the above happen by only changing the head of F?, i.e., modifying the rule /. F -> (F1[#] + F2[#] &) somehow?










share|improve this question









New contributor




Viktor Gakis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$




I recently stumbled upon a function F[X][Y] that has two separate arguments X,Y. Note that it is not of the form F[X, Y]!



So for F[X][Y], first F acts on X and then F[X] acts on Y. Now for the purposes of my work I need to split the function F = F1 + F2, but I can't successfully feed the second argument Y neither F1[X] nor F2[X] in the end.



Here's my description in code:



F[X][Y]
% /. F -> (F1[#] + F2[#] &)


this gives as an output



(F1[X] + F2[X])[Y]


but what I need as a desired output is



F1[X][Y] + F2[X][Y]


So my question is:



How can one start from F[X][Y] so that one ends up with the desired output F1[X][Y] + F2[X][Y]?



Bonus question.



Can the above happen by only changing the head of F?, i.e., modifying the rule /. F -> (F1[#] + F2[#] &) somehow?







function-construction






share|improve this question









New contributor




Viktor Gakis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Viktor Gakis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 8 hours ago









m_goldberg

85.9k872196




85.9k872196






New contributor




Viktor Gakis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 10 hours ago









Viktor GakisViktor Gakis

212




212




New contributor




Viktor Gakis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Viktor Gakis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Viktor Gakis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








  • 7




    $begingroup$
    % /. F -> (F1[#] + F2[#] &) // Through
    $endgroup$
    – Coolwater
    10 hours ago








  • 4




    $begingroup$
    % /. F[x_][y_] -> F1[x][y] + F2[x][y]
    $endgroup$
    – Roman
    10 hours ago










  • $begingroup$
    Thank you both a lot for your fast answers, both of them work perfectly.
    $endgroup$
    – Viktor Gakis
    9 hours ago














  • 7




    $begingroup$
    % /. F -> (F1[#] + F2[#] &) // Through
    $endgroup$
    – Coolwater
    10 hours ago








  • 4




    $begingroup$
    % /. F[x_][y_] -> F1[x][y] + F2[x][y]
    $endgroup$
    – Roman
    10 hours ago










  • $begingroup$
    Thank you both a lot for your fast answers, both of them work perfectly.
    $endgroup$
    – Viktor Gakis
    9 hours ago








7




7




$begingroup$
% /. F -> (F1[#] + F2[#] &) // Through
$endgroup$
– Coolwater
10 hours ago






$begingroup$
% /. F -> (F1[#] + F2[#] &) // Through
$endgroup$
– Coolwater
10 hours ago






4




4




$begingroup$
% /. F[x_][y_] -> F1[x][y] + F2[x][y]
$endgroup$
– Roman
10 hours ago




$begingroup$
% /. F[x_][y_] -> F1[x][y] + F2[x][y]
$endgroup$
– Roman
10 hours ago












$begingroup$
Thank you both a lot for your fast answers, both of them work perfectly.
$endgroup$
– Viktor Gakis
9 hours ago




$begingroup$
Thank you both a lot for your fast answers, both of them work perfectly.
$endgroup$
– Viktor Gakis
9 hours ago










3 Answers
3






active

oldest

votes


















4












$begingroup$

To address the 'Bonus question':



F[subFs_List, args__] := Total[Through[subFs[args]]] /. h_[x_, y__] /; MemberQ[subFs, h] :> h[x][y]


Evaluating F[{F1,F2},X,Y] returns




F1[X][Y]+F2[X][Y]



as expected






share|improve this answer









$endgroup$





















    4












    $begingroup$

    Just write it like any other function definition.



    f[x_][y_] := f1[x][y] + f2[x][y]


    Then



    f[u][v]


    gives



    f1[u][v] + f2[u][v]





    share|improve this answer









    $endgroup$





















      1












      $begingroup$

      Through @ Operate[Apply[Plus @@ Through[{f1, f2} @ #] &], f[x][y]]



      f1[x][y] + f2[x][y]







      share|improve this answer









      $endgroup$













        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',
        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/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
        });


        }
        });






        Viktor Gakis is a new contributor. Be nice, and check out our Code of Conduct.










        draft saved

        draft discarded


















        StackExchange.ready(
        function () {
        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f191189%2fhow-to-split-a-function-with-two-separate-arguments-of-the-form-fxy%23new-answer', 'question_page');
        }
        );

        Post as a guest















        Required, but never shown

























        3 Answers
        3






        active

        oldest

        votes








        3 Answers
        3






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        4












        $begingroup$

        To address the 'Bonus question':



        F[subFs_List, args__] := Total[Through[subFs[args]]] /. h_[x_, y__] /; MemberQ[subFs, h] :> h[x][y]


        Evaluating F[{F1,F2},X,Y] returns




        F1[X][Y]+F2[X][Y]



        as expected






        share|improve this answer









        $endgroup$


















          4












          $begingroup$

          To address the 'Bonus question':



          F[subFs_List, args__] := Total[Through[subFs[args]]] /. h_[x_, y__] /; MemberQ[subFs, h] :> h[x][y]


          Evaluating F[{F1,F2},X,Y] returns




          F1[X][Y]+F2[X][Y]



          as expected






          share|improve this answer









          $endgroup$
















            4












            4








            4





            $begingroup$

            To address the 'Bonus question':



            F[subFs_List, args__] := Total[Through[subFs[args]]] /. h_[x_, y__] /; MemberQ[subFs, h] :> h[x][y]


            Evaluating F[{F1,F2},X,Y] returns




            F1[X][Y]+F2[X][Y]



            as expected






            share|improve this answer









            $endgroup$



            To address the 'Bonus question':



            F[subFs_List, args__] := Total[Through[subFs[args]]] /. h_[x_, y__] /; MemberQ[subFs, h] :> h[x][y]


            Evaluating F[{F1,F2},X,Y] returns




            F1[X][Y]+F2[X][Y]



            as expected







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered 9 hours ago









            user42582user42582

            2,8431524




            2,8431524























                4












                $begingroup$

                Just write it like any other function definition.



                f[x_][y_] := f1[x][y] + f2[x][y]


                Then



                f[u][v]


                gives



                f1[u][v] + f2[u][v]





                share|improve this answer









                $endgroup$


















                  4












                  $begingroup$

                  Just write it like any other function definition.



                  f[x_][y_] := f1[x][y] + f2[x][y]


                  Then



                  f[u][v]


                  gives



                  f1[u][v] + f2[u][v]





                  share|improve this answer









                  $endgroup$
















                    4












                    4








                    4





                    $begingroup$

                    Just write it like any other function definition.



                    f[x_][y_] := f1[x][y] + f2[x][y]


                    Then



                    f[u][v]


                    gives



                    f1[u][v] + f2[u][v]





                    share|improve this answer









                    $endgroup$



                    Just write it like any other function definition.



                    f[x_][y_] := f1[x][y] + f2[x][y]


                    Then



                    f[u][v]


                    gives



                    f1[u][v] + f2[u][v]






                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered 8 hours ago









                    m_goldbergm_goldberg

                    85.9k872196




                    85.9k872196























                        1












                        $begingroup$

                        Through @ Operate[Apply[Plus @@ Through[{f1, f2} @ #] &], f[x][y]]



                        f1[x][y] + f2[x][y]







                        share|improve this answer









                        $endgroup$


















                          1












                          $begingroup$

                          Through @ Operate[Apply[Plus @@ Through[{f1, f2} @ #] &], f[x][y]]



                          f1[x][y] + f2[x][y]







                          share|improve this answer









                          $endgroup$
















                            1












                            1








                            1





                            $begingroup$

                            Through @ Operate[Apply[Plus @@ Through[{f1, f2} @ #] &], f[x][y]]



                            f1[x][y] + f2[x][y]







                            share|improve this answer









                            $endgroup$



                            Through @ Operate[Apply[Plus @@ Through[{f1, f2} @ #] &], f[x][y]]



                            f1[x][y] + f2[x][y]








                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered 3 hours ago









                            kglrkglr

                            183k10200415




                            183k10200415






















                                Viktor Gakis is a new contributor. Be nice, and check out our Code of Conduct.










                                draft saved

                                draft discarded


















                                Viktor Gakis is a new contributor. Be nice, and check out our Code of Conduct.













                                Viktor Gakis is a new contributor. Be nice, and check out our Code of Conduct.












                                Viktor Gakis is a new contributor. Be nice, and check out our Code of Conduct.
















                                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%2f191189%2fhow-to-split-a-function-with-two-separate-arguments-of-the-form-fxy%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

                                what is the purpose of having a “thru cal” on RF PCB?

                                What does Gandalf whisper to the Moth on the Orthanc in Isengard?

                                magento2 creating a lot of catalogrule_product_temp tables