Skip to content

Commit 0de7716

Browse files
kangwonleegithub-actions[bot]
authored andcommitted
Clean ipynb 45b76f7
1 parent 45b76f7 commit 0de7716

File tree

1 file changed

+35
-3
lines changed

1 file changed

+35
-3
lines changed

30_num_int/00_zeroth_order.ipynb

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -363,19 +363,51 @@
363363
},
364364
{
365365
"cell_type": "markdown",
366-
"source": "### 대화형 탐색<br>Interactive Exploration\n\n분할 수 $n$ 을 바꾸어 가며 직사각형이 반원에 어떻게 근사하는지 관찰해 보자.<br>\nChange the number of partitions $n$ and observe how the rectangles approximate the half circle.",
366+
"source": [
367+
"### 대화형 탐색<br>Interactive Exploration\n",
368+
"\n",
369+
"분할 수 $n$ 을 바꾸어 가며 직사각형이 반원에 어떻게 근사하는지 관찰해 보자.<br>\n",
370+
"Change the number of partitions $n$ and observe how the rectangles approximate the half circle.\n"
371+
],
367372
"metadata": {}
368373
},
369374
{
370375
"cell_type": "code",
371-
"source": "from ipywidgets import interact, IntSlider\n\n\ndef plot_num_int_0(n):\n x_curve = py.sort(r * py.cos(py.deg2rad(py.linspace(0, 180, 256))))\n y_curve = py.sqrt(r**2 - x_curve**2)\n\n x_bar = py.linspace(-r, r, n + 1)\n y_bar = py.sqrt(py.abs(r**2 - x_bar**2))\n dx = x_bar[1] - x_bar[0]\n\n py.fill_between(x_curve, y_curve, alpha=0.3)\n py.bar(x_bar[:-1], y_bar[:-1], width=dx, alpha=0.5, align='edge', edgecolor='k')\n\n area = sum(y_bar[:-1]) * dx\n py.title(f'n = {n}, Area = {area:.6f}, Error = {abs(area - 1):.2e}')\n py.axis('equal')\n py.grid(True)\n py.show()\n\n\ninteract(plot_num_int_0, n=IntSlider(min=2, max=200, step=1, value=10,\n description='n :'));",
376+
"source": [
377+
"from ipywidgets import interact, IntSlider\n",
378+
"\n",
379+
"\n",
380+
"def plot_num_int_0(n):\n",
381+
" x_curve = py.sort(r * py.cos(py.deg2rad(py.linspace(0, 180, 256))))\n",
382+
" y_curve = py.sqrt(r**2 - x_curve**2)\n",
383+
"\n",
384+
" x_bar = py.linspace(-r, r, n + 1)\n",
385+
" y_bar = py.sqrt(py.abs(r**2 - x_bar**2))\n",
386+
" dx = x_bar[1] - x_bar[0]\n",
387+
"\n",
388+
" py.fill_between(x_curve, y_curve, alpha=0.3)\n",
389+
" py.bar(x_bar[:-1], y_bar[:-1], width=dx, alpha=0.5, align='edge', edgecolor='k')\n",
390+
"\n",
391+
" area = sum(y_bar[:-1]) * dx\n",
392+
" py.title(f'n = {n}, Area = {area:.6f}, Error = {abs(area - 1):.2e}')\n",
393+
" py.axis('equal')\n",
394+
" py.grid(True)\n",
395+
" py.show()\n",
396+
"\n",
397+
"\n",
398+
"interact(plot_num_int_0, n=IntSlider(min=2, max=200, step=1, value=10,\n",
399+
" description='n :'));\n"
400+
],
372401
"metadata": {},
373402
"execution_count": null,
374403
"outputs": []
375404
},
376405
{
377406
"cell_type": "markdown",
378-
"source": "$n$을 2에서 200까지 바꾸어 보자. 오차가 어떻게 줄어드는가?<br>\nTry changing $n$ from 2 to 200. How does the error decrease?",
407+
"source": [
408+
"$n$을 2에서 200까지 바꾸어 보자. 오차가 어떻게 줄어드는가?<br>\n",
409+
"Try changing $n$ from 2 to 200. How does the error decrease?\n"
410+
],
379411
"metadata": {}
380412
},
381413
{

0 commit comments

Comments
 (0)