{"id":6498,"date":"2020-12-04T00:01:33","date_gmt":"2020-12-04T05:01:33","guid":{"rendered":"https:\/\/blogs.mathworks.com\/cleve\/?p=6498"},"modified":"2020-12-04T08:21:01","modified_gmt":"2020-12-04T13:21:01","slug":"a-famous-equation-x2-2x","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/cleve\/2020\/12\/04\/a-famous-equation-x2-2x\/","title":{"rendered":"A Famous Equation, x^2 = 2^x"},"content":{"rendered":"<div class=\"content\"><!--introduction--><p>A recent episode of the popular YouTube channel <a href=\"https:\/\/www.youtube.com\/watch?v=ndA0sF_0Rwk&amp;list=PU_SvYP0k05UKiJ_2ndB02IA&amp;index=44\">\"blackpenredpen\"<\/a> is about solutions to the famous equation<\/p><p><tt>x^2 = 2^x<\/tt><\/p><p>You should be able to see two solutions yourself, <tt>x = 2<\/tt> and <tt>x = 4<\/tt>, because <tt>2^2 = 2^2<\/tt> and <tt>4^2 = 2^4<\/tt>.<\/p><p>This post is about a third solution.<\/p><!--\/introduction--><h3>Contents<\/h3><div><ul><li><a href=\"#97542339-a27e-498e-a9dd-a23ae459296e\">Two graphs<\/a><\/li><li><a href=\"#ad1efb2c-f8d0-43b1-af38-ce03c7f19077\">The negative solution<\/a><\/li><li><a href=\"#e6fbb1ca-5c9a-4f22-a112-f83dd9ab61b4\">Logarithm<\/a><\/li><li><a href=\"#cf21aff2-f714-4476-bbc8-850aaf98a28a\">LambertW<\/a><\/li><li><a href=\"#fe59b3a8-2f48-45a5-bed7-58498b31059e\">Many digits<\/a><\/li><li><a href=\"#1a414af5-cf18-4ea0-9602-36e5eb4c6370\">Fixed points<\/a><\/li><li><a href=\"#edf933d0-798c-4955-8914-92a34b5702c1\">Thanks<\/a><\/li><li><a href=\"#4a739d11-c23a-443e-93b3-c2f6a02c1861\">Code<\/a><\/li><\/ul><\/div><h4>Two graphs<a name=\"97542339-a27e-498e-a9dd-a23ae459296e\"><\/a><\/h4><p>The figure shows the graphs of <tt>x^2<\/tt> and <tt>2^x<\/tt> and their intersections. The narrow silver area is the only region the right half plane where <tt>x^2<\/tt> is greater than <tt>2^x<\/tt>.<\/p><p>We can see there are three intersections -- the two we knew about at <tt>x = 2<\/tt> and <tt>x = 4<\/tt> and a third one at a negative value of <tt>x<\/tt>. <a href=\"https:\/\/www.youtube.com\/watch?v=ndA0sF_0Rwk&amp;list=PU_SvYP0k05UKiJ_2ndB02IA&amp;index=44\">Blackpen<\/a> carefully explains how to characterize this negative solution.<\/p><pre class=\"codeinput\">   black_pen_plot\r\n<\/pre><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"http:\/\/blogs.mathworks.com\/cleve\/files\/black_pen_blog_01.png\" alt=\"\"> <h4>The negative solution<a name=\"ad1efb2c-f8d0-43b1-af38-ce03c7f19077\"><\/a><\/h4><p>I was pleased to learn that our Symbolic Math Toolbox can find all three solutions, provided we indicate that we are only interested in real-valued solutions.  (The behavior of <tt>x^2 = 2^x<\/tt> for complex <tt>x<\/tt> is a topic for another day.)<\/p><pre class=\"codeinput\">   syms <span class=\"string\">x<\/span> <span class=\"string\">real<\/span>\r\n   z = solve(x^2 == 2^x)\r\n<\/pre><pre class=\"codeoutput\"> \r\nz =\r\n \r\n                                2\r\n                                4\r\n-(2*lambertw(0, log(2)\/2))\/log(2)\r\n \r\n<\/pre><p>We want to know more about that third solution.<\/p><pre class=\"codeinput\">   z = z(3)\r\n<\/pre><pre class=\"codeoutput\"> \r\nz =\r\n \r\n-(2*lambertw(0, log(2)\/2))\/log(2)\r\n \r\n<\/pre><p>The function <tt>lambertw(x)<\/tt> involved in this solution is an old friend, <a href=\"https:\/\/blogs.mathworks.com\/cleve\/2013\/09\/02\/the-lambert-w-function\">the LambertW function<\/a>.<\/p><h4>Logarithm<a name=\"e6fbb1ca-5c9a-4f22-a112-f83dd9ab61b4\"><\/a><\/h4><p>The blue curve in the following figure is a plot of <tt>exp(x)<\/tt>. It goes to zero for negative <tt>x<\/tt> and grows exponentially for positive <tt>x<\/tt>. Imagine interchanging the x and y axes by reflecting the blue curve about the diagonal dashed line to produce the orange curve.  The orange curve is familiar.  It is a plot of the functional inverse of <tt>exp(x)<\/tt> which we know as <tt>log(x)<\/tt>.  If <tt>y = log(x)<\/tt> then <tt>x = exp(y)<\/tt>.<\/p><pre class=\"codeinput\">   log_plot\r\n<\/pre><pre class=\"codeoutput\">Current plot released\r\n<\/pre><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"http:\/\/blogs.mathworks.com\/cleve\/files\/black_pen_blog_02.png\" alt=\"\"> <h4>LambertW<a name=\"cf21aff2-f714-4476-bbc8-850aaf98a28a\"><\/a><\/h4><p>The blue curve in the following figure is now a plot of <tt>x*exp(x)<\/tt>. Reflecting the blue curve about the diagonal produces the orange curve, a plot of the functional inverse of <tt>x*exp(x)<\/tt>.  This function is not as familiar as <tt>log(x)<\/tt>.  It is <tt>lambertw(x)<\/tt>. If <tt>y = lambertw(x)<\/tt> then <tt>x = y*exp(y)<\/tt>.<\/p><p>We need to evaluate <tt>y = lambertw(x)<\/tt> at <tt>x = log(2)\/2<\/tt>.  This is the black dot.  Once we have <tt>x<\/tt> and <tt>y<\/tt>, the negative solution to our famous equation is simply <tt>z = -y\/x<\/tt>.<\/p><pre class=\"codeinput\">   lambertw_plot\r\n<\/pre><pre class=\"codeoutput\">Current plot released\r\n<\/pre><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"http:\/\/blogs.mathworks.com\/cleve\/files\/black_pen_blog_03.png\" alt=\"\"> <h4>Many digits<a name=\"fe59b3a8-2f48-45a5-bed7-58498b31059e\"><\/a><\/h4><p>The Symbolic Math Toolbox variable precision arithmetic, <tt>vpa<\/tt>, can produce the numeric value of the negative solution to any number of digits.<\/p><pre class=\"codeinput\">    z\r\n    vpaz = vpa(z,75)\r\n<\/pre><pre class=\"codeoutput\"> \r\nz =\r\n \r\n-(2*lambertw(0, log(2)\/2))\/log(2)\r\n \r\n \r\nvpaz =\r\n \r\n-0.766664695962123093111204422510314848006675346669832058460884376935552795725\r\n \r\n<\/pre><h4>Fixed points<a name=\"1a414af5-cf18-4ea0-9602-36e5eb4c6370\"><\/a><\/h4><p>Here is your homework.  Investigate the iteration:<\/p><p><tt>x = sign(x)*2^(x\/2)<\/tt><\/p><p>Consider three situations:<\/p><div><ul><li>Starting values between 0 and 4.<\/li><li>Starting values greater than 4.<\/li><li>Starting values less than 0.<\/li><\/ul><\/div><h4>Thanks<a name=\"edf933d0-798c-4955-8914-92a34b5702c1\"><\/a><\/h4><p>Thanks to Mark Round for suggesting only real solutions.<\/p><h4>Code<a name=\"4a739d11-c23a-443e-93b3-c2f6a02c1861\"><\/a><\/h4><p>The code for the figures is available.<\/p><p><a href=\"https:\/\/blogs.mathworks.com\/cleve\/files\/black_pen_plot.m\">black_pen_plot<\/a><\/p><p><a href=\"https:\/\/blogs.mathworks.com\/cleve\/files\/log_plot.m\">log_plot<\/a><\/p><p><a href=\"https:\/\/blogs.mathworks.com\/cleve\/files\/lambertw_plot.m\">lambertw_plot<\/a><\/p><script language=\"JavaScript\"> <!-- \r\n    function grabCode_e71067b5fcb04153a8718a481650f002() {\r\n        \/\/ Remember the title so we can use it in the new page\r\n        title = document.title;\r\n\r\n        \/\/ Break up these strings so that their presence\r\n        \/\/ in the Javascript doesn't mess up the search for\r\n        \/\/ the MATLAB code.\r\n        t1='e71067b5fcb04153a8718a481650f002 ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' e71067b5fcb04153a8718a481650f002';\r\n    \r\n        b=document.getElementsByTagName('body')[0];\r\n        i1=b.innerHTML.indexOf(t1)+t1.length;\r\n        i2=b.innerHTML.indexOf(t2);\r\n \r\n        code_string = b.innerHTML.substring(i1, i2);\r\n        code_string = code_string.replace(\/REPLACE_WITH_DASH_DASH\/g,'--');\r\n\r\n        \/\/ Use \/x3C\/g instead of the less-than character to avoid errors \r\n        \/\/ in the XML parser.\r\n        \/\/ Use '\\x26#60;' instead of '<' so that the XML parser\r\n        \/\/ doesn't go ahead and substitute the less-than character. \r\n        code_string = code_string.replace(\/\\x3C\/g, '\\x26#60;');\r\n\r\n        copyright = 'Copyright 2020 The MathWorks, Inc.';\r\n\r\n        w = window.open();\r\n        d = w.document;\r\n        d.write('<pre>\\n');\r\n        d.write(code_string);\r\n\r\n        \/\/ Add copyright line at the bottom if specified.\r\n        if (copyright.length > 0) {\r\n            d.writeln('');\r\n            d.writeln('%%');\r\n            if (copyright.length > 0) {\r\n                d.writeln('% _' + copyright + '_');\r\n            }\r\n        }\r\n\r\n        d.write('<\/pre>\\n');\r\n\r\n        d.title = title + ' (MATLAB code)';\r\n        d.close();\r\n    }   \r\n     --> <\/script><p style=\"text-align: right; font-size: xx-small; font-weight:lighter;   font-style: italic; color: gray\"><br><a href=\"javascript:grabCode_e71067b5fcb04153a8718a481650f002()\"><span style=\"font-size: x-small;        font-style: italic;\">Get \r\n      the MATLAB code <noscript>(requires JavaScript)<\/noscript><\/span><\/a><br><br>\r\n      Published with MATLAB&reg; R2020b<br><\/p><\/div><!--\r\ne71067b5fcb04153a8718a481650f002 ##### SOURCE BEGIN #####\r\n%% x^2 = 2^x\r\n% A recent episode of the popular YouTube channel\r\n% <https:\/\/www.youtube.com\/watch?v=ndA0sF_0Rwk&list=PU_SvYP0k05UKiJ_2ndB02IA&index=44\r\n% \"blackpenredpen\"> is about solutions to the famous equation\r\n%\r\n% |x^2 = 2^x|\r\n%\r\n% You should be able to see two solutions yourself, |x = 2| and |x = 4|,\r\n% because |2^2 = 2^2| and |4^2 = 2^4|.\r\n%\r\n% This post is about a third solution.\r\n\r\n%% Two graphs\r\n% The figure shows the graphs of |x^2| and |2^x| and their intersections.\r\n% The narrow silver area is the only region the right half plane\r\n% where |x^2| is greater than |2^x|. \r\n\r\n%%\r\n% We can see there are three intersections REPLACE_WITH_DASH_DASH the two we knew about at\r\n% |x = 2| and |x = 4| and a third one at a negative value of |x|.\r\n% <https:\/\/www.youtube.com\/watch?v=ndA0sF_0Rwk&list=PU_SvYP0k05UKiJ_2ndB02IA&index=44\r\n% Blackpen> carefully explains how to characterize this\r\n% negative solution.\r\n\r\n   black_pen_plot\r\n   \r\n%% The negative solution\r\n%\r\n% I was pleased to learn that our Symbolic Math Toolbox can\r\n% find all three solutions, provided we indicate that we are only\r\n% interested in real-valued solutions.  (The behavior of |x^2 = 2^x|\r\n% for complex |x| is a topic for another day.)\r\n\r\n   syms x real\r\n   z = solve(x^2 == 2^x)\r\n   \r\n%%\r\n% We want to know more about that third solution.\r\n\r\n   z = z(3)\r\n   \r\n%%\r\n% The function |lambertw(x)| involved in this solution is an\r\n% old friend,\r\n% <https:\/\/blogs.mathworks.com\/cleve\/2013\/09\/02\/the-lambert-w-function\r\n% the LambertW function>.\r\n\r\n%% Logarithm\r\n% The blue curve in the following figure is a plot of |exp(x)|.\r\n% It goes to zero for negative |x| and grows exponentially for positive |x|. \r\n% Imagine interchanging the x and y axes by reflecting the blue curve about\r\n% the diagonal dashed line to produce the orange curve.  The orange curve\r\n% is familiar.  It is a plot of the functional inverse of |exp(x)|\r\n% which we know as |log(x)|.  If |y = log(x)| then |x = exp(y)|.\r\n\r\n   log_plot\r\n   \r\n%% LambertW\r\n% The blue curve in the following figure is now a plot of |x*exp(x)|.\r\n% Reflecting the blue curve about the diagonal produces the orange curve,\r\n% a plot of the functional inverse of |x*exp(x)|.  This function is not\r\n% as familiar as |log(x)|.  It is |lambertw(x)|.\r\n% If |y = lambertw(x)| then |x = y*exp(y)|.\r\n%\r\n% We need to evaluate |y = lambertw(x)| at |x = log(2)\/2|.  This is the\r\n% black dot.  Once we have |x| and |y|, the negative solution to our\r\n% famous equation is simply |z = -y\/x|.\r\n\r\n   lambertw_plot\r\n   \r\n%% Many digits\r\n% The Symbolic Math Toolbox variable precision arithmetic, |vpa|,\r\n% can produce the numeric value of the negative solution to\r\n% any number of digits.\r\n\r\n    z\r\n    vpaz = vpa(z,75)\r\n   \r\n      \r\n%% Fixed points\r\n% Here is your homework.  Investigate the iteration:\r\n%\r\n% |x = sign(x)*2^(x\/2)|\r\n% \r\n% Consider three situations:\r\n%\r\n% * Starting values between 0 and 4.\r\n% * Starting values greater than 4.\r\n% * Starting values less than 0.\r\n\r\n%% Thanks\r\n% Thanks to Mark Round for suggesting only real solutions.\r\n\r\n%% Code\r\n% The code for the figures is available.\r\n%\r\n% <https:\/\/blogs.mathworks.com\/cleve\/files\/black_pen_plot.m\r\n% black_pen_plot>\r\n%\r\n% <https:\/\/blogs.mathworks.com\/cleve\/files\/log_plot.m\r\n% log_plot>\r\n%\r\n% <https:\/\/blogs.mathworks.com\/cleve\/files\/lambertw_plot.m\r\n% lambertw_plot>\r\n\r\n\r\n##### SOURCE END ##### e71067b5fcb04153a8718a481650f002\r\n-->","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img src=\"https:\/\/blogs.mathworks.com\/cleve\/files\/black_pen_blog_01.png\" class=\"img-responsive attachment-post-thumbnail size-post-thumbnail wp-post-image\" alt=\"\" decoding=\"async\" loading=\"lazy\" \/><\/div><!--introduction--><p>A recent episode of the popular YouTube channel <a href=\"https:\/\/www.youtube.com\/watch?v=ndA0sF_0Rwk&amp;list=PU_SvYP0k05UKiJ_2ndB02IA&amp;index=44\">\"blackpenredpen\"<\/a> is about solutions to the famous equation... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/cleve\/2020\/12\/04\/a-famous-equation-x2-2x\/\">read more >><\/a><\/p>","protected":false},"author":78,"featured_media":6490,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[4,16,8],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/posts\/6498"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/users\/78"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/comments?post=6498"}],"version-history":[{"count":3,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/posts\/6498\/revisions"}],"predecessor-version":[{"id":6514,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/posts\/6498\/revisions\/6514"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/media\/6490"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/media?parent=6498"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/categories?post=6498"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/tags?post=6498"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}