---
title: "Integrate"
language: "en"
type: "Symbol"
summary: "Integrate[f, x] gives the indefinite integral \\[Integral]f d x. Integrate[f, {x, xmin, xmax}] gives the definite integral \\[Integral]_xmin^xmax\\ f\\ d x. Integrate[f, {x, xmin, xmax}, {y, ymin, ymax}, ...] gives the multiple integral \\[Integral]_xmin^xmaxd x \\[Integral]_ymin^ymaxd y\\ \\ ...\\ f. Integrate[f, {x, y, ...} \\[Element] reg] integrates over the geometric region reg."
keywords: 
- anti-derivative
- area
- areas
- calculus
- differential equations
- Dwight's tables
- Gradshteyn-Ryzhik
- integration
- integration over regions
- Marichev-Adamchik methods
- measures
- Mellin transform methods
- mensuration
- multiple integrals
- region integrals
- Risch algorithm
- Slater's Theorem
- surface integrals
- volume integrals
- volumes
- int
- Int
- integrate
- intparts
- polyint
canonical_url: "https://reference.wolfram.com/language/ref/Integrate.html"
source: "Wolfram Language Documentation"
related_guides: 
  - 
    title: "Calculus"
    link: "https://reference.wolfram.com/language/guide/Calculus.en.md"
  - 
    title: "Functions of Complex Variables"
    link: "https://reference.wolfram.com/language/guide/FunctionsOfComplexVariables.en.md"
  - 
    title: "Geometric Computation"
    link: "https://reference.wolfram.com/language/guide/GeometricComputation.en.md"
  - 
    title: "Mathematical Data"
    link: "https://reference.wolfram.com/language/guide/MathematicalData.en.md"
  - 
    title: "Solvers over Regions"
    link: "https://reference.wolfram.com/language/guide/GeometricSolvers.en.md"
  - 
    title: "Symbolic Vectors, Matrices and Arrays"
    link: "https://reference.wolfram.com/language/guide/SymbolicArrays.en.md"
  - 
    title: "Precollege Education"
    link: "https://reference.wolfram.com/language/guide/PrecollegeEducation.en.md"
  - 
    title: "Integral Transforms"
    link: "https://reference.wolfram.com/language/guide/IntegralTransforms.en.md"
  - 
    title: "Scientific Models"
    link: "https://reference.wolfram.com/language/guide/ScientificModels.en.md"
  - 
    title: "Analytic Number Theory"
    link: "https://reference.wolfram.com/language/guide/AnalyticNumberTheory.en.md"
  - 
    title: "Multiplicative Number Theory"
    link: "https://reference.wolfram.com/language/guide/MultiplicativeNumberTheory.en.md"
  - 
    title: "Polygons"
    link: "https://reference.wolfram.com/language/guide/Polygons.en.md"
  - 
    title: "Polyhedra"
    link: "https://reference.wolfram.com/language/guide/Polyhedra.en.md"
related_tutorials: 
  - 
    title: "Symbolic Mathematics: Basic Operations"
    link: "https://reference.wolfram.com/language/tutorial/SymbolicCalculations.en.md"
  - 
    title: "Simplifying Algebraic Expressions"
    link: "https://reference.wolfram.com/language/tutorial/AlgebraicCalculations.en.md#16626"
  - 
    title: "Integration"
    link: "https://reference.wolfram.com/language/tutorial/Calculus.en.md#26107"
  - 
    title: "Indefinite Integrals"
    link: "https://reference.wolfram.com/language/tutorial/Calculus.en.md#6667"
  - 
    title: "Integrals over Regions"
    link: "https://reference.wolfram.com/language/tutorial/Calculus.en.md#489977920"
  - 
    title: "Implementation notes: Algebra and Calculus"
    link: "https://reference.wolfram.com/language/tutorial/SomeNotesOnInternalImplementation.en.md#11173"
---
# Integrate (∫)

Integrate[f, x] gives the indefinite integral $\int f dx$. 

Integrate[f, {x, xmin, xmax}] gives the definite integral $\int _{x_{\text{\textit{min}}}}^{x_{\text{\textit{max}}}} f dx$. 

Integrate[f, {x, xmin, xmax}, {y, ymin, ymax}, …] gives the multiple integral $\int _{x_{\text{\textit{min}}}}^{x_{\text{\textit{max}}}}dx\int _{y_{\text{\textit{min}}}}^{y_{\text{\textit{max}}}}dy \ldots 
f$. 

Integrate[f, {x, y, …}∈reg] integrates over the geometric region reg.

## Details and Options

* ``Integrate[f, x]`` can be entered as ``∫f\[DifferentialD]x``.

