Skip to content

Instantly share code, notes, and snippets.

@tomasaschan
Last active August 29, 2015 14:00
Show Gist options
  • Select an option

  • Save tomasaschan/11283326 to your computer and use it in GitHub Desktop.

Select an option

Save tomasaschan/11283326 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"metadata": {
"language": "Julia",
"name": "Cubic B-splines"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": "# Cubic B-splines in Julia\n\nAfter having worked on this for a few days, pouring over every text on the subject that I've been able to find and implementing at least a dozen solutions that didn't work, I think it's time to be a little more formal and seek peer review of my thought process.\n\nThe implementation below is entirely based on [these lecture notes][1] by [Dr Y. Sue Liu][2] at the University of Edinburgh.\n\n[1]: http://www.geos.ed.ac.uk/~yliu23/docs/lect_spline.pdf\n[2]: http://www.geos.ed.ac.uk/~yliu23/\n\n### Introduction\n\nThe function we're interpolating is $f(x) = \\frac{1}{1+x^2}\\sin(x)$, on the interval $x\\in[-4,4]$, on a uniformly spaced grid with spacing 1, i.e. with grid points $x_k = -4,-3,\\ldots,3,4$ for $k = 0,\\ldots,N$, and corresponding data values $f_k=f(x_k)$."
},
{
"cell_type": "code",
"collapsed": false,
"input": "using Gadfly\n\nf(x) = sin(-x)./(1.+x.^2)\nxk = Float64[-4:4]\nfk = f(xk)\nplot(layer(f,-4,4),layer(x=xk,y=fk,Geom.point))",
"language": "python",
"metadata": {},
"outputs": [
{
"html": "<div id=\"gadflyplot-xlzgPvVu90Xt2HPNJ0fZ\"></div>\n<script>\n(function (module) {\nfunction draw_with_data(data, parent_id) {\n var g = d3.select(parent_id)\n .append(\"svg\")\n .attr(\"width\", \"120mm\")\n .attr(\"height\", \"80mm\")\n .attr(\"viewBox\", \"0 0 120 80\")\n .attr(\"stroke-width\", \"0.5\")\n .attr(\"style\", \"stroke:black;fill:black\");\n g.append(\"defs\");\n var ctx = {\n \"scale\": 1.0,\n \"tx\": 0.0,\n \"ty\": 0.0\n };\n(function (g) {\n g.attr(\"stroke\", \"none\")\n .attr(\"fill\", \"#000000\")\n .attr(\"stroke-width\", 0.3)\n .attr(\"font-family\", \"Helvetic,Arial,sans\")\n .style(\"font-size\", \"3.88px\");\n (function (g) {\n g.attr(\"class\", \"plotroot xscalable yscalable\");\n (function (g) {\n g.attr(\"stroke\", \"none\")\n .attr(\"fill\", \"#4C404B\")\n .attr(\"font-family\", \"'PT Sans','Helvetica Neue','Helvetica',sans-serif\")\n .style(\"font-size\", \"3.18px\")\n .attr(\"class\", \"guide ylabels\");\n g.append(\"svg:text\")\n .attr(\"x\", 14.47)\n .attr(\"y\", 65.93)\n .attr(\"text-anchor\", \"end\")\n .style(\"dominant-baseline\", \"central\")\n .call(function(text) {\n text.text(\"-0.5\");\n })\n;\n (function (g) {\n g.attr(\"visibility\", \"hidden\");\n g.append(\"svg:text\")\n .attr(\"x\", 14.47)\n .attr(\"y\", -81.96)\n .attr(\"text-anchor\", \"end\")\n .style(\"dominant-baseline\", \"central\")\n .call(function(text) {\n text.text(\"2.0\");\n })\n;\n }(g.append(\"g\")));\n (function (g) {\n g.attr(\"visibility\", \"hidden\");\n g.append(\"svg:text\")\n .attr(\"x\", 14.47)\n .attr(\"y\", -52.38)\n .attr(\"text-anchor\", \"end\")\n .style(\"dominant-baseline\", \"central\")\n .call(function(text) {\n text.text(\"1.5\");\n })\n;\n }(g.append(\"g\")));\n (function (g) {\n g.attr(\"visibility\", \"hidden\");\n g.append(\"svg:text\")\n .attr(\"x\", 14.47)\n .attr(\"y\", 125.09)\n .attr(\"text-anchor\", \"end\")\n .style(\"dominant-baseline\", \"central\")\n .call(function(text) {\n text.text(\"-1.5\");\n })\n;\n }(g.append(\"g\")));\n g.append(\"svg:text\")\n .attr(\"x\", 14.47)\n .attr(\"y\", 6.77)\n .attr(\"text-anchor\", \"end\")\n .style(\"dominant-baseline\", \"central\")\n .call(function(text) {\n text.text(\"0.5\");\n })\n;\n (function (g) {\n g.attr(\"visibility\", \"hidden\");\n g.append(\"svg:text\")\n .attr(\"x\", 14.47)\n .attr(\"y\", 154.67)\n .attr(\"text-anchor\", \"end\")\n .style(\"dominant-baseline\", \"central\")\n .call(function(text) {\n text.text(\"-2.0\");\n })\n;\n }(g.append(\"g\")));\n (function (g) {\n g.attr(\"visibility\", \"hidden\");\n g.append(\"svg:text\")\n .attr(\"x\", 14.47)\n .attr(\"y\", -22.8)\n .attr(\"text-anchor\", \"end\")\n .style(\"dominant-baseline\", \"central\")\n .call(function(text) {\n text.text(\"1.0\");\n })\n;\n }(g.append(\"g\")));\n g.append(\"svg:text\")\n .attr(\"x\", 14.47)\n .attr(\"y\", 36.35)\n .attr(\"text-anchor\", \"end\")\n .style(\"dominant-baseline\", \"central\")\n .call(function(text) {\n text.text(\"0.0\");\n })\n;\n (function (g) {\n g.attr(\"visibility\", \"hidden\");\n g.append(\"svg:text\")\n .attr(\"x\", 14.47)\n .attr(\"y\", 95.51)\n .attr(\"text-anchor\", \"end\")\n .style(\"dominant-baseline\", \"central\")\n .call(function(text) {\n text.text(\"-1.0\");\n })\n;\n }(g.append(\"g\")));\n }(g.append(\"g\")));\n (function (g) {\n g.attr(\"stroke\", \"none\")\n .attr(\"fill\", \"#4C404B\")\n .attr(\"font-family\", \"'PT Sans','Helvetica Neue','Helvetica',sans-serif\")\n .style(\"font-size\", \"3.18px\")\n .attr(\"class\", \"guide xlabels\");\n g.append(\"svg:text\")\n .attr(\"x\", 88.71)\n .attr(\"y\", 74)\n .attr(\"text-anchor\", \"middle\")\n .call(function(text) {\n text.text(\"2\");\n })\n;\n g.append(\"svg:text\")\n .attr(\"x\", 18.28)\n .attr(\"y\", 74)\n .attr(\"text-anchor\", \"middle\")\n .call(function(text) {\n text.text(\"-4\");\n })\n;\n (function (g) {\n g.attr(\"visibility\", \"hidden\");\n g.append(\"svg:text\")\n .attr(\"x\", 182.61)\n .attr(\"y\", 74)\n .attr(\"text-anchor\", \"middle\")\n .call(function(text) {\n text.text(\"10\");\n })\n;\n }(g.append(\"g\")));\n g.append(\"svg:text\")\n .attr(\"x\", 41.76)\n .attr(\"y\", 74)\n .attr(\"text-anchor\", \"middle\")\n .call(function(text) {\n text.text(\"-2\");\n })\n;\n (function (g) {\n g.attr(\"visibility\", \"hidden\");\n g.append(\"svg:text\")\n .attr(\"x\", -5.19)\n .attr(\"y\", 74)\n .attr(\"text-anchor\", \"middle\")\n .call(function(text) {\n text.text(\"-6\");\n })\n;\n }(g.append(\"g\")));\n (function (g) {\n g.attr(\"visibility\", \"hidden\");\n g.append(\"svg:text\")\n .attr(\"x\", -52.14)\n .attr(\"y\", 74)\n .attr(\"text-anchor\", \"middle\")\n .call(function(text) {\n text.text(\"-10\");\n })\n;\n }(g.append(\"g\")));\n (function (g) {\n g.attr(\"visibility\", \"hidden\");\n g.append(\"svg:text\")\n .attr(\"x\", 229.56)\n .attr(\"y\", 74)\n .attr(\"text-anchor\", \"middle\")\n .call(function(text) {\n text.text(\"14\");\n })\n;\n }(g.append(\"g\")));\n g.append(\"svg:text\")\n .attr(\"x\", 112.18)\n .attr(\"y\", 74)\n .attr(\"text-anchor\", \"middle\")\n .call(function(text) {\n text.text(\"4\");\n })\n;\n (function (g) {\n g.attr(\"visibility\", \"hidden\");\n g.append(\"svg:text\")\n .attr(\"x\", 159.13)\n .attr(\"y\", 74)\n .attr(\"text-anchor\", \"middle\")\n .call(function(text) {\n text.text(\"8\");\n })\n;\n }(g.append(\"g\")));\n (function (g) {\n g.attr(\"visibility\", \"hidden\");\n g.append(\"svg:text\")\n .attr(\"x\", -99.09)\n .attr(\"y\", 74)\n .attr(\"text-anchor\", \"middle\")\n .call(function(text) {\n text.text(\"-14\");\n })\n;\n }(g.append(\"g\")));\n (function (g) {\n g.attr(\"visibility\", \"hidden\");\n g.append(\"svg:text\")\n .attr(\"x\", 135.66)\n .attr(\"y\", 74)\n .attr(\"text-anchor\", \"middle\")\n .call(function(text) {\n text.text(\"6\");\n })\n;\n }(g.append(\"g\")));\n g.append(\"svg:text\")\n .attr(\"x\", 65.23)\n .attr(\"y\", 74)\n .attr(\"text-anchor\", \"middle\")\n .call(function(text) {\n text.text(\"0\");\n })\n;\n (function (g) {\n g.attr(\"visibility\", \"hidden\");\n g.append(\"svg:text\")\n .attr(\"x\", -28.67)\n .attr(\"y\", 74)\n .attr(\"text-anchor\", \"middle\")\n .call(function(text) {\n text.text(\"-8\");\n })\n;\n }(g.append(\"g\")));\n (function (g) {\n g.attr(\"visibility\", \"hidden\");\n g.append(\"svg:text\")\n .attr(\"x\", 206.08)\n .attr(\"y\", 74)\n .attr(\"text-anchor\", \"middle\")\n .call(function(text) {\n text.text(\"12\");\n })\n;\n }(g.append(\"g\")));\n (function (g) {\n g.attr(\"visibility\", \"hidden\");\n g.append(\"svg:text\")\n .attr(\"x\", -75.62)\n .attr(\"y\", 74)\n .attr(\"text-anchor\", \"middle\")\n .call(function(text) {\n text.text(\"-12\");\n })\n;\n }(g.append(\"g\")));\n }(g.append(\"g\")));\n (function (g) {\n g.on(\"mouseover\", guide_background_mouseover(\"#C6C6C9\"))\n .on(\"mouseout\", guide_background_mouseout(\"#F0F0F3\"))\n .call(zoom_behavior(ctx))\n;\n (function (g) {\n d3.select(\"defs\")\n .append(\"svg:clipPath\")\n .attr(\"id\", parent_id + \"_clippath0\")\n .append(\"svg:path\")\n .attr(\"d\", \" M15.47,5 L 115 5 115 67.71 15.47 67.71 z\");g.attr(\"clip-path\", \"url(#\" + parent_id + \"_clippath0)\");\n (function (g) {\n g.attr(\"class\", \"guide background\")\n .attr(\"stroke\", \"#F1F1F5\")\n .attr(\"fill\", \"#FAFAFA\")\n .attr(\"opacity\", 1.00);\n g.append(\"svg:path\")\n .attr(\"d\", \"M15.47,5 L 115 5 115 67.71 15.47 67.71 z\");\n }(g.append(\"g\")));\n (function (g) {\n g.attr(\"stroke\", \"#F0F0F3\")\n .attr(\"stroke-width\", 0.2)\n .attr(\"class\", \"guide ygridlines xfixed\");\n g.append(\"svg:path\")\n .attr(\"d\", \"M15.47,-81.96 L 115 -81.96\");\n g.append(\"svg:path\")\n .attr(\"d\", \"M15.47,125.09 L 115 125.09\");\n g.append(\"svg:path\")\n .attr(\"d\", \"M15.47,154.67 L 115 154.67\");\n g.append(\"svg:path\")\n .attr(\"d\", \"M15.47,36.35 L 115 36.35\");\n g.append(\"svg:path\")\n .attr(\"d\", \"M15.47,95.51 L 115 95.51\");\n g.append(\"svg:path\")\n .attr(\"d\", \"M15.47,-22.8 L 115 -22.8\");\n g.append(\"svg:path\")\n .attr(\"d\", \"M15.47,6.77 L 115 6.77\");\n g.append(\"svg:path\")\n .attr(\"d\", \"M15.47,-52.38 L 115 -52.38\");\n g.append(\"svg:path\")\n .attr(\"d\", \"M15.47,65.93 L 115 65.93\");\n }(g.append(\"g\")));\n (function (g) {\n g.attr(\"stroke\", \"#F0F0F3\")\n .attr(\"stroke-width\", 0.2)\n .attr(\"class\", \"guide xgridlines yfixed\");\n g.append(\"svg:path\")\n .attr(\"d\", \"M18.28,5 L 18.28 67.71\");\n g.append(\"svg:path\")\n .attr(\"d\", \"M41.76,5 L 41.76 67.71\");\n g.append(\"svg:path\")\n .attr(\"d\", \"M-52.14,5 L -52.14 67.71\");\n g.append(\"svg:path\")\n .attr(\"d\", \"M112.18,5 L 112.18 67.71\");\n g.append(\"svg:path\")\n .attr(\"d\", \"M-99.09,5 L -99.09 67.71\");\n g.append(\"svg:path\")\n .attr(\"d\", \"M65.23,5 L 65.23 67.71\");\n g.append(\"svg:path\")\n .attr(\"d\", \"M206.08,5 L 206.08 67.71\");\n g.append(\"svg:path\")\n .attr(\"d\", \"M-75.62,5 L -75.62 67.71\");\n g.append(\"svg:path\")\n .attr(\"d\", \"M-28.67,5 L -28.67 67.71\");\n g.append(\"svg:path\")\n .attr(\"d\", \"M135.66,5 L 135.66 67.71\");\n g.append(\"svg:path\")\n .attr(\"d\", \"M159.13,5 L 159.13 67.71\");\n g.append(\"svg:path\")\n .attr(\"d\", \"M229.56,5 L 229.56 67.71\");\n g.append(\"svg:path\")\n .attr(\"d\", \"M-5.19,5 L -5.19 67.71\");\n g.append(\"svg:path\")\n .attr(\"d\", \"M182.61,5 L 182.61 67.71\");\n g.append(\"svg:path\")\n .attr(\"d\", \"M88.71,5 L 88.71 67.71\");\n }(g.append(\"g\")));\n }(g.append(\"g\")));\n (function (g) {\n d3.select(\"defs\")\n .append(\"svg:clipPath\")\n .attr(\"id\", parent_id + \"_clippath1\")\n .append(\"svg:path\")\n .attr(\"d\", \" M15.47,5 L 115 5 115 67.71 15.47 67.71 z\");g.attr(\"clip-path\", \"url(#\" + parent_id + \"_clippath1)\");\n (function (g) {\n g.attr(\"class\", \"plotpanel\");\n (function (g) {\n g.attr(\"stroke-width\", 0.3);\n (function (g) {\n g.attr(\"stroke-width\", 0.3);\ng.selectAll(\"form0\")\n .data(d3.zip(data[0],data[1]))\n .enter()\n .append(\"circle\")\n.attr(\"cx\", function(d) { return d[0]; })\n.attr(\"cy\", function(d) { return d[1]; })\n.attr(\"r\", 0.6)\n.attr(\"class\", \"geometry color_LCHab(70.0,60.0,240.0)\")\n.on(\"mouseout\", geom_point_mouseout(10.00, 0.50), false)\n.on(\"mouseover\", geom_point_mouseover(10.00, 0.50), false)\n.attr(\"stroke\", \"#0096DD\")\n.attr(\"fill\", \"#00BFFF\")\n;\n }(g.append(\"g\")));\n }(g.append(\"g\")));\n (function (g) {\n g.attr(\"fill\", \"none\")\n .attr(\"stroke-width\", 0.3);\n (function (g) {\n g.attr(\"stroke\", \"#00BFFF\")\n .attr(\"class\", \"geometry\");\n g.append(\"svg:path\")\n .attr(\"d\", \"M18.28,38.99 L 18.66 38.95 19.04 38.91 19.41 38.87 19.79 38.82 20.17 38.77 20.55 38.71 20.92 38.65 21.3 38.58 21.68 38.51 22.05 38.44 22.43 38.36 22.81 38.27 23.19 38.18 23.56 38.08 23.94 37.98 24.32 37.87 24.69 37.76 25.07 37.64 25.45 37.52 25.83 37.39 26.2 37.25 26.58 37.11 26.96 36.96 27.33 36.81 27.71 36.65 28.09 36.48 28.47 36.3 28.84 36.12 29.22 35.94 29.6 35.74 29.97 35.54 30.35 35.34 30.73 35.12 31.11 34.9 31.48 34.68 31.86 34.44 32.24 34.2 32.61 33.95 32.99 33.69 33.37 33.43 33.74 33.16 34.12 32.88 34.5 32.59 34.88 32.3 35.25 32 35.63 31.69 36.01 31.37 36.38 31.05 36.76 30.71 37.14 30.37 37.52 30.03 37.89 29.67 38.27 29.31 38.65 28.94 39.02 28.56 39.4 28.17 39.78 27.78 40.16 27.38 40.53 26.97 40.91 26.56 41.29 26.13 41.66 25.7 42.04 25.27 42.42 24.82 42.8 24.38 43.17 23.92 43.55 23.46 43.93 22.99 44.3 22.52 44.68 22.04 45.06 21.56 45.44 21.07 45.81 20.58 46.19 20.09 46.57 19.59 46.94 19.1 47.32 18.6 47.7 18.1 48.08 17.61 48.45 17.11 48.83 16.62 49.21 16.14 49.58 15.65 49.96 15.18 50.34 14.72 50.71 14.26 51.09 13.82 51.47 13.4 51.85 12.99 52.22 12.6 52.6 12.23 52.98 11.89 53.35 11.57 53.73 11.29 54.11 11.05 54.49 10.84 54.86 10.67 55.24 10.56 55.62 10.49 55.99 10.48 56.37 10.53 56.75 10.65 57.13 10.84 57.5 11.1 57.88 11.45 58.26 11.87 58.63 12.39 59.01 13 59.39 13.71 59.77 14.52 60.14 15.43 60.52 16.44 60.9 17.56 61.27 18.77 61.65 20.09 62.03 21.51 62.41 23.01 62.78 24.6 63.16 26.27 63.54 28.01 63.91 29.8 64.29 31.64 64.67 33.51 65.04 35.4 65.42 37.3 65.8 39.2 66.18 41.07 66.55 42.91 66.93 44.7 67.31 46.44 67.68 48.11 68.06 49.7 68.44 51.2 68.82 52.62 69.19 53.93 69.57 55.15 69.95 56.27 70.32 57.28 70.7 58.19 71.08 59 71.46 59.7 71.83 60.32 72.21 60.83 72.59 61.26 72.96 61.61 73.34 61.87 73.72 62.06 74.1 62.18 74.47 62.23 74.85 62.22 75.23 62.15 75.6 62.04 75.98 61.87 76.36 61.66 76.74 61.42 77.11 61.13 77.49 60.82 77.87 60.48 78.24 60.11 78.62 59.72 79 59.31 79.37 58.89 79.75 58.45 80.13 57.99 80.51 57.53 80.88 57.05 81.26 56.57 81.64 56.09 82.01 55.6 82.39 55.1 82.77 54.6 83.15 54.11 83.52 53.61 83.9 53.11 84.28 52.62 84.65 52.13 85.03 51.64 85.41 51.15 85.79 50.67 86.16 50.19 86.54 49.72 86.92 49.25 87.29 48.79 87.67 48.33 88.05 47.88 88.43 47.44 88.8 47 89.18 46.57 89.56 46.15 89.93 45.74 90.31 45.33 90.69 44.93 91.07 44.53 91.44 44.15 91.82 43.77 92.2 43.4 92.57 43.04 92.95 42.68 93.33 42.33 93.7 41.99 94.08 41.66 94.46 41.34 94.84 41.02 95.21 40.71 95.59 40.41 95.97 40.12 96.34 39.83 96.72 39.55 97.1 39.28 97.48 39.02 97.85 38.76 98.23 38.51 98.61 38.27 98.98 38.03 99.36 37.8 99.74 37.58 100.12 37.37 100.49 37.16 100.87 36.96 101.25 36.77 101.62 36.58 102 36.4 102.38 36.23 102.76 36.06 103.13 35.9 103.51 35.75 103.89 35.6 104.26 35.46 104.64 35.32 105.02 35.19 105.4 35.07 105.77 34.95 106.15 34.84 106.53 34.73 106.9 34.63 107.28 34.53 107.66 34.44 108.03 34.35 108.41 34.27 108.79 34.2 109.17 34.12 109.54 34.06 109.92 34 110.3 33.94 110.67 33.89 111.05 33.84 111.43 33.8 111.81 33.76 112.18 33.72\");\n }(g.append(\"g\")));\n }(g.append(\"g\")));\n }(g.append(\"g\")));\n }(g.append(\"g\")));\n (function (g) {\n d3.select(\"defs\")\n .append(\"svg:clipPath\")\n .attr(\"id\", parent_id + \"_clippath2\")\n .append(\"svg:path\")\n .attr(\"d\", \" M15.47,5 L 115 5 115 67.71 15.47 67.71 z\");g.attr(\"clip-path\", \"url(#\" + parent_id + \"_clippath2)\");\n (function (g) {\n g.attr(\"stroke\", \"none\")\n .attr(\"class\", \"guide zoomslider\")\n .attr(\"opacity\", 0.00);\n (function (g) {\n g.attr(\"stroke\", \"#6A6A6A\")\n .attr(\"stroke-opacity\", 0.00)\n .attr(\"stroke-width\", 0.3)\n .attr(\"fill\", \"#EAEAEA\")\n .on(\"click\", zoomin_behavior(ctx))\n.on(\"dblclick\", function() { d3.event.stopPropagation(); })\n.on(\"mouseover\", zoomslider_button_mouseover(\"#cd5c5c\"))\n.on(\"mouseout\", zoomslider_button_mouseover(\"#6a6a6a\"))\n;\n g.append(\"svg:path\")\n .attr(\"d\", \"M108,8 L 112 8 112 12 108 12 z\");\n (function (g) {\n g.attr(\"fill\", \"#6A6A6A\")\n .attr(\"class\", \"button_logo\");\n g.append(\"svg:path\")\n .attr(\"d\", \"M108.8,9.6 L 109.6 9.6 109.6 8.8 110.4 8.8 110.4 9.6 111.2 9.6 111.2 10.4 110.4 10.4 110.4 11.2 109.6 11.2 109.6 10.4 108.8 10.4 z\");\n }(g.append(\"g\")));\n }(g.append(\"g\")));\n (function (g) {\n g.attr(\"fill\", \"#EAEAEA\")\n .on(\"click\", zoomslider_track_behavior(ctx, 82, 99));\n g.append(\"svg:path\")\n .attr(\"d\", \"M88.5,8 L 107.5 8 107.5 12 88.5 12 z\");\n }(g.append(\"g\")));\n (function (g) {\n g.attr(\"fill\", \"#6A6A6A\")\n .attr(\"class\", \"zoomslider_thumb\")\n .call(zoomslider_behavior(ctx, 82, 99))\n.on(\"mouseover\", zoomslider_thumb_mouseover(\"#cd5c5c\"))\n.on(\"mouseout\", zoomslider_thumb_mouseover(\"#6a6a6a\"))\n;\n g.append(\"svg:path\")\n .attr(\"d\", \"M97,8 L 99 8 99 12 97 12 z\");\n }(g.append(\"g\")));\n (function (g) {\n g.attr(\"stroke\", \"#6A6A6A\")\n .attr(\"stroke-opacity\", 0.00)\n .attr(\"stroke-width\", 0.3)\n .attr(\"fill\", \"#EAEAEA\")\n .on(\"click\", zoomout_behavior(ctx))\n.on(\"dblclick\", function() { d3.event.stopPropagation(); })\n.on(\"mouseover\", zoomslider_button_mouseover(\"#cd5c5c\"))\n.on(\"mouseout\", zoomslider_button_mouseover(\"#6a6a6a\"))\n;\n g.append(\"svg:path\")\n .attr(\"d\", \"M84,8 L 88 8 88 12 84 12 z\");\n (function (g) {\n g.attr(\"fill\", \"#6A6A6A\")\n .attr(\"class\", \"button_logo\");\n g.append(\"svg:path\")\n .attr(\"d\", \"M84.8,9.6 L 87.2 9.6 87.2 10.4 84.8 10.4 z\");\n }(g.append(\"g\")));\n }(g.append(\"g\")));\n }(g.append(\"g\")));\n }(g.append(\"g\")));\n }(g.append(\"g\")));\n }(g.append(\"g\")));\n}(g.append(\"g\")));\n d3.select(parent_id)\n .selectAll(\"path\")\n .each(function() {\n var sw = parseFloat(window.getComputedStyle(this).getPropertyValue(\"stroke-width\"));\n d3.select(this)\n .attr(\"vector-effect\", \"non-scaling-stroke\")\n .style(\"stroke-width\", sw + \"mm\");\n });\n}\n\nvar data = [\n [18.283647798742138,30.021069182389937,41.758490566037736,53.495911949685535,65.23333333333333,76.97075471698113,88.70817610062893,100.44559748427673,112.18301886792453],\n [38.98778615297455,35.51931756238169,25.595576828831362,11.463957701731836,36.35416666666667,61.2443756316015,47.112756504501974,37.189015770951656,33.72054718035879]];\n\nvar draw = function(parent_id) {\n draw_with_data(data, parent_id);\n};\n\nif ('undefined' !== typeof module) {\n module.exports = draw;\n} else if ('undefined' !== typeof window) {\n window.draw = draw\n}\n\nreturn module;\n})({}).exports(\"#gadflyplot-xlzgPvVu90Xt2HPNJ0fZ\");\n//@ sourceURL=gadflyplot-xlzgPvVu90Xt2HPNJ0fZ.js\n</script>\n",
"metadata": {},
"output_type": "display_data",
"text": "D3(120.0,80.0,IOBuffer(Uint8[0x66,0x75,0x6e,0x63,0x74,0x69,0x6f,0x6e,0x20,0x64 \u2026 0x20,0x3d,0x20,0x64,0x72,0x61,0x77,0x0a,0x7d,0x0a],true,true,true,false,18775,9223372036854775807,18776),0,String[],Bool[],1,3,[0xc5ec6942ec940b17=>([18.2836,30.0211,41.7585,53.4959,65.2333,76.9708,88.7082,100.446,112.183],0),0xaf5e7ed0bf788cc3=>([38.9878,35.5193,25.5956,11.464,36.3542,61.2444,47.1128,37.189,33.7205],1)],true,false,nothing,true)"
},
{
"html": "",
"metadata": {},
"output_type": "pyout",
"prompt_number": 5,
"text": "Plot(...)"
}
],
"prompt_number": 5
},
{
"cell_type": "markdown",
"metadata": {},
"source": "As described by Dr. Liu (eqn 3.8) the cubic B-splines are given by the following expression\n\n$$ B_0(x) =\\begin{cases}\n0 & x - x_0\\le -2 \\\\\n\\frac{1}{6} (2+(x-x_0))^3 & -2 \\le x-x_0 \\le -1 \\\\\n\\frac{2}{3} - \\frac{1}{2}(x-x_0)^2(2+(x-x_0)) & -1\\le x-x_0\\le 0 \\\\\n\\frac{2}{3} - \\frac{1}{2}(x-x_0)^2(2-(x-x_0)) & 0 \\le x-x_0\\le 1 \\\\\n\\frac{1}{6} (2-(x-x_0))^3 & 1 \\le x-x_0 \\le 2 \\\\\n0 & 2\\le x-x_0\n\\end{cases}$$\n\nwhere, in the context of this example, $x_0=-4$, while in Grid.jl we will have $x_0=1$. Liu also defines the translated spline\n\n$$B_k(x) = B_0(x-k+x_0)$$\n\ncorresponding to $B_0(x)$ shifted to the right by $k$ nodes. We now define the interpolating polynomial as a linear combination of translated base splines, i.e.\n\n$$S(x) = \\sum_{k=-1}^{N+1} a_k B_k(x)$$\n\nwhere the start and end of the sum is decided by what translations of the base spline that will be nonzero on our domain. (In principle, we could have summed from $-\\infty$ to $\\infty$, but these will be the only nonzero terms.)\n\n### Setting up the equation system\n\nRequiring that this polynomial is truly interpolating, we find\n\n$$S(x_k) = a_{k-1}B_{k-1}(x_k) + a_{k}B_{k}(x_k) + a_{k+1}B_{k+1}(x_k) + a_{k+2}B_{k+2}(x_k) = f_k$$\n\nUsing the translation relation and the definition of the base splines, one finds that\n\n$$ \\frac{1}{6} (a_{k-1}+4a_k+a_{k+1}) = f_k$$\n\nBy specifying the boundary condition $S''(x) = 0$ at both edges, one can also obtain four more equations:\n\n$$a_{-1} -2a_0 + a_1 = 0\\\\\na_0 = f_0\\\\\na_N = f_N\\\\\na_{N-1}-2a_N + a_{N+1} = 0$$\n\nand together they make up the following equation system\n\n$$\\begin{pmatrix}\n1 & -2 & 1 \\\\\n & 1 \\\\\n & 1 & 4 & 1 \\\\\n & & 1 & 4 & 1 \\\\\n & & & \\ddots & \\ddots & \\ddots \\\\\n & & & & 1 & 4 & 1 \\\\\n & & & & & 1 & 4 \\\\\n & & & & & & 1 \\\\\n & & & & & 1 & -2 & 1\n\\end{pmatrix} \n\\begin{pmatrix}a_{-1} \\\\ a_0 \\\\ \\ldots \\\\ \\\\\\\\\\\\\\\\\\\\ a_N \\\\ a_{N+1}\\end{pmatrix} \n= \n\\begin{pmatrix}0 \\\\ f_0 \\\\ 6*f_1 \\\\ 6*f_2 \\\\\\\\\\\\\\\\\\\\ f_N \\\\ f_{N+1}\\end{pmatrix} \n$$"
},
{
"cell_type": "code",
"collapsed": false,
"input": "# The system matrix consists of a 9x9 matrix for coefficients a0-a8 (located at -4,-3,...,-4) as given by eqn (3.21)\n# wrapped by a top and a bottom row for the boundary conditions, as given by eqn (3.19)\ndu = ones(Float64,10)\ndu[1:2] = [2 0]\ndu[end] = 0\ndl = copy(flipud(du))\nd = fill(convert(Float64,4),11)\nd[1:2] = d[end-1:end] = 1\nA = diagm(d) + diagm(du,1) + diagm(dl,-1)\nA[1,3] = A[end,end-2] = 1;\n\n# The right hand side of the system\nb = vcat(0., f(-4), 6.*f(Float64[-3:3]), f(4), 0.)\n\nA # Uncomment this row to see the full system matrix\n#A[2:end-1,2:end-1] # Uncomment this row to see the system matrix as in eqn (3.21) of Liu's notes",
"language": "python",
"metadata": {},
"outputs": [
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 21,
"text": "11x11 Array{Float64,2}:\n 1.0 2.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0\n 0.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0\n 0.0 1.0 4.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0\n 0.0 0.0 1.0 4.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0\n 0.0 0.0 0.0 1.0 4.0 1.0 0.0 0.0 0.0 0.0 0.0\n 0.0 0.0 0.0 0.0 1.0 4.0 1.0 0.0 0.0 0.0 0.0\n 0.0 0.0 0.0 0.0 0.0 1.0 4.0 1.0 0.0 0.0 0.0\n 0.0 0.0 0.0 0.0 0.0 0.0 1.0 4.0 1.0 0.0 0.0\n 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 4.0 1.0 0.0\n 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 0.0\n 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 2.0 1.0"
}
],
"prompt_number": 21
},
{
"cell_type": "markdown",
"metadata": {},
"source": "We solve this system for the spline coefficients."
},
{
"cell_type": "code",
"collapsed": false,
"input": "# Solving for the spline coefficients\nak = A\\b\nak'",
"language": "python",
"metadata": {},
"outputs": [
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 22,
"text": "1x11 Array{Float64,2}:\n 0.0872922 -0.0445178 0.00174343 \u2026 -0.00174343 0.0445178 -0.0872922"
}
],
"prompt_number": 22
},
{
"cell_type": "markdown",
"metadata": {},
"source": "##Wait, what?\n\nOn page 7 in Liu's notes the values one should obtain by solving this system are tabulated. These aren't even close! For example, the second element from the left above, corresopnding to $a_0$, should be equal to $f(-4)$"
},
{
"cell_type": "code",
"collapsed": false,
"input": "f(-4)",
"language": "python",
"metadata": {},
"outputs": [
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 23,
"text": "-0.04451779384164284"
}
],
"prompt_number": 23
},
{
"cell_type": "markdown",
"metadata": {},
"source": "OK, so given the same function with the same input, we get a different result compared to Liu. Yes, I tried working with degrees instead of radians too - that gave us this:"
},
{
"cell_type": "code",
"collapsed": false,
"input": "f2(x) = sind(x) / (1+x^2)\nf2(-4)",
"language": "python",
"metadata": {},
"outputs": [
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 27,
"text": "-0.004103321984948547"
}
],
"prompt_number": 27
},
{
"cell_type": "markdown",
"metadata": {},
"source": "Still not the same as in the notes, not by a long shoSomething has gone awry already, but I have no idea what. Oh well, let's continue anyway. Just to see if we can get somewhere.\n\nWe start by defining the base spline function and the translated splines, and then express the interpolating polynomial through the `spline` function, which simply calculates the linear combination above."
},
{
"cell_type": "code",
"collapsed": false,
"input": "x0 = -4\nfunction base_spline_0(x) # Eqn (3.20)\n Dx = x-x0\n if Dx < -2 return 0 end\n if Dx < -1 return (2+Dx)^3/6 end\n if Dx < 0 return 2/3 - Dx^2*(2+Dx)/2 end\n if Dx < 1 return 2/3 + Dx^2*(2-Dx)/2 end\n if Dx < 2 return (2-Dx)^3/6 end\n return 0\nend\nbase_spline_k(x,k) = base_spline_0(x+x0-k)\n\nfunction spline(x)\n k = ifloor(x)\n sum([ak[k+2]*base_spline_k(x,k) for k = -1:9])\nend;",
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 25
},
{
"cell_type": "markdown",
"metadata": {},
"source": "Finally, we plot the resulting spline together with the original values:"
},
{
"cell_type": "code",
"collapsed": false,
"input": "plot(layer(spline,-4,4),layer(f,-4,4))",
"language": "python",
"metadata": {},
"outputs": [
{
"html": "<div id=\"gadflyplot-oXxwVR2au5g215gZpuxz\"></div>\n<script>\n(function (module) {\nfunction draw_with_data(data, parent_id) {\n var g = d3.select(parent_id)\n .append(\"svg\")\n .attr(\"width\", \"120mm\")\n .attr(\"height\", \"80mm\")\n .attr(\"viewBox\", \"0 0 120 80\")\n .attr(\"stroke-width\", \"0.5\")\n .attr(\"style\", \"stroke:black;fill:black\");\n g.append(\"defs\");\n var ctx = {\n \"scale\": 1.0,\n \"tx\": 0.0,\n \"ty\": 0.0\n };\n(function (g) {\n g.attr(\"stroke\", \"none\")\n .attr(\"fill\", \"#000000\")\n .attr(\"stroke-width\", 0.3)\n .attr(\"font-family\", \"Helvetic,Arial,sans\")\n .style(\"font-size\", \"3.88px\");\n (function (g) {\n g.attr(\"class\", \"plotroot xscalable yscalable\");\n (function (g) {\n g.attr(\"stroke\", \"none\")\n .attr(\"fill\", \"#4C404B\")\n .attr(\"font-family\", \"'PT Sans','Helvetica Neue','Helvetica',sans-serif\")\n .style(\"font-size\", \"3.18px\")\n .attr(\"class\", \"guide ylabels\");\n (function (g) {\n g.attr(\"visibility\", \"hidden\");\n g.append(\"svg:text\")\n .attr(\"x\", 14.47)\n .attr(\"y\", -52.38)\n .attr(\"text-anchor\", \"end\")\n .style(\"dominant-baseline\", \"central\")\n .call(function(text) {\n text.text(\"2.5\");\n })\n;\n }(g.append(\"g\")));\n (function (g) {\n g.attr(\"visibility\", \"hidden\");\n g.append(\"svg:text\")\n .attr(\"x\", 14.47)\n .attr(\"y\", 105.37)\n .attr(\"text-anchor\", \"end\")\n .style(\"dominant-baseline\", \"central\")\n .call(function(text) {\n text.text(\"-1.5\");\n })\n;\n }(g.append(\"g\")));\n (function (g) {\n g.attr(\"visibility\", \"hidden\");\n g.append(\"svg:text\")\n .attr(\"x\", 14.47)\n .attr(\"y\", 144.81)\n .attr(\"text-anchor\", \"end\")\n .style(\"dominant-baseline\", \"central\")\n .call(function(text) {\n text.text(\"-2.5\");\n })\n;\n }(g.append(\"g\")));\n g.append(\"svg:text\")\n .attr(\"x\", 14.47)\n .attr(\"y\", 6.77)\n .attr(\"text-anchor\", \"end\")\n .style(\"dominant-baseline\", \"central\")\n .call(function(text) {\n text.text(\"1.0\");\n })\n;\n (function (g) {\n g.attr(\"visibility\", \"hidden\");\n g.append(\"svg:text\")\n .attr(\"x\", 14.47)\n .attr(\"y\", -32.66)\n .attr(\"text-anchor\", \"end\")\n .style(\"dominant-baseline\", \"central\")\n .call(function(text) {\n text.text(\"2.0\");\n })\n;\n }(g.append(\"g\")));\n (function (g) {\n g.attr(\"visibility\", \"hidden\");\n g.append(\"svg:text\")\n .attr(\"x\", 14.47)\n .attr(\"y\", -12.94)\n .attr(\"text-anchor\", \"end\")\n .style(\"dominant-baseline\", \"central\")\n .call(function(text) {\n text.text(\"1.5\");\n })\n;\n }(g.append(\"g\")));\n g.append(\"svg:text\")\n .attr(\"x\", 14.47)\n .attr(\"y\", 26.49)\n .attr(\"text-anchor\", \"end\")\n .style(\"dominant-baseline\", \"central\")\n .call(function(text) {\n text.text(\"0.5\");\n })\n;\n (function (g) {\n g.attr(\"visibility\", \"hidden\");\n g.append(\"svg:text\")\n .attr(\"x\", 14.47)\n .attr(\"y\", 125.09)\n .attr(\"text-anchor\", \"end\")\n .style(\"dominant-baseline\", \"central\")\n .call(function(text) {\n text.text(\"-2.0\");\n })\n;\n }(g.append(\"g\")));\n (function (g) {\n g.attr(\"visibility\", \"hidden\");\n g.append(\"svg:text\")\n .attr(\"x\", 14.47)\n .attr(\"y\", -72.1)\n .attr(\"text-anchor\", \"end\")\n .style(\"dominant-baseline\", \"central\")\n .call(function(text) {\n text.text(\"3.0\");\n })\n;\n }(g.append(\"g\")));\n g.append(\"svg:text\")\n .attr(\"x\", 14.47)\n .attr(\"y\", 65.93)\n .attr(\"text-anchor\", \"end\")\n .style(\"dominant-baseline\", \"central\")\n .call(function(text) {\n text.text(\"-0.5\");\n })\n;\n g.append(\"svg:text\")\n .attr(\"x\", 14.47)\n .attr(\"y\", 46.21)\n .attr(\"text-anchor\", \"end\")\n .style(\"dominant-baseline\", \"central\")\n .call(function(text) {\n text.text(\"0.0\");\n })\n;\n (function (g) {\n g.attr(\"visibility\", \"hidden\");\n g.append(\"svg:text\")\n .attr(\"x\", 14.47)\n .attr(\"y\", 85.65)\n .attr(\"text-anchor\", \"end\")\n .style(\"dominant-baseline\", \"central\")\n .call(function(text) {\n text.text(\"-1.0\");\n })\n;\n }(g.append(\"g\")));\n }(g.append(\"g\")));\n (function (g) {\n g.attr(\"stroke\", \"none\")\n .attr(\"fill\", \"#4C404B\")\n .attr(\"font-family\", \"'PT Sans','Helvetica Neue','Helvetica',sans-serif\")\n .style(\"font-size\", \"3.18px\")\n .attr(\"class\", \"guide xlabels\");\n g.append(\"svg:text\")\n .attr(\"x\", 88.71)\n .attr(\"y\", 74)\n .attr(\"text-anchor\", \"middle\")\n .call(function(text) {\n text.text(\"2\");\n })\n;\n g.append(\"svg:text\")\n .attr(\"x\", 18.28)\n .attr(\"y\", 74)\n .attr(\"text-anchor\", \"middle\")\n .call(function(text) {\n text.text(\"-4\");\n })\n;\n (function (g) {\n g.attr(\"visibility\", \"hidden\");\n g.append(\"svg:text\")\n .attr(\"x\", 182.61)\n .attr(\"y\", 74)\n .attr(\"text-anchor\", \"middle\")\n .call(function(text) {\n text.text(\"10\");\n })\n;\n }(g.append(\"g\")));\n g.append(\"svg:text\")\n .attr(\"x\", 41.76)\n .attr(\"y\", 74)\n .attr(\"text-anchor\", \"middle\")\n .call(function(text) {\n text.text(\"-2\");\n })\n;\n (function (g) {\n g.attr(\"visibility\", \"hidden\");\n g.append(\"svg:text\")\n .attr(\"x\", -5.19)\n .attr(\"y\", 74)\n .attr(\"text-anchor\", \"middle\")\n .call(function(text) {\n text.text(\"-6\");\n })\n;\n }(g.append(\"g\")));\n (function (g) {\n g.attr(\"visibility\", \"hidden\");\n g.append(\"svg:text\")\n .attr(\"x\", -52.14)\n .attr(\"y\", 74)\n .attr(\"text-anchor\", \"middle\")\n .call(function(text) {\n text.text(\"-10\");\n })\n;\n }(g.append(\"g\")));\n (function (g) {\n g.attr(\"visibility\", \"hidden\");\n g.append(\"svg:text\")\n .attr(\"x\", 229.56)\n .attr(\"y\", 74)\n .attr(\"text-anchor\", \"middle\")\n .call(function(text) {\n text.text(\"14\");\n })\n;\n }(g.append(\"g\")));\n g.append(\"svg:text\")\n .attr(\"x\", 112.18)\n .attr(\"y\", 74)\n .attr(\"text-anchor\", \"middle\")\n .call(function(text) {\n text.text(\"4\");\n })\n;\n (function (g) {\n g.attr(\"visibility\", \"hidden\");\n g.append(\"svg:text\")\n .attr(\"x\", 159.13)\n .attr(\"y\", 74)\n .attr(\"text-anchor\", \"middle\")\n .call(function(text) {\n text.text(\"8\");\n })\n;\n }(g.append(\"g\")));\n (function (g) {\n g.attr(\"visibility\", \"hidden\");\n g.append(\"svg:text\")\n .attr(\"x\", -99.09)\n .attr(\"y\", 74)\n .attr(\"text-anchor\", \"middle\")\n .call(function(text) {\n text.text(\"-14\");\n })\n;\n }(g.append(\"g\")));\n (function (g) {\n g.attr(\"visibility\", \"hidden\");\n g.append(\"svg:text\")\n .attr(\"x\", 135.66)\n .attr(\"y\", 74)\n .attr(\"text-anchor\", \"middle\")\n .call(function(text) {\n text.text(\"6\");\n })\n;\n }(g.append(\"g\")));\n g.append(\"svg:text\")\n .attr(\"x\", 65.23)\n .attr(\"y\", 74)\n .attr(\"text-anchor\", \"middle\")\n .call(function(text) {\n text.text(\"0\");\n })\n;\n (function (g) {\n g.attr(\"visibility\", \"hidden\");\n g.append(\"svg:text\")\n .attr(\"x\", -28.67)\n .attr(\"y\", 74)\n .attr(\"text-anchor\", \"middle\")\n .call(function(text) {\n text.text(\"-8\");\n })\n;\n }(g.append(\"g\")));\n (function (g) {\n g.attr(\"visibility\", \"hidden\");\n g.append(\"svg:text\")\n .attr(\"x\", 206.08)\n .attr(\"y\", 74)\n .attr(\"text-anchor\", \"middle\")\n .call(function(text) {\n text.text(\"12\");\n })\n;\n }(g.append(\"g\")));\n (function (g) {\n g.attr(\"visibility\", \"hidden\");\n g.append(\"svg:text\")\n .attr(\"x\", -75.62)\n .attr(\"y\", 74)\n .attr(\"text-anchor\", \"middle\")\n .call(function(text) {\n text.text(\"-12\");\n })\n;\n }(g.append(\"g\")));\n }(g.append(\"g\")));\n (function (g) {\n g.on(\"mouseover\", guide_background_mouseover(\"#C6C6C9\"))\n .on(\"mouseout\", guide_background_mouseout(\"#F0F0F3\"))\n .call(zoom_behavior(ctx))\n;\n (function (g) {\n d3.select(\"defs\")\n .append(\"svg:clipPath\")\n .attr(\"id\", parent_id + \"_clippath0\")\n .append(\"svg:path\")\n .attr(\"d\", \" M15.47,5 L 115 5 115 67.71 15.47 67.71 z\");g.attr(\"clip-path\", \"url(#\" + parent_id + \"_clippath0)\");\n (function (g) {\n g.attr(\"class\", \"guide background\")\n .attr(\"stroke\", \"#F1F1F5\")\n .attr(\"fill\", \"#FAFAFA\")\n .attr(\"opacity\", 1.00);\n g.append(\"svg:path\")\n .attr(\"d\", \"M15.47,5 L 115 5 115 67.71 15.47 67.71 z\");\n }(g.append(\"g\")));\n (function (g) {\n g.attr(\"stroke\", \"#F0F0F3\")\n .attr(\"stroke-width\", 0.2)\n .attr(\"class\", \"guide ygridlines xfixed\");\n g.append(\"svg:path\")\n .attr(\"d\", \"M15.47,105.37 L 115 105.37\");\n g.append(\"svg:path\")\n .attr(\"d\", \"M15.47,6.77 L 115 6.77\");\n g.append(\"svg:path\")\n .attr(\"d\", \"M15.47,-12.94 L 115 -12.94\");\n g.append(\"svg:path\")\n .attr(\"d\", \"M15.47,125.09 L 115 125.09\");\n g.append(\"svg:path\")\n .attr(\"d\", \"M15.47,65.93 L 115 65.93\");\n g.append(\"svg:path\")\n .attr(\"d\", \"M15.47,85.65 L 115 85.65\");\n g.append(\"svg:path\")\n .attr(\"d\", \"M15.47,46.21 L 115 46.21\");\n g.append(\"svg:path\")\n .attr(\"d\", \"M15.47,-72.1 L 115 -72.1\");\n g.append(\"svg:path\")\n .attr(\"d\", \"M15.47,26.49 L 115 26.49\");\n g.append(\"svg:path\")\n .attr(\"d\", \"M15.47,-32.66 L 115 -32.66\");\n g.append(\"svg:path\")\n .attr(\"d\", \"M15.47,144.81 L 115 144.81\");\n g.append(\"svg:path\")\n .attr(\"d\", \"M15.47,-52.38 L 115 -52.38\");\n }(g.append(\"g\")));\n (function (g) {\n g.attr(\"stroke\", \"#F0F0F3\")\n .attr(\"stroke-width\", 0.2)\n .attr(\"class\", \"guide xgridlines yfixed\");\n g.append(\"svg:path\")\n .attr(\"d\", \"M18.28,5 L 18.28 67.71\");\n g.append(\"svg:path\")\n .attr(\"d\", \"M41.76,5 L 41.76 67.71\");\n g.append(\"svg:path\")\n .attr(\"d\", \"M-52.14,5 L -52.14 67.71\");\n g.append(\"svg:path\")\n .attr(\"d\", \"M112.18,5 L 112.18 67.71\");\n g.append(\"svg:path\")\n .attr(\"d\", \"M-99.09,5 L -99.09 67.71\");\n g.append(\"svg:path\")\n .attr(\"d\", \"M65.23,5 L 65.23 67.71\");\n g.append(\"svg:path\")\n .attr(\"d\", \"M206.08,5 L 206.08 67.71\");\n g.append(\"svg:path\")\n .attr(\"d\", \"M-75.62,5 L -75.62 67.71\");\n g.append(\"svg:path\")\n .attr(\"d\", \"M-28.67,5 L -28.67 67.71\");\n g.append(\"svg:path\")\n .attr(\"d\", \"M135.66,5 L 135.66 67.71\");\n g.append(\"svg:path\")\n .attr(\"d\", \"M159.13,5 L 159.13 67.71\");\n g.append(\"svg:path\")\n .attr(\"d\", \"M229.56,5 L 229.56 67.71\");\n g.append(\"svg:path\")\n .attr(\"d\", \"M-5.19,5 L -5.19 67.71\");\n g.append(\"svg:path\")\n .attr(\"d\", \"M182.61,5 L 182.61 67.71\");\n g.append(\"svg:path\")\n .attr(\"d\", \"M88.71,5 L 88.71 67.71\");\n }(g.append(\"g\")));\n }(g.append(\"g\")));\n (function (g) {\n d3.select(\"defs\")\n .append(\"svg:clipPath\")\n .attr(\"id\", parent_id + \"_clippath1\")\n .append(\"svg:path\")\n .attr(\"d\", \" M15.47,5 L 115 5 115 67.71 15.47 67.71 z\");g.attr(\"clip-path\", \"url(#\" + parent_id + \"_clippath1)\");\n (function (g) {\n g.attr(\"class\", \"plotpanel\");\n (function (g) {\n g.attr(\"fill\", \"none\")\n .attr(\"stroke-width\", 0.3);\n (function (g) {\n g.attr(\"stroke\", \"#00BFFF\")\n .attr(\"class\", \"geometry\");\n g.append(\"svg:path\")\n .attr(\"d\", \"M18.28,47.97 L 18.66 47.95 19.04 47.92 19.41 47.89 19.79 47.86 20.17 47.82 20.55 47.79 20.92 47.74 21.3 47.7 21.68 47.65 22.05 47.6 22.43 47.55 22.81 47.49 23.19 47.43 23.56 47.37 23.94 47.3 24.32 47.23 24.69 47.15 25.07 47.07 25.45 46.99 25.83 46.9 26.2 46.81 26.58 46.72 26.96 46.62 27.33 46.52 27.71 46.41 28.09 46.3 28.47 46.18 28.84 46.06 29.22 45.94 29.6 45.81 29.97 45.67 30.35 45.54 30.73 45.39 31.11 45.25 31.48 45.1 31.86 44.94 32.24 44.78 32.61 44.61 32.99 44.44 33.37 44.26 33.74 44.08 34.12 43.9 34.5 43.71 34.88 43.51 35.25 43.31 35.63 43.1 36.01 42.89 36.38 42.68 36.76 42.45 37.14 42.23 37.52 42 37.89 41.76 38.27 41.52 38.65 41.27 39.02 41.02 39.4 40.76 39.78 40.5 40.16 40.23 40.53 39.96 40.91 39.68 41.29 39.4 41.66 39.11 42.04 38.82 42.42 38.53 42.8 38.23 43.17 37.92 43.55 37.62 43.93 37.3 44.3 36.99 44.68 36.67 45.06 36.35 45.44 36.03 45.81 35.7 46.19 35.37 46.57 35.04 46.94 34.71 47.32 34.38 47.7 34.05 48.08 33.72 48.45 33.39 48.83 33.06 49.21 32.73 49.58 32.41 49.96 32.1 50.34 31.79 50.71 31.49 51.09 31.19 51.47 30.91 51.85 30.64 52.22 30.38 52.6 30.13 52.98 29.9 53.35 29.69 53.73 29.51 54.11 29.34 54.49 29.2 54.86 29.09 55.24 29.01 55.62 28.97 55.99 28.96 56.37 29 56.75 29.08 57.13 29.2 57.5 29.38 57.88 29.61 58.26 29.89 58.63 30.24 59.01 30.65 59.39 31.12 59.77 31.66 60.14 32.26 60.52 32.94 60.9 33.68 61.27 34.49 61.65 35.37 62.03 36.32 62.41 37.32 62.78 38.38 63.16 39.49 63.54 40.65 63.91 41.84 64.29 43.07 64.67 44.32 65.04 45.58 65.42 46.85 65.8 48.11 66.18 49.36 66.55 50.58 66.93 51.78 67.31 52.94 67.68 54.05 68.06 55.11 68.44 56.11 68.82 57.06 69.19 57.93 69.57 58.75 69.95 59.49 70.32 60.16 70.7 60.77 71.08 61.31 71.46 61.78 71.83 62.19 72.21 62.53 72.59 62.82 72.96 63.05 73.34 63.22 73.72 63.35 74.1 63.43 74.47 63.46 74.85 63.46 75.23 63.41 75.6 63.33 75.98 63.23 76.36 63.09 76.74 62.92 77.11 62.73 77.49 62.53 77.87 62.3 78.24 62.05 78.62 61.79 79 61.52 79.37 61.24 79.75 60.94 80.13 60.64 80.51 60.33 80.88 60.01 81.26 59.69 81.64 59.37 82.01 59.04 82.39 58.71 82.77 58.38 83.15 58.05 83.52 57.72 83.9 57.39 84.28 57.06 84.65 56.73 85.03 56.4 85.41 56.08 85.79 55.76 86.16 55.44 86.54 55.12 86.92 54.81 87.29 54.5 87.67 54.2 88.05 53.9 88.43 53.6 88.8 53.31 89.18 53.03 89.56 52.75 89.93 52.47 90.31 52.2 90.69 51.93 91.07 51.67 91.44 51.41 91.82 51.16 92.2 50.91 92.57 50.67 92.95 50.43 93.33 50.2 93.7 49.97 94.08 49.75 94.46 49.54 94.84 49.32 95.21 49.12 95.59 48.92 95.97 48.72 96.34 48.53 96.72 48.35 97.1 48.16 97.48 47.99 97.85 47.82 98.23 47.65 98.61 47.49 98.98 47.33 99.36 47.18 99.74 47.03 100.12 46.89 100.49 46.75 100.87 46.62 101.25 46.49 101.62 46.37 102 46.25 102.38 46.13 102.76 46.02 103.13 45.91 103.51 45.81 103.89 45.71 104.26 45.62 104.64 45.53 105.02 45.44 105.4 45.36 105.77 45.28 106.15 45.2 106.53 45.13 106.9 45.06 107.28 45 107.66 44.94 108.03 44.88 108.41 44.83 108.79 44.77 109.17 44.73 109.54 44.68 109.92 44.64 110.3 44.6 110.67 44.57 111.05 44.54 111.43 44.51 111.81 44.48 112.18 44.46\");\n }(g.append(\"g\")));\n }(g.append(\"g\")));\n (function (g) {\n g.attr(\"fill\", \"none\")\n .attr(\"stroke-width\", 0.3);\n (function (g) {\n g.attr(\"stroke\", \"#00BFFF\")\n .attr(\"class\", \"geometry\");\n g.append(\"svg:path\")\n .attr(\"d\", \"M18.28,46.21 L 18.66 46.21 19.04 46.21 19.41 46.21 19.79 46.21 20.17 46.21 20.55 46.21 20.92 46.21 21.3 46.21 21.68 46.21 22.05 46.21 22.43 46.21 22.81 46.21 23.19 46.21 23.56 46.21 23.94 46.21 24.32 46.21 24.69 46.21 25.07 46.21 25.45 46.21 25.83 46.21 26.2 46.21 26.58 46.21 26.96 46.21 27.33 46.21 27.71 46.21 28.09 46.21 28.47 46.21 28.84 46.21 29.22 46.21 29.6 46.21 29.97 46.21 30.35 46.21 30.73 46.21 31.11 46.21 31.48 46.21 31.86 46.21 32.24 46.21 32.61 46.21 32.99 46.2 33.37 46.2 33.74 46.2 34.12 46.19 34.5 46.18 34.88 46.17 35.25 46.16 35.63 46.15 36.01 46.14 36.38 46.12 36.76 46.11 37.14 46.09 37.52 46.06 37.89 46.04 38.27 46.01 38.65 45.99 39.02 45.95 39.4 45.92 39.78 45.88 40.16 45.84 40.53 45.8 40.91 45.76 41.29 45.71 41.66 45.65 42.04 45.6 42.42 45.54 42.8 45.48 43.17 45.41 43.55 45.34 43.93 45.28 44.3 45.21 44.68 45.14 45.06 45.06 45.44 44.99 45.81 44.92 46.19 44.85 46.57 44.78 46.94 44.72 47.32 44.65 47.7 44.59 48.08 44.53 48.45 44.47 48.83 44.42 49.21 44.37 49.58 44.32 49.96 44.28 50.34 44.25 50.71 44.22 51.09 44.2 51.47 44.18 51.85 44.17 52.22 44.16 52.6 44.17 52.98 44.18 53.35 44.2 53.73 44.23 54.11 44.25 54.49 44.27 54.86 44.28 55.24 44.29 55.62 44.29 55.99 44.29 56.37 44.28 56.75 44.28 57.13 44.26 57.5 44.25 57.88 44.22 58.26 44.2 58.63 44.17 59.01 44.14 59.39 44.11 59.77 44.08 60.14 44.04 60.52 44 60.9 43.95 61.27 43.91 61.65 43.86 62.03 43.81 62.41 43.76 62.78 43.71 63.16 43.66 63.54 43.61 63.91 43.55 64.29 43.5 64.67 43.44 65.04 43.38 65.42 46.83 65.8 46.88 66.18 46.93 66.55 46.99 66.93 47.04 67.31 47.09 67.68 47.14 68.06 47.19 68.44 47.24 68.82 47.28 69.19 47.33 69.57 47.37 69.95 47.41 70.32 47.44 70.7 47.48 71.08 47.51 71.46 47.53 71.83 47.56 72.21 47.58 72.59 47.59 72.96 47.6 73.34 47.61 73.72 47.61 74.1 47.61 74.47 47.6 74.85 47.59 75.23 47.57 75.6 47.55 75.98 47.52 76.36 47.48 76.74 47.44 77.11 45.62 77.49 45.51 77.87 45.4 78.24 45.28 78.62 45.16 79 45.03 79.37 44.9 79.75 44.76 80.13 44.62 80.51 44.47 80.88 44.32 81.26 44.15 81.64 43.98 82.01 43.81 82.39 43.62 82.77 43.43 83.15 43.22 83.52 43.01 83.9 42.79 84.28 42.56 84.65 42.32 85.03 42.06 85.41 41.8 85.79 41.52 86.16 41.24 86.54 40.94 86.92 40.63 87.29 40.31 87.67 39.97 88.05 39.62 88.43 39.25 88.8 38.95 89.18 38.54 89.56 38.11 89.93 37.64 90.31 37.15 90.69 36.64 91.07 36.11 91.44 35.57 91.82 35 92.2 34.43 92.57 33.85 92.95 33.27 93.33 32.68 93.7 32.09 94.08 31.5 94.46 30.93 94.84 30.36 95.21 29.8 95.59 29.25 95.97 28.73 96.34 28.22 96.72 27.74 97.1 27.28 97.48 26.85 97.85 26.45 98.23 26.09 98.61 25.76 98.98 25.48 99.36 25.23 99.74 25.04 100.12 24.89 100.49 29.63 100.87 29.67 101.25 29.67 101.62 29.62 102 29.52 102.38 29.38 102.76 29.21 103.13 29 103.51 28.77 103.89 28.5 104.26 28.21 104.64 27.91 105.02 27.58 105.4 27.24 105.77 26.89 106.15 26.53 106.53 26.17 106.9 25.81 107.28 25.45 107.66 25.1 108.03 24.75 108.41 24.42 108.79 24.11 109.17 23.81 109.54 23.54 109.92 23.29 110.3 23.07 110.67 22.88 111.05 22.73 111.43 22.62 111.81 22.55 112.18 22.53\");\n }(g.append(\"g\")));\n }(g.append(\"g\")));\n }(g.append(\"g\")));\n }(g.append(\"g\")));\n (function (g) {\n d3.select(\"defs\")\n .append(\"svg:clipPath\")\n .attr(\"id\", parent_id + \"_clippath2\")\n .append(\"svg:path\")\n .attr(\"d\", \" M15.47,5 L 115 5 115 67.71 15.47 67.71 z\");g.attr(\"clip-path\", \"url(#\" + parent_id + \"_clippath2)\");\n (function (g) {\n g.attr(\"stroke\", \"none\")\n .attr(\"class\", \"guide zoomslider\")\n .attr(\"opacity\", 0.00);\n (function (g) {\n g.attr(\"stroke\", \"#6A6A6A\")\n .attr(\"stroke-opacity\", 0.00)\n .attr(\"stroke-width\", 0.3)\n .attr(\"fill\", \"#EAEAEA\")\n .on(\"click\", zoomin_behavior(ctx))\n.on(\"dblclick\", function() { d3.event.stopPropagation(); })\n.on(\"mouseover\", zoomslider_button_mouseover(\"#cd5c5c\"))\n.on(\"mouseout\", zoomslider_button_mouseover(\"#6a6a6a\"))\n;\n g.append(\"svg:path\")\n .attr(\"d\", \"M108,8 L 112 8 112 12 108 12 z\");\n (function (g) {\n g.attr(\"fill\", \"#6A6A6A\")\n .attr(\"class\", \"button_logo\");\n g.append(\"svg:path\")\n .attr(\"d\", \"M108.8,9.6 L 109.6 9.6 109.6 8.8 110.4 8.8 110.4 9.6 111.2 9.6 111.2 10.4 110.4 10.4 110.4 11.2 109.6 11.2 109.6 10.4 108.8 10.4 z\");\n }(g.append(\"g\")));\n }(g.append(\"g\")));\n (function (g) {\n g.attr(\"fill\", \"#EAEAEA\")\n .on(\"click\", zoomslider_track_behavior(ctx, 82, 99));\n g.append(\"svg:path\")\n .attr(\"d\", \"M88.5,8 L 107.5 8 107.5 12 88.5 12 z\");\n }(g.append(\"g\")));\n (function (g) {\n g.attr(\"fill\", \"#6A6A6A\")\n .attr(\"class\", \"zoomslider_thumb\")\n .call(zoomslider_behavior(ctx, 82, 99))\n.on(\"mouseover\", zoomslider_thumb_mouseover(\"#cd5c5c\"))\n.on(\"mouseout\", zoomslider_thumb_mouseover(\"#6a6a6a\"))\n;\n g.append(\"svg:path\")\n .attr(\"d\", \"M97,8 L 99 8 99 12 97 12 z\");\n }(g.append(\"g\")));\n (function (g) {\n g.attr(\"stroke\", \"#6A6A6A\")\n .attr(\"stroke-opacity\", 0.00)\n .attr(\"stroke-width\", 0.3)\n .attr(\"fill\", \"#EAEAEA\")\n .on(\"click\", zoomout_behavior(ctx))\n.on(\"dblclick\", function() { d3.event.stopPropagation(); })\n.on(\"mouseover\", zoomslider_button_mouseover(\"#cd5c5c\"))\n.on(\"mouseout\", zoomslider_button_mouseover(\"#6a6a6a\"))\n;\n g.append(\"svg:path\")\n .attr(\"d\", \"M84,8 L 88 8 88 12 84 12 z\");\n (function (g) {\n g.attr(\"fill\", \"#6A6A6A\")\n .attr(\"class\", \"button_logo\");\n g.append(\"svg:path\")\n .attr(\"d\", \"M84.8,9.6 L 87.2 9.6 87.2 10.4 84.8 10.4 z\");\n }(g.append(\"g\")));\n }(g.append(\"g\")));\n }(g.append(\"g\")));\n }(g.append(\"g\")));\n }(g.append(\"g\")));\n }(g.append(\"g\")));\n}(g.append(\"g\")));\n d3.select(parent_id)\n .selectAll(\"path\")\n .each(function() {\n var sw = parseFloat(window.getComputedStyle(this).getPropertyValue(\"stroke-width\"));\n d3.select(this)\n .attr(\"vector-effect\", \"non-scaling-stroke\")\n .style(\"stroke-width\", sw + \"mm\");\n });\n}\n\nvar data = [\n];\n\nvar draw = function(parent_id) {\n draw_with_data(data, parent_id);\n};\n\nif ('undefined' !== typeof module) {\n module.exports = draw;\n} else if ('undefined' !== typeof window) {\n window.draw = draw\n}\n\nreturn module;\n})({}).exports(\"#gadflyplot-oXxwVR2au5g215gZpuxz\");\n//@ sourceURL=gadflyplot-oXxwVR2au5g215gZpuxz.js\n</script>\n",
"metadata": {},
"output_type": "display_data",
"text": "D3(120.0,80.0,IOBuffer(Uint8[0x66,0x75,0x6e,0x63,0x74,0x69,0x6f,0x6e,0x20,0x64 \u2026 0x20,0x3d,0x20,0x64,0x72,0x61,0x77,0x0a,0x7d,0x0a],true,true,true,false,22259,9223372036854775807,22260),0,String[],Bool[],0,3,Dict{Uint64,(Any,Int64)}(),true,false,nothing,true)"
},
{
"html": "",
"metadata": {},
"output_type": "pyout",
"prompt_number": 26,
"text": "Plot(...)"
}
],
"prompt_number": 26
},
{
"cell_type": "markdown",
"metadata": {},
"source": "Obviously, something went wrong. That's not an interpolation.\n\n###Things I've ruled out (I think)\n\n* The system matrix looks correct to me\n* The right-hand side does too. However, the function values don't seem to match up with the paper. "
}
],
"metadata": {}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment