台形公式
さらに一区間の幅が
a k − a k − 1 = b − a n ( k = 1 , ... , n ) {\displaystyle a_{k}-a_{k-1}={\frac {b-a}{n}}\quad (k=1,\dots ,n)}
と一定になるようにk 番目の区切りを
a k = a + k b − a n ( k = 0 , ... , n ) {\displaystyle a_{k}=a+k{\frac {b-a}{n}}\quad (k=0,\dots ,n)}
ととることで
∫ a b f ( x ) d x ≈ ∑ k = 1 n ( b − a ) f ( a k − 1 ) + f ( a k ) 2 n = b − a 2 n ∑ k = 1 n ( f ( a k − 1 ) + f ( a k ) ) = b − a 2 n ( f ( a 0 ) + 2 f ( a 1 ) + 2 f ( a 2 ) + ⋯ + 2 f ( a n − 1 ) + f ( a n ) ) = b − a n { f ( a ) + f ( b ) 2 + ∑ k = 1 n − 1 f ( a + k b − a n ) } {\displaystyle {\begin{aligned}\int _{a}^{b}f(x)\,\mathrm {d} x&\approx \sum _{k=1}^{n}(b-a){\frac {f(a_{k-1})+f(a_{k})}{2n}}\\&={\frac {b-a}{2n}}\sum _{k=1}^{n}(f(a_{k-1})+f(a_{k}))\\&={\frac {b-a}{2n}}\left(f(a_{0})+2f(a_{1})+2f(a_{2})+\cdots +2f(a_{n-1})+f(a_{n})\right)\\&={\frac {b-a}{n}}\left\{{\frac {f(a)+f(b)}{2}}+\sum _{k=1}^{n-1}f\left(a+k{\frac {b-a}{n}}\right)\right\}\end{aligned}}}