quadrule(3)

✨ quadrule β€” C library of quadrature rules ✨

okay so bestie, welcome to quadrule(3) πŸ’– this is a Library Functions Manual page, meaning it's a section 3 C library situation, and it is lowkey a whole buffet of quadrature rules. integrals? approximated. abscissas? computed. weights? served fresh. no cap. πŸŽ€


🌸 NAME 🌸

quadrule β€” C library of quadrature rules πŸ¦‹

✨ SYNOPSIS ✨

#include <quadrule.h>

πŸ‘‘ DESCRIPTION πŸ‘‘

okay so this library is genuinely iconic and it comes in three whole flavors, so let's break it down like a group chat πŸ’…

🌈 APPROXIMATING INTEGRALS 🌈

the following functions take a set of abscissas and weights you already have, and use them to compute an approximation to an integral. it's giving "we have the ingredients, now we bake" πŸ“

  • double summer ( double func ( double x ), int order, double xtab[], double weight[] ) β€” carries out a quadrature rule over a single interval. one interval, one vibe. ✨
  • double sum_sub ( double func ( double x ), double a, double b, int nsub, int order, double xlo, double xhi, double xtab[], double weight[] ) β€” carries out a composite quadrature rule. more subintervals, more accuracy, more slay.
    • xlo and xhi are the left and right endpoints of the interval over which the quadrature rule was defined.
    • a and b are the lower and upper limits of integration.
    • nsub is the number of equal subintervals into which the finite interval (a,b) is to be subdivided for higher accuracy. nsub must be at least 1 β€” like, do not pass it 0, that's not the move πŸ™ˆ
  • double bdf_sum ( double func ( double x ), int order, double xtab[], double weight[] ) β€” carries out explicit backward difference quadrature on [0,1]. requires xtab and weight to be pre-computed from bdfc_set or bdfp_set. πŸ”₯
  • double laguerre_sum ( double func ( double x ), double a, int order, double xtab[], double weight[] ) β€” carries out Laguerre quadrature over [ A, +oo ). requires xtab and weight to be pre-computed from laguerre_compute, gen_laguerre_compute, or laguerre_set.
  • void summer_gk ( double func ( double x ), int orderg, double weightg[], double *resultg, int orderk , double xtabk[], double weightk[], double *resultk ) β€” carries out Gauss-Kronrod quadrature over a single interval. before you call this, weightg should be pre-computed from legendre_compute_dr or legendre_set. also, xtabk and weightk should be pre-computed from kronrod_set. the orders have to follow the relation orderk = 2 * orderg + 1 β€” it's giving "matched set, don't break the pairing" πŸ’œ. resultk will contain the result of the Gauss-Kronrod sum. resultg contains an intermediate sum, using only the Gauss quadrature.
  • void sum_sub_gk ( double func ( double x ), double a, double b, int nsub, int orderg, double weightg[], double *resultg, int orderk, double xtabk[], double weightk[], double *resultk, double *error ) β€” carries out a composite Gauss-Kronrod rule. it approximates the integral of func from a to b, by dividing the domain into nsub subdomains, and applying a Gauss-Kronrod rule on each subdomain. main character energy fr fr. πŸ‘‘

and then there's this little utility function, for modifying existing weights / abscissas before you compute an integral:

  • void rule_adjust ( double a, double b, double c, double d, int order, double xtab[], double weight[] ) β€” maps a quadrature rule from [A,B] to [C,D]. xtab and weight are overwritten β€” heads up, it does not ask first πŸ’€

πŸŽ€ COMPUTING QUADRATURE ABSCISSAS / WEIGHTS πŸŽ€

the following functions compute arrays of abscissas and weights (xtab, weight) for a particular quadrature rule, for any given order. the range of the abscissas is ( -1 <= x < 1 ) unless otherwise given. 🌸

