{"id":510,"date":"2014-07-09T09:45:45","date_gmt":"2014-07-09T06:45:45","guid":{"rendered":"http:\/\/www.sjut.org\/math\/?p=510"},"modified":"2014-07-15T16:47:50","modified_gmt":"2014-07-15T13:47:50","slug":"mat210-2014-07-08","status":"publish","type":"post","link":"http:\/\/www.sjut.org\/math\/index.php\/mat210-2014-07-08\/","title":{"rendered":"MAT210 Workshop July 8 &#038; 9"},"content":{"rendered":"<p>In this workshop we will work on the solution to the <a title=\"MAT210 Interpolation Problem\" href=\"http:\/\/www.sjut.org\/math\/index.php\/mat210-2014-06-16\/\" target=\"_blank\">shortest path problem assigned a few weeks ago<\/a>.<\/p>\n<p>The purpose of the assignment was to demonstrate:<\/p>\n<ol>\n<li>That there are a variety of curves that could pass through <em>n<\/em> points and that it is important to have an <em>objective<\/em> in choosing the appropriate curve. In this case there are two objectives:\n<ol>\n<li>Smooth curves,\u00a0 so the robot is not subjected to jerking motion<\/li>\n<li>Shortest curve, so the robot can pass the points most efficiently<\/li>\n<\/ol>\n<\/li>\n<li>That working with splines requires handling a piecewise function. In this case the integration must be done piecewise.<\/li>\n<\/ol>\n<p>This problem involves interpolation and calculus, so a good tool is Maxima, which has the ability to do both Lagrangian Interpolation and Cubic Splines plus the ability to find the derivatives and do the necessary integration.<\/p>\n<p>Maxima is available for installation on a Windows PC as wxMaxima (<a title=\"wxMaxima Project Page\" href=\"http:\/\/sourceforge.net\/projects\/wxmaxima\/\" target=\"_blank\">download here<\/a>), but we will use the online version at <a title=\"Maxima Online\" href=\"http:\/\/www.maxima-online.org\" target=\"_blank\">http:\/\/www.maxima-online.org<\/a>. Click on that link to bring up the online Maxima calculator in a new window, then cut an paste the code below into the\u00a0<em><strong>Instructions to<\/strong><\/em><em><strong>Maxima<\/strong><\/em> box. Clicking on <em><strong>Calculate<\/strong><\/em> will then do all the work and reveal that splines, while more complicated, produce a shorter path for the robot. (What % reduction in the length is noted?)<\/p>\n<p>To complete the assignment, repeat the calculation with the following (x,y) data, then send an e-mail to math@sjut.org containing:<\/p>\n<ol>\n<li>Name &amp; Registration Number<\/li>\n<li>(x,y) data<\/li>\n<li>Brief comparison of the two path lengths and the shape of the curves &#8211; <em>remembering the objective<\/em>.<\/li>\n<li>The plot of the paths (either &#8220;Copy Image&#8221; and paste into the email or &#8220;Save Image As&#8221; and attach to the email).<\/li>\n<\/ol>\n<p><strong>(x,y) data<\/strong><\/p>\n<pre><code>\r\n[2,4],[4,5],[5,6],[6,3],[8,2],[10.6,5]\r\n<\/code><\/pre>\n<p><strong>Maxima script to calculate the lengths:<\/strong><\/p>\n<pre><code>\/* Enter the data *\/\r\nA:matrix([2,7.2],[4.5,7.1],[5.25,6],[7.81,5],[9.2,3.5],[10.6,5]);\r\nkmax:length(A)-1$\r\nx0:lmin(list_matrix_entries(submatrix(A,2)))$\r\nx1:lmax(list_matrix_entries(submatrix(A,2)))$\r\n\/* Nth order polynomial using Lagrangian interpolation *\/\r\nload(interpol)$\r\nf_nth: lagrange(A)$\r\ndf_nth: sqrt(1+(diff(f_nth,x)^2))$\r\nL_nth:romberg(df_nth,x,x0,x1);\r\n\/* Cubic spline interpolation *\/\r\n\/* Calculate the splines *\/\r\nf_cs:cspline(A)$\r\n\/* Pull out the cubic polynomial for each subinterval *\/\r\nh1[i,j]:=1$ \r\nL_splines:0$\r\nf_splines: matrix([0])$\r\nfor k:1 thru kmax do\r\n\u00a0\u00a0\u00a0 (\u00a0\u00a0 kill(h2,h3),\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 h2[i,j]:=A[k,1]+(i-1)\/3*(A[k+1,1]-A[k,1]), \r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 h3[i,j]:=ev(f_cs,x=C2[i,1]),\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 C1:genmatrix(h1,4,1), C2:genmatrix(h2,4,1), C3:C2^2, C4:C2^3,\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 C:addcol(C1,C2,C3,C4),\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 D:genmatrix(h3,4,1),\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 aCS:invert(C).D,\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 f_spline:matrix([1,x,x^2,x^3]).aCS,\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 f_splines:addrow(f_splines,[f_spline]),\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 df_spline:sqrt(1+(diff(f_spline,x))^2),\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 L_splines:L_splines+romberg(df_spline,x,A[k,1],A[k+1,1])\r\n\u00a0\u00a0\u00a0 )$\r\n\/* The result *\/\r\nf_splines:submatrix(1,f_splines);\r\nL_splines;\r\nL_nth;\r\nL_diff:(L_nth-L_splines)\/L_nth * 100;\r\nplot2d ([f_nth, f_cs], [x, x0, x1], [legend, \"Nth Order Polynomial\", \"Cubic Splines\"])$ \r\n\r\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>In this workshop we will work on the solution to the shortest path problem assigned a few weeks ago. The purpose of the assignment was to demonstrate: That there are [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[43],"tags":[35,54],"jetpack_featured_media_url":"","_links":{"self":[{"href":"http:\/\/www.sjut.org\/math\/index.php\/wp-json\/wp\/v2\/posts\/510"}],"collection":[{"href":"http:\/\/www.sjut.org\/math\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.sjut.org\/math\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.sjut.org\/math\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.sjut.org\/math\/index.php\/wp-json\/wp\/v2\/comments?post=510"}],"version-history":[{"count":10,"href":"http:\/\/www.sjut.org\/math\/index.php\/wp-json\/wp\/v2\/posts\/510\/revisions"}],"predecessor-version":[{"id":636,"href":"http:\/\/www.sjut.org\/math\/index.php\/wp-json\/wp\/v2\/posts\/510\/revisions\/636"}],"wp:attachment":[{"href":"http:\/\/www.sjut.org\/math\/index.php\/wp-json\/wp\/v2\/media?parent=510"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.sjut.org\/math\/index.php\/wp-json\/wp\/v2\/categories?post=510"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.sjut.org\/math\/index.php\/wp-json\/wp\/v2\/tags?post=510"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}