# What is the integral of a function?

Finds the antiderivative of a function of x, and the definite integral between two limits, each checked numerically.

- Page: https://www.acalculator.org/math/integral-calculator
- JSON spec: https://www.acalculator.org/math/integral-calculator.json
- Version: d2d21c76dece

## Default answer

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.

## Inputs

| Key | Label | Description |
| --- | --- | --- |
| f | Function f(x) | The function of x to integrate, typed like x^2 sin(x), e^(-x) or sqrt(1 - x^2). |
| type | Integral | Indefinite gives the antiderivative; definite also gives the area between two limits. |
| a | Lower limit a | Where the definite integral starts: a number or a constant such as pi/2. |
| b | Upper limit b | Where the definite integral ends: a number or a constant such as pi. |

## Outputs

| Key | Label | Description |
| --- | --- | --- |
| value | Definite integral | The integral of f from a to b: the signed area between the curve and the x axis. |
| antiderivative | Antiderivative | A function F(x) + C whose derivative is f(x), with C any constant. |
| exact | Exact value | The definite integral as an exact expression, F(b) − F(a). |

## 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.

## Assumptions

- 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

1. f = x^2 sin(x), type = 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.
2. f = x^2 sin(x), type = definite, a = 0, b = pi gives value = 5.869604, exact = π^2 - 4. Source: hand calculation in content.mdx: F(π) − F(0) = (π² − 2) − 2 = π² − 4; mpmath quad in docs/progress/WP-90.md.
3. f = 1/x, type = indefinite gives antiderivative = ln|x| + C. Source: standard table of integrals (the derivative of ln|x| is 1/x for x ≠ 0), content.mdx.
4. f = e^(-x^2), type = definite, a = 0, b = 1 gives value = 0.746824. Source: (√π/2) erf(1) = 0.7468241328124270, Abramowitz and Stegun 7.1 (erf(1) = 0.8427007929497149); mpmath in docs/progress/WP-90.md.

## FAQ

### 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.

## Sources

- OpenStax, Calculus Volume 1, section 5.3 The Fundamental Theorem of Calculus: https://openstax.org/books/calculus-volume-1/pages/5-3-the-fundamental-theorem-of-calculus
- OpenStax, Calculus Volume 2, section 3.1 Integration by Parts: https://openstax.org/books/calculus-volume-2/pages/3-1-integration-by-parts
- NIST Digital Library of Mathematical Functions, section 7.2 Error functions (erf and the integral of e^(−t²)): https://dlmf.nist.gov/7.2
