20 @brief This script computes Gauss-Jacobi quadrature roots and weights using SymPy.
23 The script takes polynomial degree, alpha, and beta parameters to compute
24 Gauss-Jacobi quadrature roots and weights. It uses scipy.special.roots_jacobi
32 from scipy.special
import roots_jacobi
36 roots, weights = roots_jacobi(n=n, alpha=alpha, beta=beta)
37 for idx, root
in enumerate(roots):
38 sign =
" " if root >= 0
else ""
39 root_str = f
"{root:23.17E}"
40 weight_str = f
"{weights[idx]:23.17E}"
41 print(f
"Root:{sign} {root_str} Weight: {weight_str}")
44 if __name__ ==
"__main__":
45 parser = argparse.ArgumentParser(description=
"Compute Gauss-Jacobi quadrature.")
46 parser.add_argument(
"--npts", type=int, default=5, help=
"Degree of the polynomial.")
47 parser.add_argument(
"--alpha", type=float, default=0, help=
"Alpha parameter.")
48 parser.add_argument(
"--beta", type=float, default=12, help=
"Beta parameter.")
50 args = parser.parse_args()
52 main(args.npts, args.alpha, args.beta)