# 定积分计算器

> The definite integral of any function f(x) between two limits, by adaptive Gauss–Kronrod quadrature to about 20 significant digits, with the area shaded.

交互版本：https://www.calcopenly.com/zh/math/integral-calculator
主题：数学计算器

A definite integral ∫ₐᵇ f(x) dx is the signed area between f and the x-axis from a to b, with area below the axis counted as negative. The calculator uses the 15-point Gauss–Kronrod rule from QUADPACK (routine QK15), which samples f at 15 points on each piece and compares the result with the embedded 7-point Gauss rule to estimate its own error. The piece with the largest error is split in two until the total estimated error falls below 10⁻²⁰ of the answer.

It suits integrals with no convenient antiderivative, such as the bell curve e^(−x²), and checking answers found by hand. The default, ∫₀¹ e^(−x²) dx, equals (√π/2)·erf(1) ≈ 0.7468241328 and took 45 evaluations of f over 2 subintervals.

Trig functions use radians, and limits accept expressions such as pi/2. Integrable endpoint singularities, like √x or ln x at 0, are handled because Gauss–Kronrod nodes never touch the endpoints. Swapping the limits flips the sign.

## 输入

- **Function f(x)**: Use x as the variable, e.g. x^2 * sin(x), 1/x, sqrt(x). Trig functions use radians here.
- **Lower limit a**: Numbers or expressions like pi/2
- **Upper limit b**

## 结果

- 积分 — 主要结果
- Estimated error
- Function evaluations
- Subintervals used

## 公式

$$
\begin{aligned} \int_a^b f(x)\,dx &\approx \frac{b-a}{2}\sum_{i=1}^{15} w_i\, f(t_i) \\[4pt] t_i &= \frac{a+b}{2} + \frac{b-a}{2}\,x_i \end{aligned}
$$

## 计算示例

### ∫₀¹ e^(−x²) dx

- Function f(x): exp(-x^2)
- Lower limit a: 0
- Upper limit b: 1
- **积分: 0.746824132812**
- 核验来源：(√π/2)·erf(1): Python decimal, erf by its Maclaurin series at 70 digits (hp.py)

### ∫₀^π sin x dx

- Function f(x): sin(x)
- Lower limit a: 0
- Upper limit b: pi
- **积分: 2**
- 核验来源：−cos π + cos 0 = 2 (antiderivative)

### ∫₁² 1/x dx

- Function f(x): 1/x
- Lower limit a: 1
- Upper limit b: 2
- **积分: 0.69314718056**
- 核验来源：ln 2: Python Decimal(2).ln()

### ∫₀³ x⁵eˣ dx

- Function f(x): x^5 * exp(x)
- Lower limit a: 0
- Upper limit b: 3
- **积分: 1,686.671880008638**
- 核验来源：Antiderivative eˣ(x⁵ − 5x⁴ + 20x³ − 60x² + 120x − 120) evaluated in Python decimal

### ∫₀¹ √x dx (endpoint where f′ is infinite)

- Function f(x): sqrt(x)
- Lower limit a: 0
- Upper limit b: 1
- **积分: 0.666666666667**
- 核验来源：2/3 from the antiderivative (2/3)x^(3/2)

### Reversed limits ∫₁⁰ x² dx

- Function f(x): x^2
- Lower limit a: 1
- Upper limit b: 0
- **积分: -0.333333333333**
- 核验来源：−(1³ − 0³)/3 = −1/3

## 常见问题

### What does a definite integral represent?

The signed area between the curve and the x-axis over an interval: area above the axis counts as positive and area below as negative. ∫₀^π sin x dx = 2 because one arch of the sine curve encloses an area of 2, while ∫₀^2π sin x dx = 0 because the second arch lies below the axis and cancels the first. It is also a total change: integrating speed over time gives distance traveled.

### How do you evaluate a definite integral by hand?

Find an antiderivative F with F′ = f, then subtract: ∫ₐᵇ f(x) dx = F(b) − F(a), which is the fundamental theorem of calculus. For ∫₁² 1/x dx, F(x) = ln x, so the answer is ln 2 − ln 1 ≈ 0.693147. When no elementary antiderivative exists, as for e^(−x²), a numerical rule like this one is the practical route.

### What is Gauss–Kronrod quadrature?

A rule that estimates an integral from a weighted sum of f at carefully placed points. The 7-point Gauss rule integrates every polynomial up to degree 13 exactly; Kronrod's extension adds 8 more points and reuses the first 7, so comparing the two estimates gives an error bound without extra evaluations. QUADPACK's QK15 routine, used here, pairs it with repeated splitting of the worst subinterval.

### What is the integral of e^(−x²)?

It has no antiderivative among elementary functions, so it is written with the error function: ∫₀ˣ e^(−t²) dt = (√π/2) erf(x). From 0 to 1 the value is about 0.7468241328, and over the whole real line it is √π ≈ 1.7724539. This Gaussian integral is what makes the normal distribution's total probability equal 1.

### Can a definite integral be negative?

Yes, when more of the area lies below the x-axis than above it, or when the limits run backward. ∫₁² (−x) dx = −1.5, and the integral of x² from 1 down to 0 is −1/3, the negative of ∫₀¹ x² dx = 1/3. For the total area regardless of sign, integrate the absolute value instead: ∫₀^2π |sin x| dx = 4, entered as abs(sin(x)).

### “定积分计算器”有多准确？

准确性取决于输入值和方法的假设。十进制运算使用50位有效数字，但估算、数值方法和源数据的精度可能较低；显示时的舍入并不能消除这些限制。 已按独立来源核验的计算示例：7。 例如，“∫₀¹ e^(−x²) dx”根据(√π/2)·erf(1): Python decimal, erf by its Maclaurin series at 70 digits (hp.py)进行核验。

### 这种方法出自哪里？

Piessens, de Doncker-Kapenga, Überhuber, Kahaner — QUADPACK (1983), routine QK15; Wolfram MathWorld — Gauss-Kronrod Quadrature; Laurie, Calculation of Gauss-Kronrod quadrature rules, Math. Comp. 66 (1997).

## 来源

- [Piessens, de Doncker-Kapenga, Überhuber, Kahaner — QUADPACK (1983), routine QK15](https://www.netlib.org/quadpack/qk15.f)
- [Wolfram MathWorld — Gauss-Kronrod Quadrature](https://mathworld.wolfram.com/Gauss-KronrodQuadrature.html)
- [Laurie, Calculation of Gauss-Kronrod quadrature rules, Math. Comp. 66 (1997)](https://doi.org/10.1090/S0025-5718-97-00861-2)
