{"worksheets": [{"cells": [{"source": ["# Finite Differences"], "cell_type": "markdown", "metadata": {}}, {"outputs": [], "metadata": {}, "prompt_number": 1, "collapsed": false, "cell_type": "code", "input": ["import numpy as np\n", "import numpy.linalg as la\n", "import matplotlib.pyplot as pt"], "language": "python"}, {"outputs": [{"output_type": "pyout", "metadata": {}, "prompt_number": 29, "text": ["array([-0.125, 0. , 0.125])"]}], "metadata": {}, "prompt_number": 29, "collapsed": false, "cell_type": "code", "input": ["degree = 2\n", "h = 0.25\n", "\n", "# Assume even degree so that there's a well-defined middle node.\n", "assert degree % 2 == 0\n", "\n", "nodes = np.linspace(-h/2, h/2, degree+1)\n", "nodes"], "language": "python"}, {"source": ["Now construct `V` (the generalized Vandermonde) and `Vprime` (the generalized Vandermonde for the derivatives):"], "cell_type": "markdown", "metadata": {}}, {"outputs": [], "metadata": {}, "prompt_number": 30, "collapsed": false, "cell_type": "code", "input": ["V = np.array([\n", " nodes**i\n", " for i in range(degree+1)\n", "]).T"], "language": "python"}, {"outputs": [], "metadata": {}, "prompt_number": 31, "collapsed": false, "cell_type": "code", "input": ["def monomial_deriv(i, x):\n", " if i == 0:\n", " return 0*x\n", " else:\n", " return i*nodes**(i-1)\n", "\n", "Vprime = np.array([\n", " monomial_deriv(i, nodes)\n", " for i in range(degree+1)\n", "]).T"], "language": "python"}, {"source": ["Combine them to form the derivative matrix:"], "cell_type": "markdown", "metadata": {}}, {"outputs": [], "metadata": {}, "prompt_number": 32, "collapsed": false, "cell_type": "code", "input": ["diff_mat = Vprime.dot(la.inv(V))"], "language": "python"}, {"source": ["Let's say we only care about the derivative at the middle node:"], "cell_type": "markdown", "metadata": {}}, {"outputs": [{"output_type": "pyout", "metadata": {}, "prompt_number": 33, "text": ["array([-4., 0., 4.])"]}], "metadata": {}, "prompt_number": 33, "collapsed": false, "cell_type": "code", "input": ["finite_difference_weights = diff_mat[degree//2]\n", "finite_difference_weights"], "language": "python"}, {"source": ["* What have we learned?\n", "* What formula does this amount to?\n", "* How do these weights scale with $h$?\n", "* What formula does this amount to, really?\n", "* What happens if we change the degree?\n", "* What happens if we shift all nodes?\n", "* What happens if we shift only one of the nodes?\n", "* How do we apply this formula?"], "cell_type": "markdown", "metadata": {}}, {"outputs": [], "metadata": {}, "prompt_number": 36, "collapsed": false, "cell_type": "code", "input": ["# * We could have left the middle point out. :)\n", "# * -4*f(x-0.25) + 4*f(x+0.25)\n", "# * They scale with 1/h, as you might expect.\n", "# * (f(x-h/2) + f(x+h/2))/h\n", "# * We get a more complicated (but more accurate) formula.\n", "# * Nothing.\n", "# * We get a different formula (that's valid for those nodes).\n", "# * See below."], "language": "python"}, {"outputs": [], "metadata": {}, "prompt_number": 55, "collapsed": false, "cell_type": "code", "input": ["def f(x):\n", " return np.sin(4*x)\n", "def df(x):\n", " return 4*np.cos(4*x)"], "language": "python"}, {"outputs": [{"output_type": "pyout", "metadata": {}, "prompt_number": 56, "text": ["[]"]}, {"png": "iVBORw0KGgoAAAANSUhEUgAAAX4AAAEACAYAAAC08h1NAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xl4lNX5//H3nQSDfN0VcYGKBPVr1SIuyKIYWwlBWsGK\nC7WKKyiauNUVFaqlvaxWgaBiwQVXrDvfhkJSNVdcEIoogsBPiVjRCioKFSWRhPP74wQEzDKZmcyZ\n5fO6rlwmk4eZz2PgnpP7Oc855pxDREQyR1boACIiklgq/CIiGUaFX0Qkw6jwi4hkGBV+EZEMo8Iv\nIpJhYi78Zvagma0ys4VNHDPBzD4wswVm1j3W1xQRkejFY8T/EFDY2DfN7CSgq3PuAGA4cF8cXlNE\nRKIUc+F3zr0KfN3EIScDU+uPnQPsYmYdYn1dERGJTiJ6/PsCK7b4+hOgYwJeV0REGpCoi7u2zdda\nJ0JEJJCcBLzGp0CnLb7uWP/YVsxMbwYiIlFwzm07uG5SIkb804FzAMysJ7DGObeqoQOdc2n7MXr0\n6OAZIvnYuNFRXu7o08fR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vyg8Frn3FfBQreAmT0JHA/sUX9j6Wh8\nay7laws0f360sLboBi4RkQyjPXdFRDKMCr+ISIZR4RcRyTAq/CIiGUaFX0Qkw6jwi4hkGBV+EZEM\no8IvIpJh/j8JPyQj3YJqFQAAAABJRU5ErkJggg==\n", "output_type": "display_data", "metadata": {}, "text": [""]}], "metadata": {}, "prompt_number": 56, "collapsed": false, "cell_type": "code", "input": ["x = np.arange(10) * 0.125\n", "pt.plot(x, f(x), \"o-\")"], "language": "python"}, {"source": ["Now use the weights to compute the finite difference derivative as `deriv`:"], "cell_type": "markdown", "metadata": {}}, {"outputs": [], "metadata": {}, "prompt_number": 57, "collapsed": false, "cell_type": "code", "input": ["fdw = finite_difference_weights\n", "\n", "fx = f(x)\n", "deriv = np.zeros(len(x)-2)\n", "for i in range(1, 1+len(deriv)):\n", " deriv[i-1] = fx[i-1]*fdw[0] + fx[i]*fdw[1] + fx[i+1]*fdw[2]"], "language": "python"}, {"source": ["Now plot the finite difference derivative:"], "cell_type": "markdown", "metadata": {}}, {"outputs": [{"output_type": "pyout", "metadata": {}, "prompt_number": 59, "text": [""]}, {"png": "iVBORw0KGgoAAAANSUhEUgAAAXUAAAEACAYAAABMEua6AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xd8jef/x/HXlWGGoAhqxLdqlFolatVBSeydqNYepWar\nQ9dXtFpV/SJ+rb2irdojCFHjxKhdSqu0RszWFjsyrt8fdxAEkXNO7pOTz/PxyMM5Obf7fjuJT65c\n9zWU1hohhBCuwc3sAEIIIexHiroQQrgQKepCCOFCpKgLIYQLkaIuhBAuRIq6EEK4ELsUdaWUu1Jq\nt1JqmT3OJ4QQInXs1VIfCOwHZNC7EEKYyOairpQqDDQGpgLK5kRCCCFSzR4t9THAe0CCHc4lhBDC\nBjYVdaVUU+Cs1no30koXQgjTKVvWflFKfQl0BOKALEBOYKHWulOSY6SfXQghUkFr/dSNZZta6lrr\nj7TWRb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WusLJmZ6CZiTuBxEXqCRUipWax3moEwpypW0AGitVyqlxiul8mjHzZdIyXt1Ajivtb4J3FRK\nbQAqAI4q6k/zPdUex3e9QMoy1QC+ANBaH06c61IK2GlWpsTvp253nidmOuKgPCn1YO47Ez0fzU6d\n/R7AYYybEJl4zM0ajBskaXGj9ImZgKIYN09ednSep8j0HPeGmlYGDpud6YHjZwCtneS98knyXvkB\nUU6QqTSwBuPGXDaMFt8LZn/9AG+Mm5FZneRrNxoYmuTreBLIY3ImbyBT4uOewExHv1eJ1/IlZTdK\nXyYFN0rt0lLXWscppfoBEYnfzNO01n8qpd5MfH2SUqoAsAPjpkiCUmpg4jf7NXtkSE0m4L9AbmBC\nYis0Vmvt54g8T5GpDdBJKRULXMNoXTlMCjOluRTmagv0UUrFYSxZYfp7pbU+oJRaBewFEoApWuv9\nZmZKPLQlEKGN3yAcKoWZvgRmKKV+w7i397524Iz0FGZ6AZipjKVNfse4z+ZQSqmfgDpAXqXUCWAo\nRhfene+ncKVUY6XUIeA60PWJ50z8CSCEEMIFuNgGUEIIkbFJURdCCBciRV0IIVyIFHUhhHAhUtSF\nEMKFSFEXQggXIkVdCCFciBR1IYRwIf8PZPBR4vbIOkAAAAAASUVORK5CYII=\n", "output_type": "display_data", "metadata": {}, "text": [""]}], "metadata": {}, "prompt_number": 59, "collapsed": false, "cell_type": "code", "input": ["pt.plot(x[1:-1], df(x[1:-1]), label=\"true\")\n", "pt.plot(x[1:-1], deriv, label=\"FD\")\n", "pt.legend()"], "language": "python"}], "metadata": {}}], "nbformat": 3, "metadata": {"name": "", "signature": "sha256:d17a40d08383110f7ef54b48ede9d81fab54e0235a5fe14e78371d33583081a2"}, "nbformat_minor": 0}