|
41 | 41 | },
|
42 | 42 | {
|
43 | 43 | "cell_type": "code",
|
44 |
| - "execution_count": 1, |
| 44 | + "execution_count": 2, |
45 | 45 | "metadata": {},
|
46 | 46 | "outputs": [],
|
47 | 47 | "source": [
|
|
73 | 73 | },
|
74 | 74 | {
|
75 | 75 | "cell_type": "code",
|
76 |
| - "execution_count": 2, |
| 76 | + "execution_count": 3, |
77 | 77 | "metadata": {},
|
78 | 78 | "outputs": [],
|
79 | 79 | "source": [
|
|
94 | 94 | },
|
95 | 95 | {
|
96 | 96 | "cell_type": "code",
|
97 |
| - "execution_count": 3, |
| 97 | + "execution_count": 4, |
98 | 98 | "metadata": {},
|
99 | 99 | "outputs": [],
|
100 | 100 | "source": [
|
|
104 | 104 | },
|
105 | 105 | {
|
106 | 106 | "cell_type": "code",
|
107 |
| - "execution_count": 4, |
| 107 | + "execution_count": 5, |
108 | 108 | "metadata": {
|
109 | 109 | "tags": []
|
110 | 110 | },
|
|
123 | 123 | },
|
124 | 124 | {
|
125 | 125 | "cell_type": "code",
|
126 |
| - "execution_count": 5, |
| 126 | + "execution_count": 6, |
127 | 127 | "metadata": {},
|
128 | 128 | "outputs": [
|
129 | 129 | {
|
|
143 | 143 | },
|
144 | 144 | {
|
145 | 145 | "cell_type": "code",
|
146 |
| - "execution_count": 6, |
| 146 | + "execution_count": 7, |
147 | 147 | "metadata": {},
|
148 | 148 | "outputs": [],
|
149 | 149 | "source": [
|
|
165 | 165 | },
|
166 | 166 | {
|
167 | 167 | "cell_type": "code",
|
168 |
| - "execution_count": 7, |
| 168 | + "execution_count": 8, |
169 | 169 | "metadata": {},
|
170 | 170 | "outputs": [],
|
171 | 171 | "source": [
|
|
175 | 175 | },
|
176 | 176 | {
|
177 | 177 | "cell_type": "code",
|
178 |
| - "execution_count": 8, |
| 178 | + "execution_count": 9, |
179 | 179 | "metadata": {},
|
180 | 180 | "outputs": [
|
181 | 181 | {
|
|
207 | 207 | },
|
208 | 208 | {
|
209 | 209 | "cell_type": "code",
|
210 |
| - "execution_count": 9, |
| 210 | + "execution_count": 10, |
211 | 211 | "metadata": {},
|
212 | 212 | "outputs": [
|
213 | 213 | {
|
|
247 | 247 | "\n",
|
248 | 248 | "(this example comes from the SciPy tutorial)\n",
|
249 | 249 | "\n",
|
250 |
| - "Notice that the limits of integration in $x$ depend on $y$.\n", |
| 250 | + "Notice that the limits of integration in $x$ depend on $y$. This means that we need to do the $x$\n", |
| 251 | + "integration first, which gives:\n", |
| 252 | + "\n", |
| 253 | + "$$I = \\int_{y=0}^{1/2} \\int_{x=0}^{1-2y} xy \\,dxdy = \\frac{1}{2} \\int_{y=0}^{1/2} y \\left [ x^2 \\right |_0^{1-2y} dy = \\frac{1}{2} \\int_0^{1/2} (1-2y)^2 y \\, dy = \\frac{1}{96}$$\n", |
251 | 254 | "\n",
|
252 | 255 | "Note the form of the function:\n",
|
253 | 256 | "\n",
|
254 | 257 | "```\n",
|
255 | 258 | "dblquad(f, a, b, xlo, xhi)\n",
|
256 | 259 | "```\n",
|
257 |
| - "where `f` = `f(y, x)` -- the y argument is first\n", |
| 260 | + "where `f` = `f(y, x)` -- the y argument is first to indicate that the $y$ integration is done first and\n", |
| 261 | + "then the $x$ and $[a, b]$ are the limits of the $x$ integration. We want the opposite in this example,\n", |
| 262 | + "so we'll switch the meaning of $x$ and $y$ in our example below.\n", |
258 | 263 | "\n",
|
259 | 264 | "The integral will be from: $y = [0, 1/2]$, and $x$ = `xlo(y)`, $x$ = `xhi(y)`"
|
260 | 265 | ]
|
261 | 266 | },
|
262 | 267 | {
|
263 | 268 | "cell_type": "code",
|
264 |
| - "execution_count": 10, |
| 269 | + "execution_count": 11, |
265 | 270 | "metadata": {},
|
266 | 271 | "outputs": [
|
267 | 272 | {
|
|
273 | 278 | }
|
274 | 279 | ],
|
275 | 280 | "source": [
|
276 |
| - "def integrand(y, x):\n", |
| 281 | + "def integrand(x, y):\n", |
277 | 282 | " return x*y\n",
|
278 | 283 | "\n",
|
279 | 284 | "def x_lower_lim(y):\n",
|
|
0 commit comments