Trapezoidal Rule Calculator

Pick a function, set the limits a and b and the number of intervals to estimate the integral.

How it is calculated

You choose one of four built-in functions (x², sin x, eˣ or √x), the limits a and b, and the number of intervals n. The tool computes the step h = (b − a) / n and then T = h × [ (f(a) + f(b)) / 2 + f(a+h) + f(a+2h) + … + f(a+(n−1)h) ]. Interior points count fully, the two end points count half. The sine is evaluated in radians. The upper limit must be larger than the lower limit, n is rounded to a whole number (2.5 becomes 3) and must be between 1 and 1,000,000, and √x needs a ≥ 0. You cannot enter your own formula or data points. The integral and the step are shown to 6 decimals.

Worked example

Take sin x from 0 to 3.14159 (about π) with n = 4. The step is h = 3.14159 / 4 = 0.785398. The end points give (0 + 0.000003) / 2, close to 0. The three inner points are sin(0.7854) = 0.7071, sin(1.5708) = 1 and sin(2.3562) = 0.7071, which sum to 2.4142. Multiplying 0.785398 × 2.4142 gives an integral of 1.896119. The exact area is 2, so four strips are about 5% low; n = 100 gives 1.999836.

Try this example →

Common mistakes

  • Typing the limits in degrees for sin x. The function works in radians, so 0 to 180 is not a half-wave; use 0 to 3.14159.
  • Entering n as the number of points. n is the number of intervals, and there are n + 1 points including both ends.
  • Putting the larger limit in a. If b is not greater than a the tool returns nothing, so swap them and change the sign of the answer yourself if you need the reverse direction.
  • Trusting a small n for a curved function. With n = 4 the sine area above is about 5% low; double n until the first digits stop changing.
  • Expecting a negative start for √x to work. The square root needs a ≥ 0, otherwise there is no result.

About this calculator

The composite trapezoidal rule approximates a definite integral by splitting the interval [a, b] into n equal-width strips of width h = (b−a)/n, treating each strip as a trapezoid under the curve, and summing their areas: ∫f(x)dx ≈ (h/2)[f(a) + 2f(x₁) + 2f(x₂) + ... + f(b)]. More strips means smaller trapezoids and a closer approximation to the true area.

It's one of the first numerical integration methods taught in calculus and numerical methods courses, and remains useful when a function has no closed-form antiderivative, or when you only have discrete data points (like sensor readings) rather than a formula. This calculator works on one of four built-in functions — x², sin(x), eˣ or √(x) — over your interval; it does not take your own formula or data points, so for measured data apply the formula by hand.

Was this helpful?

You can pick up to 3 reactions.

Comments (1)

  • Editorial team

    Not every function converges at the same pace. For the square root on 0 to 1, ten strips give 0.660509 and a thousand give 0.666660, so the error is still visible at 1,000 because the curve is steep at zero. Smooth curves such as e to the x settle far faster. A good habit is to double n and see which digits move. Which function would you like to be able to integrate here?

Popular calculators

All Calculators