This guide explains how to use faxtored_coeffs_txt.py and root_field.py with safe coefficient input.
The repository includes faxtored_coeffs_txt.py, which expands a factorized polynomial into a coefficient list and writes it to coeffs.txt.
- Open
faxtored_coeffs_txt.py. - Set the factorized polynomial expression in the
factored = ...line. - Run the script:
cd /Users/ralf/Projects/Python/Param_Poly_Root
python3 faxtored_coeffs_txt.pyThis writes the expanded coefficients into coeffs.txt in the current folder.
In faxtored_coeffs_txt.py, you can use expressions such as:
x = sp.symbols('x')
factored = (x - 5)**10 * (x**2 - 2*x + 2)**25 # use cluster_tolerance 1e-22
# factored = (x - 1)**40 * (x - 2)**30 * (x - 3)**20
# # use cluster_tolerance 1e-10Then run the script to generate the coefficients file.
Once coeffs.txt exists, run:
python3 root_field.py --coeffs-file coeffs.txtIf you have a different filename:
python3 root_field.py --coeffs-file my_coeffs.txtIf you prefer to pipe coefficients directly into the script:
echo "1 -100 4875 -154550 ..." | python3 root_field.pyor:
cat coeffs.txt | python3 root_field.pyThis avoids placing a long list directly in the shell command.
Increase arbitrary-precision decimal places for higher multiplicities or ill-conditioned polynomials:
python3 root_field.py --coeffs-file coeffs.txt --dps 800Adjust how roots are merged into clusters. Increase this when many m=1 clusters should be grouped into higher multiplicities:
python3 root_field.py --coeffs-file coeffs.txt --cluster-tol 1e-22Important: dps and cluster-tol are interdependent. The noise floor is roughly 10^(-dps / m_max), so cluster-tol should remain above that floor to avoid splitting true multiple roots.
python3 root_field.py --coeffs-file coeffs.txt --dps 800 --cluster-tol 1e-22The script prints diagnostic hints if many m=1 clusters are found, suggesting better tuning.
coeffs.txtshould contain a single line with coefficients separated by spaces or commas.- Coefficients must be provided in descending degree order, starting with the coefficient of
x^n. root_field.pysupports real and complex coefficients.- Use the file-based input path when coefficients are large or too long for a shell command.
cd /Users/ralf/Projects/Python/Param_Poly_Root
python3 factored_coeffs_txt.py
python3 root_field.py --coeffs-file coeffs.txtThis workflow uses a factorized polynomial definition to generate safe coefficient input and then analyses the roots with root_field.py.