Lesson 4 of 18
Improper Integrals
Improper Integrals
An integral with an infinite limit is defined as a limit:
If the limit exists, the integral converges. Otherwise, it diverges.
Key Examples
| Integral | Result | Converges? |
|---|---|---|
| int_1^{infty} rac{1}{x} , dx | No | |
| int_1^{infty} rac{1}{x^2} , dx | Yes | |
| int_1^{infty} rac{1}{x^p} , dx | rac{1}{p-1} | Yes if |
The p-Test
int_1^{infty} rac{1}{x^p} , dx converges if and only if .
This is why the harmonic series sum rac{1}{n} diverges (), but sum rac{1}{n^2} converges ().
Numerical Approach
Integrate to a large finite :
The truncation error is roughly . For rac{1}{x^2}, this is rac{1}{T}, so gives 5-decimal accuracy.
Your Task
Implement double improper_integral(double (*f)(double), double a, double T, int n) that approximates using the midpoint rule.
TCC compiler loading...
Loading...
Click "Run" to execute your code.