18 / 90

Day 18: 有限差分・ステップ幅・浮動小数点の影響

定義・導出例・想起練習・正直な数値的証拠を通じて、関数と変化を計算可能にする。

数学・微積分 480 分のアクティブ学習(8 時間の集中学習)
01 120 分

有限差分は近似である

Agent支援エンジニアリングチェック

前提条件

前の活動を終え、行き詰まったら記載の回復ソースを使うこと。

学習目標

導関数の定義から前進・後退・中心の有限差分を実装し、h を明示したまま解析解と比較する。近似を厳密値として扱わない。

手順

1. 数値を入れる前に、記号の h のまま 3 つのステンシルを書く:前進 [f(a+h) - f(a)]/h、後退 [f(a) - f(a-h)]/h、中心 [f(a+h) - f(a-h)]/(2h)。h の符号を見える形で残す。
2. Day 17 の結果(3 における x^2 の前進差商はちょうど 6 + h)を使い、どのステンシルが f'(3) = 6 に最も近いかを予測する。
3. f(3.1)、f(3)、f(2.9) を一度だけ計算し、その 3 つの値を 3 つのステンシルすべてで使い回す。
4. 各推定値と符号付き誤差(推定値 - 6)を表にする。
5. テイラー展開でパターンを説明する:x^2 では前進誤差はちょうど +h、後退誤差はちょうど -h で、中心ステンシルではこれが打ち消し合う。次の項は f''' を含むが、二次関数ではゼロになる。
6. どの量が厳密(f'(3)、関数値)で、どの量が近似(一般にはステンシルの出力)かを述べ、ここで中心差分が厳密になるのは特殊な場合であって規則ではない理由を説明する。

時間配分(120 分):読解 30 + 演習 55 + 確認 35。 読解:OpenStax 3.1 節(差商の極限としての導関数)と SciPy derivative ページの概要。演習:3 つのステンシル、誤差表、テイラーによる説明。確認:x=2、h=.01 の習熟項目を補助なしで解く。

練習と予測ログ

x=3 の f(x)=x^2 について h=.1 とし、前進 [f(3+h)-f(3)]/h、後退 [f(3)-f(3-h)]/h、中心 [f(3+h)-f(3-h)]/(2h) を計算する。どれが f'(3)=6 に最も近いか予測する。

独立習得基準

独力で f(x)=x^2 の x=2、h=.01 における三つの推定値を計算し、4 と比較して、どの量が厳密でどれが近似かを述べる。

権威ある出典リソースと出典情報

linking CC BY-NC-SA 4.0 attribution noncommercial share-alike

OpenStax Calculus Volume 1

著者・提供機関: OpenStax, Rice University (Gilbert Strang, Edwin Herman, et al.) | オリジナル出所URL ↗

該当セクション・タイムスタンプ: Sections 2.1-2.3 (Functions, Limits, and the Derivative); Sections 3.1-3.2 (Derivative Rules)

検証バージョンと日付: 3rd edition, verified 2026-10-30

選定理由:

Open, systematic treatment of the limit definition and derivative rules with stable section locations.

ソース前提知識:

Algebra, coordinate geometry, and function notation

安全フォールバック(オフライン回復性):

The authored derivations, tables, and exercises in these three Study Days are complete offline recovery material; use the linked section only for optional comparison.

比較対象候補リソースと選定評価 (3)
MIT OpenCourseWare 18.01SC Single Variable Calculus ↗ compared_selected_for_visual_practice [CC BY-NC-SA 4.0]

Strong exercises and transcripts, but the noncommercial share-alike terms and course navigation make OpenStax the primary stable text.

Paul's Online Math Notes: Calculus I ↗ compared_rejected_for_reuse [All Rights Reserved]

Useful reference, but rights and redistribution terms are less suitable for embedded recovery material.

SciPy Numerical Differentiation Documentation ↗ compared_selected_for_numerics [BSD-3-Clause]

A primary API reference for numerical derivative step-size behavior; it complements rather than replaces the hand derivation.

linking BSD-3-Clause

SciPy numerical derivative reference

著者・提供機関: SciPy Developers | オリジナル出所URL ↗

該当セクション・タイムスタンプ: derivative API: finite differences, step-size iteration, tolerances

検証バージョンと日付: SciPy documentation, verified 2026-10-30

選定理由:

Documents numerical differentiation as an approximation with finite step sizes and stopping criteria.

ソース前提知識:

Python arithmetic and the definition of a derivative

安全フォールバック(オフライン回復性):

The local Day 18 tables and pure-Python snippets reproduce the relevant finite-difference behavior without SciPy.

比較対象候補リソースと選定評価 (2)
NumPy: numpy.gradient ↗ compared_alternative [BSD 3-Clause License]

Array-oriented gradient estimation on sampled grids; the SciPy derivative reference matches the pointwise finite-difference helper the exercises implement.

SymPy Calculus tutorial ↗ compared_alternative [BSD License]

Symbolic rather than numerical differentiation; useful for exact cross-checks but not the finite-difference practice target.

02 120 分

ステップ幅:打ち切り誤差と丸め誤差

独立習得チェック(AI 支援なし)

前提条件

前の活動を終え、行き詰まったら記載の回復ソースを使うこと。

学習目標

最小の h が常に最良とは限らない理由を説明する:打ち切り誤差は一般に h とともに減るが、近い関数値が区別できなくなると浮動小数点の桁落ちや丸めが増える。

手順

1. 計算の前に予測する:中心差分の打ち切り誤差はおよそ h^2 で小さくなり、丸め誤差はおよそ eps/h で大きくなる(倍精度では eps ≈ 2.2e-16)。両者が交わると思う位置を書いておく。
2. h = .1, 1e-3, 1e-5, 1e-8, 1e-12 について中心差分 (sin(1+h) - sin(1-h))/(2h) を計算し、有効数字 12 桁以上で表示する。
3. 各絶対誤差は、10 桁表示の 0.5403023059 ではなく、演算精度の math.cos(1) に対して測る。
4. 誤差が減らなくなり増え始める行(転換点)に印を付ける。
5. 転換点を 2 文で説明する:1 文は打ち切り誤差、もう 1 文は桁落ちと丸めについて。
6. この表は 1 つの関数・1 つの点・1 つの精度を示すだけであり、普遍的な最良の h を与えるものではないと明記する。

時間配分(120 分):読解 25 + 演習 60 + 確認 35。 読解:SciPy derivative ページ(刻み幅、許容誤差)と活動 1 のノート。演習:誤差と転換点を含む 5 行の表。確認:3 行を補助なしで再現し、1e-12 が 1e-5 より悪い理由を説明する習熟項目。

練習と予測ログ

解析的な導関数が cos(1)≈0.5403023059(10 桁の表示。誤差は演算精度の cos(1) に対して測る)である sin(1) に中心差分を使う。h=.1, 1e-3, 1e-5, 1e-8, 1e-12 を比較する。習慣で最小の h を選ぶのではなく、最良の領域を説明する。

独立習得基準

支援なしで、電卓か Python を使い少なくとも三つの表の行を再現し、cos(1) に対する絶対誤差を計算し、ここで h=1e-12 が h=1e-5 より悪い理由を説明する。

権威ある出典リソースと出典情報

linking CC BY-NC-SA 4.0 attribution noncommercial share-alike

OpenStax Calculus Volume 1

著者・提供機関: OpenStax, Rice University (Gilbert Strang, Edwin Herman, et al.) | オリジナル出所URL ↗

該当セクション・タイムスタンプ: Sections 2.1-2.3 (Functions, Limits, and the Derivative); Sections 3.1-3.2 (Derivative Rules)

検証バージョンと日付: 3rd edition, verified 2026-10-30

選定理由:

Open, systematic treatment of the limit definition and derivative rules with stable section locations.

ソース前提知識:

Algebra, coordinate geometry, and function notation

安全フォールバック(オフライン回復性):

The authored derivations, tables, and exercises in these three Study Days are complete offline recovery material; use the linked section only for optional comparison.

比較対象候補リソースと選定評価 (3)
MIT OpenCourseWare 18.01SC Single Variable Calculus ↗ compared_selected_for_visual_practice [CC BY-NC-SA 4.0]

Strong exercises and transcripts, but the noncommercial share-alike terms and course navigation make OpenStax the primary stable text.

Paul's Online Math Notes: Calculus I ↗ compared_rejected_for_reuse [All Rights Reserved]

Useful reference, but rights and redistribution terms are less suitable for embedded recovery material.

SciPy Numerical Differentiation Documentation ↗ compared_selected_for_numerics [BSD-3-Clause]

A primary API reference for numerical derivative step-size behavior; it complements rather than replaces the hand derivation.

linking BSD-3-Clause

SciPy numerical derivative reference

著者・提供機関: SciPy Developers | オリジナル出所URL ↗

該当セクション・タイムスタンプ: derivative API: finite differences, step-size iteration, tolerances

検証バージョンと日付: SciPy documentation, verified 2026-10-30

選定理由:

Documents numerical differentiation as an approximation with finite step sizes and stopping criteria.

ソース前提知識:

Python arithmetic and the definition of a derivative

安全フォールバック(オフライン回復性):

The local Day 18 tables and pure-Python snippets reproduce the relevant finite-difference behavior without SciPy.

比較対象候補リソースと選定評価 (2)
NumPy: numpy.gradient ↗ compared_alternative [BSD 3-Clause License]

Array-oriented gradient estimation on sampled grids; the SciPy derivative reference matches the pointwise finite-difference helper the exercises implement.

SymPy Calculus tutorial ↗ compared_alternative [BSD License]

Symbolic rather than numerical differentiation; useful for exact cross-checks but not the finite-difference practice target.

03 120 分

数値実験と失敗分析

Agent支援エンジニアリングチェック

前提条件

前の活動を終え、行き詰まったら記載の回復ソースを使うこと。

学習目標

再現可能な純粋 Python の有限差分実験を実行し、前進誤差と中心誤差を比較し、h が極小になるとき sqrt(1+h)-sqrt(1) で桁落ちを診断する。

手順

1. 実行を再現できるよう、スクリプトの最初で sys.version を表示する。
2. 基準値は分けておく:math.cos(1) を一度だけ計算し、有限差分から導かない。
3. h = .1, 1e-3, 1e-5, 1e-8, 1e-12 をループし、sin(1) について h、前進誤差、中心誤差を指数表記で表示する。
4. 桁落ちの例を加える:h = 1e-8, 1e-12, 1e-16 での前進推定 (sqrt(1+h) - sqrt(1))/h。実行前に、倍精度で 1 + 1e-16 が何になり、それが分子に何をもたらすかを予測する。
5. 不安定な行も含めてすべての行を残す。悪い行を隠した実験は証拠にならない。
6. 各領域について 1 行の診断を書く:打ち切り誤差が支配的、桁落ち・丸めが支配的、または有効数字の完全な喪失。

時間配分(120 分):読解 20 + 演習 70 + 確認 30。 読解:ヒントと活動 2 の表。演習:スクリプトを書いて実行し、出力全体を記録する。確認:表と診断を参考解答と比べ、食い違う行があれば表示形式を変えて再実行する。

練習と予測ログ

sin(1) について h、前進誤差、中心誤差を表示する短いスクリプトを書く。平方根の例に h=1e-16 を加え、浮動小数点で分子が区別できるか予測する。

独立習得基準

独立した作業には、実行可能なコード、少なくとも四つの h 値を記録した表、打ち切り誤差と桁落ち・丸めを区別する書面の診断を含めること。

権威ある出典リソースと出典情報

linking CC BY-NC-SA 4.0 attribution noncommercial share-alike

OpenStax Calculus Volume 1

著者・提供機関: OpenStax, Rice University (Gilbert Strang, Edwin Herman, et al.) | オリジナル出所URL ↗

該当セクション・タイムスタンプ: Sections 2.1-2.3 (Functions, Limits, and the Derivative); Sections 3.1-3.2 (Derivative Rules)

検証バージョンと日付: 3rd edition, verified 2026-10-30

選定理由:

Open, systematic treatment of the limit definition and derivative rules with stable section locations.

ソース前提知識:

Algebra, coordinate geometry, and function notation

安全フォールバック(オフライン回復性):

The authored derivations, tables, and exercises in these three Study Days are complete offline recovery material; use the linked section only for optional comparison.

比較対象候補リソースと選定評価 (3)
MIT OpenCourseWare 18.01SC Single Variable Calculus ↗ compared_selected_for_visual_practice [CC BY-NC-SA 4.0]

Strong exercises and transcripts, but the noncommercial share-alike terms and course navigation make OpenStax the primary stable text.

Paul's Online Math Notes: Calculus I ↗ compared_rejected_for_reuse [All Rights Reserved]

Useful reference, but rights and redistribution terms are less suitable for embedded recovery material.

SciPy Numerical Differentiation Documentation ↗ compared_selected_for_numerics [BSD-3-Clause]

A primary API reference for numerical derivative step-size behavior; it complements rather than replaces the hand derivation.

linking BSD-3-Clause

SciPy numerical derivative reference

著者・提供機関: SciPy Developers | オリジナル出所URL ↗

該当セクション・タイムスタンプ: derivative API: finite differences, step-size iteration, tolerances

検証バージョンと日付: SciPy documentation, verified 2026-10-30

選定理由:

Documents numerical differentiation as an approximation with finite step sizes and stopping criteria.

ソース前提知識:

Python arithmetic and the definition of a derivative

安全フォールバック(オフライン回復性):

The local Day 18 tables and pure-Python snippets reproduce the relevant finite-difference behavior without SciPy.

比較対象候補リソースと選定評価 (2)
NumPy: numpy.gradient ↗ compared_alternative [BSD 3-Clause License]

Array-oriented gradient estimation on sampled grids; the SciPy derivative reference matches the pointwise finite-difference helper the exercises implement.

SymPy Calculus tutorial ↗ compared_alternative [BSD License]

Symbolic rather than numerical differentiation; useful for exact cross-checks but not the finite-difference practice target.

04 120 分

想起・復習・独立習得

独立習得チェック(AI 支援なし)

前提条件

前の活動を終え、行き詰まったら記載の回復ソースを使うこと。

学習目標

解析的導関数・微分不可能性・有限差分・数値誤差を、モデル訓練の数学のための防御可能な検証手順に統合する。

手順

1. 本もノートも閉じる。問題の (1)-(6) を記憶だけで順に答える。
2. (1) と (2) では値だけでなく根拠を示す:x^3 に使う法則を挙げ、0 における |x| の左右の傾きを両方書く。
3. (3) では手順を定める:ステンシル、数桁にわたる h の集合、受け入れ基準(例えば、丸めが支配する前に推定値が近づいていく相対誤差の許容値)。
4. (4) では記録する証拠の項目を挙げる:関数、点、dtype、h の値、推定値、基準値、誤差、失敗。
5. (5) では関数・点・h を自分で選んで明示し、中心差分の計算を解析的な導関数との誤差まで進める。
6. (6) では限界を述べる文を自分の言葉で書く。
7. 参考解答で採点する。間違えた項目ごとに Day 16-18 の対応する活動を見直し、同等の問題を補助なしで解き直す。

時間配分(120 分):読解 15 + 演習 60 + 確認 45。 読解:なし(閉巻の想起練習)。演習:6 部構成の解答と計算例。確認:採点し、見直し、間違えた項目を補助なしで解き直す。

練習と予測ログ

閉巻で:(1) x^3 の 2 での微分係数を答える。(2) |x| が 0 で微分可能かとその理由を述べる。(3) ブラックボックスの滑らかな関数を調べる有限差分ステンシルと h の方針を選ぶ。(4) 記録する証拠を挙げる。(5) 関数・点・h を自分で選んで明示した中心差分の計算過程を含める。(6) 有限差分による確認は検証の証拠であり、微分可能性や厳密性の証明ではないことを明確に述べる。

独立習得基準

独立習得チェック:四つの小問への回答と、中心差分の完全な計算、有限差分は検証の証拠であって微分可能性や厳密性の証明ではないという明確な記述を提出する。

権威ある出典リソースと出典情報

linking CC BY-NC-SA 4.0 attribution noncommercial share-alike

OpenStax Calculus Volume 1

著者・提供機関: OpenStax, Rice University (Gilbert Strang, Edwin Herman, et al.) | オリジナル出所URL ↗

該当セクション・タイムスタンプ: Sections 2.1-2.3 (Functions, Limits, and the Derivative); Sections 3.1-3.2 (Derivative Rules)

検証バージョンと日付: 3rd edition, verified 2026-10-30

選定理由:

Open, systematic treatment of the limit definition and derivative rules with stable section locations.

ソース前提知識:

Algebra, coordinate geometry, and function notation

安全フォールバック(オフライン回復性):

The authored derivations, tables, and exercises in these three Study Days are complete offline recovery material; use the linked section only for optional comparison.

比較対象候補リソースと選定評価 (3)
MIT OpenCourseWare 18.01SC Single Variable Calculus ↗ compared_selected_for_visual_practice [CC BY-NC-SA 4.0]

Strong exercises and transcripts, but the noncommercial share-alike terms and course navigation make OpenStax the primary stable text.

Paul's Online Math Notes: Calculus I ↗ compared_rejected_for_reuse [All Rights Reserved]

Useful reference, but rights and redistribution terms are less suitable for embedded recovery material.

SciPy Numerical Differentiation Documentation ↗ compared_selected_for_numerics [BSD-3-Clause]

A primary API reference for numerical derivative step-size behavior; it complements rather than replaces the hand derivation.

linking BSD-3-Clause

SciPy numerical derivative reference

著者・提供機関: SciPy Developers | オリジナル出所URL ↗

該当セクション・タイムスタンプ: derivative API: finite differences, step-size iteration, tolerances

検証バージョンと日付: SciPy documentation, verified 2026-10-30

選定理由:

Documents numerical differentiation as an approximation with finite step sizes and stopping criteria.

ソース前提知識:

Python arithmetic and the definition of a derivative

安全フォールバック(オフライン回復性):

The local Day 18 tables and pure-Python snippets reproduce the relevant finite-difference behavior without SciPy.

比較対象候補リソースと選定評価 (2)
NumPy: numpy.gradient ↗ compared_alternative [BSD 3-Clause License]

Array-oriented gradient estimation on sampled grids; the SciPy derivative reference matches the pointwise finite-difference helper the exercises implement.

SymPy Calculus tutorial ↗ compared_alternative [BSD License]

Symbolic rather than numerical differentiation; useful for exact cross-checks but not the finite-difference practice target.