Skip to content

Commit a66c188

Browse files
committed
added section about integrals to documentation
1 parent bec7569 commit a66c188

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

docs/src/documentation.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
Documentation of all types and methods in module [TensorCrossInterpolation](https://gitlab.com/tensors4fields/TensorCrossInterpolation.jl).
44

5-
```@index
6-
```
7-
85
## Matrix approximation
96

107

@@ -47,6 +44,12 @@ Modules = [TensorCrossInterpolation]
4744
Pages = ["tensorci2.jl"]
4845
```
4946

47+
### Integration
48+
```@autodocs
49+
Modules = [TensorCrossInterpolation]
50+
Pages = ["integration.jl"]
51+
```
52+
5053
## Helpers and utility methods
5154
```@autodocs
5255
Modules = [TensorCrossInterpolation]

docs/src/index.md

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@ This is the documentation for [TensorCrossInterpolation](https://gitlab.com/tens
88

99
With the user manual and usage examples below, users should be able to use this library as a "black box" in most cases. Detailed documentation of (almost) all methods can be found in the [Documentation](@ref) section, and [Implementation](@ref) contains a detailed explanation of this implementation of TCI.
1010

11-
```@contents
12-
Pages = ["index.md", "documentation.md", "implementation.md"]
13-
```
14-
1511
## Interpolating functions
1612

1713
The most convenient way to create a TCI is [`crossinterpolate2`](@ref). For example, consider the lorentzian in 5 dimensions, i.e. $f(\mathbf v) = 1/(1 + \mathbf v^2)$ on a mesh $\mathbf{v} \in \{1, 2, ..., 10\}^5$.
@@ -34,7 +30,7 @@ println("TCI approximation: $(tci([1, 2, 3, 4, 5]))")
3430
For easy integration into tensor network algorithms, the tensor train can be converted to ITensors MPS format. If you're using julia version 1.9 or later, an extension is automatically loaded if both `TensorCrossInterpolation.jl` and `ITensors.jl` are present.
3531
For older versions of julia, use the package using [TCIITensorConversion.jl](https://gitlab.com/tensors4fields/tciitensorconversion.jl).
3632

37-
## Sums
33+
## Sums and Integrals
3834

3935
Tensor trains are a way to efficiently obtain sums over all lattice sites, since this sum can be factorized:
4036
```@example simple
@@ -47,6 +43,22 @@ println("Sum of tensor train: $sumtt")
4743
```
4844
For further information, see [`sum`](@ref).
4945

46+
This factorized sum can be used for efficient evaluation of high-dimensional integrals. This is implemented with Gauss-Kronrod quadrature rules in [`integrate`](@ref). For example, the integral
47+
```math
48+
I = 10^3 \int\limits_{[-1, +1]^{10}} d^{10} \vec{x} \,
49+
\cos\!\left(10 \textstyle\sum_{n=1}^{10} x_n^2 \right)
50+
\exp\!\left[-10^{-3}\left(\textstyle\sum_{n=1}^{10} x_n\right)^4\right]
51+
```
52+
is evaluated by the following code:
53+
```@example simple
54+
function f(x)
55+
return 1e3 * cos(10 * sum(x .^ 2)) * exp(-sum(x)^4 / 1e3)
56+
end
57+
I = TCI.integrate(Float64, f, fill(-1.0, 10), fill(+1.0, 10); GKorder=15, tolerance=1e-8)
58+
println("GK15 integral value: $I")
59+
```
60+
The argument `GKorder` controls the Gauss-Kronrod quadrature rule used for the integration, and `tolerance` controls the tolerance in the TCI approximation, which is distinct from the tolerance in the integral. For complicated functions, it is recommended to integrate using two different GK rules and to compare the results to get a good estimate of the discretization error.
61+
5062
## Properties of the TCI object
5163

5264
After running the code above, `tci` is a [`TensorCI2`](@ref) object that can be interrogated for various properties. The most important ones are the rank (i.e. maximum bond dimension) and the link dimensions:

0 commit comments

Comments
 (0)