{"id":320,"date":"2012-09-24T12:17:21","date_gmt":"2012-09-24T17:17:21","guid":{"rendered":"https:\/\/blogs.mathworks.com\/cleve\/?p=320"},"modified":"2013-05-02T10:03:01","modified_gmt":"2013-05-02T15:03:01","slug":"supremum","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/cleve\/2012\/09\/24\/supremum\/","title":{"rendered":"Supremum"},"content":{"rendered":"<!DOCTYPE html\r\n  PUBLIC \"-\/\/W3C\/\/DTD HTML 4.01 Transitional\/\/EN\">\r\n<style type=\"text\/css\">\r\n\r\nh1 { font-size:18pt; }\r\nh2.titlebg { font-size:13pt; }\r\nh3 { color:#4A4F55; padding:0px; margin:5px 0px 5px; font-family:Arial, Helvetica, sans-serif; font-size:11pt; font-weight:bold; line-height:140%; border-bottom:1px solid #d6d4d4; display:block; }\r\nh4 { color:#4A4F55; padding:0px; margin:0px 0px 5px; font-family:Arial, Helvetica, sans-serif; font-size:10pt; font-weight:bold; line-height:140%; border-bottom:1px solid #d6d4d4; display:block; }\r\n   \r\np { padding:0px; margin:0px 0px 20px; }\r\nimg { padding:0px; margin:0px 0px 20px; border:none; }\r\np img, pre img, tt img, li img { margin-bottom:0px; } \r\n\r\nul { padding:0px; margin:0px 0px 20px 23px; list-style:square; }\r\nul li { padding:0px; margin:0px 0px 7px 0px; background:none; }\r\nul li ul { padding:5px 0px 0px; margin:0px 0px 7px 23px; }\r\nul li ol li { list-style:decimal; }\r\nol { padding:0px; margin:0px 0px 20px 0px; list-style:decimal; }\r\nol li { padding:0px; margin:0px 0px 7px 23px; list-style-type:decimal; }\r\nol li ol { padding:5px 0px 0px; margin:0px 0px 7px 0px; }\r\nol li ol li { list-style-type:lower-alpha; }\r\nol li ul { padding-top:7px; }\r\nol li ul li { list-style:square; }\r\n\r\npre, tt, code { font-size:12px; }\r\npre { margin:0px 0px 20px; }\r\npre.error { color:red; }\r\npre.codeinput { padding:10px; border:1px solid #d3d3d3; background:#f7f7f7; }\r\npre.codeoutput { padding:10px 11px; margin:0px 0px 20px; color:#4c4c4c; }\r\n\r\n@media print { pre.codeinput, pre.codeoutput { word-wrap:break-word; width:100%; } }\r\n\r\nspan.keyword { color:#0000FF }\r\nspan.comment { color:#228B22 }\r\nspan.string { color:#A020F0 }\r\nspan.untermstring { color:#B20000 }\r\nspan.syscmd { color:#B28C00 }\r\n\r\n.footer { width:auto; padding:10px 0px; margin:25px 0px 0px; border-top:1px dotted #878787; font-size:0.8em; line-height:140%; font-style:italic; color:#878787; text-align:left; float:none; }\r\n.footer p { margin:0px; }\r\n\r\n  <\/style><div class=\"content\"><!--introduction--><p>Find the supremum of this function.<\/p><!--\/introduction--><h3>Contents<\/h3><div><ul><li><a href=\"#ac9e2900-7c51-4b06-bd7a-5365c9a3fe0a\">Favorite Function<\/a><\/li><li><a href=\"#bf1c0ab5-cb13-40ab-9e7b-8dd43a038806\">Calculus<\/a><\/li><li><a href=\"#02af74c5-483f-41e7-8252-d257490923e8\">Sample<\/a><\/li><li><a href=\"#f881d20f-d532-4000-b756-603a1256d240\">Think<\/a><\/li><li><a href=\"#0235a391-4959-42b6-bb2f-96006a30ddb9\">Supremum<\/a><\/li><\/ul><\/div><h4>Favorite Function<a name=\"ac9e2900-7c51-4b06-bd7a-5365c9a3fe0a\"><\/a><\/h4><p>Here is one of my favorite functions. What is its maximum?<\/p><p>$$ f(x) = \\tan { \\sin {x} } - \\sin { \\tan {x} } $$<\/p><p>Let's plot it with <tt>ezplot<\/tt>, which is pronounced <i>easy-plot<\/i>.<\/p><pre class=\"codeinput\">f = @(x) tan(sin(x)) - sin(tan(x))\r\nezplot(f,[-pi,pi])\r\n<\/pre><pre class=\"codeoutput\">\r\nf = \r\n\r\n    @(x)tan(sin(x))-sin(tan(x))\r\n\r\n<\/pre><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/cleve\/supremum_01.png\" alt=\"\"> <p>The function is very flat at the origin. Its Taylor series begins with $x^7$. It oscillates infinitely often near $\\pm \\pi\/2$. It is linear as it approaches zero again at $\\pm \\pi$. And, most important for our purposes here, <tt>ezplot<\/tt> has picked the limit on the <i>y<\/i>-axes to be between 2.5 and 3.<\/p><pre class=\"codeinput\">syms <span class=\"string\">x<\/span>\r\nF = sym(f)\r\ndisp(<span class=\"string\">'taylor = '<\/span>)\r\npretty(taylor(F,x,<span class=\"string\">'order'<\/span>,10))\r\nylim = get(gca,<span class=\"string\">'ylim'<\/span>)\r\n<\/pre><pre class=\"codeoutput\"> \r\nF =\r\n \r\ntan(sin(x)) - sin(tan(x))\r\n \r\ntaylor = \r\n \r\n      9    7 \r\n  29 x    x \r\n  ----- + -- \r\n   756    30\r\n\r\nylim =\r\n\r\n  -2.867712755182179   2.867712755182179\r\n\r\n<\/pre><h4>Calculus<a name=\"bf1c0ab5-cb13-40ab-9e7b-8dd43a038806\"><\/a><\/h4><p>We learn in calculus that a maximum occurs at a zero of the derivative. But this function is not differentiable in the vicinity of $\\pi\/2$. The most interesting thing about an <tt>ezplot<\/tt> of the derivative is the title. Trying to find a zero of <tt>diff(F)<\/tt> is meaningless.<\/p><pre class=\"codeinput\">ezplot(diff(F),[-pi,pi])\r\n<\/pre><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/cleve\/supremum_02.png\" alt=\"\"> <h4>Sample<a name=\"02af74c5-483f-41e7-8252-d257490923e8\"><\/a><\/h4><p>We can sample the function near $\\pi\/2$ to get a numerical approximation to the value of the maximum.  Is that good enough?<\/p><pre class=\"codeinput\">x = 3*pi\/8 + pi\/4*rand(1,1000000);\r\ny = f(x);\r\nformat <span class=\"string\">long<\/span>\r\nsmax = max(y)\r\n<\/pre><pre class=\"codeoutput\">\r\nsmax =\r\n\r\n   2.557406355782225\r\n\r\n<\/pre><h4>Think<a name=\"f881d20f-d532-4000-b756-603a1256d240\"><\/a><\/h4><p>The computer has been a help, but we can do this without it.<\/p><p>$$ \\sin{x} \\le 1 $$<\/p><p>so<\/p><p>$$ \\sin{ \\tan {x} } \\le 1 $$<\/p><p>and<\/p><p>$$ \\tan {\\sin{x}} \\le \\tan {1} $$<\/p><p>Consequently<\/p><p>$$ f(x) \\le 1 + \\tan {1} $$<\/p><h4>Supremum<a name=\"0235a391-4959-42b6-bb2f-96006a30ddb9\"><\/a><\/h4><p>But I want to be a little more careful. As $x$ approaches $\\pi\/2$, $\\tan{x}$ blows up. So $f(x)$ is actually not defined at $\\pi\/2$. For the domain of this function, one of the less than or equals changes to just a less than.<\/p><p>$$ \\sin{x} &lt; 1 $$<\/p><p>$$ \\tan {\\sin{x}} &lt; \\tan {1} $$<\/p><p>$$ f(x) &lt; 1 + \\tan {1} $$<\/p><p>The precise answer to my original question is that this function does not have a maximum.  It has a \"least upper bound\" or <i>supremum<\/i>, the smallest quantity that the function does not exceed.  The <i>sup<\/i> is:<\/p><p>$$ \\sup {f(x)} = 1 + \\tan {1} $$<\/p><p>Now we can take a look at the numerical value.<\/p><pre class=\"codeinput\">sup = 1 + tan(1)\r\n<\/pre><pre class=\"codeoutput\">\r\nsup =\r\n\r\n   2.557407724654902\r\n\r\n<\/pre><script language=\"JavaScript\"> <!-- \r\n    function grabCode_249e710675e04c9ca22ab0db190e36db() {\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='249e710675e04c9ca22ab0db190e36db ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' 249e710675e04c9ca22ab0db190e36db';\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 2012 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_249e710675e04c9ca22ab0db190e36db()\"><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; 7.14<br><\/p><p class=\"footer\"><br>\r\n      Published with MATLAB&reg; 7.14<br><\/p><\/div><!--\r\n249e710675e04c9ca22ab0db190e36db ##### SOURCE BEGIN #####\r\n%% Supremum\r\n% Find the supremum of this function.\r\n\r\n%% Favorite Function\r\n% Here is one of my favorite functions.\r\n% What is its maximum?\r\n%\r\n% $$ f(x) = \\tan { \\sin {x} } - \\sin { \\tan {x} } $$\r\n%\r\n\r\n%%\r\n% Let's plot it with |ezplot|, which is pronounced _easy-plot_.\r\n\r\nf = @(x) tan(sin(x)) - sin(tan(x))\r\nezplot(f,[-pi,pi])\r\n\r\n%%\r\n% The function is very flat at the origin.\r\n% Its Taylor series begins with $x^7$.\r\n% It oscillates infinitely often near $\\pm \\pi\/2$.\r\n% It is linear as it approaches zero again at $\\pm \\pi$.\r\n% And, most important for our purposes here, |ezplot| has picked the\r\n% limit on the _y_-axes to be between 2.5 and 3.\r\n\r\nsyms x\r\nF = sym(f)\r\ndisp('taylor = ')\r\npretty(taylor(F,x,'order',10))\r\nylim = get(gca,'ylim')\r\n\r\n%% Calculus\r\n% We learn in calculus that a maximum occurs at a zero of the derivative.\r\n% But this function is not differentiable in the vicinity of $\\pi\/2$.\r\n% The most interesting thing about an |ezplot| of the derivative is the title.\r\n% Trying to find a zero of |diff(F)| is meaningless.\r\n\r\nezplot(diff(F),[-pi,pi])\r\n\r\n%% Sample\r\n% We can sample the function near $\\pi\/2$ to get a numerical approximation\r\n% to the value of the maximum.  Is that good enough?\r\n\r\nx = 3*pi\/8 + pi\/4*rand(1,1000000);\r\ny = f(x);\r\nformat long\r\nsmax = max(y)\r\n\r\n%% Think\r\n% The computer has been a help, but we can do this without it.\r\n%\r\n% $$ \\sin{x} \\le 1 $$\r\n%\r\n% so\r\n%\r\n% $$ \\sin{ \\tan {x} } \\le 1 $$\r\n%\r\n% and\r\n%\r\n% $$ \\tan {\\sin{x}} \\le \\tan {1} $$\r\n%\r\n% Consequently\r\n%\r\n% $$ f(x) \\le 1 + \\tan {1} $$\r\n%\r\n\r\n%% Supremum\r\n% But I want to be a little more careful.\r\n% As $x$ approaches $\\pi\/2$, $\\tan{x}$ blows up.\r\n% So $f(x)$ is actually not defined at $\\pi\/2$.\r\n% For the domain of this function, one of the less than or equals\r\n% changes to just a less than.\r\n%\r\n% $$ \\sin{x} < 1 $$\r\n%\r\n% $$ \\tan {\\sin{x}} < \\tan {1} $$\r\n%\r\n% $$ f(x) < 1 + \\tan {1} $$\r\n%\r\n\r\n%%\r\n% The precise answer to my original question is that this function does\r\n% not have a maximum.  It has a \"least upper bound\" or _supremum_,\r\n% the smallest quantity that the function does not exceed.  The _sup_ is:\r\n%\r\n% $$ \\sup {f(x)} = 1 + \\tan {1} $$\r\n%\r\n\r\n%%\r\n% Now we can take a look at the numerical value.\r\n\r\nsup = 1 + tan(1)\r\n\r\n##### SOURCE END ##### 249e710675e04c9ca22ab0db190e36db\r\n-->","protected":false},"excerpt":{"rendered":"<!--introduction--><p>Find the supremum of this function.... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/cleve\/2012\/09\/24\/supremum\/\">read more >><\/a><\/p>","protected":false},"author":78,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[12],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/posts\/320"}],"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=320"}],"version-history":[{"count":8,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/posts\/320\/revisions"}],"predecessor-version":[{"id":327,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/posts\/320\/revisions\/327"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/media?parent=320"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/categories?post=320"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/tags?post=320"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}