Controls
Function f(x)
Which height to use
Readings
- Riemann sum
- 5.9063
- Exact integral
- 9
- Error (sum − exact)
- −3.0938
- Relative error
- 34.38%
- Strip width Δx
- 0.75
How to use this simulation
- Pick a function from “Function f(x)”: x², x³, sin x, eˣ or √x. The black curve is y = f(x). The two orange ticks on the axis mark the ends a and b of the interval you are measuring.
- The shaded strips are the Riemann sum. “Number of strips, n” sets how many there are, from 1 to 100. Start with n = 4 and see the rectangles stick out above or fall short of the curve.
- Choose “Which height to use”. Left end and right end take the height of the curve at the edge of each strip. Midpoint takes it in the middle. Trapezoid joins the two edge heights with a slanted top.
- Move the n slider up. The error between your “Riemann sum” and the “Exact integral” shrinks. Watch which rule shrinks it fastest. Press play to let n sweep upward by itself.
- Drag a and b to change the interval. Colour tells the sign: blue strips lie above the axis and count as positive, red strips lie below it and count as negative, so the sum is a net area.
- Read the error. “Error (sum − exact)” keeps its sign: plus means you overshot, minus means you undershot. “Relative error” says how big that is as a percentage of the true value.
Area of a shape with a curvy edge
Rectangles and triangles have formulas. A shape with a curved edge does not. Think of a piece of land bounded by a straight road on one side and a winding river on the other. There is no neat formula for its area. But there is a neat trick: cut the land into thin vertical strips.
Each thin strip is almost a rectangle, and you can find the area of a rectangle. Add the areas up and you have an estimate of the whole. Cut the strips thinner and the estimate improves. That is the entire idea behind integration.
Building a Riemann sum
Pick the interval [a, b] and the number of strips n. Every strip has the same width, Δx = (b − a) / n. For each strip choose a sample point, read the curve’s height there, and make a rectangle that wide and that tall. Its area is height × Δx.
Here is f(x) = x² on [0, 3] with n = 4. The strip width is Δx = 0.75. The exact area is 9, as we will check below. The Riemann sum is the total of the four rectangle areas.
Δx = (b − a) / n
Sₙ = f(x₁)·Δx + f(x₂)·Δx + … + f(xₙ)·Δxx₁, x₂, … are the sample points, one per strip
∫ from a to b of f(x) dx = lim (n → ∞) Sₙthe definite integral
Four ways to pick the height
The rule says where in the strip to read the height. Different choices give different answers, and each has a personality.
- Left end: height at the strip’s left edge. On a rising curve every rectangle sits under the curve, so the sum underestimates.
- Right end: height at the right edge. On a rising curve every rectangle pokes above the curve, so the sum overestimates.
- Midpoint: height in the middle. The overshoot on one side nearly cancels the shortfall on the other, so it is usually much more accurate.
- Trapezoid: average of the left and right sums. The slanted top hugs the curve better than a flat one.
The four rules on one example
All four rules on x² over [0, 3] with only four strips. The left sum is 5.9063 and the right sum is 12.6563, one under and one over the true value 9. Midpoint and trapezoid land much closer.
| Rule | Sum | Error |
|---|---|---|
| Left end | 5.9063 | −3.0938 |
| Right end | 12.6563 | +3.6563 |
| Midpoint | 8.8594 | −0.1406 |
| Trapezoid | 9.2813 | +0.2813 |
More strips, smaller error
Now keep the left rule but grow n. The table shows the sum and the error, plus the error multiplied by n. That last column settles near −13.5: so the error shrinks like 1 ÷ n. Double the strips, halve the error.
| n | Left sum | Error | Error × n |
|---|---|---|---|
| 1 | 0.0000 | −9.0000 | -9.000 |
| 2 | 3.3750 | −5.6250 | -11.250 |
| 4 | 5.9063 | −3.0938 | -12.375 |
| 10 | 7.6950 | −1.3050 | -13.050 |
| 100 | 8.8655 | −0.1346 | -13.455 |
Above and below the axis: signed area
A rectangle below the x-axis has a negative height, so it contributes a negative area. The Riemann sum, and the definite integral it leads to, are net areas: area above the axis minus area below. That is why the strips are coloured blue above and red below in the simulation.
If you want the plain total area, split the interval where the curve crosses the axis and add the sizes of the pieces.
From the sum to the integral
Let n go to infinity and the strips become infinitely thin. The sum settles on a single number, the definite integral. We rarely compute that limit by hand. Instead we use the antiderivative: if F′(x) = f(x), then the integral from a to b is F(b) − F(a).
The simulation uses exactly this to print “Exact integral”. For x² the antiderivative is x³/3, for x³ it is x⁴/4, for sin x it is −cos x, for eˣ it is eˣ, and for √x it is (2/3)x^(3/2).
∫ from a to b of f(x) dx = F(b) − F(a)where F′ = f
∫ x² dx = x³ / 3so x² over [0, 3] gives 27/3 = 9
Try it in the simulation
Six quick experiments, a minute each.
- Choose x² on [0, 3] with the left rule. Slide n from 1 to 100. What does the error do each time you double n?
- Switch to the midpoint rule at n = 4. How does its error compare to the left rule at n = 4? And at n = 8?
- Choose sin x and the right rule. Is the sum above or below the exact value? Why does it change if you move the interval to include the downward part of the wave?
- Choose x³ and set a = −2 and b = 2. The strips turn red on the left. What is the exact integral? Why?
- Choose √x with the left rule. The curve is very steep at 0, so convergence is slow. How many strips does it take to get the error under 0.05?
- Choose eˣ and compare left and right at n = 10. The exact answer sits between them. How close is the trapezoid sum?
Solved problems
Eight common questions. Every number below is computed with the same functions as the simulation.
Problem 1: x² on [0, 3] with four strips
Δx = 0.75. The left rule reads f at 0, 0.75, 1.5, 2.25. The sums for all four rules are in the table above: left 5.9063, right 12.6563. Exact: 27 ÷ 3 = 9.
Problem 2: how fast does the left sum converge?
Use the table in “More strips, smaller error”: n = 1 gives a terrible estimate, n = 10 is within about 1.3, and n = 100 is within about 0.135. The error is almost exactly 13.5 ÷ n. Predict the error at n = 1000 and check it in your head: about 0.0135.
Problem 3: midpoint against trapezoid
For x² on [0, 3] with n = 4, midpoint gives 8.8594 (error −0.1406) and trapezoid gives 9.2813 (error +0.2813). The errors have opposite signs and the trapezoid’s is about twice as large. Mixing two parts midpoint with one part trapezoid, (2M + T) ÷ 3, gives 9.0000, exactly right. This is the idea behind Simpson’s rule.
Problem 4: sin x, midpoint and trapezoid
Over [0, 3] the exact area is 1 − cos 3 = 1.9900. A midpoint sum with six strips gives 2.0109, error +0.0209. Over [0, π] the exact area is 2. A trapezoid sum with ten strips gives 1.9835, error −0.0165. Trapezoids on a bump always undershoot, because the chords lie below the curve.
Problem 5: x³ on [−2, 2], net area
The graph is odd: the area below on the left cancels the area above on the right, so the exact integral is 0. With four strips the left sum is -8, the right sum is 8 and the midpoint sum is 0. Left and right are equal and opposite, and the midpoint rule is exact by symmetry. The total unsigned area is 2 × 4.
Problem 6: eˣ on [0, 2], an increasing curve
With ten strips the left sum is 5.7714 and the right sum is 7.0492. The exact value e² − 1 = 6.3891 is between them, as it must be for an increasing curve. The trapezoid sum 6.4103 is the average of the two, and sits just above the exact value because eˣ is convex.
Problem 7: √x on [0, 4], slow at the start
Exact: (2/3) × 8 = 5.3333. √x climbs very steeply near 0, which spoils the quick convergence. The table shows the errors of the left and midpoint rules for three values of n.
| n | Left error | Midpoint error |
|---|---|---|
| 4 | −1.1871 | +0.0505 |
| 16 | −0.2747 | +0.0070 |
| 100 | −0.0416 | +0.0005 |
Problem 8: how many strips for an error below 0.01?
Take the trapezoid rule on x² over [0, 3]. The error is roughly 4.5 ÷ n², so we need 4.5 ÷ n² < 0.01, which gives n > 21.2. Testing: n = 21 has error +0.0102, not quite enough; n = 22 has error +0.0093, and the strip width is 0.1364.
Common mistakes
Four slips that cost marks every year.
- Using n points instead of n strips. Δx is (b − a) divided by the number of strips.
- Forgetting to multiply by Δx. Adding up the heights alone is not an area.
- Reading the right ends in the left rule (or the other way round). Write the sample points down first.
- Treating a negative integral as an error. It simply means more area below the axis than above.
Where Riemann sums are used
Distance travelled is the area under a velocity-time graph, and a car’s trip computer adds thin time-strips to get it. Total rainfall, the energy used by a house, the work done by a changing force, the amount of medicine in the blood: all areas under curves. Computers use these rules, in smarter forms, whenever a function has no neat antiderivative.
Exam corner
Typical SSC higher-math, HSC and first-year questions on this topic.
- Estimate an area using given rectangles or trapezoids and state whether it over- or under-estimates.
- Write a sum in Σ notation for given n, a and b.
- Evaluate a definite integral with the antiderivative and compare it to a sum.
- Say how the error changes when n doubles.
Revision summary
Δx = (b − a) / n. Sum of height × Δx. Left, right, midpoint, trapezoid. Error shrinks as n grows: like 1/n for left and right, like 1/n² for midpoint and trapezoid. Limit of the sums is the definite integral, F(b) − F(a).
Frequently asked questions
What is a Riemann sum?
It is an estimate of the area under a curve made by splitting the interval into strips, replacing each with a rectangle, and adding the rectangle areas.
What is the difference between left, right and midpoint sums?
Only where the rectangle’s height is read: at the left edge, the right edge, or the middle of each strip. The midpoint rule is usually the most accurate of the three.
Why does the sum get better as n increases?
Thinner strips fit the curve more closely, so the gap between each rectangle and the curve shrinks. In the limit it vanishes and the sum equals the integral.
How is a Riemann sum related to the integral?
The definite integral is the limit of the Riemann sums as n goes to infinity. In practice we compute it with an antiderivative: F(b) − F(a).
Why is my sum negative?
Strips below the x-axis count as negative area. If more of the region lies below the axis than above, the net result is negative.
When is the left sum an underestimate?
When the function is increasing on the whole interval. If it is decreasing, the left sum overestimates.
Which rule should I use in an exam?
Use whichever the question names. If you choose, the trapezoid or midpoint rule gives a better answer for the same number of strips. State your rule and show the table.
Keep studying this topic
The animation made the idea click; now turn it into marks. Syllabus, suggestions, textbooks and admission-test guides are below.
HSC
HSC Higher Mathematics: syllabus and preparation
Admission
Engineering admission test preparation
Textbook
Class 9-10 Mathematics textbook
SSC
SSC Mathematics: syllabus and preparation
SSC
SSC Higher Mathematics: syllabus and preparation
Textbook
Class 9-10 Higher Mathematics textbook
Admission
Jahangirnagar University mathematical and physical sciences unit
English
Paragraph: Artificial Intelligence
Bangla
রচনা: কৃত্রিম বুদ্ধিমত্তা (in Bangla)
SSC
SSC suggestions
HSC
HSC suggestions
Admission
University admission guide
SSC
SSC syllabus
HSC
HSC syllabus
Test prep
GRE Quantitative Reasoning guide
Test prep
Digital SAT Math guide
Scholarship
Scholarships to study abroad
Tool
Compound interest calculator
Career
Data scientist resume example
Career
Cover letter examples
More math animations
Grade 8–10
Pythagorean Theorem
The Pythagorean theorem explained: formula a² + b² = c², two proofs you can watch, the converse, Pythagorean triples and 10 worked examples. Drag the triangle yourself.
Grade 10–11
Trigonometric Ratios and the Unit Circle
Drag a point round the unit circle and watch sin, cos and tan change. Standard angle table, ASTC signs, identities, radians and graphs, with solved examples.
Grade 9–11
Quadratic functions and their graphs
Drag the vertex and change a, b, c to see how a quadratic function graph moves. Learn factoring, completing the square, the quadratic formula and discriminant.
Grade 9–10
Circle theorems
All the circle theorems with drag-and-check diagrams: angle at the centre, same segment, semicircle, cyclic quadrilateral, chords, tangents and alternate segment.
Grade 9–10
Heights and distances: elevation and depression angles
What angle of elevation and angle of depression mean, how the height-and-distance formula works, and how two observations solve a tower's height without ever measuring it — with an interactive simulation and solved problems.
Grade 9–11
Probability: experimental vs theoretical probability
What probability means, how the sample-space formula P(E) = n(E)/n(S) works, and why experimental frequency edges closer to theoretical probability the more you flip, roll or draw — with a coin, dice and coloured-ball simulator.
Grade 10–11
Arithmetic and Geometric Sequences
Learn the arithmetic and geometric sequence formulas for the nth term and sum, Gauss's pairing trick, and the sum-to-infinity formula a/(1−r), with a drag-and-slide bar-chart simulation and worked examples.
Grade 9–10
Mean, Median and Mode
Learn the mean, median and mode formulas, why the median resists an outlier while the mean does not, and the grouped-data median/mode formulas, by dragging points on a number line, with worked examples.
Grade 7–11
Sets and Venn Diagrams
Shade union, intersection, difference and complement on a live Venn diagram, drop numbers into regions, check n(A ∪ B) and test De Morgan’s laws, with solved problems.
Grade 8–10
Linear equations: graphs, slope and simultaneous pairs
See slope, intercepts and angle on a straight line, then graph two linear equations to find where they meet. Learn the ratio test for one, none or infinite solutions.
Grade 10–12
Graphs of sin, cos and tan
Plot y = A sin(Bx + C) + D with sliders: see amplitude, period, phase shift, range and the asymptotes of tan live. Trigonometric graphs with solved examples.
Grade 9–10
Completing the Square and the Quadratic Formula
Watch algebra tiles complete the square, then solve quadratic equations, find the vertex and see why the formula works. Free interactive simulation with solved examples.
Grade 7–10
Area of a Circle: Proof, Formula and Solved Problems
Cut a circle into slices, slide them into a rectangle and watch the area become πr². Free interactive simulation with circumference, pi, sectors, arcs and solved problems.
Grade 8–10
Volume and Surface Area of Solids: Cube, Cuboid, Cylinder, Cone, Sphere
Rotate six solids in 3D, unfold their nets and pour a cone into a cylinder to see why it takes exactly three. Free simulation with volume, CSA and TSA formulas and solved problems.
Grade 8–10
Similar Triangles: Scale Factor, AA, SSS, SAS and Shadow Heights
Scale a triangle with a slider and watch angles stay equal, side ratios stay k and area grow by k². Free interactive similar triangles simulation with AA, SSS, SAS tests and shadow problems.
Grade 9–11
Coordinate Geometry: Distance, Midpoint, Slope, Section Formula and Locus
Drag points on a grid and watch the distance formula, midpoint, slope and section formula update live. Free coordinate geometry simulation with the perpendicular-bisector locus and solved problems.
Grade 11–12
Conic Sections: Circle, Ellipse, Parabola and Hyperbola
Tilt a plane through a double cone and watch a circle, ellipse, parabola or hyperbola appear, with its standard equation, foci and eccentricity. Free conic sections simulation with solved problems.
Grade 9–11
Function Transformations: Shifts, Stretches and Reflections
Pick x², |x|, √x, sin x or 2^x and drag sliders for a, b, h and k. Watch shifts, stretches, squeezes and reflections move the graph, with the parent faded behind. Free simulation with solved problems.
Grade 11–12
Derivative as the Slope of a Tangent: Secant to Tangent
Drag a point P on x², x³, sin x, eˣ or 1/x and shrink the gap h to zero. Watch the secant become the tangent and its slope become the derivative, with the derivative graph below. Free simulation.
Grade 11–12
Limits and the ε–δ Definition: A Visual Guide
See the epsilon-delta definition of a limit. Pick a function, shrink ε and watch the δ band follow it, with left and right limits, a hole, sin x / x and a jump where no δ works. Free simulation.
Grade 11–12
3D Vectors: Sum, Dot Product and Cross Product
Drag to rotate two 3D vectors. See the sum as a parallelogram, the dot product as a shadow and an angle, and the cross product as a perpendicular arrow whose length is the area. Free simulation.
Grade 11–12
Matrix Transformations: Rotation, Reflection, Shear and the Determinant
Change a 2×2 matrix and watch the grid, a unit square and an F-shape move. See where i-hat and j-hat land, the determinant as signed area, and the inverse. Free simulation.
Grade 11–12
Complex Numbers: Sum, Product, Powers and Roots on the Argand Plane
Drag two complex numbers on the Argand plane. See the sum as a parallelogram, the product as a rotation and stretch, conjugates, powers as a spiral and roots of unity. Free simulation.
Grade 9–12
Binary Number System: Place Value, Conversion and Addition
Flip bits and see decimal, binary, octal and hex change together. Watch conversion by repeated division by 2, regrouping into octal and hex, and binary addition with carries. Free, with worked examples.
Animations in other subjects
Physics
Refraction of light
Physics
Ohm's law
Physics
Projectile motion
Physics
Simple pendulum
Physics
Electric field
Physics
Wave interference
Physics
Free Fall
Physics
Lens ray diagrams
Physics
Newton's Laws of Motion
Physics
Spherical mirror ray diagrams
Physics
Electromagnetic Induction
Physics
Conservation of Momentum and Collisions
Physics
Work, Energy and Power
Physics
Inclined Plane
Physics
Uniform circular motion
Physics
Transverse and Longitudinal Waves
Physics
Levers and moments
Physics
Centre of mass
Physics
Spring-mass SHM
Physics
Vector addition: triangle and parallelogram laws
Physics
Relative velocity: trains and river crossing
Physics
Kepler's laws and elliptical orbits
Physics
Newton’s law of gravitation, g and satellites
Physics
Standing waves in strings and pipes
Physics
Resonance tube and the speed of sound
Physics
Beats: when two close notes pulse
Physics
Doppler effect: moving sources, listeners and sonic booms
Physics
Prism, dispersion of light and the rainbow
Physics
Kirchhoff’s laws: junction rule and loop rule
Physics
Wheatstone bridge and metre bridge
Physics
Single-slit diffraction
Physics
Defects of the human eye and their correction
Physics
Polarisation of light: Malus’s law and Brewster’s law
Physics
Charging and discharging a capacitor: the RC time constant
Physics
Magnetic field lines: bar magnet, current-carrying wire and solenoid
Physics
AC generator
Physics
Transformer
Physics
Heat transfer: conduction, convection and radiation
Physics
Photoelectric effect: Einstein’s equation and the stopping potential
Physics
Motor effect: force on a current-carrying wire and the DC motor
Physics
Gas molecules and kinetic theory: pressure, temperature and speed
Physics
The semiconductor diode: p–n junction, I–V curve and rectifier
Physics
Radioactive decay: half-life, the decay law and penetration
Physics
The Bohr atom: orbits, energy levels and the hydrogen spectrum
Chemistry
Structure of the atom
Chemistry
Acids, Bases and the pH Scale
Chemistry
Electron configuration
Chemistry
Gas laws: Boyle, Charles, Gay-Lussac, Avogadro and PV = nRT
Chemistry
How an Ionic Bond Forms
Chemistry
Electrolysis and Faraday’s Laws
Chemistry
Covalent Bond
Chemistry
Periodic Trends
Chemistry
Reaction rate and collision theory
Chemistry
States of matter: solid, liquid, gas and the heating curve
Chemistry
Atomic orbitals: the shapes of s, p and d, quantum numbers and nodes
Chemistry
Molecular shapes and VSEPR theory: bond pairs, lone pairs and angles
Chemistry
The mole concept: molar mass, Avogadro’s number and molar volume
Chemistry
Diffusion and effusion: Graham’s law of gases
Chemistry
Balancing chemical equations: method, examples and practice
Chemistry
Chemical equilibrium: the equilibrium constant Kc and Le Chatelier’s principle
Chemistry
Titration: finding an unknown concentration with a burette and an indicator
Chemistry
Galvanic cell: the Daniell cell, EMF and the Nernst equation
Chemistry
Redox reactions: oxidation numbers, electron transfer and half-equations
Chemistry
Hydrocarbons: alkanes, alkenes, alkynes and structural isomers in 3D
Chemistry
Functional groups: alcohols, aldehydes, ketones, acids, esters and amines
Chemistry
Polymerisation: addition and condensation polymers, polythene and nylon
Chemistry
Separation techniques: filtration, distillation, chromatography, crystallisation
Chemistry
Crystal lattice: SC, BCC and FCC unit cells, packing efficiency and density
Chemistry
Radioactivity: Alpha, Beta, Gamma Decay and Half-Life
Biology
Mitosis cell division
Biology
Diffusion and Osmosis
Biology
Photosynthesis
Biology
The human heart: structure and function
Biology
Mendelian Genetics
Biology
DNA Replication
Biology
Cellular Respiration
Biology
Enzyme Action
Biology
The Nerve Impulse and the Action Potential
Biology
The Nephron and Urine Formation
Biology
Meiosis Cell Division
Biology
Digestive System
Biology
Breathing Mechanism: Inhalation and Exhalation
Biology
Protein synthesis
Biology
Blood circulation: double circulation and cardiac output
Biology
Cell structure and organelles: plant cell vs animal cell
Biology
Reflex action and the reflex arc
Biology
The human eye: parts, image formation and accommodation
Biology
Muscle contraction and the sliding-filament model
Biology
Transport in plants: xylem, phloem and transpiration
Biology
Food chain and food web: energy flow and the 10 % rule
Biology
Population growth: exponential and logistic curves
Biology
Natural selection: peppered moths and the sooty tree
Biology
Immune response: primary and secondary antibody response
Biology






















