Ekuation

Math

Integral Calculator

The Integral Calculator computes definite integrals of any single-variable function entered as a standard math expression. It applies composite Simpson's 1/3 rule (the default), composite trapezoidal rule, or composite midpoint rule with error estimation via Richardson extrapolation. The interactive Mafs graph displays the shaded region between f(x) and the x-axis with color-coded positive and negative regions and an overlaid Riemann sum rectangle visualization controlled by a real-time slider.

Enter a mathematical expression using x as the variable.

Details: Most accurate (O(h^4))

Number of subdivisions for the numerical calculation.

Number of rectangles shown in the visualization.

Integral Calculator Tips

Click to show tips

Try an Example

Pick a scenario to see how the calculator works, then adjust the values

Basic Polynomial

Integrate x^2 from 0 to 1 using Simpson's rule. Exact answer: 1/3.

Key values: x^2 · [0, 1] · Simpson's rule

Trigonometric Integral

Integrate sin(x) from 0 to pi. Exact answer: 2.

Key values: sin(x) · [0, pi] · Exact: 2

Area Under a Bell Curve

Approximate the Gaussian integral e^(-x^2) from -3 to 3.

Key values: e^(-x^2) · [-3, 3] · Gaussian

Documentation

What Is a Definite Integral?

A definite integral computes the signed area between a function f(x)f(x) and the xx-axis over the interval [a,b][a, b]. It is denoted:

abf(x)dx\int_a^b f(x)\,dx

The Fundamental Theorem of Calculus (Part 2) connects antiderivatives to definite integrals: if F(x)=f(x)F'(x) = f(x), then

abf(x)dx=F(b)F(a)\int_a^b f(x)\,dx = F(b) - F(a)

However, many functions have no elementary antiderivative. For example, ex2e^{-x^2} and sin(x)x\frac{\sin(x)}{x} cannot be integrated symbolically. In these cases, numerical integration methods approximate the integral to high precision, which is exactly what this calculator does.

