{"id":6219,"date":"2020-05-03T15:25:32","date_gmt":"2020-05-03T19:25:32","guid":{"rendered":"https:\/\/blogs.mathworks.com\/cleve\/?p=6219"},"modified":"2020-06-10T13:21:44","modified_gmt":"2020-06-10T17:21:44","slug":"precise-setting-of-a-delicate-parameter-with-pibar","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/cleve\/2020\/05\/03\/precise-setting-of-a-delicate-parameter-with-pibar\/","title":{"rendered":"Precise Setting of a Delicate Parameter with &#8220;pibar&#8221;"},"content":{"rendered":"<div class=\"content\"><!--introduction--><p>(A slight revision of the post I made a few hours ago.)<\/p><p>We are still working on the Kuramoto model of self-synchronizing oscillators that I made <a href=\"https:\/\/blogs.mathworks.com\/cleve\/2019\/10\/30\/stability-of-kuramoto-oscillators\/\">blog posts<\/a> about last fall,  My colleagues and I expect to eventually write a serious  paper.  In the meantime, let me tell you about an unusual user interface control that I am using in our Kuramoto experiments.<\/p><p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"http:\/\/blogs.mathworks.com\/cleve\/files\/new_pibar_gif.gif\" alt=\"\"> <\/p><!--\/introduction--><h3>Contents<\/h3><div><ul><li><a href=\"#4166e71c-47dc-4fb8-85aa-a57b3a56c8f2\">pibar<\/a><\/li><li><a href=\"#7b377e60-39a6-4f97-b04e-1ac7643c4b3c\">pi and truepi<\/a><\/li><li><a href=\"#1ab56e17-ddc4-44f1-aae9-9be369b59538\">Code<\/a><\/li><\/ul><\/div><h4>pibar<a name=\"4166e71c-47dc-4fb8-85aa-a57b3a56c8f2\"><\/a><\/h4><p>For reasons that I need not get into right now, I want to make very small changes in the usually constant value of <tt>pi<\/tt>. This special slider does the job.  It varies <tt>pi<\/tt> between 3.1 and 3.2 in discrete steps, each step deleting or inserting one digit in the decimal expansion of <tt>pi<\/tt>.<\/p><p>The slider starts in the center and <tt>pi<\/tt> returns its traditional value.  With the default settings, if you move the slider to the left from the center, you get<\/p><pre>  |pi| = 3.1415926535<\/pre><pre>  |pi| = 3.141592653<\/pre><pre>  |pi| = 3.14159265<\/pre><pre>    . . . .<\/pre><pre>  |pi| = 3.141<\/pre><pre>  |pi| = 3.14<\/pre><pre>  |pi| = 3.1<\/pre><p>It's easy to see what's happening in this direction because each step just chops off one digit.<\/p><p>Starting in the center and moving right is a little trickier because step rounds up.  The first three and last three steps are<\/p><pre>  |pi| = 3.1415926536<\/pre><pre>  |pi| = 3.141592654<\/pre><pre>  |pi| = 3.14159266<\/pre><pre>    . . . .<\/pre><pre>  |pi| = 3.142<\/pre><pre>  |pi| = 3.15<\/pre><pre>  |pi| = 3.2<\/pre><h4>pi and truepi<a name=\"7b377e60-39a6-4f97-b04e-1ac7643c4b3c\"><\/a><\/h4><p>The <tt>pibar<\/tt> suite consists of three functions.<\/p><div><ul><li><tt>pibar<\/tt> sets up the tool.  You can center on any value you choose; it doesn't have to be <tt>pi<\/tt>.  Another parameter sets the number of digits.<\/li><\/ul><\/div><div><ul><li><tt>pi<\/tt> returns the current value provided by the slider.<\/li><\/ul><\/div><div><ul><li><tt>truepi<\/tt> always returns <tt>4*atan(1)<\/tt>, which is the double precision floating point number nearest to $\\pi$.  This is the value we get for <tt>pi<\/tt> when <tt>pibar<\/tt> is not messing with it.<\/li><\/ul><\/div><h4>Code<a name=\"1ab56e17-ddc4-44f1-aae9-9be369b59538\"><\/a><\/h4><p>The <tt>pibar<\/tt> suite is <a href=\"https:\/\/blogs.mathworks.com\/cleve\/files\/pibar_suite.m\">available here<\/a>.  It is also included in <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/59085-cleve_lab\">version 5.3 of Cleve_Lab<\/a>, replacing last month's April 1 contribution.<\/p><p>Please let me know if you find anything useful to do with this.<\/p><script language=\"JavaScript\"> <!-- \r\n    function grabCode_16d368cce000415fb9da3d7eb42ad942() {\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='16d368cce000415fb9da3d7eb42ad942 ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' 16d368cce000415fb9da3d7eb42ad942';\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_16d368cce000415fb9da3d7eb42ad942()\"><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; R2019b<br><\/p><\/div><!--\r\n16d368cce000415fb9da3d7eb42ad942 ##### SOURCE BEGIN #####\r\n%%  Precise Setting of a Delicate Parameter with \"pibar\"\r\n% (A slight revision of the post I made a few hours ago.)\r\n%\r\n% We are still working on the Kuramoto model of self-synchronizing oscillators\r\n% that I made \r\n% <https:\/\/blogs.mathworks.com\/cleve\/2019\/10\/30\/stability-of-kuramoto-oscillators\/\r\n% blog posts> about last fall,  My colleagues and I expect to eventually\r\n% write a serious  paper.  In the meantime, let me tell you about an\r\n% unusual user interface control that I am using in our Kuramoto\r\n% experiments.\r\n%\r\n% <<new_pibar_gif.gif>>\r\n%\r\n%% pibar\r\n% For reasons that I need not get into right now, I want to make very\r\n% small changes in the usually constant value of |pi|.\r\n% This special slider does the job.  It varies |pi| between 3.1 and 3.2\r\n% in discrete steps, each step deleting or inserting one digit\r\n% in the decimal expansion of |pi|.\r\n\r\n%%\r\n% The slider starts in the center and |pi| returns its traditional\r\n% value.  With the default settings, if you move the slider to the left\r\n% from the center, you get \r\n%\r\n%    |pi| = 3.1415926535\r\n%\r\n%    |pi| = 3.141592653\r\n%\r\n%    |pi| = 3.14159265\r\n%\r\n%      . . . . \r\n%\r\n%    |pi| = 3.141\r\n%\r\n%    |pi| = 3.14\r\n% \r\n%    |pi| = 3.1\r\n%\r\n% It's easy to see what's happening in this direction because each step\r\n% just chops off one digit.\r\n\r\n%%\r\n% Starting in the center and moving right is a little trickier because\r\n% step rounds up.  The first three and last three steps are\r\n%\r\n%    |pi| = 3.1415926536\r\n%\r\n%    |pi| = 3.141592654\r\n%\r\n%    |pi| = 3.14159266\r\n%\r\n%      . . . . \r\n%\r\n%\r\n%    |pi| = 3.142\r\n%\r\n%    |pi| = 3.15\r\n% \r\n%    |pi| = 3.2\r\n\r\n%% pi and truepi\r\n% The |pibar| suite consists of three functions.\r\n%\r\n% * |pibar| sets up the tool.  You can center on any value you choose;\r\n% it doesn't have to be |pi|.  Another parameter sets the number of\r\n% digits.\r\n%\r\n% * |pi| returns the current value provided by the slider.\r\n%\r\n% * |truepi| always returns |4*atan(1)|, which is the double precision\r\n% floating point number nearest to $\\pi$.  This is the value we\r\n% get for |pi| when |pibar| is not messing with it.\r\n\r\n%% Code\r\n% The |pibar| suite is <https:\/\/blogs.mathworks.com\/cleve\/files\/pibar_suite.m\r\n% available here>.  It is also included in\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/59085-cleve_lab\r\n% version 5.3 of Cleve_Lab>, replacing last month's April 1 contribution.\r\n\r\n%%\r\n% Please let me know if you find anything useful to do with this.\r\n##### SOURCE END ##### 16d368cce000415fb9da3d7eb42ad942\r\n-->","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img src=\"https:\/\/blogs.mathworks.com\/cleve\/files\/new_pibar_gif.gif\" class=\"img-responsive attachment-post-thumbnail size-post-thumbnail wp-post-image\" alt=\"\" decoding=\"async\" loading=\"lazy\" \/><\/div><!--introduction--><p>(A slight revision of the post I made a few hours ago.)... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/cleve\/2020\/05\/03\/precise-setting-of-a-delicate-parameter-with-pibar\/\">read more >><\/a><\/p>","protected":false},"author":78,"featured_media":6217,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[5,7,37],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/posts\/6219"}],"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=6219"}],"version-history":[{"count":2,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/posts\/6219\/revisions"}],"predecessor-version":[{"id":6223,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/posts\/6219\/revisions\/6223"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/media\/6217"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/media?parent=6219"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/categories?post=6219"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/tags?post=6219"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}