Recursively finding all roots of continuous functions using Chebyshev polynomials.
To use chebroots, first construct a ChebRoots object by providing it with the function whose roots should be found. Then, the find_all_roots method returns all roots in the specified interval as well as the numerical error at every root.
from chebroots import ChebRoots
fun = lambda x: x**2 - 1
interval = [-2, +2]
roots, error = ChebRoots(fun).find_all_roots(interval)The Jupyter Notebooks (.ipynb) in the docs directory provide more detailed examples, including how to set user-defined tolerances. They can be viewed directly, for example on GitHub, or opened and used interactively with Binder. To launch the latest version, click here or on the "launch binder" badge above.
First, git clone the repository to your local machine and navigate (cd) to the directory.
On a standard Python installation, use
pip install -e .to install chebroots and its dependencies. Note the . to specify the current directory. The -e/--editable flag is optional but highly encouraged.
Alternatively, if you are using the conda package manager, you can use
conda env create -f environment.ymlto install chebroots, its dependencies, and additional (development) tools automatically. By default this creates an environment with name chebroots-dev, but that can be changed with the optional -n YOUR-NAME argument. The development environment is specified in environment.yml, which was created with
conda env export --name chebroots-dev --from-history | grep --invert-match '^prefix:' > environment.ymlchebroots uses black for code formatting. A GitHub Action automatically checks that all Python code is properly formatted. Before committing any changes to the code, run the auto-formatter:
black src/