How to Use This Calculator

  1. Enter an expression in the input field. Use standard math notation:x^2, sin(x), exp(-x^2), x*exp(x). The variable must be x.
  2. Set the lower bound aa and upper bound bb.
  3. Choose an integration method (default: Simpson's 1/3 rule, the most accurate option).
  4. Click Calculate to see the numerical result, error estimate, and interactive shaded area graph.
  5. Adjust the Riemann rectangles slider to visualize how rectangles approximate the area under the curve. Watch the approximation converge as you increase the number of rectangles.

Formulas: Numerical Integration Methods

Simpson's 1/3 Rule (Default)

The most accurate of the three methods, with O(h4)O(h^4) convergence, exact for polynomials up to degree 3. For the full formula, error bounds, and guidance on when Simpson's rule is the best choice, see the Simpson's Rule Calculator guide.

Trapezoidal Rule

Simple and robust with O(h2)O(h^2) convergence, exact for linear functions. Especially effective for periodic functions over complete periods. For the full formula, error analysis, and strengths, see the Trapezoidal Rule Calculator guide.

Midpoint Rule

Same O(h2)O(h^2) convergence as trapezoidal but with half the error constant. Naturally robust for endpoint singularities. For the full formula, error analysis, and comparison with the trapezoidal rule, see the Midpoint Rule Calculator guide.

Richardson Extrapolation Error Estimate

This calculator estimates error by comparing results at nn and n/2n/2 subdivisions:

E^=InIn/2\hat{E} = |I_n - I_{n/2}|

This approximates the truncation error. It is not a statistical confidence interval. Smaller values indicate higher accuracy.

Convergence Comparison

MethodConvergenceError at n=100Exact for
Simpson's 1/3O(h4)O(h^4)1011\sim 10^{-11}Polynomials up to degree 3
TrapezoidalO(h2)O(h^2)105\sim 10^{-5}Linear functions
MidpointO(h2)O(h^2)105\sim 10^{-5}Linear functions

Real-World Examples

1. Parabolic Hill Cross-Section Area

A road cuts through a hill with cross-section described by y=0.01x2+0.6xy = -0.01x^2 + 0.6x meters, where xx runs from 0 to 60 m.

060(0.01x2+0.6x)dx=360 m2\int_0^{60} (-0.01x^2 + 0.6x)\,dx = 360 \text{ m}^2

Integration is needed because the height varies continuously — you cannot use a simple base-times-height formula.

2. Work Done by a Spring

A spring with constant k=4900k = 4900 N/m is compressed 0.15 m. The work done equals:

W=00.154900xdx=55.1 JW = \int_0^{0.15} 4900x\,dx = 55.1 \text{ J}

Because force varies with displacement (F=kxF = kx), integration is required to accumulate the total work.

3. Velocity to Displacement

A particle has velocity v(t)=t2+6tv(t) = -t^2 + 6t m/s. The displacement over 6 seconds:

06(t2+6t)dt=36 m\int_0^6 (-t^2 + 6t)\,dt = 36 \text{ m}

Displacement is the integral of velocity because velocity is the derivative of position.

4. Gaussian Integral (Probability)

The function ex2e^{-x^2} has no elementary antiderivative. The integral from 0 to 1 is:

01ex2dx0.7468\int_0^1 e^{-x^2}\,dx \approx 0.7468

This value is related to the error function erf(1)\text{erf}(1) and is fundamental in probability and statistics.

5. Consumer Surplus (Economics)

A demand curve is P=500.5QP = 50 - 0.5Q with equilibrium at Q=53.33Q = 53.33, P=23.33P = 23.33. Consumer surplus:

CS=053.33(500.5Q)dQP×Q$711CS = \int_0^{53.33} (50 - 0.5Q)\,dQ - P \times Q \approx \$711

Signed Area vs. Total Area

This is the most common student misconception in integral calculus. The definite integral computes signed area: regions above the xx-axis are positive, and regions below are negative.

Example:

02πsin(x)dx=0(signed area)\int_0^{2\pi} \sin(x)\,dx = 0 \quad \text{(signed area)}

The positive lobe (from 0 to π\pi) and the negative lobe (from π\pi to 2π2\pi) cancel exactly. However, the total area (integral of f(x)|f(x)|) is:

02πsin(x)dx=4(total area)\int_0^{2\pi} |\sin(x)|\,dx = 4 \quad \text{(total area)}

This calculator displays both values. If you expected a positive area but got zero (or a small number), check the Total Area result.

Common Integration Techniques

When computing integrals by hand, these techniques help find antiderivatives:

TechniqueFormulaUse When
u-Substitutionf(g(x))g(x)dx=f(u)du\int f(g(x))g'(x)\,dx = \int f(u)\,duComposite function with inner derivative present
Integration by Partsudv=uvvdu\int u\,dv = uv - \int v\,duProduct of two functions (use LIATE rule)
Partial FractionsP(x)Q(x)=Axr1+Bxr2+\frac{P(x)}{Q(x)} = \frac{A}{x-r_1} + \frac{B}{x-r_2} + \cdotsRational functions where deg(P) < deg(Q)
Trig Substitutiona2x2x=asinθ\sqrt{a^2 - x^2} \to x = a\sin\thetaIntegrands with radical expressions

Frequently Asked Questions

What if my function has no elementary antiderivative?

Functions like ex2e^{-x^2} and sin(x)x\frac{\sin(x)}{x} are proven non-elementary by Liouville's theorem. The calculator uses numerical methods automatically. The result is an approximation shown with the \approx symbol.

Why is my result 0 when I expected a positive area?

The integral computes signed area. If f(x)f(x) is negative over part of [a,b][a, b], those regions subtract. Use the "Total Area" result, which computes abf(x)dx\int_a^b |f(x)|\,dx instead.

What does the error estimate mean?

The error estimate is InIn/2|I_n - I_{n/2}|, comparing results at nn and n/2n/2 subdivisions. It approximates the truncation error from the numerical method, not a statistical confidence interval. Smaller is better.

Why does my integral appear to diverge?

If f(x)f(x) has a vertical asymptote within [a,b][a, b] (e.g., 1/x21/x^2 on [1,1][-1, 1]), the integral diverges and the calculator reports an error. Try excluding the singularity from the bounds.

Which method should I use?

Use Simpson's rule (default) for smooth functions — it achieves approximately 11 correct digits with n=1000n = 1000. Use Midpoint rule when f(x)f(x) is undefined at the endpoints (e.g., 1/x1/\sqrt{x} at x=0x = 0). Trapezoidal is rarely preferred over either but is included for educational comparison.

References

  • OpenStax. “The Fundamental Theorem of Calculus.” Calculus Volume 1, Section 5.3. https://openstax.org/books/calculus-volume-1/pages/5-3-the-fundamental-theorem-of-calculus
  • Wikipedia. “Fundamental theorem of calculus.” https://en.wikipedia.org/wiki/Fundamental_theorem_of_calculus
  • Wikipedia. “Simpson’s rule.” https://en.wikipedia.org/wiki/Simpson%27s_rule
  • Mathematics LibreTexts. “Numerical Integration.” https://math.libretexts.org/Courses/Community_College_of_Denver/MAT_2420_Calculus_II/03:_Techniques_of_Integration/3.06:_Numerical_Integration
  • Wikipedia. “Romberg’s method.” https://en.wikipedia.org/wiki/Romberg%27s_method

Disclaimer

All results are numerical approximations. The accuracy depends on the smoothness of f(x)f(x), the interval width, and the number of subdivisions. For integrals with singularities or highly oscillatory behavior, results may be less accurate. Verify critical calculations with additional methods. This calculator is intended for educational use.

Specialized Calculators

Choose from 7 specialized versions of this calculator, each optimized for specific use cases and calculation methods.

Related Calculators

6 Calculators

More Math calculators

Calculator Search

Search and find calculators