{"id":2091,"date":"2009-12-27T11:43:52","date_gmt":"2009-12-27T10:43:52","guid":{"rendered":"http:\/\/www.walkingrandomly.com\/?p=2091"},"modified":"2009-12-29T10:31:42","modified_gmt":"2009-12-29T09:31:42","slug":"walking-randomly-sage-bounty-hunt-1","status":"publish","type":"post","link":"https:\/\/walkingrandomly.com\/?p=2091","title":{"rendered":"Walking Randomly Sage bounty hunt #1"},"content":{"rendered":"<p>Regular readers of Walking Randomly will know that I am a big fan of the <a href=\"http:\/\/reference.wolfram.com\/mathematica\/ref\/Manipulate.html\">Manipulate<\/a> function in Mathematica.\u00a0 Manipulate allows you to easily create interactive mathematical demonstrations for teaching, research or just plain fun and is the basis of the incredibly popular <a href=\"http:\/\/demonstrations.wolfram.com\/\">Wolfram Demonstrations Project<\/a>.<\/p>\n<p><a href=\"http:\/\/www.sagemath.org\/\">Sage<\/a>, probably the best open source mathematics software available right now, has a similar function called <a href=\"http:\/\/wiki.sagemath.org\/interact\">interact<\/a> and I have been playing with it a bit recently (see <a href=\"https:\/\/www.walkingrandomly.com\/?p=2006\">here<\/a> and <a href=\"https:\/\/www.walkingrandomly.com\/?p=1879\">here<\/a>) along with <a href=\"http:\/\/sumidiot.wordpress.com\/2009\/12\/23\/the-steinhaus-conjecture\/\">some other math bloggers<\/a>.\u00a0 The Sage team have done a fantastic job with the interact function but it is missing a major piece of functionality in my humble opinion &#8211; a Locator control.<\/p>\n<p>In Mathematica the default control for Manipulate is a slider:<\/p>\n<pre>Manipulate[Plot[Sin[n x], {x, -Pi, Pi}], {n, 1, 10}]<\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/www.walkingrandomly.com\/images\/SAGE\/manipulate-sin.png\" alt=\"Manipulate Sine\" \/><\/p>\n<p>The slider is also the default control for Sage&#8217;s interact:<\/p>\n<pre>@interact\r\ndef _(n=(1,10)):\r\n    plt=plot(sin(n*x),(x,-pi,pi))\r\n    show(plt)<\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/www.walkingrandomly.com\/images\/SAGE\/sine-interact.png\" alt=\"Interact Sine\" \/><\/p>\n<p>Both systems allow the user to use other controls such as text boxes, checkboxes and dropdown menus but Mathematica has a control called a <a href=\"http:\/\/reference.wolfram.com\/mathematica\/ref\/Locator.html\">Locator<\/a> that Sage is missing.\u00a0 Locator controls allow you to directly interact with a plot or graphic.\u00a0 For example, the following Mathematica code (taken from its help system) draws a polygon and allows the user to click and drag the control points to change its shape.<\/p>\n<pre>Manipulate[Graphics[Polygon[pts], PlotRange -&gt; 1],\r\n {{pts, {{0, 0}, {.5, 0}, {0, .5}}}, Locator}]<\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/www.walkingrandomly.com\/images\/SAGE\/locator-1.png\" alt=\"Mathematica Locator Example\" \/><\/p>\n<p>The Locator control has several useful options that allow you to customise your demonstration even further.  For example, perhaps you want to allow the user to move the vertices of the polygon but you don&#8217;t want them to be able to actually see the control points.  No problem, just add <strong>Appearance -&gt; None<\/strong> to your code and you&#8217;ll get what you want.<\/p>\n<pre>Manipulate[Graphics[Polygon[pts], PlotRange -&gt; 1],\r\n {{pts, {{0, 0}, {.5, 0}, {0, .5}}}, Locator, Appearance -&gt; None}]<\/pre>\n<p>Another useful option is <strong>LocatorAutoCreate -&gt; True<\/strong> which allows the user to create extra control points by holding down CTRL and ALT (or just ALT &#8211; it depends on your system it seems) as they click in the active area.<\/p>\n<pre>Manipulate[Graphics[Polygon[pts], PlotRange -&gt; 1],\r\n {{pts, {{0, 0}, {.5, 0}, {0, .5}}}, Locator,\r\n  LocatorAutoCreate -&gt; True}]<\/pre>\n<p>When you add all of this functionality together you can do some very cool stuff with just a few lines of code.  Theodore Gray&#8217;s <a href=\"http:\/\/demonstrations.wolfram.com\/CurveFitting\/\">curve fitting code<\/a> on the Wolfram Demonstrations project is a perfect example.<\/p>\n<p>All of these features are demonstrated in the video below<\/p>\n<p><object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" width=\"425\" height=\"344\" codebase=\"http:\/\/download.macromedia.com\/pub\/shockwave\/cabs\/flash\/swflash.cab#version=6,0,40,0\"><param name=\"allowFullScreen\" value=\"true\" \/><param name=\"allowscriptaccess\" value=\"always\" \/><param name=\"src\" value=\"http:\/\/www.youtube.com\/v\/6wOLBVFdek8&amp;hl=en_GB&amp;fs=1&amp;rel=0\" \/><param name=\"allowfullscreen\" value=\"true\" \/><\/object><\/p>\n<p>So, onto the bounty hunt.\u00a0 I am offering 25 pounds worth (about 40 American Dollars) of books from Amazon to anyone who writes the code to implement a Locator control for Sage&#8217;s interact function.\u00a0 To get the prize your code must fulfil the following spec<\/p>\n<ul>\n<li>Your code must be accepted into the Sage codebase and become part of the standard install.\u00a0 This should ensure that it is of reasonable quality.<\/li>\n<li><span>There should be an option like Mathematica&#8217;s <\/span><strong>LocatorAutoCreate -&gt; True<\/strong> to allow the user to create new locator points interactively by Alt-clicking (or via some other suitable method).<\/li>\n<li><span>There should be an option to alter the appearance of the Locator control (e.g. equivalent to Mathematica&#8217;s <strong>Appearance -&gt; x<\/strong> option).\u00a0 As a minimum you should be able to do something like <strong>Appearance-&gt;None<\/strong><\/span><\/li>\n<li><span>You should provide demonstration code that implements everything shown in the video above.<\/span><\/li>\n<li><span>I have to be happy with it!<\/span><\/li>\n<\/ul>\n<p>And the details of the prize:<\/p>\n<ul>\n<li>I only have one prize &#8211; 25 pounds worth of books (about 40 American dollars) from Amazon.\u00a0 If more than one person claims it then the prize will be split.<\/li>\n<li>The 25 pounds includes whatever it will cost for postage and packing.<\/li>\n<li>I won&#8217;t send you the voucher &#8211; I will send you the books of your choice as a &#8216;gift&#8217;.\u00a0 This will mean that you&#8217;ll have to send me your postal address.  Don&#8217;t enter if this bothers you for some reason.<\/li>\n<li>I expect you to be sensible regarding the exact value of the prize.\u00a0 So if your books come to 24.50 then we&#8217;ll call it even.\u00a0 Similarly if they come to 25.50 then I won&#8217;t argue.<\/li>\n<li>I am not doing this on behalf of any organisation.\u00a0 It&#8217;s my personal money.<\/li>\n<li>My decision is final and I can withdraw this prize offer at any time without explanation.\u00a0 I hope you realise that I am just covering my back by saying this &#8211; I have every intention of giving the prize but whenever money is involved one always worries about the possibility of being ripped off.<\/li>\n<\/ul>\n<p>Good luck!<\/p>\n<p><strong>Update (29th December 2009):<\/strong> The bounty hunt has only been going for a few days and the bounty has already doubled to 50 pounds which is around 80 American dollars.\u00a0 Thanks to <a href=\"http:\/\/drj11.wordpress.com\/\">David Jones<\/a> for his generosity.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Regular readers of Walking Randomly will know that I am a big fan of the Manipulate function in Mathematica.\u00a0 Manipulate allows you to easily create interactive mathematical demonstrations for teaching, research or just plain fun and is the basis of the incredibly popular Wolfram Demonstrations Project. Sage, probably the best open source mathematics software available [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","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":[4,8,24,18],"tags":[],"class_list":["post-2091","post","type-post","status-publish","format-standard","hentry","category-math-software","category-mathematica","category-sage-interactions","category-wolfram-demonstrations"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p3swhs-xJ","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/posts\/2091","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=2091"}],"version-history":[{"count":25,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/posts\/2091\/revisions"}],"predecessor-version":[{"id":2123,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/posts\/2091\/revisions\/2123"}],"wp:attachment":[{"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2091"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2091"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2091"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}