keisoku

Trapezoidal Rule Calculator

Approximate the definite integral of f(x) using the trapezoidal rule. Split [a, b] into n subintervals and view the result, step size, and each sample point.

Input

Enter a function f(x), the limits a and b, and the number of subintervals n to approximate the definite integral with the trapezoidal rule.

e.g. sin(x), x^2, exp(-x^2). Supports pi, e, and implicit multiplication such as 2x.

Result

Approximation of ∫ from 0 to 3.1416 of f(x) dx

1.9998355039

Subintervals n

100

Step size h

0.0314159265

Sample points

101

Sample points

Rows are thinned out when there are many points. Endpoints have weight 1 and interior points have weight 2.

kxf(x)Weight
0001
10.03141592650.03141075912
20.06283185310.06279051952
30.09424777960.09410831332
40.12566370610.12533323362
50.15707963270.1564344652
60.18849555920.18738131462
70.21991148580.21814324142
80.25132741230.24868988722
90.28274333880.2789911062
100.31415926540.30901699442
110.34557519190.33873792022
120.37699111840.36812455272
130.4084070450.39714789062
140.43982297150.42577929162
150.4712388980.45399049972
160.50265482460.48175367412
170.53407075110.50904141582
180.56548667760.5358267952
190.59690260420.56208337792
200.62831853070.58778525232
210.65973445730.61290705372
220.69115038380.63742398972
230.72256631030.66131186532
240.75398223690.68454710592
250.78539816340.70710678122
260.81681408990.72896862742
270.84823001650.75011106962
280.8796459430.77051324282
290.91106186950.79015501242
300.94247779610.80901699442
310.97389372260.82708057432
321.00530964910.84432792552
331.03672557570.8607420272
341.06814150220.876306682
351.09955742880.89100652422
361.13097335530.90482705252
371.16238928180.91775462572
381.19380520840.92977648592
391.22522113490.9408807692
401.25663706140.95105651632
411.2880529880.96029368572
421.31946891450.96858316112
431.3508848410.97591676192
441.38230076760.98228725072
451.41371669410.98768834062
461.44513262070.99211470132
471.47654854720.99556196462
481.50796447370.99802672842
491.53938040030.99950656042
501.570796326812
511.60221225330.99950656042
521.63362817990.99802672842
531.66504410640.99556196462
541.69646003290.99211470132
551.72787595950.98768834062
561.7592918860.98228725072
571.79070781250.97591676192
581.82212373910.96858316112
591.85353966560.96029368572
601.88495559220.95105651632
611.91637151870.9408807692
621.94778744520.92977648592
631.97920337180.91775462572
642.01061929830.90482705252
652.04203522480.89100652422
662.07345115140.876306682
672.10486707790.8607420272
682.13628300440.84432792552
692.1676989310.82708057432
702.19911485750.80901699442
712.2305307840.79015501242
722.26194671060.77051324282
732.29336263710.75011106962
742.32477856370.72896862742
752.35619449020.70710678122
762.38761041670.68454710592
772.41902634330.66131186532
782.45044226980.63742398972
792.48185819630.61290705372
802.51327412290.58778525232
812.54469004940.56208337792
822.57610597590.5358267952
832.60752190250.50904141582
842.6389378290.48175367412
852.67035375560.45399049972
862.70176968210.42577929162
872.73318560860.39714789062
882.76460153520.36812455272
892.79601746170.33873792022
902.82743338820.30901699442
912.85884931480.2789911062
922.89026524130.24868988722
932.92168116780.21814324142
942.95309709440.18738131462
952.98451302090.1564344652
963.01592894740.12533323362
973.0473448740.09410831332
983.07876080050.06279051952
993.11017672710.03141075912
1003.141592653601

How it works

  • The composite trapezoidal rule divides the interval [a, b] into n equal subintervals and approximates each piece as a trapezoid, then sums the areas.
  • The step size is h = (b - a) / n and the sample points are x_k = a + k·h for k = 0, 1, …, n.
  • The approximation is h × ( f(x0)/2 + f(x1) + … + f(x_{n-1}) + f(xn)/2 ). Endpoints carry weight 1 and interior points carry weight 2.
  • Increasing n reduces the error and converges toward the true value; for a smooth f the error decreases roughly in proportion to h².
  • Expressions are evaluated by a built-in safe parser supporting + - * / ^, parentheses, implicit multiplication, the variable x, the constants pi and e, and functions such as sin, cos, tan, exp, log, and sqrt.

Reviews

Tell us what you think of this calculator.

Write a review

  1. Home
  2. Trapezoidal Rule Calculator