{ "metadata": { "name": "trapezoid_rule_solution" }, "nbformat": 2, "worksheets": [ { "cells": [ { "cell_type": "markdown", "source": [ "Basic numerical integration: the trapezoid rule", "===============================================", "", "**Illustrates**: basic array slicing, functions as first class objects.", "", "In this exercise, you are tasked with implementing the simple trapezoid rule", "formula for numerical integration. If we want to compute the definite integral", "", "$$", " \\int_{a}^{b}f(x)dx", "$$", "", "we can partition the integration interval $[a,b]$ into smaller subintervals,", "and approximate the area under the curve for each subinterval by the area of", "the trapezoid created by linearly interpolating between the two function values", "at each end of the subinterval:", "", "", "", "The blue line represents the function $f(x)$ and the red line", "is the linear interpolation. By subdividing the interval $[a,b]$, the area under $f(x)$ can thus be approximated as the sum of the areas of all", "the resulting trapezoids. ", "", "If we denote by $x_{i}$ ($i=0,\\ldots,n,$ with $x_{0}=a$ and", "$x_{n}=b$) the abscissas where the function is sampled, then", "", "$$", " \\int_{a}^{b}f(x)dx\\approx\\frac{1}{2}\\sum_{i=1}^{n}\\left(x_{i}-x_{i-1}\\right)\\left(f(x_{i})+f(x_{i-1})\\right).", "$$", "", "The common case of using equally spaced abscissas with spacing $h=(b-a)/n$ reads simply", "", "$$", " \\int_{a}^{b}f(x)dx\\approx\\frac{h}{2}\\sum_{i=1}^{n}\\left(f(x_{i})+f(x_{i-1})\\right).", "$$", "", "One frequently receives the function values already precomputed, $y_{i}=f(x_{i}),$", "so the equation above becomes", "", "$$", " \\int_{a}^{b}f(x)dx\\approx\\frac{1}{2}\\sum_{i=1}^{n}\\left(x_{i}-x_{i-1}\\right)\\left(y_{i}+y_{i-1}\\right).", "$$" ] }, { "cell_type": "markdown", "source": [ "## Exercises", "", "### 1", "", "Write a function trapz(x, y), that applies the trapezoid formula to pre-computed values, ", "where x and y are 1-d arrays." ] }, { "cell_type": "code", "collapsed": true, "input": [ "def trapz(x, y):", " return 0.5*np.sum((x[1:]-x[:-1])*(y[1:]+y[:-1]))" ], "language": "python", "outputs": [], "prompt_number": 9 }, { "cell_type": "markdown", "source": [ "### 2 ", "", "Write a function trapzf(f, a, b, npts=100) that accepts a function f, the endpoints a", "and b and the number of samples to take npts. Sample the function uniformly at these", "points and return the value of the integral." ] }, { "cell_type": "code", "collapsed": true, "input": [ "def trapzf(f, a, b, npts=100):", " x = np.linspace(a, b, npts)", " y = f(x)", " return trapz(x, y)" ], "language": "python", "outputs": [], "prompt_number": 10 }, { "cell_type": "markdown", "source": [ "### 3", "", "Verify that both functions above are correct by showing that they produces correct values ", "for a simple integral such as $\\int_0^3 x^2$." ] }, { "cell_type": "code", "collapsed": false, "input": [ "exact = 9.0", "x = linspace(0, 3, 50)", "y = x**2", "", "print exact", "print trapz(x, y)", "", "def f(x): return x**2", "print trapzf(f, 0, 3, 50)" ], "language": "python", "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "9.0", "9.00187421908", "9.00187421908" ] } ], "prompt_number": 16 }, { "cell_type": "markdown", "source": [ "### 4", "", "Repeat the integration for several values of npts, and plot the error as a function of npts ", "for the integral in #3." ] }, { "cell_type": "code", "collapsed": false, "input": [ "npts = [5, 10, 20, 50, 100, 200]", "err = []", "for n in npts:", " err.append(trapzf(f, 0, 3, n)-exact)" ], "language": "python", "outputs": [], "prompt_number": 18 }, { "cell_type": "code", "collapsed": false, "input": [ "plt.semilogy(npts, np.abs(err))", "plt.title(r'Trapezoid approximation to $\\int_0^3 x^2$')", "plt.xlabel('npts')", "plt.ylabel('Error')" ], "language": "python", "outputs": [ { "output_type": "pyout", "prompt_number": 25, "text": [ "<matplotlib.text.Text at 0x472cc50>" ] }, { "output_type": "display_data", "png": "iVBORw0KGgoAAAANSUhEUgAAAYwAAAEeCAYAAACZlyICAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3XlcVWX+B/DPBVcUBTdEURZDAUFAQxQFr1Zo4jaZpTWk\n4EYZbvOz5ufUC3KaMWo0jZlxSc2yySkbHdFflGQBYogouKQyKopUIpIYmygIz++PM964stwLdzl3\n+b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PPbYY7CxscG4ceNUfRSzZ89G\nhw4dMHPmTOTk5KCmpgZCCLVJ38aOHYv58+dj586d6Nixo1yHQKQTBgaRlhwcHFRfd+jQAXfv3gWg\nPpPqg9k+H571880338TGjRtx/vx5+Pr6ora21ggVE+kXA4NIR5999hlqamqwb98+DB8+HB06dICr\nqytKSkpUn8nPz8ewYcOQkJCAjh07ori4WMaKidqGfRhEWmpurQAPDw+MGDECHh4eeOeddwAA4eHh\n+PjjjxEYGIjExES8++67uHTpEuzs7PDb3/4WLi4uxiydSC84SopIB+PHj8e6deswfPhwuUshMjhe\nkiIiIq2whUFERFphC4OIiLTCwCAiIq0wMIiISCsMDCIi0goDg4iItMLAICIirfw/2WuE7eTq6TEA\nAAAASUVORK5CYII=\n" } ], "prompt_number": 25 }, { "cell_type": "markdown", "source": [ "## An illustration using matplotlib and scipy", "", "We define a function with a little more complex look" ] }, { "cell_type": "code", "collapsed": true, "input": [ "def f(x):", " return (x-3)*(x-5)*(x-7)+85", "", "x = linspace(0, 10, 200)", "y = f(x)" ], "language": "python", "outputs": [], "prompt_number": 2 }, { "cell_type": "markdown", "source": [ "Choose a region to integrate over and take only a few points in that region" ] }, { "cell_type": "code", "collapsed": true, "input": [ "a, b = 1, 9", "xint = x[logical_and(x>=a, x<=b)][::30]", "yint = y[logical_and(x>=a, x<=b)][::30]" ], "language": "python", "outputs": [], "prompt_number": 3 }, { "cell_type": "markdown", "source": [ "Plot both the function and the area below it in the trapezoid approximation" ] }, { "cell_type": "code", "collapsed": false, "input": [ "plot(x, y, lw=2)", "axis([0, 10, 0, 140])", "fill_between(xint, 0, yint, facecolor='gray', alpha=0.4)", "text(0.5 * (a + b), 30,r\"$\\int_a^b f(x)dx$\", horizontalalignment='center', fontsize=20);" ], "language": "python", "outputs": [ { "output_type": "display_data", "png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAD3CAYAAADmBxSSAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIAB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cuXLhAp06dWL169X330yjhbqr+781F+/bt6du3LwCurq707t2bmJgYlatS\nR1paGrt27WLGjBkt/mL7/v37mT9/PnZ2dlhZWVVew2pp7O3tMRgM5OTkUFhYSEFBAc7OzmqX1WiC\ng4Pv+H11Oh3Tp0/H1taWadOm1Sk/GyXc79b/XcDFixeJjY2lf//+apeiirlz57J8+XIsLMx2mKNG\nkZaWRlFREaGhoQQFBfHBBx9QVFSkdlmqsLe3JywsjK5du9K+fXt+85vftNj/HxWqZ6i3tzc6ne6+\n27Ts/1Eqy83N5bnnnmPlypW0boGTw+7YsYN27drh7+/f4s/ai4qKiI+PZ9y4cURGRhIbG8vXX3+t\ndlmquHbtGqGhoZw9e5akpCSOHTvGzp071S5LVcb8/2iUcA8MDOTcuXOVP8fGxjJgwIDGOLTZ0uv1\njBs3jsmTJzNmzBi1y1HF0aNH2bZtGx4eHkyYMIGDBw8yZcoUtctSRY8ePfDy8uKpp57C3t6eCRMm\nsHv3brXLUoVOp2PAgAH06NGDhx56iPHjx3P48GG1y1JVYGAgcXFxAMTFxREYGHjfbRol3KX/e00G\ng4Hp06fTp0+fFtcToLqlS5eSmppKYmIiGzduZPjw4ayrmA29BfL09CQqKory8nJ27tzJyJEj1S5J\nFcHBwcTExJCdnU1xcTG7d+/mscceU7ssVQUFBREeHk5hYSHh4eF1OjlutGaZiv7vI0eO5KWXXmrR\n/d+PHDnC+vXrOXjwIP7+/vj7+99xdbwlaum9ZT766CNmz55NQEAAdnZ2PN9CJzJo06YNCxYs4Jln\nnmHw4MH4+fkxbNgwtctqNBMmTGDQoEHEx8fTuXNn/v3vfxMaGkpKSgpeXl6kp6czc+bM++5HY2jp\njZ1CCNEMyQVVIYRohiTchRCiGZJwF0KIZkjCXQghmiEJdyGEaIYk3IUQohn6/0A3Dhj0UlGDAAAA\nAElFTkSuQmCC\n" } ], "prompt_number": 4 }, { "cell_type": "markdown", "source": [ "In practice, we don't need to implement numerical integration ourselves, as scipy has both basic trapezoid", "rule integrators and more sophisticated ones. Here we illustrate both:" ] }, { "cell_type": "code", "collapsed": false, "input": [ "from scipy.integrate import quad, trapz", "integral, error = quad(f, 1, 9)", "print \"The integral is:\", integral, \"+/-\", error", "print \"The trapezoid approximation with\", len(xint), \"points is:\", trapz(yint, xint)" ], "language": "python", "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "The integral is: 680.0 +/- 7.54951656745e-12", "The trapezoid approximation with 6 points is: 621.286411141" ] } ], "prompt_number": 5 }, { "cell_type": "code", "collapsed": true, "input": [], "language": "python", "outputs": [], "prompt_number": " " } ] } ] }