* ``∫`` can be entered as esc`` int ``esc or [`\[Integral]`](https://reference.wolfram.com/language/ref/character/Integral.en.md).

* ``\[DifferentialD]`` is not an ordinary ``d``; it is entered as esc`` dd ``esc or [`\[DifferentialD]`](https://reference.wolfram.com/language/ref/character/DifferentialD.en.md).

* ``Integrate[f, {x, y, …}∈reg]`` can be entered as ``∫{x, y, …}∈regf``.

* ``Integrate[f, {x, xmin, xmax}]`` can be entered with ``xmin`` as a subscript and ``xmax`` as a superscript to ``∫``.

* Multiple integrals use a variant of the standard iterator notation. The first variable given corresponds to the outermost integral and is done last. »

* ``Integrate`` can evaluate integrals of rational functions. It can also evaluate integrals that involve exponential, logarithmic, trigonometric, and inverse trigonometric functions, so long as the result comes out in terms of the same set of functions.

* ``Integrate`` can give results in terms of many special functions.

* ``Integrate`` carries out some simplifications on integrals it cannot explicitly do.

* You can get a numerical result by applying ``N`` to a definite integral. »

* You can assign values to patterns involving ``Integrate`` to give results for new classes of integrals.

* The integration variable can be a construct such as ``x[i]`` or any expression whose head is not a mathematical function.

* For indefinite integrals, ``Integrate`` tries to find results that are correct for almost all values of parameters.

* For definite integrals, the following options can be given:

|                      |               |                                                                    |
| :------------------- | :------------ | :----------------------------------------------------------------- |
| Assumptions          | \$Assumptions | assumptions to make about parameters                               |
| GenerateConditions   | Automatic     | whether to generate answers that involve conditions on parameters  |
| GeneratedParameters  | None          | how to name generated parameters                                   |
| PrincipalValue       | False         | whether to find Cauchy principal values                            |

* ``Integrate`` can evaluate essentially all indefinite integrals and most definite integrals listed in standard books of tables.

* In ``StandardForm``, ``Integrate[f, x]`` is output as ``∫f\[DifferentialD]x``.

---

## Examples (189)

### Basic Examples (4)

An indefinite integral:

```wl
In[1]:= Integrate[x ^ 2 + Sin[x], x]

Out[1]= (x^3/3) - Cos[x]
```

---

Compute a definite integral:

```wl
In[1]:= Integrate[1 / (x ^ 3 + 1), {x, 0, 1}]

Out[1]= (1/18) (2 Sqrt[3] π + Log[64])
```

Visualize the area given by this integral:

```wl
In[2]:= Plot[(1/x^3 + 1), {x, 0, 1}, Filling -> Axis]

Out[2]= [image]
```

---

Use esc`` int ``esc to enter ``∫`` and esc`` dd ``esc to enter ``\[DifferentialD]`` :

```wl
In[1]:= ∫Sqrt[x + Sqrt[x]]\[DifferentialD]x

Out[1]= (1/12) (Sqrt[Sqrt[x] + x] (-3 + 2 Sqrt[x] + 8 x) + 3 ArcTanh[(Sqrt[Sqrt[x] + x]/1 + Sqrt[x])])

In[2]:= TraditionalForm[%]

Out[2]//TraditionalForm= $$\frac{1}{12} \left(\sqrt{x+\sqrt{x}} \left(8 x+2 \sqrt{x}-3\right)+3 \tanh ^{-1}\left(\frac{\sqrt{x+\sqrt{x}}}{\sqrt{x}+1}\right)\right)$$
```

---

Use ctrl+_ to enter the lower limit, then ctrl+% for the upper limit:

```wl
In[1]:= Subsuperscript[∫, 0, ∞]Log[x] Exp[-x^2]\[DifferentialD]x

Out[1]= -(1/4) Sqrt[π] (EulerGamma + Log[4])
```

### Scope (78)

#### Basic Uses (13)

Compute an indefinite integral:

```wl
In[1]:= int = Integrate[1 / (x ^ 3 + 1), x]

Out[1]= (ArcTan[(-1 + 2 x/Sqrt[3])]/Sqrt[3]) + (1/3) Log[1 + x] - (1/6) Log[1 - x + x^2]
```

Verify the answer by differentiation:

```wl
In[2]:= D[int, x]//Simplify

Out[2]= (1/1 + x^3)
```

---

Use esc`` intt ``esc to enter a template $\int \square  \, d\square$ and tab to move between fields:

```wl
In[1]:= ∫(a x ^ 2  + b x  + c)\[DifferentialD]x

Out[1]= c x + (b x^2/2) + (a x^3/3)
```

---

Include the constant of integration in an indefinite integral:

```wl
In[1]:= Integrate[x ^ 2, x, GeneratedParameters -> C]

Out[1]= (x^3/3) + C[1]
```

---

Compute a definite integral over a finite interval:

```wl
In[1]:= Integrate[(2x + 3) / (x ^ 2 + 5x + 6), {x, 0, 2}]

Out[1]= Log[(125/54)]
```

Infinite interval:

```wl
In[2]:= Integrate[BesselJ[2, x] / (1 + x ^ 2), {x, 0, ∞}]

Out[2]= (1/6) (2 - 3 π BesselI[2, 1] + 3 π StruveL[2, 1])
```

Doubly infinite interval:

```wl
In[3]:= Integrate[Sin[x] / x, {x, -∞, ∞}]

Out[3]= π
```

---

Use esc`` dintt ``esc to enter a template $\int_{\square }^{\square } \square  \, d\square$ and tab to move between fields:

```wl
In[1]:= Subsuperscript[∫, 0, π]Cos[x]\[DifferentialD]x

Out[1]= 0
```

---

Integrate a function with a symbolic parameter:

```wl
In[1]:= Integrate[(a x/x^3 + 2), {x, 1, ∞}]

Out[1]= (a (Sqrt[3] π - 2 Sqrt[3] ArcTan[(-1 + 2^2 / 3/Sqrt[3])] - Log[4 + 2 2^1 / 3 - 2 2^2 / 3] + 2 Log[2 + 2^2 / 3])/6 2^1 / 3)
```

An integral that only converges for some values of parameters:

```wl
In[2]:= Integrate[Exp[-c x^2], {x, -∞, ∞}]

Out[2]= ConditionalExpression[Sqrt[Pi]/Sqrt[c], Re[c] > 0]
```

Specify alternate assumptions to use:

```wl
In[3]:= Integrate[Exp[-c x^2], {x, -∞, ∞}, Assumptions -> Re[c] == 0]

Out[3]= ((-c)^3 / 4 Sqrt[(π/2)] (-1 + Sign[c])/c^5 / 4)
```

---

Multivariate integrals:

```wl
In[1]:= Integrate[(BesselJ[3, y]/x + 1), {x, 0, 5}, {y, 0, 5}]

Out[1]= -((-1 + (2/5) BesselJ[1, 5] + BesselJ[2, 5]) Log[6])

In[2]:= Integrate[Exp[-x + y], {x, 0, ∞}, {y, 0, 1}]

Out[2]= -1 + E
```

---

Multiple integral with ``x`` integration last:

```wl
In[1]:= Integrate[Sin[x y], {x, 0, 1}, {y, 0, x}]

Out[1]= (1/2) (EulerGamma - CosIntegral[1])
```

In ``StandardForm``, the differential ``\[DifferentialD]y`` precedes ``\[DifferentialD]x`` :

```wl
In[2]:= Subsuperscript[∫, 0, 1]Subsuperscript[∫, 0, x]Sin[x y]\[DifferentialD]y\[DifferentialD]x

Out[2]= (1/2) (EulerGamma - CosIntegral[1])
```

Visualize the function over the domain of integration:

```wl
In[3]:= Plot3D[Sin[x y], {x, y}∈Triangle[{{0, 0}, {0, 1}, {1, 0}}]]

Out[3]= [image]
```

---

Integrals over standard regions:

```wl
In[1]:= Integrate[1, {x, y}∈Circle[]]

Out[1]= 2 π
```

The character ``∈`` can be entered as esc`` el ``esc or [`\[Element]`](https://reference.wolfram.com/language/ref/character/Element.en.md) :

```wl
In[2]:= Integrate[1, x∈Ball[3]]

Out[2]= (4 π/3)
```

Enter a region specification $\text{vars}\in \text{reg}$ in an underscript using ctrl+shift+, :

```wl
In[3]:= Underscript[∫, {x, y, z}∈Tetrahedron[]](x^4 y^5 + z^10)

Out[3]= (1385/759103488 Sqrt[2])
```

---

Use esc`` rintt ``esc to enter a template $\underset{\blacksquare \in \square }{\int }\square$ and tab to move between fields:

```wl
In[1]:= Underscript[∫, {x, y}∈Rectangle[]]x y^2

Out[1]= (1/6)
```

---

Formal integrals:

```wl
In[1]:= Integrate[f'[x], x]

Out[1]= f[x]

In[2]:= Integrate[((1 - f[x])f'[x]) / E ^ f[x], x]

Out[2]= E^-f[x] f[x]
```

---

Integrals of vector- and array-valued functions:

```wl
In[1]:= Integrate[{x, (1/Sqrt[x]), Sin[x]}, {x, 0, 5}]

Out[1]= {(25/2), 2 Sqrt[5], 1 - Cos[5]}

In[2]:=
Integrate[(⁠|         |         |         |
| ------- | ------- | ------- |
| x       | Sqrt[x] | x^1 / 3 |
| Sqrt[x] | x^1 / 3 | x^1 / 4 |
| x^1 / 3 | x^1 / 4 | x^1 / 5 |⁠), {x, 0, 5}]//MatrixForm

Out[2]//MatrixForm=
(⁠|                |                |                |
| -------------- | -------------- | -------------- |
| (25/2)         | (10 Sqrt[5]/3) | (15 5^1 / 3/4) |
| (10 Sqrt[5]/3) | (15 5^1 / 3/4) | 4 5^1 / 4      |
| (15 5^1 / 3/4) | 4 5^1 / 4      | (25 5^1 / 5/6) |⁠)
```

---

Invoke ``NIntegrate`` automatically if symbolic integration fails:

```wl
In[1]:= Integrate[E ^ (-x ^ x), {x, 0, 1}]

Out[1]= Subsuperscript[∫, 0, 1]E^-x^x\[DifferentialD]x

In[2]:= N[%]

Out[2]= 0.458542
```

#### Indefinite Integrals (10)

Some basic integrals:

```wl
In[1]:= ∫x^n\[DifferentialD]x

Out[1]= (x^1 + n/1 + n)

In[2]:= ∫(1/x)\[DifferentialD]x

Out[2]= Log[x]

In[3]:= ∫Sin[x]\[DifferentialD]x

Out[3]= -Cos[x]

In[4]:= ∫Exp[x]\[DifferentialD]x

Out[4]= E^x
```

Generate an answer with a constant of integration:

```wl
In[5]:= Integrate[Exp[x], x, GeneratedParameters -> C]

Out[5]= E^x + C[1]
```

---

Integrals of trigonometric functions:

```wl
In[1]:= ∫Sec[x]^2\[DifferentialD]x

Out[1]= Tan[x]

In[2]:= ∫Cot[x]\[DifferentialD]x

Out[2]= Log[Sin[x]]

In[3]:= ∫Sec[x]\[DifferentialD]x

Out[3]= ArcCoth[Sin[x]]
```

Verify the previous answer via differentiation:

```wl
In[4]:= D[%, x]//Simplify

Out[4]= Sec[x]
```

---

Create a nicely formatted table of integrals:

```wl
In[1]:= flist = {x ^ n, 1 / x, b^x, Log[x], Sin[x], Cos[x], (1/x^2 + a^2), (1/x^2 - a^2)};

In[2]:= Grid[Prepend[Transpose[{flist, Integrate[flist, x]}], {f[x], ∫f[x]\[DifferentialD]x}], IconizedObject[«Grid options»]]//TraditionalForm

Out[2]//TraditionalForm=
$$\begin{array}{cc}
 f(x) & \int f(x) \, dx \\
 x^n & \frac{x^{n+1}}{n+1} \\
 \frac{1}{x} & \log (x) \\
 b^x & \frac{b^x}{\log (b)} \\
 \log (x) & x \log (x)-x \\
 \sin (x) & -\cos (x) \\
 \cos (x) & \sin (x) \\
 \frac{1}{a^2+x^2} & \frac{\tan ^{-1}\left(\frac{x}{a}\right)}{a} \\
 \frac{1}{x^2-a^2} & -\frac{\tanh ^{-1}\left(\frac{x}{a}\right)}{a} \\
\end{array}$$
```

---

Rational functions can always be integrated in closed form:

```wl
In[1]:= Integrate[1 / (x ^ 4 - 1), x]

Out[1]= -(ArcTan[x]/2) + (1/4) Log[1 - x] - (1/4) Log[1 + x]

In[2]:= Integrate[( x + 1/a^2  x^2  + c^2), x]

Out[2]= (ArcTan[(a x/c)]/a c) + (Log[c^2 + a^2 x^2]/2 a^2)
```

Sometimes they involve sums of ``Root`` objects:

```wl
In[3]:= Integrate[1 / (x ^ 5 + 2x + 1), x]

Out[3]= RootSum[1 + 2 #1 + #1^5&, (Log[x - #1]/2 + 5 #1^4)&]
```

---

Integrals of general elementary functions:

```wl
In[1]:= ∫ArcSin[x]\[DifferentialD]x

Out[1]= Sqrt[1 - x^2] + x ArcSin[x]

In[2]:= ∫Cosh[x]\[DifferentialD]x

Out[2]= Sinh[x]

In[3]:= ∫(x^2/Sqrt[a^2 + x^2])\[DifferentialD]x

Out[3]= (1/2) x Sqrt[a^2 + x^2] - (1/2) a^2 ArcTanh[(x/Sqrt[a^2 + x^2])]

In[4]:= ∫Exp[a x]Cos[b x]\[DifferentialD]x

Out[4]= (E^a x (a Cos[b x] + b Sin[b x])/a^2 + b^2)
```

---

``Integrate`` returns antiderivatives valid in the complex plane where applicable:

```wl
In[1]:= int\[DoubleStruckCapitalC][x_] = ∫Tan[x]\[DifferentialD]x

Out[1]= -Log[Cos[x]]

In[2]:= D[int\[DoubleStruckCapitalC][x], x]

Out[2]= Tan[x]
```

A common antiderivative found in integral tables for $\tan (x)$ is $\log (| \sec (x)| )$ :

```wl
In[3]:= int\[DoubleStruckCapitalR][x_] = Log[RealAbs[Sec[x]]];
```

This is a valid antiderivative for real values of $x$ :

```wl
In[4]:= Simplify[D[int\[DoubleStruckCapitalR][x], x]]

Out[4]= Tan[x]
```

On the real line, the two integrals have the same real part:

```wl
In[5]:= FullSimplify[Re[int\[DoubleStruckCapitalC][x]] == Re[int\[DoubleStruckCapitalR][x]]]

Out[5]= True

In[6]:= Plot[{Re[int\[DoubleStruckCapitalC][x]], Re[int\[DoubleStruckCapitalR][x]]}, {x, 0, 4Pi}, PlotTheme -> {"Detailed", "NeonColors", "DashedLines"}]

Out[6]= [image]
```

But the imaginary parts differ by $\pi$ on any interval where $\cos (x)$ is negative:

```wl
In[7]:= Plot[{Im[int\[DoubleStruckCapitalC][x]], Im[int\[DoubleStruckCapitalR][x]], Cos[x]}, {x, 0, 4Pi}, PlotTheme -> {"Detailed", "NeonColors", "DashedLines"}]

Out[7]= [image]
```

---

Similar integrals can lead to functions of different kinds:

```wl
In[1]:= Integrate[Sqrt[x]Sqrt[1 + x], x]

Out[1]= (1/4) (Sqrt[x] Sqrt[1 + x] (1 + 2 x) - ArcTanh[(1/Sqrt[(x/1 + x)])])

In[2]:= Integrate[Sqrt[x]Sqrt[1 + x]Sqrt[2 + x], x]

Out[2]= (2/5) (Sqrt[x] (1 + x)^3 / 2 Sqrt[2 + x] - (2 Sqrt[(1 + x/2 + x)] (2 + x)/Sqrt[x]) - (2 I Sqrt[(1 + x/2 + x)] Sqrt[(2 + x/x)] EllipticE[I ArcSinh[(1/Sqrt[x])], 2]/Sqrt[1 + (1/x)]))
```

---

Many integrals can be done only in terms of special functions such as ``Erf`` :

```wl
In[1]:= Integrate[Exp[-x ^ 2], x]

Out[1]= (1/2) Sqrt[π] Erf[x]
```

Generalizations of ``Log`` such as ``PolyLog`` and ``LogIntegral``:

```wl
In[2]:= Integrate[Log[1 + x] ^ 2 / x, x]

Out[2]= Log[-x] Log[1 + x]^2 + 2 Log[1 + x] PolyLog[2, 1 + x] - 2 PolyLog[3, 1 + x]

In[3]:= Integrate[Log[Log[x]], x]

Out[3]= x Log[Log[x]] - LogIntegral[x]
```

Hypergeometric functions such as ``Hypergeometric2F1`` :

```wl
In[4]:= Integrate[Tan[x] ^ n, x]

Out[4]= (Hypergeometric2F1[1, (1 + n/2), (3 + n/2), -Tan[x]^2] Tan[x]^1 + n/1 + n)
```

---

Create a nicely-formatted table of special function integrals:

```wl
In[1]:= flist = {BesselJ[0, x], Erf[x], EllipticE[x], Sqrt[x]PolyLog[2, x], AiryAi[x], SinhIntegral[2 / (x + 1)]};

In[2]:= Grid[Prepend[Transpose[{flist, Integrate[flist, x]}], {f[x], ∫f[x]\[DifferentialD]x}], IconizedObject[«Grid options»]]//TraditionalForm

Out[2]//TraditionalForm=
$$\begin{array}{cc}
 f(x) & \int f(x) \, dx \\
 J_0(x) & x  _1F_2\left(\frac{1}{2};1,\frac{3}{2};-\frac{x^2}{4}\right) \\
 \text{erf}(x) & x \text{erf}(x)+\frac{e^{-x^2}}{\sqrt{\pi }} \\
 E(x) & \frac{2 x K(x)}{3}-\frac{2 K(x)}{3}+\frac{2 x E(x)}{3 ... a \left(\frac{4}{3}\right) \Gamma \left(\frac{5}{3}\right)} \\
 \text{Shi}\left(\frac{2}{x+1}\right) & (x+1) \left(\text{Shi}\left(\frac{2}{x+1}\right)+\sinh \left(\frac{2}{x+1}\right)\right)-2 \text{Chi}\left(\frac{2}{x+1}\right)
\\
\end{array}$$
```

---

The variable of integration need not be a single symbol:

```wl
In[1]:= Integrate[p[x]Log[p[x]], p[x]]

Out[1]= -(1/4) p[x]^2 + (1/2) Log[p[x]] p[x]^2
```

#### Definite Integrals (13)

Integrate a polynomial:

```wl
In[1]:= Integrate[x ^ 4 + x ^ 2 + 1, {x, 1, 3}]

Out[1]= (886/15)
```

Visualize the area under the curve:

```wl
In[2]:= Plot[x ^ 4 + x ^ 2 + 1, {x, 1, 3}, Filling -> Axis]

Out[2]= [image]
```

Integrate a symbolic polynomial:

```wl
In[3]:= Integrate[a x ^ 2 + b x + c, {x, -2, 2}]

Out[3]= (16 a/3) + 4 c
```

Integrate over a symbolic range:

```wl
In[4]:= Integrate[x ^ n + n x, {x, 0, a}, Assumptions -> n > 1 && n∈ℤ]

Out[4]= (1/2) a (a n + (2 a^n/1 + n))
```

---

Rational functions:

```wl
In[1]:= Integrate[1 / (x ^ 4 + x ^ 2 + 1), {x, 0, Infinity}]

Out[1]= (π/2 Sqrt[3])

In[2]:= Plot[(1/x^4 + x^2 + 1), {x, 0, 5}, Filling -> Axis, PlotRange -> All, Epilog -> {RGBColor[0.368417, 0.506779, 0.709798], Arrow[{{0, 0}, {5, 0}}]}]

Out[2]= [image]

In[3]:= Integrate[(4x ^ 2 - 7x - 12) / ((x + 2)(x - 3)), {x, -1, 2}]

Out[3]= 12 - (21 Log[4]/5)

In[4]:= Plot[(4 x^2 - 7 x - 12/(x + 2) (x - 3)), {x, -1, 2}, Filling -> 0, PlotRange -> All]

Out[4]= [image]
```

---

Algebraic functions:

```wl
In[1]:= Integrate[(1 + x^3) CubeRoot[x], {x, -1, 1}]

Out[1]= (6/13)

In[2]:= Plot[(1 + x^3) CubeRoot[x], {x, -1, 1}, Filling -> Axis, FillingStyle -> {RGBColor[0.95, 0.627, 0.1425, 0.2], RGBColor[0.24, 0.6, 0.8, 0.2]}]

Out[2]= [image]

In[3]:= Integrate[1 / ((2 + x ^ 2)Sqrt[4 + 3x ^ 2]), {x, -∞, ∞}]

Out[3]= ArcCosh[Sqrt[(3/2)]]

In[4]:= Plot[(1/(2 + x^2) Sqrt[4 + 3 x^2]), {x, -7, 7}, Filling -> 0, AxesOrigin -> {0, 0}, Epilog -> {RGBColor[0.368417, 0.506779, 0.709798], Arrowheads[{-Medium, Medium}], Arrow[{{-7, 0}, {7, 0}}]}]

Out[4]= [image]
```

---

Trigonometric functions:

```wl
In[1]:= Integrate[Cos[2x] ^ 4, {x, 0, π}]

Out[1]= (3 π/8)

In[2]:= Plot[Cos[2x] ^ 4, {x, 0, π / 2}, Filling -> Axis]

Out[2]= [image]

In[3]:= Integrate[x ^ 2Sin[2x], {x, 0, 2π}]

Out[3]= -2 π^2

In[4]:= Plot[x ^ 2Sin[2x], {x, 0, 2π}, Filling -> Axis, FillingStyle -> {RGBColor[0.95, 0.627, 0.1425, 0.2], RGBColor[0.24, 0.6, 0.8, 0.2]}]

Out[4]= [image]
```

---

Exponential and logarithmic functions:

```wl
In[1]:= Integrate[x ^ 5Log[x], {x, 1, 2}]

Out[1]= -(7/4) + (16 Log[64]/9)

In[2]:= Plot[x ^ 5Log[x], {x, 1, 2}, Filling -> Axis]

Out[2]= [image]

In[3]:= Integrate[Exp[-x + Exp[-x]], {x, 0, ∞}]

Out[3]= -1 + E

In[4]:= Plot[Exp[-x + Exp[-x]], {x, 0, 4}, PlotRange -> Full, Filling -> Axis, Epilog -> {RGBColor[0.368417, 0.506779, 0.709798], Arrowheads[Medium], Arrow[{{0, 0}, {4, 0}}]}]

Out[4]= [image]
```

---

Hyperbolic trigonometric functions:

```wl
In[1]:= Integrate[x Cosh[x], {x, 0, a}]

Out[1]= 1 - Cosh[a] + a Sinh[a]

In[2]:= Integrate[x^2 Sech[x]^2, {x, -∞, ∞}]

Out[3]= (π^2/6)
```

---

Integrate a function with a vertical asymptote:

```wl
In[1]:= Integrate[x / Sqrt[1 - x], {x, 0, 1}]

Out[1]= (4/3)

In[2]:= Plot[x / Sqrt[1 - x], {x, 0, 1}, Filling -> Axis]

Out[2]= [image]
```

This can be viewed as a limit of the result of integration on a smaller interval:

```wl
In[3]:= Underscript[\[Limit], a -> 1^ - ]Subsuperscript[∫, 0, a](x/Sqrt[1 - x])\[DifferentialD]x

Out[3]= (4/3)
```

---

Compute the integral of a function with two vertical asymptotes:

```wl
In[1]:= area = Subsuperscript[∫, -1, 1](x^2/Sqrt[1 - x^4])\[DifferentialD]x

Out[1]= (2 Sqrt[π] Gamma[(7/4)]/3 Gamma[(5/4)])

In[2]:= %//N

Out[2]= 1.19814

In[3]:= Plot[(x^2/Sqrt[1 - x^4]), {x, -1, 1}, Filling -> 0]

Out[3]= [image]
```

This can be viewed as a multivariate limit of the result of integration on a smaller interval:

```wl
In[4]:= area == Limit[Integrate[(x^2/Sqrt[1 - x^4]), {x, a, b}, Assumptions -> -1 < a < b < 1], {a, b} -> {-1, 1}, Direction -> {"FromAbove", "FromBelow"}]

Out[4]= True
```

---

Integrals over infinite intervals can be viewed as limits of integrals over finite domains:

```wl
In[1]:= Integrate[x E ^ (-x), {x, 1, ∞}]

Out[1]= (2/E)
```

The preceding is the limit as $a\to \infty$ of the integral from $1$ to $a$ :

```wl
In[2]:= % == Underscript[\[Limit], a -> ∞]Integrate[x E ^ (-x), {x, 1, a}]

Out[2]= True
```

An integral over reals:

```wl
In[3]:= Subsuperscript[∫, -∞, ∞]E^-x^2\[DifferentialD]x

Out[3]= Sqrt[π]
```

It is the bivariate limit of a finite integral:

```wl
In[4]:= % == Underscript[\[Limit], {a, b} -> {-∞, ∞}]Subsuperscript[∫, a, b]E^-x^2\[DifferentialD]x

Out[4]= True
```

---

When there are parameters, conditions that ensure convergence may be reported:

```wl
In[1]:= Integrate[x ^ n, {x, 0, 1}]

Out[1]= ConditionalExpression[1/(1 + n), Re[n] > -1]

In[2]:= Integrate[E ^ (a x), {x, 0, ∞}]

Out[2]= ConditionalExpression[-(1/a), Re[a] < 0]
```

---

Integrals of elementary functions may produce special function answers:

```wl
In[1]:= Integrate[Sin[t] / t, {t, a, b}]

Out[1]= -SinIntegral[a] + SinIntegral[b]

In[2]:= Integrate[Cos[Sin[x] ^ 2], {x, 0, 2π}]

Out[2]= 2 π BesselJ[0, (1/2)] Cos[(1/2)]

In[3]:= %//N

Out[3]= 5.17474

In[4]:= Plot[Cos[Sin[x] ^ 2], {x, 0, 2π}, Filling -> 0, PlotRange -> {0, 1}]

Out[4]= [image]
```

---

Create a formatted table of definite integrals over the positive reals of special functions:

```wl
In[1]:= flist = {BesselJ[2, x] / x, BesselK[0, x] ^ 2, AiryAi[x] ^ 2, Exp[-x] Sinc[x], Sin[x]Erfc[x]};

In[2]:= Grid[Prepend[Transpose[{flist, Subsuperscript[∫, 0, ∞]flist\[DifferentialD]x}], {f[x], Subsuperscript[∫, 0, ∞]f[x]\[DifferentialD]x}], IconizedObject[«Grid options»]]//TraditionalForm

Out[2]//TraditionalForm=
$$\begin{array}{cc}
 f(x) & \int_0^{\infty } f(x) \, dx \\
 \frac{J_2(x)}{x} & \frac{1}{2} \\
 K_0(x){}^2 & \frac{\pi ^2}{4} \\
 \text{Ai}(x)^2 & \frac{1}{3^{2/3} \Gamma \left(\frac{1}{3}\right)^2} \\
 e^{-x} \text{sinc}(x) & \frac{\pi }{4} \\
 \text{erfc}(x) \sin (x) & 1-\frac{1}{\sqrt[4]{e}} \\
\end{array}$$
```

---

Integral along a complex line:

```wl
In[1]:= Integrate[Sqrt[x], {x, I, 3 - I}]

Out[1]= -(2/3) ((-1)^3 / 4 - (3 - I)^3 / 2)
```

Integrate along a piecewise linear contour in the complex plane:

```wl
In[2]:= Integrate[(1/z + 1 / 2), {z, 1, E^(I π/3), E^(2 I π/3), -1, E^-(2 I π/3), E^-(I π/3), 1}]//FullSimplify

Out[2]= 2 I π
```

Integrate the same function along a circular contour:

```wl
In[3]:= Integrate[(I Exp[I ω]/Exp[I ω] + 1 / 2), {ω, 0, 2π}]

Out[3]= 2 I π
```

Plot the function and paths of integration:

```wl
In[4]:= ComplexPlot[(1/z + 1 / 2), {z, -1.2 - 1.2I, 1.2 + 1.2I}, Epilog -> {Thick, Arrowheads[Medium], White, Arrow[{{1, -.05}, {1, 0}}], Circle[], Dashed, Black, Arrow[ReIm /@ Exp[2π I / 6 Range[0, 6]]]}]

Out[4]= [image]
```

#### Integrals of Piecewise and Generalized Functions (12)

Compute the indefinite integral of a ``Piecewise`` function:

```wl
In[1]:= f[x_]   := Piecewise[{{-x^2, x < 0}, {x^2, True}}]

In[2]:= ∫f[x]\[DifferentialD]x

Out[2]= Piecewise[{{-(x^3/3), x <= 0}}, x^3/3]
```

In this case, the derivative of the integral equals the original function:

```wl
In[3]:= Simplify[D[%, x] == f[x]]

Out[3]= True
```

---

Integrate a discontinuous ``Piecewise`` function:

```wl
In[1]:= f[x_]   := Piecewise[{{-x + 1, x < 0}, {x, 0 < x < 1}, {x^2, True}}]

In[2]:= g[x_] = ∫f[x]\[DifferentialD]x

Out[2]= Piecewise[{{x - x^2/2, x <= 0}, {x^2/2, Inequality[0, Less, x, LessEqual, 1]}}, 1/6 + x^3/3]
```

Except at the point of discontinuity, the derivative of ``g`` equals ``f`` :

```wl
In[3]:= Resolve[ForAll[x, x != 0 && x∈ℝ, Derivative[1][g][x] == f[x]]]

Out[3]= True
```

Visualize the function and its antiderivative:

```wl
In[4]:= Plot[{f[x], g[x]}, {x, -2, 2}, PlotTheme -> {"Detailed", "DashedLines"}]

Out[4]= [image]
```

---

Integrate functions that are piecewise-defined:

```wl
In[1]:= unitInt[x_] = Integrate[x UnitStep[x], x]

Out[1]= (1/2) x^2 UnitStep[x]

In[2]:= Plot[{x UnitStep[x], unitInt[x]}, {x, -2, 2}, PlotTheme -> {"Detailed", "DashedLines"}]

Out[2]= [image]

In[3]:= clipInt[x_] = Integrate[Clip[x] ^ 2, x]

Out[3]= Piecewise[{{x, x <= -1}, {-(2/3) + x^3/3, Inequality[-1, Less, x, LessEqual, 1]}}, -(4/3) + x]

In[4]:= Plot[{Clip[x] ^ 2, clipInt[x]}, {x, -2, 2}, PlotTheme -> {"Detailed", "DashedLines"}]

Out[4]= [image]
```

---

Integrate a piecewise function with infinitely many cases:

```wl
In[1]:= maxInt[x_] = Integrate[Max[Sin[x], Cos[x]], x]

Out[1]= Piecewise[{{Sin[x], Cos[x] - Sin[x] >= 0}}, -Cos[x]]
```

Everywhere it is defined, the derivative of ``maxInt`` equals the original function:

```wl
In[2]:= Simplify[D[maxInt[x], x] == Max[Sin[x], Cos[x]]]

Out[2]= True
```

However, ``maxInt`` itself is discontinuous:

```wl
In[3]:= Plot[{Max[Sin[x], Cos[x]], maxInt[x]}, {x, 0, 4Pi}, PlotTheme -> {"Detailed", "DashedLines"}]

Out[3]= [image]
```

---

Compute a definite integral of a ``Piecewise`` function:

```wl
In[1]:= f[x_] := Piecewise[{{1, x < 2}, {x^3, 2 < x < 3}}, 0]

In[2]:= Integrate[f[x], {x, 0, 3}]

Out[2]= (73/4)
```

Compute the integral with a variable endpoint:

```wl
In[3]:= int[x_] = Integrate[f[t], {t, 0, x}, Assumptions -> x > 0]

Out[3]= Piecewise[{{73/4, x > 3}, {x, x <= 2}}, (1/4)*(-8 + x^4)]
```

Visualize the function and its integral:

```wl
In[4]:= Plot[{f[x], int[x]}, {x, 0, 4}, PlotTheme -> {"Detailed", "DashedLines"}]

Out[4]= [image]
```

---

Compute definite integrals of piecewise functions such as ``Floor`` :

```wl
In[1]:= Integrate[Floor[x ^ 2], {x, 0, 3}]

Out[1]= 21 - 3 Sqrt[2] - Sqrt[3] - Sqrt[5] - Sqrt[6] - Sqrt[7]

In[2]:= Plot[Floor[x ^ 2], {x, 0, 3}, Filling -> Axis]

Out[2]= [image]
```

``PrimePi`` :

```wl
In[3]:= Integrate[PrimePi[n], {n, 0, 100}]

Out[3]= 1440

In[4]:= Plot[PrimePi[x], {x, 0, 100}, Filling -> Axis]

Out[4]= [image]
```

A composition of piecewise functions:

```wl
In[5]:= Integrate[Ceiling[x ^ 2 + TriangleWave[x]], {x, -2, 2} ]

Out[5]= 42 - 3 Sqrt[2] - 3 Sqrt[3] - Sqrt[5] - Sqrt[6] - Sqrt[7] - Sqrt[10] - Sqrt[11] - Sqrt[13] - Sqrt[14] - Sqrt[15]
```

---

Compute the definite integral with a variable upper limit:

```wl
In[1]:= f[x_] := x ^ 2 UnitStep[x + 1]

In[2]:= int[a_] = Integrate[f[x], {x, -3, a}]

Out[2]= ConditionalExpression[(1/3)*(1 + a^3)*UnitStep[1 + a], Element[a, Reals]]

In[3]:= Plot[{f[a], int[a]}, {a, -2, 2}, PlotTheme -> {"Detailed", "DashedLines"}]

Out[3]= [image]
```

---

A function with an infinite number of cases:

```wl
In[1]:= f[x_] := Max[Sin[x], Cos[x]]

In[2]:= f[x]//PiecewiseExpand

Out[2]= Piecewise[{{Cos[x], Cos[x] - Sin[x] >= 0}}, Sin[x]]
```

Integrate over a finite number of cases using ``Assumptions`` :

```wl
In[3]:= maxInt[a_] = Integrate[f[x], {x, 0, a}, Assumptions -> 0 < a < 2Pi]

Out[3]=
Piecewise[{{3/Sqrt[2], a == 2*Pi - 2*ArcTan[1 + Sqrt[2]]}, {1 + Sqrt[2], a == Pi}, 
  {Sqrt[2] - Cos[a], Pi < a < 2*Pi - 2*ArcTan[1 + Sqrt[2]] || -2*ArcTan[1 - Sqrt[2]] < a < Pi}, 
  {Sin[a], a <= -2*ArcTan[1 - Sqrt[2]]}}, 2*Sqrt[2] + Sin[a]]
```

The integral is a continuous function of the upper limit over the domain of integration:

```wl
In[4]:= Plot[{f[a], maxInt[a]}, {a, 0, 2Pi}, PlotTheme -> {"Detailed", "DashedLines"}]

Out[4]= [image]
```

---

Integrate generalized functions:

```wl
In[1]:= Integrate[DiracDelta[x], {x, -∞, ∞}]

Out[1]= 1

In[2]:= Integrate[Sin[x] ^ 2 HeavisideTheta[x + π]HeavisideTheta[π - x], {x, -∞, ∞}]

Out[2]= π

In[3]:= Integrate[DiracDelta[Cos[x ^ 2 - 1]], {x, -2, 2}]

Out[3]= Sqrt[(2/2 + π)]
```

---

Indefinite integrals of generalized functions return generalized functions:

```wl
In[1]:= Integrate[DiracDelta[x], x]

Out[1]= HeavisideTheta[x]
```

A nested integral:

```wl
In[2]:= Integrate[DiracDelta[x], x, x]

Out[2]= x HeavisideTheta[x]
```

---

Integrate generalized functions over subsets of the reals:

```wl
In[1]:= Integrate[f[x] DiracDelta[x - a], {x, -1, 1}, Assumptions -> a∈Reals]

Out[1]= f[a] HeavisideTheta[1 - a] HeavisideTheta[1 + a]

In[2]:= Integrate[Cos[x - a] HeavisideLambda[x], {x, 0, Pi}, Assumptions -> a∈Reals]

Out[2]= -Cos[1 - a] + Cos[a] + Sin[a]
```

---

Integrate an interpolating function:

```wl
In[1]:= f = Interpolation[{10, -5, 10, -10, 20}]

Out[1]=
InterpolatingFunction[{{1, 5}}, {5, 3, 0, {5}, {4}, 0, 0, 0, 0, Automatic, {}, {}, False}, 
 {{1, 2, 3, 4, 5}}, {{10}, {-5}, {10}, {-10}, {20}}, {Automatic}]

In[2]:= g = Head[Integrate[f[x], x]]

Out[2]=
InterpolatingFunction[{{1, 5}}, {5, 3, 1, {5}, {5}, 0, 0, 0, 0, Automatic, {}, {}, False}, 
 {{1, 2, 3, 4, 5}}, {{0, 10}, {Rational[-65, 24], -5}, {0, 10}, {Rational[-5, 8], -10}, 
  {Rational[-10, 3], 20}}, {Automatic}]
```

Test that ``g`` is a correct antiderivative at ``x == 3.5`` :

```wl
In[3]:= g'[3.5] == f[3.5]

Out[3]= True
```

Visualize the function and its antiderivative:

```wl
In[4]:= Plot[{f[x], g[x]}, {x, 1, 5}, PlotTheme -> {"Detailed", "DashedLines"}]

Out[4]= [image]
```

#### Nested Integrals (12)

Compute a second antiderivative of a function:

```wl
In[1]:= Integrate[a x ^ 2 + b x + c, x, x]//Expand

Out[1]= (c x^2/2) + (b x^3/6) + (a x^4/12)

In[2]:= D[%, {x, 2}]

Out[2]= c + b x + a x^2
```

Compute the third antiderivative:

```wl
In[3]:= ∫∫∫(1/x^2 + 4)\[DifferentialD]x\[DifferentialD]x\[DifferentialD]x

Out[3]= (1/4) ((-4 + x^2) ArcTan[(x/2)] - 2 x (-1 + Log[4 + x^2]))

In[4]:= FullSimplify[D[%, {x, 3}]]

Out[4]= (1/4 + x^2)
```

---

Integrate a function with respect to two different variables:

```wl
In[1]:= Integrate[x ^ 2Sin[y], y, x]

Out[1]= -(1/3) x^3 Cos[y]
```

The mixed partial derivative gives the original function:

```wl
In[2]:= D[%, x, y]

Out[2]= x^2 Sin[y]
```

---

Generate a constant of integration for a single integral:

```wl
In[1]:= Integrate[x, x, GeneratedParameters -> C]

Out[1]= (x^2/2) + C[1]
```

Generate constants for a nested integral with respect to the same variable:

```wl
In[2]:= Integrate[x, x, x, GeneratedParameters -> C]

Out[2]= (x^3/6) + C[1] + x C[2]
```

This is the most general second antiderivative of the integrand:

```wl
In[3]:= D[%, x, x]

Out[3]= x
```

Generate two functions of integration for a nested integral with respect to two variables:

```wl
In[4]:= Integrate[x, x, y, GeneratedParameters -> C]

Out[4]= (x^2 y/2) + C[1][y] + C[2][x]
```

This is the most general mixed antiderivative of the integrand:

```wl
In[5]:= D[%, x, y]

Out[5]= x
```

---

Integrate over the rectangle from $\{0,0\}$ to $\{a,b\}$ :

```wl
In[1]:= Integrate[Exp[x]Cos[y], {x, 0, a}, {y, 0, b}]

Out[1]= (-1 + E^a) Sin[b]
```

Equivalently:

```wl
In[2]:= Subsuperscript[∫, 0, a]Subsuperscript[∫, 0, b]Exp[x]Cos[y]\[DifferentialD]y\[DifferentialD]x

Out[2]= (-1 + E^a) Sin[b]
```

Integrate in the opposite order:

```wl
In[3]:= Subsuperscript[∫, 0, b]Subsuperscript[∫, 0, a]Exp[x]Cos[y]\[DifferentialD]x\[DifferentialD]y

Out[3]= (-1 + E^a) Sin[b]
```

---

Combine indefinite and definite integration:

```wl
In[1]:= Integrate[(x + y), {y, 0, 1}, x]

Out[1]= (x/2) + (x^2/2)
```

---

Compute a rational double integral over a rectangular region:

```wl
In[1]:= Integrate[x ^ 2y / (x + y), {x, 0, 3}, {y, 1, 2}]

Out[1]= (39/8) + 36 Log[2] - (65 Log[5]/4)
```

This gives the volume of the shaded region:

```wl
In[2]:= Plot3D[(x^2 y/x + y), {x, 0, 3}, {y, 1, 2}, Filling -> Axis, FillingStyle -> Opacity[0.6], Mesh -> None]

Out[2]= [image]
```

---

Compute a trigonometric double integral over a rectangular region:

```wl
In[1]:= Integrate[y Sin[x y], {x, 1, 4}, {y, 0, π}]

Out[1]= 0
```

There is as much positive volume (dark gray) as negative (light blue):

```wl
In[2]:= Plot3D[{y Sin[x y], 0}, {x, 1, 4}, {y, 0, π}, IconizedObject[«Plot3D options»]]

Out[2]= [image]
```

---

Compute a polynomial double integral over the area between two curves:

```wl
In[1]:= Subsuperscript[∫, -2, 2]Subsuperscript[∫, 2 x^2, 4 + x^2](8 - (3 y/3) - (3 x y/3) + (x^2 y/3) + (x^3 y/3))\[DifferentialD]y\[DifferentialD]x

Out[1]= (20224/315)
```

Visualize the domain of integration and the volume corresponding to the integral:

```wl
In[2]:= Plot[{2x ^ 2, 4 + x ^ 2}, {x, -2, 2}, Filling -> {1 -> {2}}, PlotLegends -> "Expressions"]

Out[2]= [image]

In[3]:= Plot3D[8 - (3 y/3) - (3 x y/3) + (x^2 y/3) + (x^3 y/3), {x, y}∈ImplicitRegion[-2 < x < 2 && 2 x^2 < y < 4 + x^2, {x, y}], FillingStyle -> Opacity[.5], Filling -> Axis, PlotRange -> All, ViewPoint -> {.3, 3.1, 1.3}, Mesh -> None]

Out[3]= [image]
```

---

Compute a triple integral over a rectangular prism:

```wl
In[1]:= Integrate[Cos[z]Exp[x]y, {x, 0, 1}, {y, -1, 2}, {z, 0, 3}]

Out[1]= (3/2) (-1 + E) Sin[3]
```

Visualize the region of integration:

```wl
In[2]:= RegionPlot3D[0 < x < 1 && -1 < y < 2 && 0 < z < 3, {x, -0.5, 1.5}, {y, -1.5, 2.5}, {z, -0.5, 3.5}]

Out[2]= [image]
```

---

Compute an algebraic triple integral over a cone-shaped 3D region:

```wl
In[1]:= Integrate[Sqrt[x ^ 2 + z ^ 2]y, {x, -2, 2}, {y, x ^ 2, 4}, {z, -Sqrt[y - x ^ 2], Sqrt[y - x ^ 2]}]//FullSimplify

Out[1]= (512 π/21)
```

Visualize the region of integration:

```wl
In[2]:= RegionPlot3D[y > x ^ 2 + z ^ 2 && 0 < y < 4, {x, -3, 3}, {y, -0.5, 4.5}, {z, -3, 3}]

Out[2]= [image]
```

---

Integrate a multivariate function over a five-dimensional cube:

```wl
In[1]:= Integrate[a b ^ 2  - c / d ^ e, {a, 0, 1}, {b, 1, 2}, {c, 2, 3}, {d, 3, 4}, {e, 4, 5}]

Out[1]= (7/6) + (5/2) (-ExpIntegralEi[-4 Log[3]] + ExpIntegralEi[-3 Log[3]] + ExpIntegralEi[-4 Log[4]] - ExpIntegralEi[-3 Log[4]])

In[2]:= N[%]

Out[2]= 1.15636
```

---

Integrate $f(r,\theta )=\frac{\sin (\theta )}{r}$ over the unit ball in 4 dimensions:

```wl
In[1]:= f[r_, θ_] := (Sin[θ]/r)
```

Look up the coordinate ranges for hyperspherical coordinates in ``CoordinateChartData`` :

```wl
In[2]:= CoordinateChartData["Hyperspherical", "CoordinateRangeAssumptions", {r, θ, φ, ψ}]

Out[2]= r > 0 && 0 < θ < π && 0 < φ < π && -π < ψ ≤ π
```

Also look up the volume factor:

```wl
In[3]:= CoordinateChartData["Hyperspherical", "VolumeFactor", {r, θ, φ, ψ}]

Out[3]= r^3 Sin[θ]^2 Sin[φ]
```

Do the integral:

```wl
In[4]:= Subsuperscript[∫, -π, π]Subsuperscript[∫, 0, π]Subsuperscript[∫, 0, π]Subsuperscript[∫, 0, R]f[r, θ](r^3 Sin[θ]^2 Sin[φ])\[DifferentialD]r\[DifferentialD]θ\[DifferentialD]φ\[DifferentialD]ψ

Out[4]= (16 π R^3/9)
```

#### Region Integrals (11)

Integrate a constant over a unit disk:

```wl
In[1]:= Integrate[1, {x, y}∈Disk[]]

Out[1]= π
```

Enter the integral in typeset form:

```wl
In[2]:= Underscript[∫, {x, y}∈Disk[]]1

Out[2]= π
```

Equivalently, integrate over a rectangular region and restrict to a disk using ``Boole`` :

```wl
In[3]:= Integrate[Boole[x ^ 2 + y ^ 2 ≤ 1], {x, -1, 1}, {y, -1, 1}]

Out[3]= π
```

---

An integral over a unit disk:

```wl
In[1]:= Subscript[∫, {x, y}∈Disk[]](Cos[3x]Sin[5y] + x^2)

Out[1]= (π/4)
```

The same integral expressed using ``Boole`` :

```wl
In[2]:= Subsuperscript[∫, -1, 1]Subsuperscript[∫, -1, 1](Cos[3x]Sin[5y] + x^2)Boole[x^2 + y^2 ≤ 1]\[DifferentialD]y\[DifferentialD]x

Out[2]= (π/4)
```

The same integral reduced to an iterated integral with bounds depending on the previous variables:

```wl
In[3]:= Subsuperscript[∫, -1, 1]Subsuperscript[∫, -Sqrt[1 - x^2], Sqrt[1 - x^2]](Cos[3x]Sin[5y] + x^2)\[DifferentialD]y\[DifferentialD]x

Out[3]= (π/4)
```

Plot the integrand over the integration region:

```wl
In[4]:= Plot3D[Cos[3x]^2Sin[5y] + 1, {x, y}∈Disk[], Filling -> 0, Mesh -> None, FillingStyle -> Automatic]

Out[4]= [image]
```

---

Express a normal definite integral using region notation:

```wl
In[1]:= Integrate[Sin[b x], {x}∈Interval[{0, Pi}]]

Out[1]= (1 - Cos[b π]/b)
```

Compare with the list notation:

```wl
In[2]:= Integrate[Sin[b x], {x, 0, Pi}]

Out[2]= (1 - Cos[b π]/b)
```

With ``GenerateConditions -> True``, assumptions are generated so that the region is non-degenerate:

```wl
In[3]:= Integrate[x^2y, {x, y}∈Rectangle[{0, 0}, {a, b}], GenerateConditions -> True]

Out[3]= ConditionalExpression[(a^3*b^2)/6, Element[a | b, Reals] && a > 0 && b > 0]
```

Compare with an iterated integral:

```wl
In[4]:= Integrate[x^2y, {x, 0, a}, {y, 0, b}, GenerateConditions -> True]

Out[4]= (a^3 b^2/6)
```

---

Integrate over the unit circle:

```wl
In[1]:= Subscript[∫, {x, y}∈Circle[]](x^2 y + y^2/2)

Out[1]= (π/2)
```

Express the same integral as a one-dimensional integral using polar coordinates:

```wl
In[2]:= Subsuperscript[∫, -Pi, Pi](Cos[θ]^2Sin[θ] + Sin[θ]^2/2)\[DifferentialD]θ

Out[2]= (π/2)
```

---

Integrate over a sphere of radius $r$ :

```wl
In[1]:= Underscript[∫, {x, y, z}∈Sphere[{x0, y0, z0}, r]](1/(x - x0)^2 + (y - y0)^2 + (z - z0)^2)

Out[1]= 4 π
```

---

Integrate over a finite set of points:

```wl
In[1]:= Integrate[1, {x, y, z}∈Point[{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}]]

Out[1]= 3
```

---

Regions can be given as logical combinations of inequalities:

```wl
In[1]:= int1 = Integrate[Boole[1 < x ^ 2 - y ^ 2 < 4 && x y < 1 && x > 0 && y > 0], {x, -∞, ∞}, {y, -∞, ∞} ]

Out[1]= (1/4) (8 ArcCoth[2 + Sqrt[5]] + ArcSinh[2] + 4 Log[2] - 2 Log[4] - 2 Log[(1/2) (1 + Sqrt[5])])
```

Define the region as an ``ImplicitRegion`` and integrate directly over the region:

```wl
In[2]:= reg = ImplicitRegion[1 < x ^ 2 - y ^ 2 < 4 && x y < 1 && x > 0 && y > 0, {x, y}];

In[3]:= int2 = Integrate[1, {x, y}∈reg]

Out[3]= (1/2) (-1 + 2 ArcCsch[2] + ArcSinh[2] + Log[2] - Log[4] + Log[2 (-1 + Sqrt[5])] - Log[2 (Root[-1 - #1^2 + #1^4 & , 2, 0] + Sqrt[-1 + Root[-1 - #1^2 + #1^4 & , 2, 0]^2])] + Root[-1 - #1^2 + #1^4 & , 2, 0] Sqrt[-1 + Root[-1 - #1^2 + #1^4 & , 2, 0]^2])
```

The integrals are equivalent:

```wl
In[4]:= FullSimplify[int1 - int2]

Out[4]= 0
```

Visualize the domain of integration:

```wl
In[5]:= RegionPlot[reg]

Out[5]= [image]
```

---

Integral over a three-dimensional region defined by inequalities:

```wl
In[1]:= reg = ImplicitRegion[x + 2y + 3z < 2 && -1 < x < y < z < 1, {x, y, z}];

In[2]:= Subscript[∫, {x, y, z}∈reg](x^2 + 2y z)

Out[2]= (53833/151875)
```

Visualize 3D regions using ``RegionPlot3D`` :

```wl
In[3]:= RegionPlot3D[reg, PlotPoints -> 65, PlotTheme -> "FrameGrid"]

Out[3]= [image]
```

---

Integrate over a solid cone:

```wl
In[1]:= Integrate[ (x ^ 2 + y ^ 2) Boole[0 ≤ z ≤ 1 && x ^ 2 + y ^ 2 ≤ z ^ 2], {x, -∞, ∞}, {y, -∞, ∞}, {z, -∞, ∞} ]

Out[1]= (π/10)
```

Visualize the domain of integration:

```wl
In[2]:= RegionPlot3D[0 ≤ z ≤ 1 && x ^ 2 + y ^ 2 ≤ z ^ 2, {x, -1, 1}, {y, -1, 1}, {z, 0, 1}]

Out[2]= [image]
```

---

Integrate a function with parameters, getting a piecewise result:

```wl
In[1]:= Integrate[Boole[ax < y], {x, 0, 1}, {y, 0, 1}]

Out[1]= Piecewise[{{1, a <= 0}, {(2 - a)/2, Inequality[0, Less, a, LessEqual, 1]}}, 1/(2*a)]
```

---

A region with infinitely many components:

```wl
In[1]:= reg = ImplicitRegion[Sin[x] > 1 / 2, {{x, 0, ∞}}];

In[2]:= Underscript[∫, {x}∈reg]Exp[-x]

Out[2]= (E^7 π / 6/1 + E^2 π / 3 + E^4 π / 3)
```

#### Symbolic Features of Integrals (7)

Integrals involving unknown functions are done when possible:

```wl
In[1]:= Integrate[f''[x] + 2 a f'[x], x]

Out[1]= 2 a f[x] + Derivative[1][f][x]
```

---

Differentiate with respect to an endpoint, yielding the fundamental theorem of calculus:

```wl
In[1]:= Integrate[f[t], {t, 0, x}]

Out[1]= Subsuperscript[∫, 0, x]f[t]\[DifferentialD]t

In[2]:= D[%, x]

Out[2]= f[x]
```

A generalization:

```wl
In[3]:= Subscript[∂, x]Subsuperscript[∫, a[x], b[x]]f[t]\[DifferentialD]t

Out[3]= -f[a[x]] Derivative[1][a][x] + f[b[x]] Derivative[1][b][x]
```

---

Symbolic integrals can be differentiated with respect to parameters:

```wl
In[1]:= Integrate[f[x, a], {x, 0, 1}]

Out[1]= Subsuperscript[∫, 0, 1]f[x, a]\[DifferentialD]x

In[2]:= D[%, a]

Out[2]= Subsuperscript[∫, 0, 1]f^(0, 1)[x, a]\[DifferentialD]x
```

Differentiate with respect to a parameter that appears in both integrand and endpoints:

```wl
In[3]:= Subscript[∂, a]Subsuperscript[∫, p[a], q[a]]f[x, a]\[DifferentialD]x

Out[3]= Subsuperscript[∫, p[a], q[a]]f^(0, 1)[x, a]\[DifferentialD]x - f[p[a], a] Derivative[1][p][a] + f[q[a], a] Derivative[1][q][a]
```

---

Use the ``Inactive`` form of ``Integrate`` :

```wl
In[1]:= Inactive[Integrate][1 / (1 + x), x]

Out[1]= Inactive[Integrate][1/(1 + x), x]
```

Differentiate:

```wl
In[2]:= D[%, x]

Out[2]= (1/1 + x)
```

---

Illustrate indefinite integral identities:

```wl
In[1]:= Inactivate[∫x^n\[DifferentialD]x, Integrate] == ∫x^n\[DifferentialD]x

Out[1]= Inactive[Integrate][x^n, x] == (x^1 + n/1 + n)

In[2]:= Inactivate[∫(1/Sqrt[1 - x^2])\[DifferentialD]x, Integrate] == ∫(1/Sqrt[1 - x^2])\[DifferentialD]x

Out[2]= Inactive[Integrate][1/Sqrt[1 - x^2], x] == ArcSin[x]
```

Verify the identities starting from the inactive forms:

```wl
In[3]:= Activate[{Inactive[Integrate][x^n, x] == (x^1 + n/1 + n), Inactive[Integrate][1/Sqrt[1 - x^2], x] == ArcSin[x]}]

Out[3]= {True, True}
```

---

Illustrate the basic commutation trick for differentiating under the integral sign:

```wl
In[1]:= Inactivate[Integrate[D[f[x, a], a], x] == ((D[Integrate[f[x, a], x], a]))]

Out[1]= Inactive[Integrate][Inactive[D][Inactive[f][x, a], a], x] == Inactive[D][Inactive[Integrate][Inactive[f][x, a], x], a]

In[2]:= Activate[Inactive[Integrate][Inactive[D][Inactive[f][x, a], a], x] == Inactive[D][Inactive[Integrate][Inactive[f][x, a], x], a]]

Out[2]= True
```

---

Compute the ``LaplaceTransform`` of an integral:

```wl
In[1]:= LaplaceTransform[Integrate[f[u], {u, 0, t}], t, s]

Out[1]= (LaplaceTransform[f[t], t, s]/s)
```

### Options (11)

#### Assumptions (3)

By default, conditions are generated on parameters that guarantee convergence:

```wl
In[1]:= Integrate[x ^ n, {x, 0, 1}]

Out[1]= ConditionalExpression[1/(1 + n), Re[n] > -1]
```

With ``Assumptions``, a result valid under the given assumptions is given:

```wl
In[2]:= Integrate[x ^ n, {x, 0, 1}, Assumptions -> n > 0]

Out[2]= (1/1 + n)
```

---

Manually specify ``Assumptions`` to test values outside the automatically generated conditions:

```wl
In[1]:= Integrate[Exp[-a x^2], {x, -∞, ∞}]

Out[1]= ConditionalExpression[Sqrt[Pi]/Sqrt[a], Re[a] > 0]
```

This integral is also convergent for purely imaginary $a$ :

```wl
In[2]:= Integrate[Exp[-a x^2], {x, -∞, ∞}, Assumptions -> Re[a] == 0]

Out[2]= ((-a)^3 / 4 Sqrt[(π/2)] (-1 + Sign[a])/a^5 / 4)
```

---

Specify assumptions to evaluate a piecewise indefinite integral:

```wl
In[1]:= Integrate[Floor[x], x]

Out[1]= ∫Floor[x]\[DifferentialD]x

In[2]:= Integrate[Floor[x], x, Assumptions -> 0 < x < 5]

Out[2]=
Piecewise[{{0, x <= 1}, {-1 + x, Inequality[1, Less, x, LessEqual, 2]}, 
  {-3 + 2*x, Inequality[2, Less, x, LessEqual, 3]}, 
  {-6 + 3*x, Inequality[3, Less, x, LessEqual, 4]}}, -10 + 4*x]
```

#### GenerateConditions (2)

By default, univariate definite integrals generate conditions on parameters that ensure convergence:

```wl
In[1]:= Integrate[Exp[-a x ^ 2], {x, 0, ∞}]

Out[1]= ConditionalExpression[Sqrt[Pi]/(2*Sqrt[a]), Re[a] > 0]
```

Generate a result without conditions:

```wl
In[2]:= Integrate[Exp[-a x ^ 2], {x, 0, ∞}, GenerateConditions -> False]

Out[2]= (Sqrt[π]/2 Sqrt[a])
```

---

Use ``GenerateConditions -> False`` to speed up integration:

```wl
In[1]:= Integrate[x ^ n, {x, -1, b}, GenerateConditions -> False]//Timing

Out[1]= {0.139881, ((-1)^n + b^1 + n/1 + n)}

In[2]:= Integrate[ x ^ n, {x, -1, b}, GenerateConditions -> True]//Timing

Out[2]=
{0.488809, ConditionalExpression[((-1)^n + b^(1 + n))/(1 + n), 
 (Im[b] != 0 || 1 + Re[b] < 0 || -1 < Re[b] < 0) && NotElement[b, Reals]]}
```

#### GeneratedParameters (4)

By default a particular antiderivative is returned:

```wl
In[1]:= Integrate[x, x]

Out[1]= (x^2/2)
```

Specify a value of ``GeneratedParameters`` to obtain the general antiderivative:

```wl
In[2]:= Integrate[x, x, GeneratedParameters -> C]

Out[2]= (x^2/2) + C[1]
```

---

One parameter is generated for each indefinite integral:

```wl
In[1]:= Integrate[Exp[2x], x, x, GeneratedParameters -> C]

Out[1]= (E^2 x/4) + C[1] + x C[2]

In[2]:= Integrate[Exp[2x], x, x, x, GeneratedParameters -> C]

Out[2]= (E^2 x/8) + C[1] + x C[2] + x^2 C[3]
```

If the input expression already contains a generated parameter, the next available index will be used:

```wl
In[3]:= Integrate[(E^2 x/8) + C[3], x, GeneratedParameters -> C]

Out[3]= (E^2 x/16) + x C[3] + C[4]
```

---

For nested integrals with multiple variables, the antiderivative contains arbitrary functions:

```wl
In[1]:= Integrate[Exp[2x], x, y, GeneratedParameters -> C]

Out[1]= (1/2) E^2 x y + C[1][y] + C[2][x]

In[2]:= Integrate[Exp[2x], x, y, z, GeneratedParameters -> C]

Out[2]= (1/2) E^2 x y z + C[1][y, z] + C[2][x, z] + C[3][x, y]
```

This is the most general antiderivative of the integrand:

```wl
In[3]:= D[%, x, y, z]

Out[3]= E^2 x
```

---

The value of ``GeneratedParameters`` is applied to the index of each generated parameter:

```wl
In[1]:= Integrate[Cos[x], x, x, GeneratedParameters -> f]

Out[1]= -Cos[x] + f[1] + x f[2]
```

The value can be a pure function:

```wl
In[2]:= Integrate[Cos[x], x, x, GeneratedParameters -> (Subscript["const", #]&)]

Out[2]= -Cos[x] + Subscript["const", 1] + x Subscript["const", 2]
```

A value of ``None`` disables generated parameters:

```wl
In[3]:= Integrate[Cos[x], x, x, GeneratedParameters -> None]

Out[3]= -Cos[x]
```

#### PrincipalValue (2)

The ordinary Riemann definite integral is divergent:

```wl
In[1]:= Integrate[1 / x, {x, -1, 2}]
```

Integrate::idiv: Integral of 1/x does not converge on {-1,2}.

```wl
Out[1]= Subsuperscript[∫, -1, 2](1/x)\[DifferentialD]x
```

The Cauchy principal value integral is finite:

```wl
In[2]:= Integrate[1 / x, {x, -1, 2}, PrincipalValue -> True]

Out[2]= Log[2]
```

The value is the limit of removing a symmetric region about the singularity:

```wl
In[3]:= Underscript[\[Limit], a -> 0^ + ](Subsuperscript[∫, -1, -a](1/x)\[DifferentialD]x + Subsuperscript[∫, a, 2](1/x)\[DifferentialD]x)

Out[3]= Log[2]
```

---

The ordinary Riemann definite integral is divergent:

```wl
In[1]:= Integrate[Tan[x], {x, 0, π}]
```

Integrate::idiv: Integral of Tan[x] does not converge on {0,\[Pi]}.

```wl
Out[1]= Subsuperscript[∫, 0, π]Tan[x]\[DifferentialD]x
```

Regularize the divergence at $x=\pi /2$ :

```wl
In[2]:= Integrate[Tan[x], {x, 0, π}, PrincipalValue -> True]

Out[2]= 0

In[3]:= Plot[Tan[x], {x, 0, Pi}, Filling -> Axis, FillingStyle -> {RGBColor[0.95, 0.627, 0.1425, 0.2], RGBColor[0.24, 0.6, 0.8, 0.2]}]

Out[3]= [image]
```

### Applications (67)

#### The Geometry of Integrals (5)

The integral $\int_a^b c \, dx$ of a constant function $c$ is the signed area of the rectangle of height $c$ and width $b-a$ :

```wl
In[1]:= Subsuperscript[∫, 1, 4]2\[DifferentialD]x

Out[1]= 6

In[2]:= % == 2×(4 - 1)

Out[2]= True

In[3]:= Subsuperscript[∫, 1, 4](-1)\[DifferentialD]x

Out[3]= -3

In[4]:= % == (-1)×(4 - 1)

Out[4]= True
```

Visualize the two rectangles:

```wl
In[5]:= Plot[{2, -1}, {x, 1, 4}, Filling -> Axis]

Out[5]= [image]
```

---

The integral $\int_a^b f(x) \, dx$ of a piecewise-constant function is the sum of the signed areas of the rectangles defined by its plot:

```wl
In[1]:=
f[x_] := Piecewise[{{0, x < 0}, {1, Inequality[0, LessEqual, x, Less, 1]}, 
  {-2, Inequality[1, LessEqual, x, Less, 3]}, {5, 3 <= x}}]

In[2]:= Subsuperscript[∫, 0, 4]f[x]\[DifferentialD]x

Out[2]= 2

In[3]:= % == 1×(1 - 0) + (-2)(3 - 1) + 5×(4 - 3)

Out[3]= True
```

Visualize the rectangles:

```wl
In[4]:= Plot[f[x], {x, 0, 4}, Filling -> Axis, FillingStyle -> {RGBColor[0.95, 0.627, 0.1425, 0.2], RGBColor[0.24, 0.6, 0.8, 0.2]}]

Out[4]= [image]
```

---

The integral $\int_a^b f(x) \, dx$ of a general function is the signed area between its plot and the horizontal axis:

```wl
In[1]:= f[x_] := x ^ 2 + 1

In[2]:= Integrate[f[x], {x, 0, 2}]

Out[2]= (14/3)

In[3]:= Plot[f[x], {x, 0, 2}, Filling -> Axis, AxesOrigin -> {0, 0}]

Out[3]= [image]
```

This can be related to the piecewise-constant case by considering rectangles defined by its plot:

```wl
In[4]:= rectangles[f_, a_, b_, n_] := {Opacity[0.75], StandardOrange, N@Table[Rectangle[{a + k(b - a) / n, 0}, {a + (k + 1)(b - a) / n, f[a + k(b - a) / n]}], {k, 0, n - 1}]}
```

For ``n == 5`` on the interval ``[0, 2]``, the rectangles are the following:

```wl
In[5]:= Plot[f[x], {x, 0, 2}, Epilog -> rectangles[f, 0, 2, 5], AxesOrigin -> {0, 0}]

Out[5]= [image]
```

The area of these rectangles defines a Riemann sum that approximates the area under the curve:

```wl
In[6]:=
RiemannSum[f_, a_, b_, n_] := 
	Sum[f[(a + (b - a)k / n)], {k, 0, n - 1}] (b - a) / n

In[7]:= RiemannSum[f, 0, 2, n]

Out[7]= (2 (2 - 6 n + 7 n^2)/3 n^2)
```

Using ``DiscreteLimit`` to obtain the exact answer as $n\to \infty$ gives the same answer as ``Integrate`` did:

```wl
In[8]:= DiscreteLimit[%, n -> ∞]

Out[8]= (14/3)
```

Visualize the process for this function as well as three others:

In[9]:=
label[f\_,a\_,b\_,n\_]:=StringForm["Subscript[A, curve]==\`\`   Subscript[A, rects]==\`\`",NumberForm[N@\!\(
\*SubsuperscriptBox[\(\[Integral]\), \(a\), \(b\)]\(f[x] \[DifferentialD]x\)\),{4,3}],NumberForm[N@RiemannSum[f,a,b,n],{4,3}]]

```wl
In[10]:= With[{a = 0, b = 2}, Manipulate[Plot[fn[x], {x, a, b}, Filling -> Axis, AxesOrigin -> {0, 0}, Epilog -> rectangles[fn, a, b, 2^n], PlotLabel -> label[fn, a, b, 2^n]], {{n, 1, Dynamic@StringForm["n = ``", 2^n]}, 1, 12, 1}, {{fn, f}, {f, CubeRoot, Sin, Abs[2# - 1]& -> $$\text{HoldForm}@| 2x-1|$$}}, SaveDefinitions -> True]]
```

Out[10]=
Manipulate[Plot[fn[x], {x, 0, 2}, Filling -> Axis, AxesOrigin -> {0, 0}, 
   Epilog -> rectangles[fn, 0, 2, 2^n], PlotLabel -> label[fn, 0, 2, 2^n]], 
  {{n, 1, Dynamic[StringForm["n  == \`\`", 2^n]]}, 1, 12, 1}, 
  {{fn, f}, {f, CubeRoot, Sin, (Ab ... x[\(A\), \(rects\)] == \`\`\)", 
      NumberForm[N[Integrate[f[x], {x, a, b}]], {4, 3}], 
      NumberForm[N[RiemannSum[f, a, b, n]], {4, 3}]], 
    RiemannSum[f\_, a\_, b\_, n\_] := Sum[f[a + (b - a)\*(k/n)], {k, 0, n - 1}]\*
      ((b - a)/n)}]

---

The Fundamental Theorem of Calculus relates a function to its integral from a fixed lower limit to a variable upper limit:

```wl
In[1]:= f[x_] := Sqrt[x ^ 2 + 1]
```

Consider the definite integral of the this from from $0$ to $x$ :

```wl
In[2]:= g[x_] = Integrate[f[t], {t, 0, x}, Assumptions -> x > 0]

Out[2]= (1/2) (x Sqrt[1 + x^2] + ArcSinh[x])
```

The Fundamental Theorem of Calculus states that $g'(x)=f(x)$ :

```wl
In[3]:= Simplify[g'[x] == f[x]]

Out[3]= True
```

This can be seen from the limit definition of derivative:

```wl
In[4]:= Limit[(g[x + h] - g[x]/h), h -> 0]

Out[4]= Sqrt[1 + x^2]
```

Note that $g(x+h)-g(x)=\int_x^{x+h} f(t) \, dt$ is an area consisting of a rectangle of height $f(x)$ and width $h$ plus a small correction that vanishes as $h\to 0$, as illustrated by the following table for $x=1$ :

```wl
In[5]:= TableForm[Table[{h, (g[1 + h] - g[1]/h), (g[1 + h] - g[1]/h) - f[1]}, {h, {.1, .05, .001, 0.0005, 0.00001, 0.00000005}}], TableHeadings -> {{}, {h, HoldForm[(g[1 + h] - g[1]/h)], HoldForm[(g[1 + h] - g[1] - f[1]h/h)]}}]

Out[5]//TableForm=
| h       | (g[1 + h] - g[1]/h) | (g[1 + h] - g[1] - f[1] h/h) |
| :------ | :------------------ | :--------------------------- |
| 0.1     | 1.45014             | 0.0359232                    |
| 0.05    | 1.43204             | 0.0178223           ... 1.41457             | 0.000353612                  |
| 0.0005  | 1.41439             | 0.000176791                  |
| 0.00001 | 1.41422             | 3.5355439078621487`*^-6      |
| 5.`*^-8 | 1.41421             | 1.498228807683688`*^-8       |
```

Hence, the limit can be seen geometrically to equal $f(x)$, as illustrated in the following visualization:

```wl
In[6]:= title[u_, k_] := IconizedObject[«Code for plot title»]

In[7]:= labels[u_, k_] := IconizedObject[«Code for labels in plot»]

In[8]:= Manipulate[Plot[{Piecewise[{{f[s], 0 ≤ s ≤ u}, {Undefined, True}}], Piecewise[{{f[s], u ≤ s ≤ u + k}, {Undefined, True}}], f[s]}, {s, 0, 3}, PlotLabel -> title[u, k], Epilog -> labels[u, k], IconizedObject[«More Plot options»]], {{u, 1.5, Style[x, Italic, 14]}, 1, 2, Appearance -> {"Labeled"}, LabelStyle -> 14}, {{k, .25, Style[h, Italic, 14]}, 0.00001, .5, Appearance -> "Labeled", LabelStyle -> 14}, SaveDefinitions -> True]

Out[8]= DynamicModule[«9»]
```

---

Integrate a discrete set of data with ``Interpolation`` :

```wl
In[1]:= data = Table[{x, Sin[(1/x + 1 / 2)]}, {x, 0, 10, 0.25}];

In[2]:= Integrate[Interpolation[data][x], {x, 0, 10}]

Out[2]= 2.7409
```

Compare with the exact area under the curved that was interpolated:

```wl
In[3]:= Integrate[Sin[(1/x + 1 / 2)], {x, 0, 10}]//N

Out[3]= 2.74325
```

Visualize the two areas:

```wl
In[4]:= {ListLinePlot[data, Filling -> Axis, ImageSize -> Small, InterpolationOrder -> 0], Plot[Interpolation[data][x], {x, 0, 10}, Filling -> Axis, ImageSize -> Small]}

Out[4]= {[image], [image]}
```

#### Area Between Curves (7)

Compute the area under the curve of $f(x)=\sqrt{9-x^2}+1$ from $-3$ to $0$ :

```wl
In[1]:= Plot[1 + Sqrt[9 - x ^ 2], {x, -3, 0}, Filling -> Axis, AxesOrigin -> {0, 0}]

Out[1]= [image]

In[2]:= Integrate[1 + Sqrt[9 - x ^ 2], {x, -3, 0}]

Out[2]= 3 + (9 π/4)
```

---

Find the area under the curve of $f(x)=\sin ^2(x) \cos ^4(x)$ from $-\pi$ to $\pi$ :

```wl
In[1]:= Plot[Sin[x] ^ 2 Cos[x] ^ 4, {x, -π, π}, Filling -> Axis]

Out[1]= [image]

In[2]:= Integrate[Sin[x] ^ 2 Cos[x] ^ 4, {x, -π, π}]

Out[2]= (π/8)
```

---

Determine the total area enclosed between of $f(x)=\sin (x)$ and the $x$-axis:

```wl
In[1]:= Plot[Sin[x], {x, -π, π}, Filling -> Axis]

Out[1]= [image]
```

The total area is given by the integral of the absolute value:

```wl
In[2]:= Integrate[RealAbs[Sin[x]], {x, -π, π}]

Out[2]= 4
```

Equivalently compute this as the sum of two integrals of the difference between the top and bottom:

```wl
In[3]:= Subsuperscript[∫, -π, 0](0 - Sin[x])\[DifferentialD]x + Subsuperscript[∫, 0, π](Sin[x] - 0)\[DifferentialD]x

Out[3]= 4
```

---

Compute the area between $f(x)=5 x-x^2$ and $g(x)=x$ from $0$ to $4$ :

```wl
In[1]:= Plot[{5x - x ^ 2, x}, {x, 0, 4}, PlotLegends -> "Expressions", Filling -> {1 -> {2}}]

Out[1]= [image]

In[2]:= Integrate[(5x - x ^ 2) - (x), {x, 0, 4}]

Out[2]= (32/3)
```

---

Find the area enclosed by $f(x)=\frac{2}{x^4+1}$ and $g(x)=x^2$ :

```wl
In[1]:= pts = Solve[y == 2 / (1 + x ^ 4) && y == x ^ 2, {x, y}, Reals]

Out[1]= {{x -> -1, y -> 1}, {x -> 1, y -> 1}}
```

Since $f(0)>g(0)$, $f$ will be above $g$ in the interval of interest and the area will equal:

```wl
In[2]:= Integrate[2 / (x ^ 4 + 1) - x ^ 2, {x, -1, 1}]

Out[2]= -(2/3) + (π + 2 ArcCoth[Sqrt[2]]/Sqrt[2])

In[3]:= %//N

Out[3]= 2.80123
```

Visualize the region of interest and the two functions:

```wl
In[4]:= Show[RegionPlot[x^2 < y < (2/x^4 + 1), {x, -1, 1}, {y, 0, 2}], Plot[{2 / (1 + x ^ 4), x ^ 2}, {x, -2, 2}, PlotLegends -> "Expressions"], PlotRange -> All]

Out[4]= [image]
```

---

Compute the area enclosed by $y=\cos (x)$ and $y=1-\frac{2 x}{\pi }$ :

```wl
In[1]:= pts = Solve[y == Cos[x] && y == 1 - 2x / π && 0 ≤ x ≤ π, {x, y}]

Out[1]= {{x -> 0, y -> 1}, {x -> (π/2), y -> 0}, {x -> π, y -> -1}}
```

Find the area as the integral of the absolute value of the difference over the entire interval:

```wl
In[2]:= Integrate[RealAbs[Cos[x] - (1 - 2x / π)], {x, 0, π}]//Expand

Out[2]= 2 - (π/2)
```

Visualize the two functions and the area between them:

```wl
In[3]:= Show[RegionPlot[y ≤ Cos[x] && y ≥ 1 - 2x / π || y ≥ Cos[x] && y ≤ 1 - 2x / π, {x, 0, π}, {y, -2, 2}, PlotPoints -> 60, PlotStyle -> Opacity[.75]], Plot[{Cos[x], 1 - 2x / π}, {x, -1, 4}, PlotTheme -> "Detailed"], Graphics[{PointSize[Large], Point[{x, y} /. pts]}], PlotRange -> All, Axes -> True]

Out[3]= [image]
```

Use the plot to split the integral into two equivalent integrals with no absolute value:

```wl
In[4]:= Subsuperscript[∫, 0, (π/2)](Cos[x] - (1 - (2 x/π)))\[DifferentialD]x + Subsuperscript[∫, (π/2), π]((1 - (2 x/π)) - Cos[x])\[DifferentialD]x

Out[4]= 2 - (π/2)
```

---

To compute the area enclosed by $y=\frac{1}{x^2}$, $y=x$, and $y=\frac{x}{8}$, first find the points of intersection:

```wl
In[1]:= pt1 = Solve[y == 1 / x ^ 2 && y == x, {x, y}, Reals]

Out[1]= {{x -> 1, y -> 1}}

In[2]:= pt2 = Solve[y == 1 / x ^ 2 && y == (1 / 8)x, {x, y}, Reals]

Out[2]= {{x -> 2, y -> (1/4)}}

In[3]:= pt3 = Solve[y == (1 / 8)x && y == x, {x, y}, Reals]

Out[3]= {{x -> 0, y -> 0}}
```

Visualize the three curves over an area containing the points:

```wl
In[4]:= ContourPlot[{y == 1 / x ^ 2, y == x, y == (1 / 8)x}, {x, -1, 3}, {y, -1, 2}, PlotLegends -> "Expressions", Axes -> True, AspectRatio -> Automatic, Epilog -> {PointSize[Large], Point[{x, y} /. Join[pt1, pt2, pt3]]}]

Out[4]= [image]
```

From the plot, it is clear $y$ is above the line $y=\frac{x}{8}$ and below the other two curves:

```wl
In[5]:= reg = ImplicitRegion[y ≤ 1 / x ^ 2 && y ≤ x && y ≥ (1 / 8)x, {x, y}]

Out[5]= ImplicitRegion[y ≤ (1/x^2) && y ≤ x && y ≥ (x/8), {x, y}]

In[6]:= RegionPlot[reg, AspectRatio -> Automatic]

Out[6]= [image]
```

Area can be found using two integrals, one for each "top function":

```wl
In[7]:= Integrate[x - (1 / 8)x, {x, 0, 1}] + Integrate[1 / x ^ 2 - (1 / 8)x, {x, 1, 2}]

Out[7]= (3/4)
```

This can be reduced to a single integral using ``Min`` :

```wl
In[8]:= Integrate[Min[x, 1 / x^2] - (1 / 8)x, {x, 0, 2}]

Out[8]= (3/4)
```

Compare with the answer returned by ``Area`` :

```wl
In[9]:= Area[reg]

Out[9]= (3/4)
```

#### Regions of Revolution (7)

Compute the volume enclosed when $y=\sin ^2(x)$ for $\pi /2<x<\pi$ is rotated about the $x$ - axis:

```wl
In[1]:= Integrate[π(Sin[x] ^ 2) ^ 2, {x, 0, π}]

Out[1]= (3 π^2/8)
```

Visualize the solid:

```wl
In[2]:= RevolutionPlot3D[Sin[x] ^ 2, {x, 0, π}, RevolutionAxis -> "X"]

Out[2]= [image]
```

---

Use cylindrical shells to find the volume enclosed when $y=x (x-1)^2$, $0<x<1$, is rotated about the $y$-axis:

```wl
In[1]:= Integrate[2π x(x(x - 1) ^ 2), {x, 0, 1}]

Out[1]= (π/15)
```

Visualize the solid, adding the cap at $y=0$ :

```wl
In[2]:= Show[RevolutionPlot3D[{x(x - 1) ^ 2}, {x, 0, 1}], RevolutionPlot3D[0, {x, 0, 1}]]

Out[2]= [image]
```

---

Find the volume of the region formed by rotating the area between $f(x)=x$ and $g(x)=x^2$ about the $y$-axis:

```wl
In[1]:=
f[x_] := x
g[x_] := x^2
```

Find where the curves intersect:

```wl
In[2]:= Solve[f[x] == g[x], x]

Out[2]= {{x -> 0}, {x -> 1}}
```

Between these two values of $x$, $f$ is above $g$ :

```wl
In[3]:= Plot[{g[x], f[x]}, {x, 0, 1}, Filling -> {2 -> {1}}]

Out[3]= [image]
```

Visualize the volume:

```wl
In[4]:= RevolutionPlot3D[{{x, f[x]}, {x, g[x]}}, {x, 0, 1}, PlotStyle -> Opacity[.6]]

Out[4]= [image]
```

Integrate cylindrical shells of height $f(x)-g(x)$ and circumference $2 \pi  x$ to find the volume:

```wl
In[5]:= Subsuperscript[∫, 0, 1]2π x(f[x] - g[x])\[DifferentialD]x

Out[5]= (π/6)
```

---

Determine the volume the region above $f(x)=\csc (x)$ and below $y=2$ for $0\leq x\leq \pi$, rotated about the $x$-axis:

```wl
In[1]:= f[x_] := Csc[x]
```

Find where the curves intersect, adding the constraint on the range of $x$ :

```wl
In[2]:= Solve[f[x] == 2 && 0 ≤ x ≤ π, x]

Out[2]= {{x -> (π/6)}, {x -> (5 π/6)}}
```

The relevant range of $x$ values is between these two points:

```wl
In[3]:= Plot[{2, f[x]}, {x, 0, π}, Filling -> {2 -> {1}}, PlotRange -> {0, 2}]

Out[3]= [image]
```

Visualize the volume:

```wl
In[4]:= Show[RevolutionPlot3D[f[x], {x, (π/6), (5 π/6)}, RevolutionAxis -> {1, 0, 0}], Graphics3D[{Opacity[.5], Cylinder[{{0, 0, 0}, {π, 0, 0}}, 2]}], ViewPoint -> {2, -2.5, 1}, PlotRange -> {{π / 6, 5π / 6}, {-2, 2}, {-2, 2}}]

Out[4]= [image]
```

Integrate washers of area $\pi \left(2^2-f(x)^2\right)$ to find the volume:

```wl
In[5]:= Subsuperscript[∫, (π/6), (5 π/6)]π(2^2 - f[x]^2)\[DifferentialD]x

Out[5]= -2 Sqrt[3] π + (8 π^2/3)

In[6]:= %//N

Out[6]= 15.4361
```

---

Compute the surface area when $y=x^3$ for $0<x<1$ is rotated about the $y$-axis:

```wl
In[1]:= RevolutionPlot3D[x ^ 3, {x, 0, 1}]

Out[1]= [image]
```

Apply the formula of the infinitesimal width of each strip:

```wl
In[2]:= w = Sqrt[1 + D[x ^ 3, x] ^ 2]

Out[2]= Sqrt[1 + 9 x^4]
```

Multiply the width by the circumference $2 \pi  x$ of each circle and integrate:

```wl
In[3]:= Subsuperscript[∫, 0, 1]2 π x w\[DifferentialD]x

Out[3]= (1/6) π (3 Sqrt[10] + ArcTanh[(3/Sqrt[10])])
```

---

Find the area when $y=\sqrt{x^2+1}$ for -$\sqrt{3}<x<\sqrt{3}$ is rotated about the $x$-axis:

```wl
In[1]:= RevolutionPlot3D[Sqrt[x^2 + 1], {x, -Sqrt[3], Sqrt[3]}, RevolutionAxis -> "X"]

Out[1]= [image]
```

The infinitesimal width of each strip is given by the following:

```wl
In[2]:= w = Sqrt[1 + D[Sqrt[x ^ 2 + 1], x]^2]

Out[2]= Sqrt[1 + (x^2/1 + x^2)]
```

Multiplying the width by the circumference $2 \pi  \sqrt{x^2+1}$ and integrating yields the answer:

```wl
In[3]:= Subsuperscript[∫, -Sqrt[3], Sqrt[3]]2 π Sqrt[x^2 + 1] w\[DifferentialD]x

Out[3]= π (2 Sqrt[21] + Sqrt[2] ArcSinh[Sqrt[6]])
```

---

Determine the surface area when $y=\frac{1}{x}$ for $1\leq x\leq  3$ is rotated about line $x=4$ :

```wl
In[1]:= f[x_] := 1 / x
```

The infinitesimal width of each strip is given by the following:

```wl
In[2]:= w = Sqrt[1 + D[f[x], x]^2]

Out[2]= Sqrt[1 + (1/x^4)]
```

Since $x<4$ for the curve in question, each strip has radius $4-x$ and width $w dx$ :

```wl
In[3]:= Subsuperscript[∫, 1, 3]2π(4 - x)w\[DifferentialD]x

Out[3]= 8 Sqrt[π] Gamma[(3/4)]^2 + π (Sqrt[2] - Sqrt[82] - ArcTanh[Sqrt[2]] + ArcTanh[Sqrt[82]] - (656/3) Sqrt[82] Hypergeometric2F1[1, (5/4), (3/4), -81])
```

Find the numerical approximation of this value:

```wl
In[4]:= %//N//Chop

Out[4]= 27.5245
```

Visualize the surface using modified cylindrical coordinates based on the line $x=4$, $z=0$ :

```wl
In[5]:= ParametricPlot3D[{Cos[θ](x - 4) + 4, 1 / x, Sin[θ](x - 4)}, {x, 1, 3}, {θ, 0, 2π}, IconizedObject[«ParametricPlot3D options»]]

Out[5]= [image]
```

#### Arc Length, Surface Area, and Volume (8)

Compute the arc length of the plot $f(x)=\frac{x^4}{8}+\frac{1}{4 x^2}$ from $1$ to $2$ :

```wl
In[1]:= f[x_] := (x^4/8) + (1/4 x^2)

In[2]:= Plot[f[x], {x, 1, 2}, PlotRange -> {0, 2}]

Out[2]= [image]
```

Apply the formula for infinitesimal arc length:

```wl
In[3]:= ds = Sqrt[1 + D[f[x], x] ^ 2]//Simplify

Out[3]= (1/2) Sqrt[2 + (1/x^6) + x^6]
```

Integrate to find the arc length:

```wl
In[4]:= Integrate[ds, {x, 1, 2}]

Out[4]= (33/16)
```

Compare with the answer returned by ``ArcLength`` :

```wl
In[5]:= ArcLength[f[x], {x, 1, 2}]

Out[5]= (33/16)
```

---

Compute the arc length of the plot $f(x)=$ from $0$ to $1$ :

```wl
In[1]:= f[x_] := Sqrt[x - x^2] + ArcSin[Sqrt[x]]

In[2]:= Plot[f[x], {x, 0, 1}]

Out[2]= [image]
```

Apply the formula for infinitesimal arc length:

```wl
In[3]:= ds = Sqrt[1 + D[f[x], x] ^ 2]//Simplify

Out[3]= Sqrt[(1/x)]
```

Integrate to find the arc length:

```wl
In[4]:= Integrate[ds, {x, 0, 1}]

Out[4]= 2
```

Compare with the answer returned by ``ArcLength`` :

```wl
In[5]:= ArcLength[f[x], {x, 0, 1}]

Out[5]= 2
```

---

Length of a parametrically defined circle:

```wl
In[1]:= {x, y} = {2Cos[u], 2Sin[u]};
```

The relevant parameter range is $0$ to $2 \pi$ :

```wl
In[2]:= ParametricPlot[{x, y}, {u, 0, 2π}]

Out[2]= [image]
```

The infinitesimal arc length is constant:

```wl
In[3]:= ds = Sqrt[D[x, u] ^ 2 + D[y, u] ^ 2]//Simplify

Out[3]= 2
```

Integrate to find the total arc length:

```wl
In[4]:= Integrate[ds, {u, 0, 2π}]

Out[4]= 4 π
```

Compare with the answer returned by ``ArcLength`` :

```wl
In[5]:= ArcLength[{x, y}, {u, 0, 2π}]

Out[5]= 4 π
```

---

Length of a 3D parametrically defined ellipse:

```wl
In[1]:= c[u_] = {1, 0, 0}2Cos[u] + Normalize[{0, 1, 1}]Sin[u]

Out[1]= {2 Cos[u], (Sin[u]/Sqrt[2]), (Sin[u]/Sqrt[2])}
```

Visualize the ellipse:

```wl
In[2]:= ParametricPlot3D[c[u], {u, 0, 2π}]

Out[2]= [image]
```

The infinitesimal arc length is non-constant:

```wl
In[3]:= ds = Sqrt[c'[u].c'[u]]

Out[3]= Sqrt[Cos[u]^2 + 4 Sin[u]^2]
```

Integrate to find the total arc length:

```wl
In[4]:= Integrate[ds, {u, 0, 2π}]

Out[4]= 4 EllipticE[-3]

In[5]:= %//N

Out[5]= 9.68845
```

Compare with the answer returned by ``ArcLength`` :

```wl
In[6]:= ArcLength[c[u], {u, 0, 2π}]

Out[6]= 4 EllipticE[-3]
```

---

Find the surface area of the plot $f(x,y)=x^2+y^2$ over the rectangle $[0,1]\times [0,1]$ :

```wl
In[1]:= f[x_, y_] := x^2 + y^2

In[2]:= Plot3D[f[x, y], {x, 0, 1}, {y, 0, 1}, BoxRatios -> Automatic]

Out[2]= [image]
```

Apply the formula for infinitesimal surface area of a plot:

```wl
In[3]:= dA = Sqrt[1 + D[f[x, y], x] ^ 2 + D[f[x, y], y] ^ 2]//Simplify

Out[3]= Sqrt[1 + 4 x^2 + 4 y^2]
```

Integrate to find the arc length:

```wl
In[4]:= Integrate[dA, {x, 0, 1}, {y, 0, 1}]

Out[4]= (1/24) (24 - 6 ArcCot[2] + ArcTan[(4/3)] + 14 Log[5])

In[5]:= %//N

Out[5]= 1.86156
```

Compare with the answer returned by ``Area`` :

```wl
In[6]:= Area[f[x, y], {x, 0, 1}, {y, 0, 1}]

Out[6]= (1/24) (24 - 6 ArcCot[2] + ArcTan[(4/3)] + 14 Log[5])
```

---

Find the area of the surface $s(u,v)=\{\cos (u) (\cos (v)+2),\sin (u) (\cos (v)+2),\sin (v)\}$ where $0\leq u,v\leq 2 \pi$ :

```wl
In[1]:= s[u_, v_] := {(2 + Cos[v])Cos[u], (2 + Cos[v])Sin[u], Sin[v]}
```

This surface is a torus:

```wl
In[2]:= ParametricPlot3D[s[u, v], {u, 0, 2π}, {v, 0, 2π}]

Out[2]= [image]
```

Apply the formula for infinitesimal surface area of a parametric surface:

```wl
In[3]:= dA = Simplify[Norm[Subscript[∂, u]s[u, v]\[Cross]Subscript[∂, v]s[u, v]], {u, v}∈ℝ]

Out[3]= 2 + Cos[v]
```

Integrate to find the total surface area:

```wl
In[4]:= Integrate[dA, {u, 0, 2π}, {v, 0, 2π}]

Out[4]= 8 π^2
```

Compare with the answer returned by ``Area`` :

```wl
In[5]:= Area[s[u, v], {u, 0, 2π}, {v, 0, 2π}]

Out[5]= 8 π^2
```

---

Find the volume of the following parametric region, where $0\leq r\leq 1$, $0\leq u,v\leq 2 \pi$ :

```wl
In[1]:= ρ[r_, u_, v_] := {(2 + r Cos[v])Cos[u], (2 + r Cos[v])Sin[u], Sin[v]}
```

This region is a solid torus:

```wl
In[2]:= ParametricPlot3D[ρ[1, u, v], {u, 0, 2Pi}, {v, 0, 2Pi}]

Out[2]= [image]
```

Compute the Jacobian determinant:

```wl
In[3]:= j = Simplify[RealAbs[Det[Grad[ρ[r, u, v], {r, u, v}]]], 0 ≤ r ≤ 1 && 0 ≤ v ≤ 2π]

Out[3]= Cos[v]^2 (2 + r Cos[v])
```

Integrate to find the volume:

```wl
In[4]:= Subsuperscript[∫, 0, 1]Subsuperscript[∫, 0, 2 π]Subsuperscript[∫, 0, 2π]j\[DifferentialD]u\[DifferentialD]v\[DifferentialD]r

Out[4]= 4 π^2
```

Compare with the answer returned by ``Volume`` :

```wl
In[5]:= Volume[ρ[r, u, v], {r, 0, 1}, {u, 0, 2Pi}, {v, 0, 2Pi}]

Out[5]= 4 π^2
```

---

Find the volume of the following parametric region, where $0\leq r\leq 1$, $0\leq \theta \leq 2 \pi$, and $0\leq \psi \leq \pi$ :

```wl
In[1]:= ρ[r_, θ_, ψ_] := {3r Cos[ψ], 2r Sin[θ]Sin[ψ], r Cos[θ]Sin[ψ]}
```

The region is an ellipsoid:

```wl
In[2]:= ParametricPlot3D[ρ[1, θ, ψ], {θ, 0, 2Pi}, {ψ, 0, Pi}]

Out[2]= [image]
```

Compute the Jacobian determinant:

```wl
In[3]:= j = Simplify[RealAbs[Det[Grad[ρ[r, θ, ψ], {r, θ, ψ}]]], 0 ≤ r ≤ 1 && 0 ≤ ψ ≤ π]

Out[3]= 6 r^2 Sin[ψ]
```

Integrate to find the volume:

```wl
In[4]:= Subsuperscript[∫, 0, 1]Subsuperscript[∫, 0, 2 π]Subsuperscript[∫, 0, π]j\[DifferentialD]ψ\[DifferentialD]θ\[DifferentialD]r

Out[4]= 8 π
```

Compare with the answer returned by ``Volume`` :

```wl
In[5]:= Volume[ρ[r, θ, ψ], {r, 0, 1}, {θ, 0, 2Pi}, {ψ, 0, Pi}]

Out[5]= 8 π
```

#### Line Integrals (6)

Compute the line integral $\oint f(s)ds$ of $f(x,y)=x+y^2$ over the origin-centered ellipse with semi-major axes $2$ and $1$ :

```wl
In[1]:= f[{x_, y_}] := x  + y^2

In[2]:= reg = Region[Circle[{0, 0}, {2, 1}], Axes -> True]

Out[2]= [image]
```

Parameterize the ellipse:

```wl
In[3]:= c[t_] := {2Cos[t], Sin[t]}

In[4]:= ParametricPlot[c[t], {t, 0, 2Pi}]

Out[4]= [image]
```

Perform the integral using the fact that $ds=\left\| c'(t)\right\| dt$ :

```wl
In[5]:= Subsuperscript[∫, 0, 2 π]f[c[t]] Norm[Derivative[1][c][t]]\[DifferentialD]t

Out[5]= (4/9) (7 EllipticE[-3] - 4 EllipticK[-3])

In[6]:= %//N

Out[6]= 5.61856
```

Compare the direct integral over the ellipse:

```wl
In[7]:= Underscript[∫, \[DoubleStruckX]∈reg]f[\[DoubleStruckX]]

Out[7]= (4/9) (7 EllipticE[-3] - 4 EllipticK[-3])
```

---

Calculate the closed line integral $\oint  \overset{\rightharpoonup }{v}\cdot d\overset{\rightharpoonup }{r}$ of $v(x,y)=\left(x y,3 y^2\right)$ over the following parametric curve:

```wl
In[1]:= c[t_] := {Cos[t], Sin[2t]}
```

The curve forms an infinity figure, traversed from red to purple as shown in the following plot:

```wl
In[2]:= Show[ParametricPlot[{Cos[x], Sin[2x]}, {x, 0, 2Pi}, PlotTheme -> "Detailed", ColorFunction -> (Hue[0.8#3]&)]]

Out[2]= [image]
```

Define the vector field $\overset{\rightharpoonup }{v}$ :

```wl
In[3]:= v[{x_, y_}] := {x y, 3y ^ 2}
```

Perform the calculation using the definition $\oint  \overset{\rightharpoonup }{v}\cdot d\overset{\rightharpoonup }{r}=\oint  \overset{\rightharpoonup }{v}\cdot \overset{\rightharpoonup }{c'}(t)dt$ :

```wl
In[4]:= Integrate[v[c[t]].c'[t], {t, 0, 2π}]

Out[4]= -(π/2)
```

---

To calculate ``∫x^4dx + x y\[DifferentialD]y`` over the triangle with vertices $(0,0)$, $(1,0)$, and $(0,1)$, define the associated vector field:

```wl
In[1]:= v[{x_, y_}] := {x^4, x y}
```

Parametrize the triangle using a piecewise-linear parametrization:

```wl
In[2]:=
c[t_] = Piecewise[{{{0, 0} + t*({1, 0} - {0, 0}), 0 <= t <= 1}, {{1, 0} + (t - 1)*({0, 1} - {1, 0}), 
   1 <= t <= 2}, {{0, 1} + (t - 2)*({0, 0} - {0, 1}), 2 <= t <= 3}, {Indeterminate, True}}]

Out[2]=
Piecewise[{{{t, 0}, 0 <= t <= 1}, {{2 - t, -1 + t}, 1 <= t <= 2}, {{0, 3 - t}, 2 <= t <= 3}}, 
 Indeterminate]
```

The parametrization is oriented counter-clockwise:

```wl
In[3]:= ParametricPlot[c[t], {t, 0, 3}, PlotTheme -> "FrameGrid", ColorFunction -> (Hue[0.8#3]&)]

Out[3]= [image]
```

Compute the line integral from the definition $\oint  \overset{\rightharpoonup }{v}\cdot d\overset{\rightharpoonup }{r}=\oint  \overset{\rightharpoonup }{v}\cdot \overset{\rightharpoonup }{c'}(t)dt$ :

```wl
In[4]:= Integrate[v[c[t]].c'[t], {t, 0, 3}]

Out[4]= (1/6)
```

---

Calculate the work done by the force $F(x,y,z)=-\frac{G m M \left(x\hat{i} y\hat{j}+z\hat{k}\right)}{\left(x^2+y^2+z^2\right)^{3/2}}$ as a particle takes the following path from $(a,0,0)$, $a>0$, to $(0,b,0)$, $b>0$ :

```wl
In[1]:= c[t_] := {a Cos[t], b Sin[t], t(t - Pi / 2)}
```

Define the force field as function from points to vectors:

```wl
In[2]:= F[{x_, y_, z_}] := -(G M m{x, y, z}/(x^2 + y^2 + z^2)^3 / 2)
```

The work done is the line integral $\int \overset{\rightharpoonup }{F}\cdot d\overset{\rightharpoonup }{r}$ :

```wl
In[3]:= Integrate[F[c[t]].c'[t], {t, 0, Pi / 2}, Assumptions -> {a > 0, b > 0}]//Expand

Out[3]= -(G m M/a) + (G m M/b)
```

---

Find a potential function for the following vector field:

```wl
In[1]:= v[{x_, y_, z_}] := {x ^ 2, y ^ 2, z ^ 2}
```

This is possible because the vector field is conservative:

```wl
In[2]:= Curl[v[{x, y, z}], {x, y, z}]

Out[2]= {0, 0, 0}
```

Define a family of straight-line curves that go from the origin at time $0$ to $(x,y,z)$ at time $1$ :

```wl
In[3]:= Subscript[c, {x_, y_, z_}][t_] := t{x, y, z}
```

Let $\phi (x,y,z)$ be the line integral of $v$ from the origin to the point $(x,y,z)$ :

```wl
In[4]:= ϕ[{x_, y_, z_}] = Subsuperscript[∫, 0, 1]v[Subscript[c, {x, y, z}][t]].D[Subscript[c, {x, y, z}][t], t]\[DifferentialD]t

Out[4]= (1/3) (x^3 + y^3 + z^3)
```

Verify that $\phi$ is a potential function for $v$ using Grad

```wl
In[5]:= Grad[ϕ[{x, y, z}], {x, y, z}] == v[{x, y, z}]

Out[5]= True
```

---

Use Green's Theorem to find the area of the area enclosed by the following curve:

```wl
In[1]:= c[u_] := {Cos[u] + 1 / 7Cos[7u + π / 3], Sin[u] + 1 / 7Sin[7u]};

In[2]:= ParametricPlot[c[u], {u, 0, 2π}]

Out[2]= [image]
```

The following vector-field has a two-dimensional ``Curl`` of $1$ :

```wl
In[3]:= v[{x_, y_}] := {0, x}

In[4]:= Curl[v[{x, y}], {x, y}]

Out[4]= 1
```

Apply Green's theorem in the form $\int \int 1 \, dA=\oint  \overset{\rightharpoonup }{v}\cdot d\overset{\rightharpoonup }{r}=\oint  \overset{\rightharpoonup }{v}\cdot \overset{\rightharpoonup
}{c'}(u)du$ to compute the area:

```wl
In[5]:= Subsuperscript[∫, 0, 2 π]v[c[u]].Derivative[1][c][u]\[DifferentialD]u

Out[5]= (15 π/14)
```

#### Surface and Volume Integrals (7)

Use Green's Theorem to compute $\int \left(\left(3 y-e^{\sin (x)}\right)dx+\left(7 x+\sqrt{y^4+1}\right)dy\right.$ over the circle centered at the origin with radius 3:

```wl
In[1]:= v[x_, y_] := {3y^3 - Exp[Sin[x]], 7x^2 + Sqrt[y^4 + 1]}
```

Visualize the vector field and circle for the line integral:

```wl
In[2]:= VectorPlot[v[x, y], {x, -3, 3}, {y, -3, 3}, Epilog -> Circle[{0, 0}, 3], PlotRangePadding -> None]

Out[2]= [image]
```

The circulation of the vector field can be computed using ``Curl`` :

```wl
In[3]:= circ = Curl[v[x, y], {x, y}]

Out[3]= 14 x - 9 y^2
```

Integrate over the interior of the circle:

```wl
In[4]:= Subsuperscript[∫, -3, 3]Subsuperscript[∫, -Sqrt[9 - y^2], Sqrt[9 - y^2]]circ\[DifferentialD]x\[DifferentialD]y

Out[4]= -(729 π/4)
```

Perform the integral using region notation:

```wl
In[5]:= Underscript[∫, {x, y}∈Disk[{0, 0}, 3]]circ

Out[5]= -(729 π/4)
```

---

Compute the integral over the unit sphere of $f(x,y,z)=(x+y+z)^4$ :

```wl
In[1]:= f[{x_, y_, z_}] := (x + y + z)^4
```

Parameterize the sphere:

```wl
In[2]:= s[θ_, φ_] := {Sin[θ]Cos[φ], Sin[θ]Sin[φ], Cos[θ]}
```

Determine infinitesimal surface area:

```wl
In[3]:= dS = Simplify[Norm[Subscript[∂, θ]s[θ, φ]\[Cross]Subscript[∂, φ]s[θ, φ]], 0 ≤ θ ≤ π && -π < φ < π]

Out[3]= Sin[θ]
```

Perform the integral $\oint fdS$ :

```wl
In[4]:= Subsuperscript[∫, 0, 2π]Subsuperscript[∫, 0, π]f[s[θ, φ]]dS\[DifferentialD]θ\[DifferentialD]φ

Out[4]= (36 π/5)
```

Compare with a region integral:

```wl
In[5]:= Subscript[∫, \[DoubleStruckCapitalX]∈Sphere[]]f[\[DoubleStruckCapitalX]]

Out[5]= (36 π/5)
```

---

Verify Stoke's theorem for $v(x,y,z)=\left\{-y,x,x^2-y^2\right\}$ for the upper unit hemisphere:

```wl
In[1]:= v[{x_, y_, z_}] := {-y, x, x ^ 2 - y ^ 2}
```

Parameterize the surface using standard spherical coordinates:

```wl
In[2]:= s[u_, v_] := {Sin[u]Cos[v], Sin[u]Sin[v], Cos[u]}
```

Visualize the surface and the vector field:

```wl
In[3]:= Show[ParametricPlot3D[s[u, v], {u, 0, Pi / 2}, {v, 0, 2Pi}], VectorPlot3D[v[{x, y, z}], {x, -1, 1}, {y, -1, 1}, {z, 0, 1}], PlotRange -> {{-1, 1}, {-1, 1}, {0, 1}}]

Out[3]= [image]
```

The boundary of the surface is the unit circle in the $x y$-plane:

```wl
In[4]:= c[t_] := {Cos[t], Sin[t], 0}
```

Compute the curl of the vector field:

```wl
In[5]:= curl[{x_, y_, z_}] = Curl[v[{x, y, z}], {x, y, z}]

Out[5]= {-2 y, -2 x, 2}
```

Compute the oriented surface area element on the hemisphere:

```wl
In[6]:= dS = Subscript[∂, u]s[u, v]\[Cross]Subscript[∂, v]s[u, v]//Simplify

Out[6]= {Cos[v] Sin[u]^2, Sin[u]^2 Sin[v], Cos[u] Sin[u]}
```

Stoke's theorem, $\int \int \left(\nabla \times \overset{\rightharpoonup }{v}\cdot d\overset{\rightharpoonup }{S}\right)=\oint  \overset{\rightharpoonup }{v}\cdot
d\overset{\rightharpoonup }{r}$, states that line integral of $\overset{\rightharpoonup }{v}$ on boundary equals the flux integral of its curl through the surface :

```wl
In[7]:= Subsuperscript[∫, 0, (π/2)]Subsuperscript[∫, 0, 2 π]curl[s[u, v]].dS\[DifferentialD]v\[DifferentialD]u == Subsuperscript[∫, 0, 2 π]v[c[t]].Derivative[1][c][t]\[DifferentialD]t

Out[7]= True
```

---

Use the divergence theorem to compute the flux of $v(x,y,z)=\left(x y,e^{x z^2}+y^2,\sin (x y)\right)$ through the surface bounded above by $z=1-x^2$, below by $z=0$, and on the side by $y+z=2$ and $y=0$ :

```wl
In[1]:= ContourPlot3D[{y + z == 2, z == 1 - x ^ 2, z == 0, y == 0}, {x, -1.5, 1.5}, {y, 0, 2}, {z, 0, 1}, ContourStyle -> Opacity[0.5], Mesh -> None]

Out[1]= [image]
```

The divergence theorem, $\oint \overset{\rightharpoonup }{v}\cdot d\overset{\rightharpoonup }{S}=\int \int \int \nabla \cdot \overset{\rightharpoonup }{v} \, dV$, relates the flux to the volume integral of the divergence:

```wl
In[2]:= Subsuperscript[∫, -1, 1]Subsuperscript[∫, 0, 1 - x^2]Subsuperscript[∫, 0, 2 - z]Div[{x y, y^2 + E^x z^2, Sin[x y]}, {x, y, z}]\[DifferentialD]y\[DifferentialD]z\[DifferentialD]x

Out[2]= (184/35)
```

---

Use Gauss's Theorem to find the volume enclosed by the following parametric surface:

```wl
In[1]:= s[u_, v_] := {(2 + Cos[v])Cos[u], (2 + Cos[v])Sin[u], Sin[v](5 / 4 - Cos[u])}

In[2]:= ParametricPlot3D[s[u, v], {u, 0, 2π}, {v, 0, 2π}]

Out[2]= [image]
```

The oriented area element on the surface is given by the following:

```wl
In[3]:= dA = Subscript[∂, u]s[u, v]\[Cross]Subscript[∂, v]s[u, v]//FullSimplify

Out[3]= {-(1/4) Cos[u] (-5 + 4 Cos[u]) Cos[v] (2 + Cos[v]) + Sin[u]^2 Sin[v]^2, (1/4) (5 Cos[v] (2 + Cos[v]) - 4 Cos[u] (1 + 2 Cos[v])) Sin[u], (2 + Cos[v]) Sin[v]}
```

The following vector-field has a divergence equal $1$ :

```wl
In[4]:= v[{x_, y_, z_}] := (1/3){x, y, z}

In[5]:= Div[v[{x, y, z}], {x, y, z}]

Out[5]= 1
```

Apply Gauss's Theorem in the form$\int \int \int 1 \, dV==\oint \overset{\rightharpoonup }{v}\cdot d\overset{\rightharpoonup }{A}$ to compute the volume:

```wl
In[6]:= Integrate[v[s[u, v]].dA, {u, 0, 2π}, {v, 0, 2π}]

Out[6]= 5 π^2
```

---

Given a mass density $\rho (x,y,z)=\left(2-y^2\right) \left(x^2+z^2\right)$, find the mass of region given by the following:

```wl
In[1]:= φ[u_, v_, w_] := {(5 + 2w Cos[v])Cos[u], 2Sin[v], (5 + 2w Cos[v])Sin[u]};
```

The ranges of the parameters are $u,v\in [0,2 \pi ]$ and $w\in [0,1]$, producing a filled torus:

```wl
In[2]:= ParametricPlot3D[φ[u, v, 1], {u, 0, 2π}, {v, 0, 2π}]

Out[2]= [image]
```

Enter the mass density function:

```wl
In[3]:= ρ[{x_, y_, z_}] := (2 - y^2)(x^2 + z^2)
```

Compute the Jacobian determinate:

```wl
In[4]:= jac = Simplify[RealAbs@Det[Grad[φ[u, v, w], {u, v, w}]], 0 ≤ w ≤ 1 && v∈Reals]

Out[4]= 4 Cos[v]^2 (5 + 2 w Cos[v])
```

Integrate to find the total mass:

```wl
In[5]:= Integrate[ρ[φ[u, v, w]]jac, {u, 0, 2π}, {v, 0, 2π}, {w, 0, 1}]

Out[5]= 1160 π^2
```

---

Derive a formula for the integral of $\sum _{i=1}^n x_i^2$ over an $n$-dimensional unit ball:

```wl
In[1]:= Table[Integrate[Sum[Indexed[x, i] ^ 2, {i, n}], x∈Ball[n]], {n, 10}]

Out[1]= {(2/3), (π/2), (4 π/5), (π^2/3), (8 π^2/21), (π^3/8), (16 π^3/135), (π^4/30), (32 π^4/1155), (π^5/144)}

In[2]:= FindSequenceFunction[%, n]

Out[2]= (n π^n / 2/2 Gamma[2 + (n/2)])
```

Verify the formula:

```wl
In[3]:= Table[(n π^n / 2/2 Gamma[2 + (n/2)]), {n, 10}]

Out[3]= {(2/3), (π/2), (4 π/5), (π^2/3), (8 π^2/21), (π^3/8), (16 π^3/135), (π^4/30), (32 π^4/1155), (π^5/144)}
```

#### Average Values and Centroids (6)

Compute the average value of $f(x)=\sin (x) \cos ^4(x)$ between $0$ and $\pi$ :

```wl
In[1]:= (Subsuperscript[∫, 0, π]Cos[x]^4 Sin[x]\[DifferentialD]x/π - 0)

Out[1]= (2/5 π)
```

Visualize the function and its average value:

```wl
In[2]:= Plot[{Cos[x] ^ 4Sin[x], 2 / (5π)}, {x, 0, π}]

Out[2]= [image]
```

---

Find the mean of $f(x,y)=x+y$ over the parallelogram based at the origin with sides $\{0,1\}$ and $\{1,1\}$ :

```wl
In[1]:= reg = Region[Parallelogram[{0, 0}, {{1, 0}, {1, 2}}], ImageSize -> Small, Axes -> True]

Out[1]= [image]
```

As $\frac{y}{2}\leq  x\leq \frac{y}{2}+1$, the mean is given by the following ratio of integrals:

```wl
In[2]:= (Integrate[x + y, {y, 0, 2}, {x, y / 2, y / 2 + 1}]/Integrate[1, {y, 0, 2}, {x, y / 2, y / 2 + 1}])

Out[2]= 2
```

Express the integrals using region notation:

```wl
In[3]:= (Integrate[x + y, {x, y}∈reg]/Area[reg])

Out[3]= 2
```

Visualize the function and its mean value:

```wl
In[4]:= Plot3D[{x + y, 2}, {x, y}∈reg, BoxRatios -> {1, 1, 1}]

Out[4]= [image]
```

---

To compute the centroid of the region under the curve of $f(x)=2 x$ from $0$ to $1$, first find the area:

```wl
In[1]:= a = Integrate[2x, {x, 0, 1}]

Out[1]= 1
```

The centroid equals the average value of the coordinates:

```wl
In[2]:= xcentroid = (1 / a)Integrate[x, {x, 0, 1}, {y, 0, 2x}]

Out[2]= (2/3)

In[3]:= ycentroid = (1 / a)Integrate[y, {x, 0, 1}, {y, 0, 2x}]

Out[3]= (2/3)
```

Compare with the answer given by ``RegionCentroid`` :

```wl
In[4]:= p = RegionCentroid[ImplicitRegion[0 ≤ y ≤ 2x && 0 ≤ x ≤ 1, {x, y}]]

Out[4]= {(2/3), (2/3)}

In[5]:= Show[Plot[2x, {x, 0, 1}, Filling -> Axis], Graphics[{PointSize[Large], Point[p]}]]

Out[5]= [image]
```

---

Determine the centroid of the region between the curves $f(x)=x^2$ and $g(x)=\sqrt{x}$ from $0$ to $1$ :

```wl
In[1]:= a = Integrate[Sqrt[x] - x ^ 2, {x, 0, 1}]

Out[1]= (1/3)

In[2]:= xcentroid = (1 / a)Integrate[x(Sqrt[x] - x ^ 2), {x, 0, 1}]

Out[2]= (9/20)

In[3]:= ycentroid = (1 / a)Integrate[(1 / 2)((Sqrt[x]) ^ 2 - (x ^ 2) ^ 2), {x, 0, 1}]

Out[3]= (9/20)
```

Compare with the answer returned by ``RegionCentroid`` :

```wl
In[4]:= p = RegionCentroid[ImplicitRegion[x ^ 2 ≤ y ≤ Sqrt[x] && 0 ≤ x ≤ 1, {x, y}]]

Out[4]= {(9/20), (9/20)}
```

Visualize the region and its centroid:

```wl
In[5]:= Show[Plot[{x ^ 2, Sqrt[x]}, {x, 0, 1}, Filling -> {1 -> {2}}, PlotLegends -> "Expressions"], Graphics[{PointSize[Large], Point[p]}]]

Out[5]= [image]
```

---

Derive general formulas for the centroid of the region under the curve $y=f(x)\geq 0$ from $a$ to $b$ using the fact that the integral gives the area under the curve:

```wl
In[1]:= A = Subsuperscript[∫, a, b]f[x]\[DifferentialD]x;
```

The $x$ centroid is the mean value of $x$ over the region from $a$ to $b$ and from $0$ to $f(x)$ :

```wl
In[2]:= (1/A)Subsuperscript[∫, a, b]Subsuperscript[∫, 0, f[x]]x\[DifferentialD]y\[DifferentialD]x

Out[2]= (Subsuperscript[∫, a, b]x f[x]\[DifferentialD]x/Subsuperscript[∫, a, b]f[x]\[DifferentialD]x)
```

The $y$ centroid is similarly the mean value of $y$ :

```wl
In[3]:= (1/A)Subsuperscript[∫, a, b]Subsuperscript[∫, 0, f[x]]y\[DifferentialD]y\[DifferentialD]x

Out[3]= (Subsuperscript[∫, a, b](f[x]^2/2)\[DifferentialD]x/Subsuperscript[∫, a, b]f[x]\[DifferentialD]x)
```

---

Find the center of mass of the origin-centered hemisphere of radius $3$ with $y\geq 0$ :

```wl
In[1]:= reg = Region[ImplicitRegion[x ^ 2 + y ^ 2 + z ^ 2 ≤ 3 && y ≥ 0, {x, y, z}]]

Out[1]= [image]
```

First compute the volume of the region:

```wl
In[2]:= v = Integrate[1, \[DoubleStruckCapitalX]∈reg]

Out[2]= 2 Sqrt[3] π
```

The center of mass is the average value of the position vector:

```wl
In[3]:= cm = (1/v)Integrate[\[DoubleStruckCapitalX], \[DoubleStruckCapitalX]∈reg]

Out[3]= {0, (3 Sqrt[3]/8), 0}
```

Visualize the center of mass:

```wl
In[4]:= Show[RegionPlot3D[DiscretizeRegion@reg, Mesh -> None, Axes -> True, PlotStyle -> Opacity[1 / 2]], Graphics3D[{StandardCyan, Sphere[cm, 0.1]}]]

Out[4]= [image]
```

#### Probability, Expectation, and Standard Deviation (7)

Compute the probability that $(x-2)^2<1$ when $x$ follows a standard normal distribution:

```wl
In[1]:= pdf = PDF[NormalDistribution[0, 1], x]

Out[1]= (E^-(x^2/2)/Sqrt[2 π])

In[2]:= Integrate[Boole[(x - 2) ^ 2 < 1]pdf, {x, -∞, ∞}]

Out[2]= (1/2) (Erfc[(1/Sqrt[2])] - Erfc[(3/Sqrt[2])])
```

Compare with the value returned by ``Probability`` :

```wl
In[3]:= Probability[(x - 2) ^ 2 < 1, x\[Distributed]NormalDistribution[0, 1]]

Out[3]= (1/2) (Erfc[-(3/Sqrt[2])] - Erfc[-(1/Sqrt[2])])
```

---

Compute the probability that $x>4$ for an exponential distribution with mean $\frac{2}{5}$. The mean is the reciprocal of the parameter:

```wl
In[1]:= Mean[ExponentialDistribution[μ]]

Out[1]= (1/μ)
```

Thus, use the probability density function (``PDF``) for ``ExponentialDistribution[5 / 2]`` :

```wl
In[2]:= PDF[ExponentialDistribution[(5/2)], x]

Out[2]= Piecewise[{{5/2/E^((5*x)/2), x >= 0}}, 0]
```

The probability that $x>4$ :

```wl
In[3]:= Integrate[(5 / 2)E ^ (-5t / 2), {t, 4, ∞}]

Out[3]= (1/E^10)
```

Since the PDF vanishes for $x<0$, the probability that $x<2$ is the integral from $0$ to $2$ :

```wl
In[4]:= Integrate[(5 / 2)E ^ (-5t / 2), {t, 0, 2}]

Out[4]= 1 - (1/E^5)
```

The corresponding probabilistic statements:

```wl
In[5]:= Probability[x > 4, x\[Distributed]ExponentialDistribution[5 / 2]]

Out[5]= (1/E^10)

In[6]:= Probability[x < 2, x\[Distributed]ExponentialDistribution[5 / 2]]//Expand

Out[6]= 1 - (1/E^5)
```

---

Compute the probability that a value is within two standard deviations of the mean in a normal distribution:

```wl
In[1]:= (1/σ Sqrt[2 π])Subsuperscript[∫, μ - 2 σ, μ + 2 σ]Exp[-((x - μ)^2/2 σ^2)]\[DifferentialD]x

Out[1]= Erf[Sqrt[2]]
```

Compare with the answer returned by ``Probability`` :

```wl
In[2]:= Probability[μ - 2σ ≤ x ≤ μ + 2σ, x\[Distributed]NormalDistribution[μ, σ]]

Out[2]= Erf[Sqrt[2]]
```

The value is approximate $95\%$ :

```wl
In[3]:= N[Erf[Sqrt[2]]]

Out[3]= 0.9545
```

This can be interpreted as saying that about $95\%$ of the entire area under the curve lies between $x=-2$ and $x=2$ in the following plot:

```wl
In[4]:=
p[x_] = PDF[NormalDistribution[0, 1], x];
tr[x_] = Piecewise[{{p[x], -2 <= x <= 2}, {Indeterminate, True}}];
Plot[{p[x], tr[x]}, {x, -3, 3}, Filling -> Axis, AxesLabel -> {x / σ, p}]

Out[4]= [image]
```

---

Compute the expectation of $\sqrt{| x| }$ when $x$ follows a standard Cauchy distribution:

```wl
In[1]:= pdf = PDF[CauchyDistribution[0, 1], x]

Out[1]= (1/π (1 + x^2))

In[2]:= Integrate[Sqrt[Abs[x]] pdf, {x, -∞, ∞}]

Out[2]= Sqrt[2]
```

Compare with the answer returned by ``Expectation`` :

```wl
In[3]:= Expectation[Sqrt[Abs[x]], x\[Distributed]CauchyDistribution[0, 1]]

Out[3]= Sqrt[2]
```

---

Mean and variance of the normal distribution:

```wl
In[1]:= Integrate[x PDF[NormalDistribution[μ, σ], x], {x, -∞, ∞}, Assumptions  -> σ > 0]

Out[1]= μ

In[2]:= Integrate[(x - μ) ^ 2PDF[NormalDistribution[μ, σ], x], {x, -∞, ∞}, Assumptions -> σ > 0]

Out[2]= σ^2
```

Compare with the built in functions ``Mean`` and ``Variance`` :

```wl
In[3]:= {Mean[NormalDistribution[μ, σ]], Variance[NormalDistribution[μ, σ]]}

Out[3]= {μ, σ^2}
```

---

Show that the standard deviation of an exponential distribution with mean μ is also μ:

```wl
In[1]:= Refine[Sqrt[(1/μ)Subsuperscript[∫, 0, ∞]E^-x  / μ(x - μ)^2\[DifferentialD]x], μ > 0]

Out[1]= μ
```

Compare with the answers returned by ``Mean`` and ``StandardDeviation`` :

```wl
In[2]:= dist = ExponentialDistribution[1 / μ];

In[3]:= {Mean[dist], StandardDeviation[dist]}

Out[3]= {μ, μ}
```

---

Compute the cumulative distribution function (``CDF``) from the probability density function (``PDF``):

```wl
In[1]:= pdf[x_] = PDF[NormalDistribution[0, 1], x]

Out[1]= (E^-(x^2/2)/Sqrt[2 π])

In[2]:= cdf[x_] = Integrate[pdf[x], {x, -∞, x}]

Out[2]= (1/2) (1 + Erf[(x/Sqrt[2])])
```

The CDF gives the area under the PDF curve from $-\infty$ to $x$ :

```wl
In[3]:= Manipulate[Plot[{pdf[x], cdf[x]}, {x, -3, u}, Filling -> {1 -> Axis}, PlotTheme -> "Detailed", PlotRange -> {{-3, 3}, {0, 1}}, PlotLabel -> x == u], {{u, 0, x}, -3.01, 3}, SaveDefinitions -> True]

Out[3]= DynamicModule[«9»]
```

#### Integral Transforms (7)

Compute a Fourier transform:

```wl
In[1]:= ft[f_, x_, ω_] := (1/Sqrt[2π])Integrate[f Exp[I ω x], {x, -∞, ∞}]

In[2]:= ft[Exp[-x ^ 2], x, ω]

Out[2]= (E^-(ω^2/4)/Sqrt[2])
```

Compare with ``FourierTransform`` :

```wl
In[3]:= FourierTransform[Exp[-x ^ 2], x, ω]

Out[3]= (E^-(ω^2/4)/Sqrt[2])
```

---

Find a Laplace transform:

```wl
In[1]:= lt[f_, x_, s_] := Integrate[f Exp[-s x], {x, 0, ∞}]

In[2]:= lt[x ^ 2, x, s]

Out[2]= ConditionalExpression[2/s^3, Re[s] > 0]
```

Compare with ``LaplaceTransform`` :

```wl
In[3]:= LaplaceTransform[x ^ 2, x, s]

Out[3]= (2/s^3)
```

---

Define the Hartley transform:

```wl
In[1]:= ht[f_, x_, ω_] := (1/Sqrt[2π])Integrate[f(Cos[ω x] + Sin[ω x]), {x, -∞, ∞}]

In[2]:= ht[Exp[-x ^ 2], x, ω]

Out[2]= (E^-(ω^2/4)/Sqrt[2])
```

Since the function is even, the Hartley transform is equivalent to ``FourierCosTransform`` :

```wl
In[3]:= FourierCosTransform[Exp[-x ^ 2], x, ω]

Out[3]= (E^-(ω^2/4)/Sqrt[2])
```

---

Find the Fourier coefficients of a function on ``[0, 1]`` :

```wl
In[1]:= a[0] = 2Integrate[x^2, {x, 0, 1}]

Out[1]= (2/3)

In[2]:= a[i_] = 2Integrate[x^2 Cos[2π i x], {x, 0, 1}, Assumptions -> i∈ℤ]

Out[2]= (2 i π Cos[2 i π] + (-1 + 2 i^2 π^2) Sin[2 i π]/2 i^3 π^3)

In[3]:= b[i_] = 2Integrate[x^2 Sin[2π i x], {x, 0, 1}]

Out[3]= (-1 + (1 - 2 i^2 π^2) Cos[2 i π] + 2 i π Sin[2 i π]/2 i^3 π^3)
```

Define the partial sums of the transform:

```wl
In[4]:= s[n_] := a[0] / 2 + Subsuperscript[∑, i = 1, n]a[i]Cos[2π i x] + Subsuperscript[∑, i = 1, n]b[i]Sin[2π i x]
```

Visualize the partial sums, which exhibit the Gibbs phenomenon due to the aperiodicity of $x^2$ :

```wl
In[5]:= Plot[{x ^ 2, s[#]}, {x, 0, 1}, PlotTheme -> {"Minimal"}, PlotLabel -> n == #, ImageSize -> 225]& /@ Range[2, 8, 2]

Out[5]= {[image], [image], [image], [image]}
```

---

Compute a Mellin transform:

```wl
In[1]:= mt[f_, x_, s_] := Integrate[f x ^ (s - 1), {x, 0, ∞}]

In[2]:= mt[Sin[x], x, s]

Out[2]= ConditionalExpression[Gamma[s]*Sin[(Pi*s)/2], -1 < Re[s] < 1]
```

Compare with ``MellinTransform`` :

```wl
In[3]:= MellinTransform[Sin[x], x, s, GenerateConditions -> True]

Out[3]= ConditionalExpression[Gamma[s]*Sin[(Pi*s)/2], -1 < Re[s] < 1]
```

---

Find a Hankel transform:

```wl
In[1]:= ht[f_, r_, s_, ν_] := Integrate[r f BesselJ[ν, r s], {r, 0, ∞}, Assumptions -> s > 0  && ν > -1 / 2]

In[2]:= ht[1 / r, r, s, 0]

Out[2]= (1/s)
```

Compare with ``HankelTransform`` :

```wl
In[3]:= HankelTransform[1 / r, r, s, ν]

Out[3]= (1/s)
```

---

Compute a quadratic fractional Fourier transform in closed form:

```wl
In[1]:= fract[α_, w_] = Sqrt[(1 - I Cot[α]) / (2π)]E ^ (I Cot[α] w ^ 2 / 2) Integrate[E ^ (-I Csc[α] w t + I Cot[α] t ^ 2 / 2) UnitBox[t], {t, -∞, ∞}]

Out[1]= -((((1/2) - (I/2)) E^(1/2) I w^2 Cot[α] - I w^2 Csc[2 α] Sqrt[1 - I Cot[α]] (Erfi[(((1/2) + (I/2)) (w - (Cos[α]/2)) Sqrt[Csc[α]]/Sqrt[Cos[α]])] - Erfi[(((1/4) + (I/4)) (2 w + Cos[α]) Sqrt[Csc[α]]/Sqrt[Cos[α]])])) / (Sqrt[2] Sqrt[Cos[α]] Sqrt[Csc[α]]))
```

Visualize the real and imaginary parts of the transform for different values of α:

```wl
In[2]:= Table[Plot[{Re[fract[α, w]], Im[fract[α, w]]}, {w, -2, 2}, Filling -> Axis, PlotRange -> All, ImageSize -> 225, PlotLabel -> α == α], {α, {0.02π, 0.09π, 3.2π, 20.9π}}]

Out[2]= {[image], [image], [image], [image]}

In[3]:= s
```

#### Real and Complex Analysis (4)

Define the standard $L^p(\mathbb{R})$ norm of a univariate function:

```wl
In[1]:= lp[p_, f_, x_] := Integrate[Abs[f] ^ p, {x, -∞, ∞}, Assumptions -> p ≥ 1] ^ (1 / p)
```

Also define a formatting for this function:

```wl
In[2]:= Format[HoldPattern[lp[p_, f_, x_]]] := HoldForm[Norm[f, L^p]]
```

Compute the norms as a function of $p$ for three different functions:

```wl
In[3]:=
f := Exp[-x^2];
g := Exp[-5 x^2];
h := HeavisideTheta[x] Exp[-5 x^2];

In[4]:= {lp[p, f, x], lp[p, g, x], lp[p, h, x]}

Out[4]= {p^-(1/2) / p π^(1/2) / p, p^-(1/2) / p ((π/5))^(1/2) / p, 2^-1 / p p^-(1/2) / p ((π/5))^(1/2) / p}
```

The norm is always eventually an increasing function of $p$, but it may be initially decreasing:

```wl
In[5]:= Plot[{lp[p, f, x], lp[p, g, x], lp[p, h, x]}, {p, 1, 12}, PlotTheme -> "Detailed", Evaluated -> True, PlotRange -> All]

Out[5]= [image]
```

The Fourier transform is an $L^2$ isomorphism (the norm of the function and its transform are equal):

```wl
In[6]:= Table[lp[2, fn, x] == lp[2, FourierTransform[fn, x, k], k], {fn, {f, g}}]//FullSimplify

Out[6]= {True, True}
```

It is not, however, an $L^p$ isomorphism for any other value, for example for $p=1$ :

```wl
In[7]:= Table[lp[1, fn, x] == lp[1, FourierTransform[fn, x, k], k], {fn, {f, g, h}}]

Out[7]= {False, False, False}
```

---

Define the weighted inner product for $L_w^2(a,b)$, with weight $w$ for functions defined on $a<x<b$ :

```wl
In[1]:= ip[w_, f_, g_, {x_, a_, b_}] := Integrate[w f Conjugate[g], {x, a, b}]
```

Orthogonality of Legendre polynomials $P_n(x)$ on $-1<x<1$ with weight function $$1$$ :

```wl
In[2]:= Table[ip[1, LegendreP[n, x], LegendreP[m, x], {x, -1, 1}], {n, 0, 4}, {m, 0, 4}]//MatrixForm

Out[2]//MatrixForm=
(⁠|   |       |       |       |       |
| - | ----- | ----- | ----- | ----- |
| 2 | 0     | 0     | 0     | 0     |
| 0 | (2/3) | 0     | 0     | 0     |
| 0 | 0     | (2/5) | 0     | 0     |
| 0 | 0     | 0     | (2/7) | 0     |
| 0 | 0     | 0     | 0     | (2/9) |⁠)
```

Orthogonality of Chebyshev polynomials $T_n(x)$ on $-1<x<1$ with weight function $\frac{1}{\sqrt{1-x^2}}$ :

```wl
In[3]:= Table[ip[(1/Sqrt[1 - x ^ 2]), ChebyshevT[n, x], ChebyshevT[m, x], {x, -1, 1}], {n, 0, 4}, {m, 0, 4}]//MatrixForm

Out[3]//MatrixForm=
(⁠|   |       |       |       |       |
| - | ----- | ----- | ----- | ----- |
| π | 0     | 0     | 0     | 0     |
| 0 | (π/2) | 0     | 0     | 0     |
| 0 | 0     | (π/2) | 0     | 0     |
| 0 | 0     | 0     | (π/2) | 0     |
| 0 | 0     | 0     | 0     | (π/2) |⁠)
```

Orthogonality of Hermite polynomials $H_n(x)$ on $-\infty <x<\infty$ with weight function $e^{-x^2}$ :

```wl
In[4]:= Table[ip[Exp[-x ^ 2], HermiteH[n, x], HermiteH[m, x], {x, -∞, ∞}], {n, 0, 4}, {m, 0, 4}]//MatrixForm

Out[4]//MatrixForm=
(⁠|         |           |           |            |             |
| ------- | --------- | --------- | ---------- | ----------- |
| Sqrt[π] | 0         | 0         | 0          | 0           |
| 0       | 2 Sqrt[π] | 0         | 0          | 0           |
| 0       | 0         | 8 Sqrt[π] | 0          | 0           |
| 0       | 0         | 0         | 48 Sqrt[π] | 0           |
| 0       | 0         | 0         | 0          | 384 Sqrt[π] |⁠)
```

---

Define an inner product on functions using ``Integrate`` :

```wl
In[1]:= dot[f_, g_] := (2/π)Subsuperscript[∫, -1, 1]Conjugate[f]gSqrt[1 - x^2]\[DifferentialD]x
```

Construct an orthonormal basis using using ``Orthogonalize`` :

```wl
In[2]:= Orthogonalize[{1, x, x^2, x^3, x^4}, dot]//Expand

Out[2]= {1, 2 x, -1 + 4 x^2, -4 x + 8 x^3, 1 - 12 x^2 + 16 x^4}
```

This inner product produces the Gegenbauer polynomials:

```wl
In[3]:= Table[GegenbauerC[n, 1, x], {n, 0, 4}]

Out[3]= {1, 2 x, -1 + 4 x^2, -4 x + 8 x^3, 1 - 12 x^2 + 16 x^4}
```

---

Compute the residue of $f$ at $z=c$ as an integral over a contour enclosing $c$ :

```wl
In[1]:= res[f_, {z_, c_}] := Underscript[\[Limit], r -> 0^ + ](1/2 π I)Subsuperscript[∫, 0, 2 π](f Dt[z, t] /.  z -> c + Exp[I t])\[DifferentialD]t

In[2]:= res[(2/z - 1), {z, 1}]

Out[2]= 2

In[3]:= res[(Sin[z]/(z - 2) ^ 3), {z, 2}]

Out[3]= -(Sin[2]/2)
```

Compare with the answers returned by ``Residue`` :

```wl
In[4]:= Residue[(2/z - 1), {z, 1}]

Out[4]= 2

In[5]:= Residue[(Sin[z]/(z - 2) ^ 3), {z, 2}]

Out[5]= -(Sin[2]/2)
```

#### Integral Representation of Special Functions (3)

Represent ``HermiteH`` in terms of ``Integrate`` :

```wl
In[1]:= Assuming[{Re[z] > 0, n∈ℤ}, FullSimplify[HermiteH[n, z] == (2^n Subsuperscript[∫, -∞, ∞]((z + I t)^n/E^t^2)\[DifferentialD]t/Sqrt[π])]]

Out[1]= True
```

Visualize the first five Hermite polynomials:

```wl
In[2]:= Plot[Table[HermiteH[n, z], {n, 0, 4}]//Evaluate, {z, 0, 4}, PlotTheme -> {"Detailed", "DashedLines"}]

Out[2]= [image]
```

---

Express ``Gamma`` in terms of a logarithmic integral:

```wl
In[1]:= Simplify[Gamma[z] == Integrate[Log[1 / t] ^ (z - 1), {t, 0, 1}], Re[z] > 0]

Out[1]= True
```

Visualize the function:

```wl
In[2]:= Plot[Gamma[z], {z, 0, 5}]

Out[2]= [image]
```

---

Represent ``Zeta`` in terms of ``Integrate`` :

```wl
In[1]:= FullSimplify[Zeta[s] == (1/Gamma[s])Subsuperscript[∫, 0, ∞](t^s - 1/E^t - 1)\[DifferentialD]t, Re[s] > 1]

Out[1]= True
```

### Properties & Relations (14)

Integration is a linear operator:

```wl
In[1]:= f[x_] = E ^ x;

In[2]:= g[x_] = x ^ 2 + 4x + 17;

In[3]:= ∫(f[x] + b g[x])\[DifferentialD]x == ∫f[x]\[DifferentialD]x + b ∫g[x]\[DifferentialD]x//Simplify

Out[3]= True
```

---

Indefinite integration is the inverse of differentiation:

```wl
In[1]:= f[x_] := x ^ n + x ^ -n

In[2]:= Integrate[f[x], x]

Out[2]= (x^1 - n/1 - n) + (x^1 + n/1 + n)

In[3]:= f[x] == D[%, x]

Out[3]= True
```

---

Definite integration can be defined in terms of ``DiscreteLimit`` and ``Sum`` :

```wl
In[1]:= f[x_] := 1 / x

In[2]:= Subsuperscript[∫, 1, 3]f[x]\[DifferentialD]x == Underscript[\[Limit], nUnderscript[ -> , ℤ]∞]Underoverscript[∑, k = 0, n - 1]f[1 + k((3 - 1)/n)](3 - 1/n)

Out[2]= True
```

---

Evaluate integrals numerically using ``N`` :

```wl
In[1]:= Integrate[Sin[Sin[x]], {x, 0, 1}]

Out[1]= Subsuperscript[∫, 0, 1]Sin[Sin[x]]\[DifferentialD]x

In[2]:= N[%]

Out[2]= 0.430606
```

This effectively calls ``NIntegrate`` :

```wl
In[3]:= NIntegrate[Sin[Sin[x]], {x, 0, 1}]

Out[3]= 0.430606
```

---

``Derivative`` with a negative integer order does integrals:

```wl
In[1]:= Derivative[-2][Function[x, x ^ n]][x]

Out[1]= (x^2 + n/(1 + n) (2 + n))

In[2]:= Integrate[x ^ n, x, x]//Factor

Out[2]= (x^2 + n/(1 + n) (2 + n))
```

---

``ArcLength`` is the integral of 1 over a one-dimensional region:

```wl
In[1]:= Underscript[∫, {x, y}∈Circle[]]1

Out[1]= 2 π

In[2]:= ArcLength[Circle[]]

Out[2]= 2 π
```

---

``Area`` is the integral of 1 over a two-dimensional region:

```wl
In[1]:= Underscript[∫, {x, y, z}∈Sphere[]]1

Out[1]= 4 π

In[2]:= Area[Sphere[]]

Out[2]= 4 π
```

---

``Volume`` is the integral of 1 over a three-dimensional region:

```wl
In[1]:= Underscript[∫, {x, y, z}∈Ball[]]1

Out[1]= (4 π/3)

In[2]:= Volume[Ball[]]

Out[2]= (4 π/3)
```

---

``RegionMeasure`` for a region $\mathcal{R}$ is given by the integral $\int _{x\in \mathcal{R}}1$ :

```wl
In[1]:= ℛ = Circle[];

In[2]:= {RegionMeasure[ℛ], Integrate[1, {x, y}∈ℛ]}

Out[2]= {2 π, 2 π}

In[3]:= ℛ = Ball[];

In[4]:= {RegionMeasure[ℛ], Integrate[1, {x, y, z}∈ℛ]}

Out[4]= {(4 π/3), (4 π/3)}
```

---

``RegionCentroid`` is equivalent to ``Integrate[p, p∈ℛ] / m`` with ``m = RegionMeasure[ℛ]`` :

```wl
In[1]:=
ℛ = Sphere[{1, 2, 3}];
m = RegionMeasure[ℛ];

In[2]:= {RegionCentroid[ℛ], Integrate[p, p∈ℛ] / m}

Out[2]= {{1, 2, 3}, {1, 2, 3}}
```

---

Solve a simple differential equation:

```wl
In[1]:= Integrate[Sin[x], x]

Out[1]= -Cos[x]
```

``DSolveValue`` returns a solution with the constant of integration:

```wl
In[2]:= DSolveValue[y'[x] == Sin[x], y[x], x]

Out[2]= C[1] - Cos[x]
```

``DSolve`` returns a substitution rule for the solution:

```wl
In[3]:= DSolve[y'[x] == Sin[x], y, x]

Out[3]= {{y -> Function[{x}, C[1] - Cos[x]]}}
```

---

``Integrate`` computes the integral in closed form:

```wl
In[1]:= closed = Integrate[Sin[x t] ^ 2, {t, 0, 1}]

Out[1]= (1/2) - (Sin[2 x]/4 x)
```

``AsymptoticIntegrate`` gives series approximating the exact result:

```wl
In[2]:= AsymptoticIntegrate[Sin[x t] ^ 2, {t, 0, 1}, {x, 0, 8}]

Out[2]= (x^2/3) - (x^4/15) + (2 x^6/315) - (x^8/2835)

In[3]:= Series[closed, {x, 0, 8}]//Normal

Out[3]= (x^2/3) - (x^4/15) + (2 x^6/315) - (x^8/2835)
```

---

``FourierTransform`` is defined in terms of an integral:

```wl
In[1]:= FourierTransform[Exp[-t ^ 2] Sin[t], t, ω] == Subsuperscript[∫, -∞, ∞]Exp[-t^2] Sin[t]( Exp[I ω t]/Sqrt[2 π])\[DifferentialD]t//Simplify

Out[1]= True
```

---

``LaplaceTransform`` is defined in terms of an integral:

```wl
In[1]:= LaplaceTransform[Exp[-t ^ 2] Sin[t], t, s] == Subsuperscript[∫, 0, ∞]Exp[-t^2] Sin[t] Exp[-s t]\[DifferentialD]t//FullSimplify

Out[1]= True
```

### Possible Issues (12)

#### Indefinite Integrals (6)

Many simple integrals cannot be evaluated in terms of standard mathematical functions:

```wl
In[1]:= Integrate[Sin[x] / Log[x], x]

Out[1]= ∫(Sin[x]/Log[x])\[DifferentialD]x
```

---

The indefinite integral of a continuous function can be discontinuous:

```wl
In[1]:= f[x_] := 1 / (2 + Sin[x])

In[2]:= Plot[{f[x], Integrate[f[x], x]}, {x, 0, 2π}, PlotTheme -> "Detailed", Evaluated -> True]

Out[2]= [image]
```

Using a definite integral with a variable upper limit can smooth the discontinuity. Find the discontinuity to the left of the plot:

```wl
In[3]:= Solve[Integrate[f[x], x] == 0 && -π < x < 0, x]

Out[3]= {{x -> -2 ArcTan[(1/2)]}}
```

In this case, integrating from previous discontinuity reproduces the values of the indefinite integral in the range $0\leq x<\pi$ :

```wl
In[4]:= Assuming[{x∈Reals}, Plot[{f[x], Integrate[f[t], {t, -2 ArcTan[(1/2)], x}]}, {x, 0, 2π}, PlotTheme -> "Detailed", Evaluated -> True, Filling -> {1 -> 0}]]

Out[4]= [image]
```

---

The derivative of an integral may not come out in the same form as the original function:

```wl
In[1]:= Integrate[1 / Sqrt[a^2 - x ^ 2], x]

Out[1]= -ArcTan[(x Sqrt[a^2 - x^2]/-a^2 + x^2)]

In[2]:= D[%, x]

Out[2]= -(-(2 x^2 Sqrt[a^2 - x^2]/(-a^2 + x^2)^2) - (x^2/Sqrt[a^2 - x^2] (-a^2 + x^2)) + (Sqrt[a^2 - x^2]/-a^2 + x^2)/1 + (x^2 (a^2 - x^2)/(-a^2 + x^2)^2))
```

``Simplify`` and related constructs can often show equivalence:

```wl
In[3]:= Simplify[%]

Out[3]= (1/Sqrt[a^2 - x^2])
```

---

Different forms of the same integrand can give integrals that differ by constants of integration:

```wl
In[1]:= Integrate[1 + (x + 1) ^ 3, x]

Out[1]= x + (1/4) (1 + x)^4

In[2]:= Integrate[Expand[1 + (x + 1) ^ 3], x]

Out[2]= 2 x + (3 x^2/2) + x^3 + (x^4/4)

In[3]:= Simplify[%% - %]

Out[3]= (1/4)
```

---

Parameters like $n$ are assumed to be generic inside indefinite integrals:

```wl
In[1]:= Integrate[x ^ n, x]

Out[1]= (x^1 + n/1 + n)

In[2]:= Integrate[x ^ -1, x]

Out[2]= Log[x]
```

Use definite integration with a variable upper limit to generate conditions:

```wl
In[3]:= Integrate[t ^ n, {t, 0, x}]

Out[3]= ConditionalExpression[x^(1 + n)/(1 + n), Re[n] > -1]
```

---

When part of a sum cannot be integrated explicitly, the whole sum will stay unintegrated:

```wl
In[1]:= Integrate[f[x] + f'[x], x]

Out[1]= ∫(f[x] + Derivative[1][f][x])\[DifferentialD]x
```

Compare with:

```wl
In[2]:= Integrate[f[x], x] + Integrate[f'[x], x]

Out[2]= f[x] + ∫f[x]\[DifferentialD]x
```

#### Definite Integrals (6)

Substituting limits into an indefinite integral may not give the correct result for a definite integral:

```wl
In[1]:= Integrate[1 / (2 + Cos[x]), {x, 0, 2π}]

Out[1]= (2 π/Sqrt[3])

In[2]:= expr = Integrate[1 / (2 + Cos[x]), x]

Out[2]= (2 ArcTan[(Tan[(x/2)]/Sqrt[3])]/Sqrt[3])

In[3]:= (expr /. x -> 2π) - (expr /. x -> 0)

Out[3]= 0
```

The presence of a discontinuity in the expression for the indefinite integral leads to the anomaly:

```wl
In[4]:= Plot[expr, {x, 0, 2π}]

Out[4]= [image]
```

---

Specifying integer assumptions may not give a simpler result:

```wl
In[1]:= Integrate[k Cos[k x], {x, -π, π}, Assumptions -> k∈Integers]

Out[1]= 2 Sin[k π]
```

Use ``Simplify`` and related functions to obtain the expected result:

```wl
In[2]:= Simplify[%, k∈Integers]

Out[2]= 0
```

---

A definite integral may have a closed form only over an infinite interval:

```wl
In[1]:= Integrate[BesselJ[2, x] / (1 + x ^ 2), {x, 0, 1}]

Out[1]= Subsuperscript[∫, 0, 1](BesselJ[2, x]/1 + x^2)\[DifferentialD]x

In[2]:= Integrate[BesselJ[2, x] / (1 + x ^ 2), {x, 0, ∞}]

Out[2]= (1/6) (2 - 3 π BesselI[2, 1] + 3 π StruveL[2, 1])
```

---

Integrals over regions do not test whether an integrand is absolutely integrable:

```wl
In[1]:= Integrate[(x^2 - y^2/(x^2 + y^2)^2), {x, y}∈Rectangle[{0, 0}, {1, 1}]]

Out[1]= (π/4)

In[2]:= Underscript[\[Limit], a -> 0^ + ]Integrate[Abs[(x^2 - y^2/(x^2 + y^2)^2)], {x, y}∈Rectangle[{a, a}, {1, 1}]]

Out[2]= ∞
```

Answers may then depend on how the region was decomposed for integration:

```wl
In[3]:= Integrate[(x ^ 2 - y ^ 2) / (x ^ 2 + y ^ 2) ^ 2, {x, 0, 1}, {y, 0, 1}]

Out[3]= (π/4)

In[4]:= Integrate[(x ^ 2 - y ^ 2) / (x ^ 2 + y ^ 2) ^ 2, {y, 0, 1}, {x, 0, 1}]

Out[4]= -(π/4)
```

---

Integrals over zero-dimensional regions use the counting measure:

```wl
In[1]:= ℛ = RegionIntersection[Ball[{0, 0, 0}, Sqrt[14]], Ball[{2, 4, 6}, Sqrt[14]]]

Out[1]= Point[{1, 2, 3}]

In[2]:= Integrate[x + y + z, {x, y, z}∈ℛ]

Out[2]= 6
```

To use the measure of the ambient space, integrate over all space with the added condition $\{x,y,z\}\in \mathcal{R}$ :

```wl
In[3]:= Integrate[(x + y + z) Boole[{x, y, z}∈ℛ], {x, y, z}∈FullRegion[3]]

Out[3]= 0
```

---

Setting ``GenerateConditions`` to ``False`` may produce unexpected answers:

```wl
In[1]:= Integrate[1 / x, {x, 0, a}, GenerateConditions -> False]

Out[1]= Log[a]
```

In this case, the condition that the integral is divergent was lost:

```wl
In[2]:= Integrate[1 / x, {x, 0, a}]
```

Integrate::idiv: Integral of 1/x does not converge on {0,a}.

```wl
Out[2]= Subsuperscript[∫, 0, a](1/x)\[DifferentialD]x
```

### Interactive Examples (1)

Consider Gabriel's horn, the interior of rotating $y=\frac{1}{x}$ around the $x$ axis for $x>1$ :

```wl
In[1]:= f[x_] := 1 / x
```

Compute the volume for arbitrary endpoint $a$ :

```wl
In[2]:= v[a_] = Integrate[π f[x] ^ 2, {x, 1, a}, Assumptions -> a > 1]

Out[2]= ((-1 + a) π/a)
```

Compute the surface area for arbitrary endpoint $a$ :

```wl
In[3]:= s[a_] = Integrate[2π f[x]Sqrt[1 + D[f[x], x] ^ 2], {x, 1, a}, Assumptions -> a > 1]

Out[3]= π (Sqrt[2] - (Sqrt[1 + a^4]/a^2) - ArcSinh[1] + ArcSinh[a^2])
```

The limit as $a\to \infty$ of the volume is finite, but the surface area is infinite:

```wl
In[4]:= Underscript[\[Limit], a -> ∞]{v[a], s[a]}

Out[4]= {π, ∞}
```

Visualize the horn along with its volume and surface area as functions of $a$ :

```wl
In[5]:= Manipulate[Column[{Style[a == b//TraditionalForm, FontSize -> 14], RevolutionPlot3D[1 / s, {s, 1, b}, RevolutionAxis -> {1, 0, 0}, PlotRange -> {{1, 15}, {-1, 1}, {-1, 1}}, Mesh -> None, ImageSize -> 300, Ticks -> None, Boxed -> False], Show[Plot[{s[x], v[x]}, {x, 1, 16}, ImageSize -> Small, PlotLegends -> {"Surface Area" == NumberForm[s[b], {5, 3}], "Volume" == NumberForm[v[b], {4, 3}]}], Graphics[{StandardOrange, PointSize[Large], Point[{b, $$v$$[b]}], StandardBlue, Point[{b, s[b]}]}]]}, Alignment -> Center], {{b, 5., a}, 1.01, 15}, SaveDefinitions -> True]

Out[5]= DynamicModule[«9»]
```

### Neat Examples (2)

The first six Borwein-type integrals are all exactly $\frac{\pi }{2}$ :

```wl
In[1]:= Table[Subsuperscript[∫, 0, ∞](Underoverscript[∏, k = 0, max](Sin[(x/2 k + 1)]/(x/2 k + 1)))\[DifferentialD]x, {max, 6}]

Out[1]= {(π/2), (π/2), (π/2), (π/2), (π/2), (π/2)}
```

From the seventh onward, they differ from $\frac{\pi }{2}$ by small amounts, for example the eighth:

```wl
In[2]:= Subsuperscript[∫, 0, ∞](Underoverscript[∏, k = 0, 8](Sin[(x/2 k + 1)]/(x/2 k + 1)))\[DifferentialD]x

Out[2]= (17708695183056190642497315530628422295569865119 π/35417390788301195294898352987527510935040000000)

In[3]:= N[% - Pi / 2]

Out[3]= -1.8724491655091225`*^-8
```

---

A logarithmic integral from Srinivasa Ramanujan's notebooks:

```wl
In[1]:= Integrate[Log[(1 + Sqrt[1 + 4x]) / 2] / x, {x, 0, 1}]

Out[1]= (π^2/15)
```

## See Also

* [`NIntegrate`](https://reference.wolfram.com/language/ref/NIntegrate.en.md)
* [`AsymptoticIntegrate`](https://reference.wolfram.com/language/ref/AsymptoticIntegrate.en.md)
* [`LineIntegrate`](https://reference.wolfram.com/language/ref/LineIntegrate.en.md)
* [`SurfaceIntegrate`](https://reference.wolfram.com/language/ref/SurfaceIntegrate.en.md)
* [`ContourIntegrate`](https://reference.wolfram.com/language/ref/ContourIntegrate.en.md)
* [`Asymptotic`](https://reference.wolfram.com/language/ref/Asymptotic.en.md)
* [`DSolve`](https://reference.wolfram.com/language/ref/DSolve.en.md)
* [`Sum`](https://reference.wolfram.com/language/ref/Sum.en.md)
* [`LaplaceTransform`](https://reference.wolfram.com/language/ref/LaplaceTransform.en.md)
* [`FourierTransform`](https://reference.wolfram.com/language/ref/FourierTransform.en.md)
* [`Convolve`](https://reference.wolfram.com/language/ref/Convolve.en.md)
* [`D`](https://reference.wolfram.com/language/ref/D.en.md)
* [`Derivative`](https://reference.wolfram.com/language/ref/Derivative.en.md)
* [`CDF`](https://reference.wolfram.com/language/ref/CDF.en.md)
* [`Expectation`](https://reference.wolfram.com/language/ref/Expectation.en.md)
* [`Probability`](https://reference.wolfram.com/language/ref/Probability.en.md)
* [`ArcLength`](https://reference.wolfram.com/language/ref/ArcLength.en.md)
* [`Area`](https://reference.wolfram.com/language/ref/Area.en.md)
* [`Volume`](https://reference.wolfram.com/language/ref/Volume.en.md)
* [`MomentOfInertia`](https://reference.wolfram.com/language/ref/MomentOfInertia.en.md)
* [`FractionalD`](https://reference.wolfram.com/language/ref/FractionalD.en.md)
* [`CaputoD`](https://reference.wolfram.com/language/ref/CaputoD.en.md)
* [`ResidueSum`](https://reference.wolfram.com/language/ref/ResidueSum.en.md)
* [`\[Integral]`](https://reference.wolfram.com/language/ref/character/Integral.en.md)
* [`\[DifferentialD]`](https://reference.wolfram.com/language/ref/character/DifferentialD.en.md)

## Tech Notes

* [Symbolic Mathematics: Basic Operations](https://reference.wolfram.com/language/tutorial/SymbolicCalculations.en.md)
* [Simplifying Algebraic Expressions](https://reference.wolfram.com/language/tutorial/AlgebraicCalculations.en.md#16626)
* [Integration](https://reference.wolfram.com/language/tutorial/Calculus.en.md#26107)
* [Indefinite Integrals](https://reference.wolfram.com/language/tutorial/Calculus.en.md#6667)
* [Integrals over Regions](https://reference.wolfram.com/language/tutorial/Calculus.en.md#489977920)
* [Implementation notes: Algebra and Calculus](https://reference.wolfram.com/language/tutorial/SomeNotesOnInternalImplementation.en.md#11173)

## Related Guides

* [`Calculus`](https://reference.wolfram.com/language/guide/Calculus.en.md)
* [Functions of Complex Variables](https://reference.wolfram.com/language/guide/FunctionsOfComplexVariables.en.md)
* [Geometric Computation](https://reference.wolfram.com/language/guide/GeometricComputation.en.md)
* [Mathematical Data](https://reference.wolfram.com/language/guide/MathematicalData.en.md)
* [Solvers over Regions](https://reference.wolfram.com/language/guide/GeometricSolvers.en.md)
* [Symbolic Vectors, Matrices and Arrays](https://reference.wolfram.com/language/guide/SymbolicArrays.en.md)
* [Precollege Education](https://reference.wolfram.com/language/guide/PrecollegeEducation.en.md)
* [Integral Transforms](https://reference.wolfram.com/language/guide/IntegralTransforms.en.md)
* [Scientific Models](https://reference.wolfram.com/language/guide/ScientificModels.en.md)
* [Analytic Number Theory](https://reference.wolfram.com/language/guide/AnalyticNumberTheory.en.md)
* [Multiplicative Number Theory](https://reference.wolfram.com/language/guide/MultiplicativeNumberTheory.en.md)
* [`Polygons`](https://reference.wolfram.com/language/guide/Polygons.en.md)
* [`Polyhedra`](https://reference.wolfram.com/language/guide/Polyhedra.en.md)

## Related Links

* [MathWorld](https://mathworld.wolfram.com/Integral.html)
* [NKS\|Online](http://www.wolframscience.com/nks/search/?q=Integrate)
* [A New Kind of Science](http://www.wolframscience.com/nks/)

## History

* Introduced in 1988 (1.0) \| Updated in 1996 (3.0) ▪ 2003 (5.0) ▪ [2014 (10.0)](https://reference.wolfram.com/language/guide/SummaryOfNewFeaturesIn100.en.md) ▪ [2019 (12.0)](https://reference.wolfram.com/language/guide/SummaryOfNewFeaturesIn120.en.md)