Skip to content

Commit e3b31d0

Browse files
committed
explain the double integration better
1 parent e1c6b5c commit e3b31d0

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

content/05-scipy/scipy-basics.ipynb

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
},
4242
{
4343
"cell_type": "code",
44-
"execution_count": 1,
44+
"execution_count": 2,
4545
"metadata": {},
4646
"outputs": [],
4747
"source": [
@@ -73,7 +73,7 @@
7373
},
7474
{
7575
"cell_type": "code",
76-
"execution_count": 2,
76+
"execution_count": 3,
7777
"metadata": {},
7878
"outputs": [],
7979
"source": [
@@ -94,7 +94,7 @@
9494
},
9595
{
9696
"cell_type": "code",
97-
"execution_count": 3,
97+
"execution_count": 4,
9898
"metadata": {},
9999
"outputs": [],
100100
"source": [
@@ -104,7 +104,7 @@
104104
},
105105
{
106106
"cell_type": "code",
107-
"execution_count": 4,
107+
"execution_count": 5,
108108
"metadata": {
109109
"tags": []
110110
},
@@ -123,7 +123,7 @@
123123
},
124124
{
125125
"cell_type": "code",
126-
"execution_count": 5,
126+
"execution_count": 6,
127127
"metadata": {},
128128
"outputs": [
129129
{
@@ -143,7 +143,7 @@
143143
},
144144
{
145145
"cell_type": "code",
146-
"execution_count": 6,
146+
"execution_count": 7,
147147
"metadata": {},
148148
"outputs": [],
149149
"source": [
@@ -165,7 +165,7 @@
165165
},
166166
{
167167
"cell_type": "code",
168-
"execution_count": 7,
168+
"execution_count": 8,
169169
"metadata": {},
170170
"outputs": [],
171171
"source": [
@@ -175,7 +175,7 @@
175175
},
176176
{
177177
"cell_type": "code",
178-
"execution_count": 8,
178+
"execution_count": 9,
179179
"metadata": {},
180180
"outputs": [
181181
{
@@ -207,7 +207,7 @@
207207
},
208208
{
209209
"cell_type": "code",
210-
"execution_count": 9,
210+
"execution_count": 10,
211211
"metadata": {},
212212
"outputs": [
213213
{
@@ -247,21 +247,26 @@
247247
"\n",
248248
"(this example comes from the SciPy tutorial)\n",
249249
"\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",
251254
"\n",
252255
"Note the form of the function:\n",
253256
"\n",
254257
"```\n",
255258
"dblquad(f, a, b, xlo, xhi)\n",
256259
"```\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",
258263
"\n",
259264
"The integral will be from: $y = [0, 1/2]$, and $x$ = `xlo(y)`, $x$ = `xhi(y)`"
260265
]
261266
},
262267
{
263268
"cell_type": "code",
264-
"execution_count": 10,
269+
"execution_count": 11,
265270
"metadata": {},
266271
"outputs": [
267272
{
@@ -273,7 +278,7 @@
273278
}
274279
],
275280
"source": [
276-
"def integrand(y, x):\n",
281+
"def integrand(x, y):\n",
277282
" return x*y\n",
278283
"\n",
279284
"def x_lower_lim(y):\n",

0 commit comments

Comments
 (0)