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.xloandxhiare the left and right endpoints of the interval over which the quadrature rule was defined.aandbare the lower and upper limits of integration.nsubis the number of equal subintervals into which the finite interval(a,b)is to be subdivided for higher accuracy.nsubmust 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]. requiresxtabandweightto be pre-computed frombdfc_setorbdfp_set. π₯double laguerre_sum ( double func ( double x ), double a, int order, double xtab[], double weight[] )β carries out Laguerre quadrature over[ A, +oo ). requiresxtabandweightto be pre-computed fromlaguerre_compute,gen_laguerre_compute, orlaguerre_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,weightgshould be pre-computed fromlegendre_compute_drorlegendre_set. also,xtabkandweightkshould be pre-computed fromkronrod_set. the orders have to follow the relationorderk = 2 * orderg + 1β it's giving "matched set, don't break the pairing" π.resultkwill contain the result of the Gauss-Kronrod sum.resultgcontains 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 offuncfromatob, by dividing the domain intonsubsubdomains, 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].xtabandweightare 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:xtabandweightmust 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 fororder = 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, for1 <= order <= 19.void bdfp_set ( int order, double xtab[], double weight[] )β sets weights for backward differentiation predictor quadrature, for1 <= order <= 19.void cheb_set ( int order, double xtab[], double weight[] )β sets abscissas and weights for Chebyshev quadrature, fororder = 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, fororder = 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, fororder = 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, fororder = 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, fororder = 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 between1and20, or31/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 be15,21,31or41, corresponding to Gauss-Legendre rules of order7,10,15or20.void laguerre_set ( int order, double xtab[], double weight[] )β sets abscissas and weights for Laguerre quadrature. the order must be between1and20, or31/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 between1and33or63/64/65,127/128/129,255/256/257. πvoid legendre_set_cos ( int order, double xtab[], double weight[] )β sets Gauss-Legendre rules forCOS(X)*F(X)on[-PI/2,PI/2]. the order must be1, 2, 4, 8 or 16.void legendre_set_cos2 ( int order, double xtab[], double weight[] )β sets Gauss-Legendre rules forCOS(X)*F(X)on[0,PI/2]. the order must be2, 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 between1through8, or16.void legendre_set_sqrtx_01 ( int order, double xtab[], double weight[] )β sets Gauss-Legendre rules forSQRT(X)*F(X)on[0,1]. the order must be between1and16or63/64,127/128.void legendre_set_sqrtx2_01 ( int order, double xtab[], double weight[] )β sets Gauss-Legendre rules forF(X)/SQRT(X)on[0,1]. the order must be be tween1and16or63/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 forF(X)on[0,1]. the order must be between1and8.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 between1and9.void legendre_set_x1_01 ( int order, double xtab[], double weight[] )β sets a Gauss-Legendre rule forX * F(X)on[0,1]. the order must be between1and8.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 between1and9.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 between1and8. (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 between2and20. no sneaking in a1, she will not accept it πvoid moulton_set ( int order, double xtab[], double weight[] )β Sets weights for AdamsβMoulton quadrature. The order must be between1and10or12,14,16,18or20. 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 between1and21.void nco_set ( int order, double xtab[], double weight[] )β Sets abscissas and weights for open NewtonβCotes quadrature. The order must be between1and7, or9. just9, not8, not10β 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 between1and17. 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 exactly1,3,7,15,31,63,127or255. 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 between1and15.
π AUTHOR π
John Burkardt
the icon, the moment, the blueprint π«Ά
π SEE ALSO π
- The official quadrule web page
http://people.sc.fsu.edu/~jburkardt/c_src/quadrule/quadrule.html
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 πΈβ¨π
π¦ where this page comes from
- debian bookworm: libquadrule-dev 0~20121001-2+b1 Β· LGPL-3.0-or-later
- debian trixie: libquadrule-dev 0~20121001-3 Β· LGPL-3.0-or-later
- ubuntu jammy: libquadrule-dev 0~20121001-2build1 Β· LGPL-3.0-or-later
- ubuntu noble: libquadrule-dev 0~20121001-2build1 Β· LGPL-3.0-or-later
- ubuntu questing: libquadrule-dev 0~20121001-3
- ubuntu resolute: libquadrule-dev 0~20121001-4 Β· LGPL-3.0-or-later
- ubuntu stonking: libquadrule-dev 0~20121001-4 Β· LGPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms