What is the integral of a function?
Type a function of x to get its antiderivative. Choose Definite and enter two limits to get the area under the curve as well.
- Antiderivative
- 2 cos(x) - x^2 cos(x) + 2x sin(x) + C
An antiderivative of x^2 sin(x) is 2 cos(x) - x^2 cos(x) + 2x sin(x) + C.
Antiderivative: 2 cos(x) - x^2 cos(x) + 2x sin(x) + C. An antiderivative of x^2 sin(x) is 2 cos(x) - x^2 cos(x) + 2x sin(x) + C.
The function and the area under it
How to calculate
Finds the antiderivative of a function of x, and the definite integral between two limits, each checked numerically.
Example with the default inputs (Function f(x) x^2 sin(x), Integral Indefinite): An antiderivative of x^2 sin(x) is 2 cos(x) - x^2 cos(x) + 2x sin(x) + C.
Method: Symbolic integration by a computer algebra system (nerdamer); the answer shows only when F′(x) equals f(x) at 20 points, and a definite integral F(b) − F(a) also matches numeric integration.
- The variable is x; log and ln are the natural logarithm; angles are in radians.
- The constant of integration C is any real number; ln|u| is shown where the algebra gives ln(u), when both check.
- A definite integral may have f infinite at an end (the limit of F there is used, or the page says it diverges) and removable gaps inside; a pole inside gives no value.
- An answer that fails its numeric check is never shown ("No verified answer").
Worked examples
Each example is checked against the calculator on every build.
- Function f(x) x^2 sin(x), Integral Indefinite gives Antiderivative 2 cos(x) - x^2 cos(x) + 2x sin(x) + C.Source: hand calculation in content.mdx: integration by parts twice; mpmath check in docs/progress/WP-90.md
- Function f(x) x^2 sin(x), Integral Definite, Lower limit a 0, Upper limit b pi gives Definite integral 5.869604, Exact value π^2 - 4.Source: hand calculation in content.mdx: F(π) − F(0) = (π² − 2) − 2 = π² − 4; mpmath quad in docs/progress/WP-90.md
- Function f(x) 1/x, Integral Indefinite gives Antiderivative ln|x| + C.Source: standard table of integrals (the derivative of ln|x| is 1/x for x ≠ 0), content.mdx
- Function f(x) e^(-x^2), Integral Definite, Lower limit a 0, Upper limit b 1 gives Definite integral 0.746824.Source: (√π/2) erf(1) = 0.7468241328124270, Abramowitz and Stegun 7.1 (erf(1) = 0.8427007929497149); mpmath in docs/progress/WP-90.md
How it works
The calculator finds an antiderivative F(x) of the function f(x) you type, so that F′(x) = f(x). It uses a computer algebra system (nerdamer, open source) to do the algebra, and when that finds nothing, standard methods: trigonometric identities (tan² = sec² − 1, sin 2u = 2 sin u cos u), partial fractions with completing the square, substitutions (u = eˣ, √x, ln x, sin x, cos x, and tan(x/2)), integration by parts for a logarithm and for g(x)/x² or g(x)/x³, a table of standard forms (such as √(a² − x²) and 1/√(x² + a²)), and splitting |ax + b| at its root. The algebra runs after you start typing, in the background, so the page stays fast.
For a definite integral from a to b it uses the fundamental theorem of calculus:
∫ from a to b of f(x) dx = F(b) − F(a)
The result is shown exactly (for example π² − 4) and as a number to 10 significant figures.
Every answer is checked before it is shown. An answer that fails its check is never shown; the page says "No verified answer" instead.
- Antiderivative: at 20 points x, the slope of F is measured numerically (a five-point central difference with step h = 0.0001 × max(1, |x|), repeated with h/2) and compared with f(x). They must agree to 1 part in a million. Points where f or F is not a real number (for example ln of a negative number) are skipped, and so are points where the two steps disagree, which happens next to a pole, a jump, or a corner such as |x| at 0. The points are fixed pseudo-random numbers, mostly between −4 and 4, some up to ±10.
- Definite integral: F(b) − F(a) must also agree with a numeric integral of f from a to b (adaptive Gauss-Kronrod quadrature, 7 and 15 points, starting from 16 equal pieces) to 1 part in 10 million of the integral of |f|. An antiderivative that jumps inside [a, b] although f is finite there (the tan(x/2) substitution gives one, at odd multiples of π) has its jumps taken out of F(b) − F(a); the value is then shown without an exact form.
- f infinite at an end (an improper integral): when f is not finite at a or b, as 1/√x is at 0, the calculator uses the limit of F at that end from inside the interval. If the limit is a number, the integral converges and has that value: ∫ from 0 to 1 of 1/√x dx = 2√1 − 2√0 = 2, and ∫ from 0 to 1 of ln(x) dx = −1. The numeric check then uses tanh-sinh quadrature, which handles a singularity at an end. If F is infinite at that end (ln|x| at 0, for 1/x), the integral diverges and the page says so.
- A gap inside [a, b]: if f is undefined at a point inside but has the same finite value on both sides (sin(x)/x at 0, where both sides approach 1), the gap is removable: it changes no area, and the calculator answers as usual (∫ from −1 to 1 of sin(x)/x dx = Si(1) − Si(−1) = 1.892166141). If f is infinite at a point inside (a pole, as 1/x² at 0, or tan(x) at π/2), the integral does not exist as a number and the page says so. If f is not a real number on part of [a, b] (ln(x) for x < 0), the page says that too.
- Logarithms: where the algebra gives ln(u), the page shows ln|u| when that also passes the check, because its derivative is the same and it is defined on both sides of u = 0.
If neither the algebra nor these methods find a formula, or the work takes more than 3 seconds, the page says so. Some integrals, like that of x^x or sin(x)/ln(x), have no formula in elementary functions; others have one the calculator does not find.
What you can type
- The variable is x. Numbers can have decimals (2.5).
- Operations: + − * / and ^ for powers. Brackets group. A number or bracket next to a letter multiplies: 2x, 3(x + 1), x sin(x).
- Constants: pi (or π) and e.
- Functions: sqrt, ln (and log, the same natural logarithm), exp, abs (or |x|), sin, cos, tan, sec, csc, cot, asin, acos, atan (arcsin, arccos, arctan also work), sinh, cosh, tanh. Angles are in radians. sin x without brackets means sin(x); sin x^2 means sin(x²).
- The limits a and b are numbers or constant expressions: 0, −1, 2.5, pi, pi/2, e.
How answers are written
The antiderivative is written in the same syntax you type, then + C: ^ for powers, a space or a number before a letter for multiplication, |u| for absolute value, π for pi, ln for the natural logarithm. Special functions appear where the integral needs one: erf(x) (the error function, from the integral of e^(−x²)), Si(x) (the sine integral, from sin(x)/x), Ci(x) (the cosine integral, from cos(x)/x), Ei(x) (the exponential integral, from eˣ/x), Shi(x) and Chi(x) (the hyperbolic sine and cosine integrals, from sinh(x)/x and cosh(x)/x). Ci and Chi are written with |x| (Ci(|x|)), so the answer is real on both sides of 0. A power of a logarithm is written with brackets, (ln|x|)^2, because ln|x|^2 means ln(|x|²); a logarithm of a positive number has no bars, ln(2). Two correct antiderivatives may look different and differ by a constant.
Assumptions
- The variable is x, angles are in radians, and log means the natural logarithm.
- C is any real constant.
- A definite integral needs finite limits a and b. f may be infinite at a or b (then the integral converges or diverges, as above) and may have removable gaps inside, but no pole inside and no part of [a, b] where it is not real.
- Only real values count: a point where f(x) is not a real number is not used in the check.
Worked examples by hand
∫ x² sin(x) dx. Integrate by parts with u = x² and dv = sin(x) dx, so du = 2x dx and v = −cos(x):
∫ x² sin(x) dx = −x² cos(x) + ∫ 2x cos(x) dx.
Integrate by parts again with u = 2x and dv = cos(x) dx: ∫ 2x cos(x) dx = 2x sin(x) − ∫ 2 sin(x) dx = 2x sin(x) + 2 cos(x). So the answer is 2 cos(x) − x² cos(x) + 2x sin(x) + C. Check: the derivative is −2 sin(x) − 2x cos(x) + x² sin(x) + 2 sin(x) + 2x cos(x) = x² sin(x).
∫ from 0 to π of x² sin(x) dx. With F(x) = 2 cos(x) − x² cos(x) + 2x sin(x): F(π) = −2 + π² + 0 = π² − 2, and F(0) = 2. So the integral is (π² − 2) − 2 = π² − 4 = 5.869604401.
∫ 1/x dx = ln|x| + C. For x > 0 the derivative of ln(x) is 1/x. For x < 0, ln|x| = ln(−x) and its derivative is (−1)/(−x) = 1/x.
∫ from 0 to 1 of e^(−x²) dx. This function has no elementary antiderivative. The error function is defined as erf(x) = (2/√π) ∫ from 0 to x of e^(−t²) dt, so the antiderivative is (√π/2) erf(x) and the integral is (√π/2)(erf(1) − erf(0)) = (√π/2) × 0.8427007929 = 0.7468241328.
A few common integrals
| f(x) | Antiderivative F(x) |
|---|---|
| xⁿ (n ≠ −1) | xⁿ⁺¹/(n + 1) + C |
| 1/x | ln|x| + C |
| eˣ | eˣ + C |
| sin(x) | −cos(x) + C |
| cos(x) | sin(x) + C |
| 1/(1 + x²) | atan(x) + C |
Other questions people ask
What is an integral?
An integral of f(x) is a function F(x) whose derivative is f(x), so integration undoes differentiation. The antiderivative of 2x is x², because the derivative of x² is 2x. A definite integral from a to b is the signed area between the curve and the x-axis over that interval.
What is the difference between a definite and an indefinite integral?
An indefinite integral is a family of functions, F(x) + C. A definite integral is one number: F(b) − F(a), by the fundamental theorem of calculus. The constant C cancels in that difference, so any antiderivative gives the same area.
Why is there a + C at the end?
The derivative of a constant is 0, so x² + 5 and x² − 1 both have derivative 2x. Every antiderivative of 2x is x² + C for some constant C. Two correct answers can look different and still differ only by a constant: sin²(x) and −cos²(x) are both antiderivatives of 2 sin(x) cos(x).
How do I type the function?
Use x as the variable, ^ for powers, and brackets where they help: x^2 sin(x), e^(-x), sqrt(1 - x^2), 1/(x^2 + 1). A number next to a letter multiplies (2x), and a space between factors multiplies too (x cos(x)). ln and log are both the natural logarithm, and angles are in radians.
What does "No verified answer" mean?
Every answer is checked before it is shown: the calculator differentiates the antiderivative numerically at 20 points and compares it with your function. If the check fails, or no formula is found, or the work takes over 3 seconds, the page says so instead of showing an answer it could not check. Some integrals, like that of x^x, have no formula in elementary functions; for others a formula exists but the calculator does not find it.
Why does the answer show ln|x| and not ln(x)?
The derivative of ln|x| is 1/x for every x except 0, while ln(x) is only defined for positive x. So ln|x| + C covers both sides of 0. It also makes definite integrals over negative numbers work: the integral of 1/x from −2 to −1 is ln 1 − ln 2 = −ln 2.