tba-solve
Numerical solver for Thermodynamic Bethe Ansatz integral equations.
Installation
pip install tba-solve
Requires NumPy and SciPy.
The equation
The Thermodynamic Bethe Ansatz (TBA) is a class of nonlinear integral equations studied in mathematical physics — in particular in statistical field theory, quantum integrability, and gauge theories. The general form is:
$$y_j(x) = f_j(x) + \sum_k \int_{-\infty}^{\infty} \varphi_{j,k}(x - t),\log!\bigl[1 + c_{j,k},e^{,\sigma_{j,k},y_k(t)}\bigr],dt$$
where $y_j(x)$ are the unknowns, $f_j(x)$ the forcing terms, $\varphi_{j,k}(x)$ the convolution kernels, $c_{j,k}$ some constants, and $\sigma_{j,k} = \pm 1$.
Due to its nonlinear structure, the TBA cannot be solved symbolically and requires a dedicated numerical treatment.
Usage
Pre-built models
from tba_solve import sinh_gordon
import numpy as np
sols = sinh_gordon(r=0.1)
y = sols[0]
x = np.linspace(-5, 5, 200)
print(y(x))
Each model function returns a list of callable solution objects (one per dependent variable), which can be evaluated at arbitrary points within the grid domain.
Available models: sinh_gordon, liouville, seiberg_witten_su2.
Custom equations
Any TBA equation can be solved by providing its decomposed components directly:
from tba_solve import TBASolver
import numpy as np
solver = TBASolver(
forcing=[lambda x: 0.1 * np.cosh(x)],
kernels=[[lambda x: -1 / (2 * np.pi * np.cosh(x))]],
crossing=[[0]],
)
sols = solver.solve()
Coupled systems
Systems of coupled TBA equations are specified in the same way. The crossing parameter indicates which dependent variable each kernel term acts on:
from tba_solve import TBASolver
import numpy as np
solver = TBASolver(
forcing=[
lambda x: 3.0 * np.exp(x),
lambda x: 3.0 * np.exp(x),
],
kernels=[
[lambda x: -1 / (np.pi * np.cosh(x))],
[lambda x: -1 / (np.pi * np.cosh(x))],
],
crossing=[[1], [0]], # equation 0 couples to y_1, equation 1 to y_0
)
y1, y2 = solver.solve()
Parameters
| Parameter | Default | Description |
|---|---|---|
forcing |
— | Forcing terms $f_j(x)$, one callable per equation |
kernels |
— | Convolution kernels $\varphi_{j,k}(x)$, nested list of callables |
crossing |
— | Index of the dependent variable in each kernel term |
constants |
all 1 | Coefficients $c_{j,k}$ inside the log terms |
signs |
all −1 | Signs $\sigma_{j,k}$ inside the exponentials |
Options
| Option | Default | Description |
|---|---|---|
grid_cutoff |
100.2 | Half-width of the symmetric grid $[-L, L]$ |
grid_resolution |
1024 | Number of grid points (ideally a power of 2) |
stopping_accuracy |
10⁻¹⁰ | Convergence threshold on relative iteration error |
max_iterations |
4000 | Hard upper bound on iterations |
damping |
0.1 | Relaxation parameter for iteration stability |
boundary_ext |
0 | External boundary terms, added to forcing |
boundary_int |
0 | Internal boundary terms, added inside each convolution |
monitor |
False | Print iteration progress |
labels |
None | Names for the solution components |
Higher grid_resolution and grid_cutoff improve accuracy at the cost of speed. Lower stopping_accuracy requires more iterations; increase max_iterations accordingly.
Method
The solver implements the method of successive approximations:
- The solution is initialised to the forcing terms.
- At each iteration, the log-terms are evaluated and convolved with the kernels using FFT, then mixed with the previous solution via a damping factor.
- Convergence is checked every 100 iterations against the relative difference between successive iterates.
- The converged solution is returned as a cubic spline interpolation over the grid.
The convolutions are computed in Fourier space for efficiency: $O(N \log N)$ per convolution per iteration, where $N$ is the grid resolution.
Origin
This package is a Python translation of the ThermodynamicBetheAnsatzSolve Wolfram Language resource function. The Wolfram version additionally includes an automatic symbolic equation parser; the Python version requires the user to provide the equation components explicitly.
References
- A. B. Zamolodchikov, "Thermodynamic Bethe Ansatz in Relativistic Models", Nucl. Phys. B 342 (1990) 695–720.
- D. Fioravanti, D. Gregori, H. Shu, "Integrability, susy SU(2) matter gauge theories and black holes", Nucl. Phys. B 1021 (2025) 117200, doi:10.1016/j.nuclphysb.2025.117200, arXiv:2208.14031.
- D. Gregori, "Resource function for the numerical solution of certain nonlinear integral equations", Wolfram Community, Staff Picks, September 23, 2025.
License
MIT
Metadata
Release files for tba-solve 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| tba_solve-0.2.0.tar.gz | 12.7 kB | Without provenance | Details for tba_solve-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| tba_solve-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for tba_solve-0.2.0-py3-none-any.whl |
Total release size: 21.9 kB
Release files / tba_solve-0.2.0.tar.gz
| Download URL | tba_solve-0.2.0.tar.gz |
|---|---|
| Size | 12.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a83d9cb89e329561f2bdef8dd8956b36b66f1e7b9ec182bdd0beb4a7c89862f4
|
|
BLAKE2b-256 checksum How to use checksums |
8a4d61cae6f5cfa9ac8ad43485c0409ca9a1ece67abd2344bb8168c701b670b4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.2
|
Release files / tba_solve-0.2.0-py3-none-any.whl
| Download URL | tba_solve-0.2.0-py3-none-any.whl |
|---|---|
| Size | 9.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
607830b88b29dcbbd6e46753184e54b5ff1ad491d50c93efd4de195543d1931e
|
|
BLAKE2b-256 checksum How to use checksums |
4bb808954ff385d5d71b29a185fafbb9b2e7ef3e00a0ff169641686b1c61ab3c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.2
|
Security for tba-solve 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.