gaussjacobiquad Module Reference

Overall driver for Gauss-Jacobi quadrature. More...

Functions/Subroutines

subroutine gauss_jacobi (npts, alpha, beta, x, wts, method)
 Compute the Gauss-Jacobi quadrature nodes and weights. More...
 

Detailed Description

Overall driver for Gauss-Jacobi quadrature.

Function/Subroutine Documentation

◆ gauss_jacobi()

subroutine gaussjacobiquad::gauss_jacobi ( integer, intent(in)  npts,
real(dp), intent(in)  alpha,
real(dp), intent(in)  beta,
real(dp), dimension(npts), intent(out)  x,
real(dp), dimension(npts), intent(out)  wts,
character(len=:), intent(in), allocatable  method 
)

Compute the Gauss-Jacobi quadrature nodes and weights.

This subroutine calculates the Gauss-Jacobi quadrature nodes and weights for the given parameters \(\alpha\) and \(\beta\), using the specified method. Gauss-Jacobi quadrature is used to approximate integrals of the form: [ \int_{-1}^{1} (1 - x)^\alpha (1 + x)^\beta f(x) \,dx \approx \sum_{i=1}^{npts} wts_i f(x_i) ] where the weights and nodes are calculated with the Jacobi polynomial, which is defined as: [ P_n^{(\alpha, \beta)}(x) = \frac{(\alpha + 1)_n}{n!} \sum_{k=0}^n \binom{n}{k} \frac{(\beta + 1)_{n-k}}{(n-k)!} \left( \frac{x-1}{2} \right)^k \left( \frac{x+1}{2} \right)^{n-k} ]

Parameters
[in]nptsNumber of quadrature points.
[in]alphaParameter alpha in the Jacobi polynomial. Must be greater than -1.
[in]betaParameter beta in the Jacobi polynomial. Must be greater than -1.
[out]xQuadrature nodes.
[out]wtsQuadrature weights.
[in]methodMethod used for calculation. Supported methods are "rec" and "gw".

Definition at line 50 of file GaussJacobiQuad.f90.

51  integer, intent(in) :: npts
52  real(dp), intent(in) :: alpha, beta
53  real(dp), intent(out) :: x(npts), wts(npts)
54  character(len=:), allocatable, intent(in) :: method
55 
56  if (npts <= 0) then
57  error stop "Number of points must be positive"
58  end if
59 
60  if (alpha <= -1.0_dp) then
61  error stop "alpha must be greater than -1"
62  end if
63 
64  if (beta <= -1.0_dp) then
65 
66  error stop "beta must be greater than -1"
67  end if
68 
69  select case (trim(method))
70  case ("rec") ! Fails at high beta
71  call gauss_jacobi_rec(npts, alpha, beta, x, wts)
72  case ("gw") ! Accurate for high beta
73  call gauss_jacobi_gw(npts, alpha, beta, x, wts)
74  case ("algo665")
75  call gauss_jacobi_algo665(npts, alpha, beta, x, wts)
76  case default
77  print*,"Error: Unknown method specified:", method
78  print*,"Supported methods: 'rec', 'gw', 'algo665'"
79  error stop
80  end select