{"id":294,"date":"2010-10-30T12:20:10","date_gmt":"2010-10-30T11:20:10","guid":{"rendered":"http:\/\/www.walkingrandomly.com\/?p=294"},"modified":"2020-10-22T15:33:03","modified_gmt":"2020-10-22T14:33:03","slug":"complex-power-towers-or-mucking-around-with-mathematica","status":"publish","type":"post","link":"https:\/\/walkingrandomly.com\/?p=294","title":{"rendered":"Complex Power Towers (Or &#8216;mucking around with Mathematica&#8217;)"},"content":{"rendered":"<p>Some time ago now, Sam Shah of <a href=\"http:\/\/samjshah.com\/\">Continuous Everywhere but Differentiable Nowhere<\/a> fame discussed the <a href=\"http:\/\/samjshah.com\/2008\/11\/09\/square-root-of-i\">standard method of obtaining the square root of the imaginary unit<\/a>, i, and in the ensuing discussion thread someone asked the question &#8220;What is i^i &#8211; that is what is i to the power i?&#8221;<\/p>\n<p>Sam immediately came back with the answer e^(-pi\/2) = 0.207879&#8230;. which is <strong>one<\/strong> of the answers but as pointed out by one of his readers, Adam Glesser, this is just one of the infinite number of potential answers that all have the form e^{-(2k+1) pi\/2} where k is an integer. Sam&#8217;s answer is the <a href=\"http:\/\/en.wikipedia.org\/wiki\/Principal_value\"><strong>principle value<\/strong><\/a> of i^i (incidentally this is the value returned by google calculator if you google i^i &#8211; It is also the value returned by <a href=\"http:\/\/www.wolfram.com\/products\/mathematica\/index.html\">Mathematica<\/a> and <a href=\"http:\/\/www.mathworks.com\/products\/matlab\/\">MATLAB<\/a>). Life gets a lot more complicated when you move to the complex plane but it also gets a lot more interesting too.<\/p>\n<p>While on the train into work one morning I was thinking about Sam&#8217;s blog post and wondered what the principal value of i^i^i (i to the power i to the power i) was equal to. Mathematica quickly provided the answer:<\/p>\n<pre>N[I^I^I]\n0.947159+0.320764 I<\/pre>\n<p>So i is imaginary, i^i is real and i^i^i is imaginary again. Would i^i^i^i be real I wondered &#8211; would be fun if it was. Let&#8217;s see:<\/p>\n<pre>N[I^I^I^I]\n0.0500922+0.602117 I<\/pre>\n<p>gah &#8211; a conjecture bites the dust &#8211; although if I am being honest it wasn&#8217;t a very good one.\u00a0 Still, since I have started making &#8216;power towers&#8217; I may as well continue and see what I can see. Why am I calling them power towers? Well, the calculation above could be written as follows:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.walkingrandomly.com\/images\/mathematica7\/i_power4.png\" alt=\"small power tower\" \/><\/p>\n<p>As I add more and more powers, the left hand side of the equation will tower up the page&#8230;.Power Towers.\u00a0 We now have a sequence of the first four power towers of i:<\/p>\n<pre>i = i\ni^i = 0.207879\ni^i^i = 0.947159 + 0.32076 I\ni^i^i^i = 0.0500922+0.602117 I<\/pre>\n<h3>Sequences of power towers<\/h3>\n<p>&#8220;Will this sequence converge or diverge?&#8221;, I wondered.\u00a0 I wasn&#8217;t in the mood to think about a rigorous mathematical proof, I just wanted to play so I turned back to Mathematica.\u00a0 First things first, I needed to come up with a way of making an arbitrarily large power tower without having to do a lot of typing.\u00a0 Mathematica&#8217;s Nest function came to the rescue and the following function allows you to create a power tower of any size for any number, not just i.<\/p>\n<pre>tower[base_, size_] := Nest[N[(base^#)] &amp;, base, size]<\/pre>\n<p>Now I can find the first term of my series by doing<\/p>\n<pre>In[1]:= tower[I, 0]\n\nOut[1]= I<\/pre>\n<p>Or the 5th term by doing<\/p>\n<pre>In[2]:= tower[I, 4] \n\nOut[2]= 0.387166 + 0.0305271 I<\/pre>\n<p>To investigate convergence I needed to create a table of these. Maybe the first 100 towers would do:<\/p>\n<pre>ColumnForm[\n Table[tower[I, n], {n, 1, 100}]\n ]<\/pre>\n<p>The last few values given by the command above are<\/p>\n<pre>0.438272+ 0.360595 I\n0.438287+ 0.360583 I\n0.438287+ 0.3606 I\n0.438275+ 0.360591 I\n0.438289+ 0.360588 I<\/pre>\n<p>Now this is interesting &#8211; As I increased the size of the power tower, the result seemed to be converging to around 0.438 + 0.361 i. Further investigation confirms that the sequence of power towers of i converges to 0.438283+ 0.360592 i.\u00a0 If you were to ask me to guess what I thought would happen with large power towers like this then I would expect them to do one of three things &#8211; diverge to infinity, stay at 1 forever or quickly converge to 0 so this is unexpected behaviour (unexpected to me at least).<\/p>\n<h3>They converge, but how?<\/h3>\n<p>My next thought was &#8216;How does it converge to this value?\u00a0 In other words, &#8216;What path through the complex plane does this sequence of power towers take?&#8221;\u00a0 Time for a graph:<\/p>\n<pre>tower[base_, size_] := Nest[N[(base^#)] &amp;, base, size];\ncomplexSplit[x_] := {Re[x], Im[x]};\nListPlot[Map[complexSplit, Table[tower[I, n], {n, 0, 49, 1}]],\n PlotRange -&gt; All]<\/pre>\n<p style=\"text-align: center;\"><img decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/www.walkingrandomly.com\/images\/mathematica7\/i_tower_spiral.png\" alt=\"Power Tower Spiral\" \/><\/p>\n<p>Who would have thought you could get a spiral from power towers? Very nice! So the next question is &#8216;What would happen if I took a different complex number as my starting point?&#8217; For example &#8211; would power towers of (0.5 + i) converge?&#8217;<\/p>\n<p>The answer turns out to be yes &#8211; power towers of (0.5 + I) converge to 0.541199+ 0.40681 I but the resulting spiral looks rather different from the one above.<\/p>\n<pre>tower[base_, size_] := Nest[N[(base^#)] &amp;, base, size];\ncomplexSplit[x_] := {Re[x], Im[x]};\nListPlot[Map[complexSplit, Table[tower[0.5 + I, n], {n, 0, 49, 1}]],\n PlotRange -&gt; All]<\/pre>\n<h3 style=\"text-align: left;\"><img decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/www.walkingrandomly.com\/images\/mathematica7\/i2_tower_spiral.png\" alt=\"Another power tower spiral\" \/>The zoo of power tower spirals<\/h3>\n<p style=\"text-align: left;\">So, taking power towers of two different complex numbers results in two qualitatively different &#8216;convergence spirals&#8217;. I wondered how many different spiral types I might find if I consider the entire complex plane?\u00a0 I already have all of the machinery I need to perform such an investigation but investigation is much more fun if it is interactive.\u00a0 Time for a Manipulate<\/p>\n<pre>complexSplit[x_] := {Re[x], Im[x]};\n\ntower[base_, size_] := Nest[N[(base^#)] &amp;, base, size];\n\ngeneratePowerSpiral[p_, nmax_] :=\n  Map[complexSplit, Table[tower[p, n], {n, 0, nmax-1, 1}]];\n\nManipulate[const = p[[1]] + p[[2]] I;\n ListPlot[generatePowerSpiral[const, n],\n PlotRange -&gt; {{-2, 2}, {-2, 2}}, Axes -&gt; ax,\n Epilog -&gt; Inset[Framed[const], {-1.5, -1.5}]], {{n, 100,\n \"Number of terms\"}, 1, 200, 1,\n Appearance -&gt; \"Labeled\"}, {{ax, True, \"Show axis\"}, {True,\n False}}, {{p, {0, 1.5}}, Locator}]<\/pre>\n<p style=\"text-align: left;\"><img decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/www.walkingrandomly.com\/images\/mathematica7\/power_tower_manipulate.png\" alt=\"Power Tower Manipulate\" \/><br \/>\nAfter playing around with this Manipulate for a few seconds it became clear to me that there is quite a rich diversity of these convergence spirals. Here are a couple more<\/p>\n<p style=\"text-align: center;\"><img decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/www.walkingrandomly.com\/images\/mathematica7\/power_tower_spirals.png\" alt=\"Power Tower Spirals\" \/><\/p>\n<p style=\"text-align: left;\">Some of them take a lot longer to converge than others and then there are those that don&#8217;t converge at all:<\/p>\n<p style=\"text-align: center;\"><img decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/www.walkingrandomly.com\/images\/mathematica7\/non_convergent_tower.png\" alt=\"non convergent power\" \/><\/p>\n<h3>Optimising the code a little<\/h3>\n<p>Before I could investigate convergence any further, I had a problem to solve: Sometimes the Manipulate would completely freeze and a message eventually popped up saying &#8220;One or more dynamic objects are taking excessively long to finish evaluating&#8230;&#8230;&#8221;\u00a0 What was causing this I wondered?<\/p>\n<p>Well, some values give overflow errors:<\/p>\n<pre>In[12]:= generatePowerSpiral[-1 + -0.5 I, 200]\n\nGeneral::ovfl: Overflow occurred in computation. &gt;&gt;\nGeneral::ovfl: Overflow occurred in computation. &gt;&gt;\nGeneral::ovfl: Overflow occurred in computation. &gt;&gt;\nGeneral::stop: Further output of General::ovfl will be suppressed during this calculation. &gt;&gt;<\/pre>\n<p>Could errors such as this be making my Manipulate unstable?\u00a0 Let&#8217;s see how long it takes Mathematica to deal with the example above<\/p>\n<pre>AbsoluteTiming[ListPlot[generatePowerSpiral[-1  -0.5 I, 200]]]<\/pre>\n<p>On my machine, the above command typically takes around 0.08 seconds to complete compared to 0.04 seconds for a tower that converges nicely; it&#8217;s slower but not so slow that it should break Manipulate.\u00a0 Still, let&#8217;s fix it anyway.<\/p>\n<p>Look at the sequence of values that make up this problematic power tower<\/p>\n<pre>generatePowerSpiral[-0.8 + 0.1 I, 10]\n\n{{-0.8, 0.1}, {-0.668442, -0.570216}, {-2.0495, -6.11826},\n{2.47539*10^7,1.59867*10^8}, {2.068155430437682*10^-211800874,\n-9.83350984373519*10^-211800875}, {Overflow[], 0}, {Indeterminate,\n  Indeterminate}, {Indeterminate, Indeterminate}, {Indeterminate,\n  Indeterminate}, {Indeterminate, Indeterminate}}<\/pre>\n<p>Everything is just fine until the term {Overflow[],0} is reached; after which we are just wasting time. Recall that the functions I am using to create these sequences are<\/p>\n<pre>complexSplit[x_] := {Re[x], Im[x]};\ntower[base_, size_] := Nest[N[(base^#)] &amp;, base, size];\ngeneratePowerSpiral[p_, nmax_] :=\n  Map[complexSplit, Table[tower[p, n], {n, 0, nmax-1, 1}]];<\/pre>\n<p>The first thing I need to do is break out of tower&#8217;s Nest function as soon as the result stops being a complex number and the <a href=\"http:\/\/reference.wolfram.com\/mathematica\/ref\/NestWhile.html\">NestWhile<\/a> function allows me to do this.\u00a0 So, I could redefine the tower function to be<\/p>\n<pre>tower[base_, size_] :=\n NestWhile[N[(base^#)] &amp;, base, MatchQ[#, _Complex] &amp;, 1, size]<\/pre>\n<p>However, I can do much better than that since my code so far is massively inefficient.\u00a0 Say I already have the first n terms of a tower sequence; to get the (n+1)th term all I need to do is a single power operation but my code is starting from the beginning and doing n power operations instead.\u00a0 So, to get the 5th term, for example, my code does this<\/p>\n<pre>I^I^I^I^I<\/pre>\n<p>instead of<\/p>\n<pre>(4th term)^I<\/pre>\n<p>The function I need to turn to is yet another variant of Nest &#8211; <a href=\"http:\/\/reference.wolfram.com\/mathematica\/ref\/NestWhileList.html\">NestWhileList<\/a><\/p>\n<pre>fasttowerspiral[base_, size_] :=\n Quiet[Map[complexSplit,\n NestWhileList[N[(base^#)] &amp;, base, MatchQ[#, _Complex] &amp;, 1,\n size, -1]]];<\/pre>\n<p>The Quiet function is there to prevent Mathematica from warning me about the Overflow error.\u00a0 I could probably do better than this and catch the Overflow error coming before it happens but since I&#8217;m only mucking around, I&#8217;ll leave that to an interested reader.\u00a0 For now it&#8217;s enough for me to know that the code is much faster than before:<\/p>\n<pre>(*Original Function*)\nAbsoluteTiming[generatePowerSpiral[I, 200];]\n\n{0.036254, Null}<\/pre>\n<pre>(*Improved Function*)\nAbsoluteTiming[fasttowerspiral[I, 200];]\n\n{0.001740, Null}<\/pre>\n<p>A factor of 20 will do nicely!<\/p>\n<h3>Making Mathematica faster by making it stupid<\/h3>\n<p>I&#8217;m still not done though. Even with these optimisations, it can take a massive amount of time to compute some of these power tower spirals. For example<\/p>\n<pre>spiral = fasttowerspiral[-0.77 - 0.11 I, 100];<\/pre>\n<p>takes 10 seconds on my machine which is thousands of times slower than most towers take to compute. What on earth is going on? Let&#8217;s look at the first few numbers to see if we can find any clues<\/p>\n<pre>In[34]:= spiral[[1 ;; 10]]\n\nOut[34]= {{-0.77, -0.11}, {-0.605189, 0.62837}, {-0.66393,\n  7.63862}, {1.05327*10^10,\n  7.62636*10^8}, {1.716487392960862*10^-155829929,\n  2.965988537183398*10^-155829929}, {1., \\\n-5.894184073663391*10^-155829929}, {-0.77, -0.11}, {-0.605189,\n  0.62837}, {-0.66393, 7.63862}, {1.05327*10^10, 7.62636*10^8}}<\/pre>\n<p>The first pair that jumps out at me is {1.716487392960862<em>10^-155829929, 2.965988537183398<\/em>10^-155829929} which is so close to {0,0} that it&#8217;s not even funny! So close, in fact, that they are not even <a href=\"http:\/\/en.wikipedia.org\/wiki\/Double_precision_floating-point_format\">double precision<\/a> numbers any more. Mathematica has realised that the calculation was going to <a href=\"http:\/\/en.wikipedia.org\/wiki\/Arithmetic_underflow\">underflow<\/a> and so it caught it and returned the result in <a href=\"http:\/\/en.wikipedia.org\/wiki\/Arbitrary-precision_arithmetic\">arbitrary precision<\/a>.<\/p>\n<p>Arbitrary precision calculations are MUCH slower than double precision ones and this is why this particular calculation takes so long. Mathematica is being very clever but its cleverness is costing me a great deal of time and not adding much to the calculation in this case. I reckon that I want Mathematica to be stupid this time and so I&#8217;ll turn off its underflow safety net.<\/p>\n<pre>SetSystemOptions[\"CatchMachineUnderflow\" -&gt; False]<\/pre>\n<p>Now our problematic calculation takes 0.000842 seconds rather than 10 seconds which is so much faster that it borders on the astonishing. The results seem just fine too!<\/p>\n<h3>When do the power towers converge?<\/h3>\n<p>We have seen that some towers converge while others do not. Let S be the set of complex numbers which lead to convergent power towers. What might S look like? To determine that I have to come up with a function that answers the question &#8216;For a given complex number z, does the infinite power tower converge?&#8217; The following is a quick stab at such a function<\/p>\n<pre>convergeQ[base_, size_] :=\n  If[Length[\n     Quiet[NestWhileList[N[(base^#)] &amp;, base, Abs[#1 - #2] &gt; 0.01 &amp;,\n       2, size, -1]]] &lt; size, 1, 0];<\/pre>\n<p>The tolerance I have chosen, 0.01, might be a little too large but these towers can take ages to converge and I&#8217;m more interested in speed than accuracy right now so 0.01 it is. <strong>convergeQ<\/strong> returns 1 when the tower seems to converge in at most <strong>size<\/strong> steps and 0 otherwise.:<\/p>\n<pre>In[3]:= convergeQ[I, 50]\nOut[3]= 1\n\nIn[4]:= convergeQ[-1 + 2 I, 50]\nOut[4]= 0<\/pre>\n<p>So, let&#8217;s apply this to a section of the complex plane.<\/p>\n<pre>towerFract[xmin_, xmax_, ymin_, ymax_, step_] :=\n ArrayPlot[\n Table[convergeQ[x + I y, 50], {y, ymin, ymax, step}, {x, xmin, xmax,step}]]\ntowerFract[-2, 2, -2, 2, 0.1]<\/pre>\n<p style=\"text-align: left;\"><img decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/www.walkingrandomly.com\/images\/mathematica7\/roughfract.png\" alt=\"Rough Power Tower Fractal\" \/><\/p>\n<p style=\"text-align: left;\">That looks like it might be interesting, possibly even fractal, behaviour but I need to increase the resolution and maybe widen the range to see what&#8217;s really going on. That&#8217;s going to take quite a bit of calculation time so I need to optimise some more.<\/p>\n<h3>Going Parallel<\/h3>\n<p>There is no point in having machines with two, four or more processor cores if you only ever use one and so it is time to see if we can get our other cores in on the act.<\/p>\n<p>It turns out that this calculation is an example of a so-called <a href=\"http:\/\/en.wikipedia.org\/wiki\/Embarrassingly_parallel\">embarrassingly parallel<\/a> problem and so life is going to be particularly easy for us.\u00a0 Basically, all we need to do is to give each core its own bit of the complex plane to work on, collect the results at the end and reap the increase in speed. Here&#8217;s the full parallel version of the power tower fractal code<\/p>\n<pre>(*Complete Parallel version of the power tower fractal code*)\n\nconvergeQ[base_, size_] :=\n If[Length[\n Quiet[NestWhileList[N[(base^#)] &amp;, base, Abs[#1 - #2] &gt; 0.01 &amp;,\n 2, size, -1]]] &lt; size, 1, 0];\n\nLaunchKernels[];\nDistributeDefinitions[convergeQ];\nParallelEvaluate[SetSystemOptions[\"CatchMachineUnderflow\" -&gt; False]];\n\ntowerFractParallel[xmin_, xmax_, ymin_, ymax_, step_] :=\n ArrayPlot[\n ParallelTable[\n convergeQ[x + I y, 50], {y, ymin, ymax, step}, {x, xmin, xmax, step}\n, Method -&gt; \"CoarsestGrained\"]]<\/pre>\n<p>This code is pretty similar to the single processor version so let&#8217;s focus on the parallel modifications.\u00a0 My <strong>convergeQ<\/strong> function is no different to the serial version so nothing new to talk about there.\u00a0 So, the first new code is<\/p>\n<pre>LaunchKernels[];<\/pre>\n<p>This launches a set of parallel Mathematica kernels. The amount that actually get launched depends on the number of cores on your machine.\u00a0 So, on my dual core laptop I get 2 and on my quad core desktop I get 4.<\/p>\n<pre>DistributeDefinitions[convergeQ];<\/pre>\n<p>All of those parallel kernels are completely clean in that they don&#8217;t know about my user defined <strong>convergeQ<\/strong> function. This line sends the definition of convergeQ to all of the freshly launched parallel kernels.<\/p>\n<pre>ParallelEvaluate[SetSystemOptions[\"CatchMachineUnderflow\" -&gt; False]];<\/pre>\n<p>Here we turn off Mathematica&#8217;s machine underflow safety net on all of our parallel kernels using the ParallelEvaluate function.<\/p>\n<p>That&#8217;s all that is necessary to set up the parallel environment.\u00a0 All that remains is to change <strong>Map<\/strong> to <strong>ParallelMap<\/strong> and to add the argument <strong>Method -&gt; &#8220;CoarsestGrained&#8221;<\/strong> which basically says to Mathematica <strong>&#8216;Each sub-calculation will take a tiny amount of time to perform so you may as well send each core lots to do at once&#8217;<\/strong> (<a href=\"https:\/\/www.walkingrandomly.com\/?p=1456\">click here for a blog post of mine<\/a> where this is discussed further).<\/p>\n<p>That&#8217;s all it took to take this embarrassingly parallel problem from a serial calculation to a parallel one.\u00a0 Let&#8217;s see if it worked.\u00a0 The test machine for what follows contains a T5800 Intel Core 2 Duo CPU running at 2Ghz on Ubuntu (if you want to repeat these timings then I suggest you <a href=\"https:\/\/www.walkingrandomly.com\/?p=2587\">read this blog post first<\/a> or you may find the parallel version going slower than the serial one).\u00a0 I&#8217;ve suppressed the output of the graphic since I only want to time calculation and not rendering time.<\/p>\n<pre>(*Serial version*)\nIn[3]= AbsoluteTiming[towerFract[-2, 2, -2, 2, 0.1];]\nOut[3]= {0.672976, Null}\n\n(*Parallel version*)\nIn[4]= AbsoluteTiming[towerFractParallel[-2, 2, -2, 2, 0.1];]\nOut[4]= {0.532504, Null}\n\nIn[5]= speedup = 0.672976\/0.532504\nOut[5]= 1.2638<\/pre>\n<p>I was hoping for a bit more than a factor of 1.26 but that&#8217;s the way it goes with parallel programming sometimes. The speedup factor gets a bit higher if you increase the size of the problem though. Let&#8217;s increase the problem size by a factor of 100.<\/p>\n<p>towerFractParallel[-2, 2, -2, 2, 0.01]<\/p>\n<p style=\"text-align: left;\">The above calculation took 41.99 seconds compared to 63.58 seconds for the serial version resulting in a speedup factor of around 1.5 (or about 34% depending on how you want to look at it).<br \/>\n<img decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/www.walkingrandomly.com\/images\/mathematica7\/betterfract.png\" alt=\"Power Tower Fractal\" \/><\/p>\n<h3>Other optimisations<\/h3>\n<p>I guess if I were really serious about optimising this problem then I could take advantage of the symmetry along the x axis or maybe I could utilise the fact that if one point in a convergence spiral converges then it follows that they all do. Maybe there are more intelligent ways to test for convergence or maybe I&#8217;d get a big speed increase from programming in C or F#?\u00a0 If anyone is interested in having a go at improving any of this and succeeds then let me know.<\/p>\n<p>I&#8217;m not going to pursue any of these or any other optimisations, however, since the above exploration is what I achieved in a single train journey to work (The write-up took rather longer though). I didn&#8217;t know where I was going and I only worried about optimisation when I had to. At each step of the way the code was <strong>fast enough<\/strong> to ensure that I could interact with the problem at hand.<\/p>\n<p>Being mostly &#8216;fast enough&#8217; with minimal programming effort is one of the reasons I like playing with Mathematica when doing explorations such as this.<\/p>\n<h3>Treading where people have gone before<\/h3>\n<p>So, back to the power tower story. As I mentioned earlier, I did most of the above in a single train journey and I didn&#8217;t have access to the internet. I was quite excited that I had found a fractal from such a relatively simple system and very much felt like I had discovered something for myself. Would this lead to something that was publishable I wondered?<\/p>\n<p>Sadly not!<\/p>\n<p style=\"text-align: left;\">It turns out that power towers have been thoroughly investigated and the act of forming a tower is called <a href=\"http:\/\/en.wikipedia.org\/wiki\/Tetration\">tetration<\/a>. I learned that when a tower converges there is an analytical formula that gives what it will converge to:<\/p>\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/walkingrandomly.com\/wp-content\/ql-cache\/quicklatex.com-8c4b964d6870f28c030ddc39dabef6c5_l3.png\" class=\"ql-img-inline-formula quicklatex-auto-format\" alt=\"&#104;&#40;&#122;&#41;&#32;&#61;&#32;&#45;&#92;&#102;&#114;&#97;&#99;&#123;&#87;&#40;&#45;&#108;&#110;&#32;&#122;&#41;&#125;&#123;&#108;&#110;&#40;&#122;&#41;\" title=\"Rendered by QuickLaTeX.com\" height=\"26\" width=\"152\" style=\"vertical-align: -4px;\"\/><\/p>\n<p>Where W is the <a href=\"http:\/\/en.wikipedia.org\/wiki\/Lambert_W_function\">Lambert W function<\/a> (<a href=\"http:\/\/www.orcca.on.ca\/LambertW\/\">click here for a cool poster<\/a> for this function).\u00a0 I discovered that other people had already made Wolfram Demonstrations for power towers too<\/p>\n<ul>\n<li><a href=\"http:\/\/demonstrations.wolfram.com\/TheRepeatedPowerFunction\/\">The Repeated Power function<\/a><\/li>\n<li><a href=\"http:\/\/demonstrations.wolfram.com\/ConvergenceOfAHyperpowerSequence\/\">Convergence of a Hyperpower Sequence<\/a><\/li>\n<\/ul>\n<p>There is even a website called <a href=\"http:\/\/www.tetration.org\/\">tetration.org<\/a> that shows &#8216;my&#8217; fractal in glorious technicolor.\u00a0 Nothing new under the sun eh?<\/p>\n<h3>Parting shots<\/h3>\n<p>Well, I didn&#8217;t discover anything new but I had a bit of fun along the way. Here&#8217;s the final Manipulate I came up with<\/p>\n<pre>Manipulate[const = p[[1]] + p[[2]] I;\n If[hz,\n  ListPlot[fasttowerspiral[const, n], PlotRange -&gt; {{-2, 2}, {-2, 2}},\n    Axes -&gt; ax,\n   Epilog -&gt; {{PointSize[Large], Red,\n      Point[complexSplit[N[h[const]]]]}, {Inset[\n       Framed[N[h[const]]], {-1, -1.5}]}}]\n  , ListPlot[fasttowerspiral[const, n],\n   PlotRange -&gt; {{-2, 2}, {-2, 2}}, Axes -&gt; ax]\n  ]\n , {{n, 100, \"Number of terms\"}, 1, 500, 1, Appearance -&gt; \"Labeled\"}\n , {{ax, True, \"Show axis\"}, {True, False}}\n , {{hz, True, \"Show h(z)\"}, {True, False}}\n , {{p, {0, 1.5}}, Locator}\n , Initialization :&gt; (\n   SetSystemOptions[\"CatchMachineUnderflow\" -&gt; False];\n   complexSplit[x_] := {Re[x], Im[x]};\n   fasttowerspiral[base_, size_] :=\n    Quiet[Map[complexSplit,\n      NestWhileList[N[(base^#)] &amp;, base, MatchQ[#, _Complex] &amp;, 1,\n       size, -1]]];\n   h[z_] := -ProductLog[-Log[z]]\/Log[z];\n   )\n ]\n<\/pre>\n<p style=\"text-align: left;\"><img decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/www.walkingrandomly.com\/images\/mathematica7\/power_tower_manipulate2.png\" alt=\"Tetration Manipulate\" \/><br \/>\nand here&#8217;s a video of a zoom into the tetration fractal that I made using spare cycles on <a href=\"http:\/\/www.manchester.ac.uk\/\">Manchester University&#8217;s<\/a> condor pool.<\/p>\n<p><iframe loading=\"lazy\" width=\"560\" height=\"315\" src=\"https:\/\/www.youtube.com\/embed\/HY8cNh2bxgk\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen><\/iframe><\/p>\n<p><strong>If you liked this blog post then you may also enjoy:<\/strong><\/p>\n<ul>\n<li><a href=\"https:\/\/www.walkingrandomly.com\/?p=151\">Simulating Harmonographs<\/a><\/li>\n<li><a href=\"https:\/\/www.walkingrandomly.com\/?p=2447\">Polygonal numbers on quadratic number spirals<\/a><\/li>\n<li><a href=\"https:\/\/www.walkingrandomly.com\/?p=1701\">The Unreasonable ineffectiveness of factoring<\/a><\/li>\n<li><a href=\"https:\/\/www.walkingrandomly.com\/?p=626\">Quadraflakes, Pentaflakes, Hexaflakes and more<\/a><\/li>\n<li><a href=\"https:\/\/www.walkingrandomly.com\/?p=19\">The equation that says Hi<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Some time ago now, Sam Shah of Continuous Everywhere but Differentiable Nowhere fame discussed the standard method of obtaining the square root of the imaginary unit, i, and in the ensuing discussion thread someone asked the question &#8220;What is i^i &#8211; that is what is i to the power i?&#8221; Sam immediately came back with [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[46,45,4,8,41,7,42,15],"tags":[],"class_list":["post-294","post","type-post","status-publish","format-standard","hentry","category-fractals","category-just-for-fun","category-math-software","category-mathematica","category-parallel-programming","category-programming","category-tutorials","category-walking-randomly"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p3swhs-4K","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/posts\/294","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=294"}],"version-history":[{"count":62,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/posts\/294\/revisions"}],"predecessor-version":[{"id":6694,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/posts\/294\/revisions\/6694"}],"wp:attachment":[{"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=294"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=294"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=294"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}