Trapezoidal Rule for Integration

I = i = 1 n h f x i + f x 1 + i 2

Split sum

I = i = 1 n h f x i 2 + i = 1 n h f x 1 + i 2

Adjust limits

I = i = 0 -1 + n h f x i 2 + i = 1 n h f x i 2

Peel terms

I = 2 i = 1 -1 + n h f x i 2 + h f x 0 2 + h f x n 2