Fix sign on the Taylor remainder term in the trapezoid derivation - #169
Open
adowling2 wants to merge 1 commit into
Open
Fix sign on the Taylor remainder term in the trapezoid derivation#169adowling2 wants to merge 1 commit into
adowling2 wants to merge 1 commit into
Conversation
The third term of the trapezoid-rule derivation is printed as
\int_a^b (x-a)^2/2 f''(a) dx = -h^3/6 f''(a) = O(h^3)
The minus sign is wrong. Antidifferentiating gives f''(a)(x-a)^3/6 evaluated
from a to b, which is +h^3/6 f''(a) for h = b-a > 0. Verified symbolically.
Nothing downstream changes: the term is immediately absorbed into O(h^3), so
the conclusion -- that one panel of the trapezoid rule is third-order accurate,
and O(h^2) once composed -- is unaffected. It is a display error only, but it is
on a page where students are being walked through the algebra line by line.
Fixed in both the -dev source and the published copy so they stay in sync.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The problem
notebooks/07/Intro-and-Newton-Cotes.ipynb, in the Taylor-series derivation of the trapezoid rule, printsThe minus sign is wrong. Antidifferentiating gives$f''(a)\frac{(x-a)^3}{6}$ evaluated from $a$ to $b$ , i.e. $+\frac{h^3}{6}f''(a)$ for $h = b - a > 0$ . Verified symbolically with sympy.
Why it is worth fixing anyway
Nothing downstream changes — the term is absorbed into$O(h^3)$ on the same line, so the conclusion that one panel of the trapezoid rule is third-order accurate (and $O(h^2)$ composite) is unaffected.
But this is a page where students are walked through the algebra line by line, and a reader who checks the integral will find it does not come out. That is exactly the reader the derivation is written for.
The change
One character, in two files — the
-devsource and the published copy, kept in sync:notebooks/07-dev/Intro-and-Newton-Cotes.ipynbnotebooks/07/Intro-and-Newton-Cotes.ipynbNo code cells touched, no outputs changed, no other prose modified.
Context
Found while cross-checking numeric-integration material for the Fall 2026 refresh of the optimization course, which draws on this chapter. The same slip appears in at least two other places and may be worth a look separately:
nsa-fall-2019/Lectures/C12-Numeric-Integration/C12-Numeric-Integration.ipynb(markdown cell 56) — co-authored with Ryan McClarren, so worth a word with him firstSeparately, and not part of this PR: the same chapter's exercise "derive the error order for midpoint and trapezoid rules" is stated without giving an answer, which is correct — the midpoint rule is$O(h^2)$ composite, not $O(h)$ , because node symmetry buys a free order that the interpolant-degree heuristic misses.
🤖 Generated with Claude Code