Skip to content

Commit 45b76f7

Browse files
beachdwellerclaude
andcommitted
feature : 30 / 00 add ipywidgets interactive slider for Riemann sum
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 963a798 commit 45b76f7

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

30_num_int/00_zeroth_order.ipynb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,23 @@
361361
"\n"
362362
]
363363
},
364+
{
365+
"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.",
367+
"metadata": {}
368+
},
369+
{
370+
"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 :'));",
372+
"metadata": {},
373+
"execution_count": null,
374+
"outputs": []
375+
},
376+
{
377+
"cell_type": "markdown",
378+
"source": "$n$을 2에서 200까지 바꾸어 보자. 오차가 어떻게 줄어드는가?<br>\nTry changing $n$ from 2 to 200. How does the error decrease?",
379+
"metadata": {}
380+
},
364381
{
365382
"cell_type": "markdown",
366383
"metadata": {},

0 commit comments

Comments
 (0)