trapezoid_rule.ipynb
117 lines
| 21.0 KiB
| text/plain
|
TextLexer
Fernando Perez
|
r4776 | { | |
Fernando Perez
|
r5784 | "metadata": { | |
"name": "trapezoid_rule" | |||
Brian Granger
|
r6035 | }, | |
"nbformat": 3, | |||
Fernando Perez
|
r5784 | "worksheets": [ | |
{ | |||
"cells": [ | |||
{ | |||
Brian Granger
|
r6035 | "cell_type": "markdown", | |
Fernando Perez
|
r5784 | "source": [ | |
Brian Granger
|
r6035 | "Basic numerical integration: the trapezoid rule", | |
"===============================================", | |||
"", | |||
"A simple illustration of the trapezoid rule for definite integration:", | |||
"", | |||
"$$", | |||
"\\int_{a}^{b} f(x)\\, dx \\approx \\frac{1}{2} \\sum_{k=1}^{N} \\left( x_{k} - x_{k-1} \\right) \\left( f(x_{k}) + f(x_{k-1}) \\right).", | |||
"$$", | |||
"<br>", | |||
Fernando Perez
|
r5784 | "First, we define a simple function and sample it between 0 and 10 at 200 points" | |
] | |||
Brian Granger
|
r6035 | }, | |
Fernando Perez
|
r5784 | { | |
Brian Granger
|
r6035 | "cell_type": "code", | |
"collapsed": true, | |||
Fernando Perez
|
r5784 | "input": [ | |
Brian Granger
|
r6035 | "def f(x):", | |
" return (x-3)*(x-5)*(x-7)+85", | |||
"", | |||
"x = linspace(0, 10, 200)", | |||
Fernando Perez
|
r5784 | "y = f(x)" | |
Brian Granger
|
r6035 | ], | |
"language": "python", | |||
"outputs": [], | |||
Fernando Perez
|
r5784 | "prompt_number": 1 | |
Brian Granger
|
r6035 | }, | |
Fernando Perez
|
r5784 | { | |
Brian Granger
|
r6035 | "cell_type": "markdown", | |
Fernando Perez
|
r5784 | "source": [ | |
"Choose a region to integrate over and take only a few points in that region" | |||
] | |||
Brian Granger
|
r6035 | }, | |
Fernando Perez
|
r5784 | { | |
Brian Granger
|
r6035 | "cell_type": "code", | |
"collapsed": true, | |||
Fernando Perez
|
r5784 | "input": [ | |
Brian Granger
|
r6035 | "a, b = 1, 9", | |
"xint = x[logical_and(x>=a, x<=b)][::30]", | |||
Fernando Perez
|
r5784 | "yint = y[logical_and(x>=a, x<=b)][::30]" | |
Brian Granger
|
r6035 | ], | |
"language": "python", | |||
"outputs": [], | |||
Fernando Perez
|
r5784 | "prompt_number": 2 | |
Brian Granger
|
r6035 | }, | |
Fernando Perez
|
r5784 | { | |
Brian Granger
|
r6035 | "cell_type": "markdown", | |
Fernando Perez
|
r5784 | "source": [ | |
"Plot both the function and the area below it in the trapezoid approximation" | |||
] | |||
Brian Granger
|
r6035 | }, | |
Fernando Perez
|
r5784 | { | |
Brian Granger
|
r6035 | "cell_type": "code", | |
"collapsed": false, | |||
Fernando Perez
|
r5784 | "input": [ | |
Brian Granger
|
r6035 | "plot(x, y, lw=2)", | |
"axis([0, 10, 0, 140])", | |||
"fill_between(xint, 0, yint, facecolor='gray', alpha=0.4)", | |||
Fernando Perez
|
r5784 | "text(0.5 * (a + b), 30,r\"$\\int_a^b f(x)dx$\", horizontalalignment='center', fontsize=20);" | |
Brian Granger
|
r6035 | ], | |
"language": "python", | |||
Fernando Perez
|
r5784 | "outputs": [ | |
{ | |||
Brian Granger
|
r6035 | "output_type": "display_data", | |
Fernando Perez
|
r5784 | "png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAD3CAYAAADmBxSSAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xt8jGf+//HX5BwycmgIRQgiCdJINIIV4tT6bg+01rYs\nug67lR4cqu23VRbdlm1V9bAr1G72u+qnVHXFWR0aWodMokVFCHKOEBIi50yS+f1xNyeCZExyT5LP\n8/GYx9y5Z+77/mQevOfOdV/3dWkMBoMBIYQQzYqF2gUIIYQwPQl3IYRohiTchRCiGZJwF0KIZkjC\nXQghmiEJdyGEaIbuGe7Tpk3Dzc0NX1/fO15bsWIFFhYWZGdnV6777LPP8PT0pFevXvz444+mr1YI\nIUSd3DPcp06dyp49e+5Yn5qayr59++jSpUvluszMTFatWsWBAwcICwtj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KiI+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" | |
} | |||
Brian Granger
|
r6035 | ], | |
Fernando Perez
|
r5784 | "prompt_number": 3 | |
Brian Granger
|
r6035 | }, | |
Fernando Perez
|
r5784 | { | |
Brian Granger
|
r6035 | "cell_type": "markdown", | |
Fernando Perez
|
r5784 | "source": [ | |
"Compute the integral both at high accuracy and with the trapezoid approximation" | |||
] | |||
Brian Granger
|
r6035 | }, | |
Fernando Perez
|
r5784 | { | |
Brian Granger
|
r6035 | "cell_type": "code", | |
"collapsed": false, | |||
Fernando Perez
|
r5784 | "input": [ | |
Brian Granger
|
r6035 | "from scipy.integrate import quad, trapz", | |
"integral, error = quad(f, 1, 9)", | |||
"print \"The integral is:\", integral, \"+/-\", error", | |||
Fernando Perez
|
r5784 | "print \"The trapezoid approximation with\", len(xint), \"points is:\", trapz(yint, xint)" | |
Brian Granger
|
r6035 | ], | |
"language": "python", | |||
Fernando Perez
|
r5784 | "outputs": [ | |
{ | |||
Brian Granger
|
r6035 | "output_type": "stream", | |
"stream": "stdout", | |||
Fernando Perez
|
r5784 | "text": [ | |
Brian Granger
|
r6035 | "The integral is: 680.0 +/- 7.54951656745e-12", | |
Fernando Perez
|
r5784 | "The trapezoid approximation with 6 points is: 621.286411141" | |
] | |||
} | |||
Brian Granger
|
r6035 | ], | |
Fernando Perez
|
r5784 | "prompt_number": 4 | |
Brian Granger
|
r6035 | }, | |
Fernando Perez
|
r5784 | { | |
Brian Granger
|
r6035 | "cell_type": "code", | |
"collapsed": true, | |||
"input": [], | |||
"language": "python", | |||
MinRK
|
r5981 | "outputs": [] | |
Fernando Perez
|
r5784 | } | |
] | |||
} | |||
] | |||
MinRK
|
r5279 | } |