NOTE: xtab and weight must be allocated before calling these functions. allocate first, then compute, that's the order of operations bestie 🫢
  • void chebyshev1_compute ( int order, double xtab[], double weight[] ) β€” computes a Gauss-Chebyshev type 1 quadrature rule.
  • void chebyshev2_compute ( int order, double xtab[], double weight[] ) β€” computes a Gauss-Chebyshev type 2 quadrature rule.
  • void chebyshev3_compute ( int order, double xtab[], double weight[] ) β€” computes a Gauss-Chebyshev type 3 quadrature rule.
  • void clenshaw_curtis_compute ( int order, double xtab[], double weight[] ) β€” computes a Clenshaw Curtis quadrature rule.
  • void fejer1_compute ( int order, double xtab[], double weight[] ) β€” computes a Fejer type 1 quadrature rule.
  • void fejer2_compute ( int order, double xtab[], double weight[] ) β€” computes a Fejer type 2 quadrature rule.
  • void gegenbauer_compute ( int order, double alpha, double xtab[], double weight[] ) β€” computes a Gauss-Gegenbauer quadrature rule.
  • void gen_hermite_compute ( int order, double alpha, double xtab[], double weight[] ) β€” computes a generalized Gauss-Hermite rule for the interval ( -infinity < x < +infinity ). 🌈
  • void gen_laguerre_compute ( int order, double alpha, double xtab[], double weight[] ) β€” computes a generalized Gauss-Laguerre quadrature rule for the interval ( alpha <= x < infinity ).
  • void hermite_ek_compute ( int order, double xtab[], double weight[] ) β€” computes a Gauss-Hermite quadrature rule, using an algorithm by Elhay and Kautsky. interval is ( -infinity < x < infinity ).
  • void hermite_ss_compute ( int order, double xtab[], double weight[] ) β€” computes a Gauss-Hermite quadrature rule, using an algorithm by Arthur Stroud and Don Secrest. interval is ( -infinity < x < infinity ).
  • void jacobi_compute ( int order, double alpha, double beta, double xtab[], double weight[] ) β€” computes a Gauss-Jacobi quadrature rule.
  • void laguerre_compute ( int order, double xtab[], double weight[] ) β€” computes a Gauss-Laguerre quadrature rule for the inverval ( 0 <= x < infinity ). (yes bestie, "inverval", we don't gatekeep the original typo 😭)
  • void legendre_compute_dr ( int order, double xtab[], double weight[] ) β€” Gauss-Legendre quadrature by Davis-Rabinowitz method.
  • void lobatto_compute ( int order, double xtab[], double weight[] ) β€” computes a Lobatto quadrature rule.
  • void nc_compute ( int order, double x_min, double x_max, double xtab[], double weight[] ) β€” computes a Newton-Cotes quadrature rule. ✨
    • ( x_min <= x <= x_max )
  • void ncc_compute ( int order, double xtab[], double weight[] ) β€” computes a Newton-Cotes Closed quadrature rule.
  • void nco_compute ( int order, double xtab[], double weight[] ) β€” computes a Newton-Cotes Open quadrature rule.
  • void ncoh_compute ( int order, double xtab[], double weight[] ) β€” computes a Newton-Cotes "open half" quadrature rule.
    • ( x_min <= x <= x_max )
  • void radau_compute ( int order, double xtab[], double weight[] ) β€” computes a Radau quadrature rule.

πŸ’… PRE-COMPUTED QUADRATURES πŸ’…

the following functions return abscissas/weights for various quadrature rules, but only for particular orders. it's giving "fixed menu, no substitutions" πŸ“

NOTE: check the valid range of order parameters for the particular function before using it. using an unsupported order will cause an abort. like, actually abort. so please read the list, bestie, i'm begging πŸ™ˆ
  • void bashforth_set ( int order, double xtab[], double weight [] ) β€” sets an Adams-Bashforth quadrature for order = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 16, 18, or 20.
  • void bdfc_set ( int order, double xtab[], double weight[] ) β€” sets weights for backward differentiation corrector quadrature, for 1 <= order <= 19.
  • void bdfp_set ( int order, double xtab[], double weight[] ) β€” sets weights for backward differentiation predictor quadrature, for 1 <= order <= 19.
  • void cheb_set ( int order, double xtab[], double weight[] ) β€” sets abscissas and weights for Chebyshev quadrature, for order = 1, 2, 3, 4, 5, 6, 7, or 9. (not 8, bestie. why not 8? no idea, that's just the lore πŸ’€)
  • void clenshaw_curtis_set ( int order, double xtab[], double weight[] ) β€” sets a Clenshaw-Curtis quadrature rule, for order = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 33, 65, or 129.
  • void fejer1_set ( int order, double xtab[], double weight[] ) β€” sets abscissas and weights for Fejer type 1 quadrature, for order = 1, 2, 3, 4, 5, 6, 7, 8, 9, or 10.
  • void fejer2_set ( int order, double xtab[], double weight[] ) β€” sets abscissas and weights for Fejer type 2 quadrature, for order = 1, 2, 3, 4, 5, 6, 7, 8, 9, or 10.
  • void hermite_genz_keister_set ( int order, double xtab[], double weight[] ) β€” sets a Hermite Genz-Keister rule, for order = 1, 3, 7, 9, 17, 19, 31, 33, or 35.
  • void hermite_set ( int order, double xtab[], double weight[] ) β€” sets abscissas and weights for Hermite quadrature. the order must be between 1 and 20, or 31/32/33, 63/64/65, 127/128/129.
  • void kronrod_set ( int order, double xtab[], double weight[] ) β€” sets abscissas and weights for Gauss-Kronrod quadrature. the order may be 15, 21, 31 or 41, corresponding to Gauss-Legendre rules of order 7, 10, 15 or 20.
  • void laguerre_set ( int order, double xtab[], double weight[] ) β€” sets abscissas and weights for Laguerre quadrature. the order must be between 1 and 20, or 31/32/33, 63/64/65, 127/128/129.
  • void legendre_set ( int order, double xtab[], double weight[] ) β€” sets abscissas and weights for Gauss-Legendre quadrature. the order must be between 1 and 33 or 63/64/65, 127/128/129, 255/256/257. πŸ‘‘
  • void legendre_set_cos ( int order, double xtab[], double weight[] ) β€” sets Gauss-Legendre rules for COS(X)*F(X) on [-PI/2,PI/2]. the order must be 1, 2, 4, 8 or 16.
  • void legendre_set_cos2 ( int order, double xtab[], double weight[] ) β€” sets Gauss-Legendre rules for COS(X)*F(X) on [0,PI/2]. the order must be 2, 4, 8 or 16.
  • void legendre_set_log ( int order, double xtab[], double weight[] ) β€” sets a Gauss-Legendre rule for - LOG(X) * F(X) on [0,1]. the order must be between 1 through 8, or 16.
  • void legendre_set_sqrtx_01 ( int order, double xtab[], double weight[] ) β€” sets Gauss-Legendre rules for SQRT(X)*F(X) on [0,1]. the order must be between 1 and 16 or 63/64, 127/128.
  • void legendre_set_sqrtx2_01 ( int order, double xtab[], double weight[] ) β€” sets Gauss-Legendre rules for F(X)/SQRT(X) on [0,1]. the order must be be tween 1 and 16 or 63/64, 127/128. (we do not touch the "be be tween". it's canon now 🫢)
  • void legendre_set_x0_01 ( int order, double xtab[], double weight[] ) β€” sets a Gauss-Legendre rule for F(X) on [0,1]. the order must be between 1 and 8.
  • void legendre_set_x1 ( int order, double xtab[], double weight[] ) β€” sets a Gauss-Legendre rule for ( 1 + X ) * F(X) on [-1,1]. the order must be between 1 and 9.
  • void legendre_set_x1_01 ( int order, double xtab[], double weight[] ) β€” sets a Gauss-Legendre rule for X * F(X) on [0,1]. the order must be between 1 and 8.
  • void legendre_set_x2 ( int order, double xtab[], double weight[] ) β€” sets Gauss-Legendre rules for ( 1 + X )^2*F(X) on [-1,1]. the order must be between 1 and 9.
  • void legendre_set_x2_01 ( int order, double xtab[], double weight[] )
  • Sets a Gauss‐Legendre rule for X*X * F(X) on [0,1]. The order must be between 1 and 8. (signature's chillin' at the end of part 1, bestie 🫢)
  • void lobatto_set ( int order, double xtab[], double weight[] ) β€” Sets abscissas and weights for Lobatto quadrature. The order must be between 2 and 20. no sneaking in a 1, she will not accept it πŸ’…
  • void moulton_set ( int order, double xtab[], double weight[] ) β€” Sets weights for Adams‐Moulton quadrature. The order must be between 1 and 10 or 12, 14, 16, 18 or 20. yeah it's a lil picky, we love that for her ✨
  • void ncc_set ( int order, double xtab[], double weight[] ) β€” Sets abscissas and weights for closed Newton‐Cotes quadrature. The order must be between 1 and 21.
  • void nco_set ( int order, double xtab[], double weight[] ) β€” Sets abscissas and weights for open Newton‐Cotes quadrature. The order must be between 1 and 7, or 9. just 9, not 8, not 10 β€” she said what she said πŸ“’
  • void ncoh_set ( int order, double xtab[], double weight[] ) β€” Sets abscissas and weights for Newton‐Cotes "open half" rules. The order must be between 1 and 17. the "open half" girls are literally so underrated πŸ¦‹
  • void patterson_set ( int order, double xtab[], double weight[] ) β€” Sets abscissas and weights for Gauss‐Patterson quadrature. The order must be exactly 1, 3, 7, 15, 31, 63, 127 or 255. that's it, that's the whole list, don't try to be cute πŸ‘‘
  • void radau_set ( int order, double xtab[], double weight[] ) β€” Sets abscissas and weights for Radau quadrature. The order must be between 1 and 15.

πŸ‘‘ AUTHOR πŸ‘‘

John Burkardt

the icon, the moment, the blueprint 🫢


🌈 SEE ALSO 🌈

go look at it, it's giving academic excellence πŸ’–


and that's the whole page, bestie!! this is quadrule(3) as of 15 Mar 2013 β€” yeah she's an elder but she ate and left no crumbs πŸŒΈβœ¨πŸ’œ