Can this power tower function be optimized to perform faster?

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











up vote
2
down vote

favorite












Take the following function defined in Mathematica:



Itr[x_, p_, n_] := x^Nest[Power[p, #] &, 1, n];


Evaluating this function even for small values of p results in very slow and processor-intensive evaluation. Is there an equivalent expression that will evaluate more efficiently and quickly?



For example, Itr[3, 1/2, 25] // N takes nearly 3 minutes to evaluate on a 2016 MacBook Pro.










share|improve this question

























    up vote
    2
    down vote

    favorite












    Take the following function defined in Mathematica:



    Itr[x_, p_, n_] := x^Nest[Power[p, #] &, 1, n];


    Evaluating this function even for small values of p results in very slow and processor-intensive evaluation. Is there an equivalent expression that will evaluate more efficiently and quickly?



    For example, Itr[3, 1/2, 25] // N takes nearly 3 minutes to evaluate on a 2016 MacBook Pro.










    share|improve this question























      up vote
      2
      down vote

      favorite









      up vote
      2
      down vote

      favorite











      Take the following function defined in Mathematica:



      Itr[x_, p_, n_] := x^Nest[Power[p, #] &, 1, n];


      Evaluating this function even for small values of p results in very slow and processor-intensive evaluation. Is there an equivalent expression that will evaluate more efficiently and quickly?



      For example, Itr[3, 1/2, 25] // N takes nearly 3 minutes to evaluate on a 2016 MacBook Pro.










      share|improve this question













      Take the following function defined in Mathematica:



      Itr[x_, p_, n_] := x^Nest[Power[p, #] &, 1, n];


      Evaluating this function even for small values of p results in very slow and processor-intensive evaluation. Is there an equivalent expression that will evaluate more efficiently and quickly?



      For example, Itr[3, 1/2, 25] // N takes nearly 3 minutes to evaluate on a 2016 MacBook Pro.







      performance-tuning evaluation






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 2 hours ago









      LBushkin

      21629




      21629




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          4
          down vote



          accepted










          Yes, use floating point numbers right from the start:



           Itr[3., 0.5, 50000000] 


          takes about one second on my machine.



          You can also perform this in higher precision, but that will take longer; for example the following computation with 100-digit precision needs also about one second on my laptop:



           Itr[3.`100, 0.5`100, 500000];


          Assuming that the nested powers converge quickly, one can also use FixedPoint in order to iterate as long as it is needed:



           f[x_, p_] := x^FixedPoint[Power[p, #] &, 1];





          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: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            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%2f182490%2fcan-this-power-tower-function-be-optimized-to-perform-faster%23new-answer', 'question_page');

            );

            Post as a guest






























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            4
            down vote



            accepted










            Yes, use floating point numbers right from the start:



             Itr[3., 0.5, 50000000] 


            takes about one second on my machine.



            You can also perform this in higher precision, but that will take longer; for example the following computation with 100-digit precision needs also about one second on my laptop:



             Itr[3.`100, 0.5`100, 500000];


            Assuming that the nested powers converge quickly, one can also use FixedPoint in order to iterate as long as it is needed:



             f[x_, p_] := x^FixedPoint[Power[p, #] &, 1];





            share|improve this answer


























              up vote
              4
              down vote



              accepted










              Yes, use floating point numbers right from the start:



               Itr[3., 0.5, 50000000] 


              takes about one second on my machine.



              You can also perform this in higher precision, but that will take longer; for example the following computation with 100-digit precision needs also about one second on my laptop:



               Itr[3.`100, 0.5`100, 500000];


              Assuming that the nested powers converge quickly, one can also use FixedPoint in order to iterate as long as it is needed:



               f[x_, p_] := x^FixedPoint[Power[p, #] &, 1];





              share|improve this answer
























                up vote
                4
                down vote



                accepted







                up vote
                4
                down vote



                accepted






                Yes, use floating point numbers right from the start:



                 Itr[3., 0.5, 50000000] 


                takes about one second on my machine.



                You can also perform this in higher precision, but that will take longer; for example the following computation with 100-digit precision needs also about one second on my laptop:



                 Itr[3.`100, 0.5`100, 500000];


                Assuming that the nested powers converge quickly, one can also use FixedPoint in order to iterate as long as it is needed:



                 f[x_, p_] := x^FixedPoint[Power[p, #] &, 1];





                share|improve this answer














                Yes, use floating point numbers right from the start:



                 Itr[3., 0.5, 50000000] 


                takes about one second on my machine.



                You can also perform this in higher precision, but that will take longer; for example the following computation with 100-digit precision needs also about one second on my laptop:



                 Itr[3.`100, 0.5`100, 500000];


                Assuming that the nested powers converge quickly, one can also use FixedPoint in order to iterate as long as it is needed:



                 f[x_, p_] := x^FixedPoint[Power[p, #] &, 1];






                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited 2 hours ago

























                answered 2 hours ago









                Henrik Schumacher

                39k254114




                39k254114



























                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f182490%2fcan-this-power-tower-function-be-optimized-to-perform-faster%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