Title: | Collection of Functions for Gaussian Quadrature |
---|---|
Description: | A collection of functions to perform Gaussian quadrature with different weight functions corresponding to the orthogonal polynomials in package orthopolynom. Examples verify the orthogonality and inner products of the polynomials. |
Authors: | Frederick Novomestky <[email protected]> |
Maintainer: | Frederick Novomestky <[email protected]> |
License: | GPL (>= 2) |
Version: | 1.0-3 |
Built: | 2024-12-01 08:01:31 UTC |
Source: | CRAN |
This function evaluates the integral of the given function between the lower and upper limits using the weight and abscissa values specified in the rule data frame. The quadrature formula uses the weight function for Chebyshev C polynomials.
chebyshev.c.quadrature(functn, rule, lower = -2, upper = 2, weighted = TRUE, ...)
chebyshev.c.quadrature(functn, rule, lower = -2, upper = 2, weighted = TRUE, ...)
functn |
an R function which should take a numeric argument x and possibly some parameters. The function returns a numerical vector value for the given argument x. |
rule |
a data frame containing the order |
lower |
numeric value for the lower limit of the integral with a default value of -2 |
upper |
numeric value for the upper limit of the integral with a default value of +2 |
weighted |
boolean value which if true causes the Chebyshev weight function to be included in the integrand |
... |
other arguments passed to the give function |
The rule argument corresponds to an order Chebyshev polynomial,
weight function and interval
.
The lower and upper limits of the integral must be finite.
The value of definite integral evaluated using Gauss Chebyshev quadrature
Frederick Novomestky [email protected]
Abramowitz, M. and I. A. Stegun, 1968. Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables, Dover Publications, Inc., New York.
Press, W. H., S. A. Teukolsky, W. T. Vetterling, and B. P. Flannery, 1992. Numerical Recipes in C, Cambridge University Press, Cambridge, U.K.
Stroud, A. H., and D. Secrest, 1966. Gaussian Quadrature Formulas, Prentice-Hall, Englewood Cliffs, NJ.
### ### this example evaluates the quadrature function for ### the Chebyshev C polynomials. it computes the integral ### of the product for all pairs of orthogonal polynomials ### from order 0 to order 16. the results are compared to ### the diagonal matrix of the inner products for the ### polynomials. it also computes the integral of the product ### of all pairs of orthonormal polynomials from order 0 ### to order 16. the resultant matrix should be an identity matrix ### ### ### set the value for the maximum polynomial order ### n <- 16 ### ### maximum order plus 1 ### np1 <- n + 1 ### ### function to construct the polynomial products by column ### by.column.products <- function( c, p.list, p.p.list ) { ### ### function to construct the polynomial products by row ### by.row.products <- function( r, c, p.list ) { row.column.product <- p.list[[r]] * p.list[[c]] return (row.column.product ) } np1 <- length( p.list ) row.list <- lapply( 1:np1, by.row.products, c, p.list ) return( row.list ) } ### ### function construct the polynomial functions by column ### by.column.functions <- function( c, p.p.products ) { ### ### function to construct the polynomial functions by row ### by.row.functions <- function( r, c, p.p.products ) { row.column.function <- as.function( p.p.products[[r]][[c]] ) return( row.column.function ) } np1 <- length( p.p.products[[1]] ) row.list <- lapply( 1:np1, by.row.functions, c, p.p.products ) return( row.list ) } ### ### function to compute the integral of the polynomials by column ### by.column.integrals <- function( c, p.p.functions ) { ### ### function to compute the integral of the polynomials by row ### by.row.integrals <- function( r, c, p.p.functions ) { row.column.integral <- chebyshev.c.quadrature( p.p.functions[[r]][[c]], order.np1.rule ) return( row.column.integral ) } np1 <- length( p.p.functions[[1]] ) row.vector <- sapply( 1:np1, by.row.integrals, c, p.p.functions ) return( row.vector ) } ### ### construct a list of the Chebyshev C orthogonal polynomials ### p.list <- chebyshev.c.polynomials( n ) ### ### construct the two dimensional list of pair products ### of polynomials ### p.p.products <- lapply( 1:np1, by.column.products, p.list ) ### ### compute the two dimensional list of functions ### corresponding to the polynomial products in ### the two dimensional list p.p.products ### p.p.functions <- lapply( 1:np1, by.column.functions, p.p.products ) ### ### get the rule table for the order np1 polynomial ### rules <- chebyshev.c.quadrature.rules( np1 ) order.np1.rule <- rules[[np1]] ### ### construct the square symmetric matrix containing ### the definite integrals over the default limits ### corresponding to the two dimensional list of ### polynomial functions ### p.p.integrals <- sapply( 1:np1, by.column.integrals, p.p.functions ) ### ### construct the diagonal matrix with the inner products ### of the orthogonal polynomials on the diagonal ### p.p.inner.products <- diag( chebyshev.c.inner.products( n ) ) print( "Integral of cross products for the orthogonal polynomials " ) print( apply( p.p.integrals, 2, round, digits=5 ) ) print( apply( p.p.inner.products, 2, round, digits=5 ) ) ### ### construct a list of the Chebyshev C orthonormal polynomials ### p.list <- chebyshev.c.polynomials( n, TRUE ) ### ### construct the two dimensional list of pair products ### of polynomials ### p.p.products <- lapply( 1:np1, by.column.products, p.list ) ### ### compute the two dimensional list of functions ### corresponding to the polynomial products in ### the two dimensional list p.p.products ### p.p.functions <- lapply( 1:np1, by.column.functions, p.p.products ) ### ### get the rule table for the order np1 polynomial ### rules <- chebyshev.c.quadrature.rules( np1, TRUE ) order.np1.rule <- rules[[np1]] ### ### construct the square symmetric matrix containing ### the definite integrals over the default limits ### corresponding to the two dimensional list of ### polynomial functions ### p.p.integrals <- sapply( 1:np1, by.column.integrals, p.p.functions ) ### ### display the matrix of integrals ### print( "Integral of cross products for the orthonormal polynomials " ) print(apply( p.p.integrals, 2, round, digits=5 ) )
### ### this example evaluates the quadrature function for ### the Chebyshev C polynomials. it computes the integral ### of the product for all pairs of orthogonal polynomials ### from order 0 to order 16. the results are compared to ### the diagonal matrix of the inner products for the ### polynomials. it also computes the integral of the product ### of all pairs of orthonormal polynomials from order 0 ### to order 16. the resultant matrix should be an identity matrix ### ### ### set the value for the maximum polynomial order ### n <- 16 ### ### maximum order plus 1 ### np1 <- n + 1 ### ### function to construct the polynomial products by column ### by.column.products <- function( c, p.list, p.p.list ) { ### ### function to construct the polynomial products by row ### by.row.products <- function( r, c, p.list ) { row.column.product <- p.list[[r]] * p.list[[c]] return (row.column.product ) } np1 <- length( p.list ) row.list <- lapply( 1:np1, by.row.products, c, p.list ) return( row.list ) } ### ### function construct the polynomial functions by column ### by.column.functions <- function( c, p.p.products ) { ### ### function to construct the polynomial functions by row ### by.row.functions <- function( r, c, p.p.products ) { row.column.function <- as.function( p.p.products[[r]][[c]] ) return( row.column.function ) } np1 <- length( p.p.products[[1]] ) row.list <- lapply( 1:np1, by.row.functions, c, p.p.products ) return( row.list ) } ### ### function to compute the integral of the polynomials by column ### by.column.integrals <- function( c, p.p.functions ) { ### ### function to compute the integral of the polynomials by row ### by.row.integrals <- function( r, c, p.p.functions ) { row.column.integral <- chebyshev.c.quadrature( p.p.functions[[r]][[c]], order.np1.rule ) return( row.column.integral ) } np1 <- length( p.p.functions[[1]] ) row.vector <- sapply( 1:np1, by.row.integrals, c, p.p.functions ) return( row.vector ) } ### ### construct a list of the Chebyshev C orthogonal polynomials ### p.list <- chebyshev.c.polynomials( n ) ### ### construct the two dimensional list of pair products ### of polynomials ### p.p.products <- lapply( 1:np1, by.column.products, p.list ) ### ### compute the two dimensional list of functions ### corresponding to the polynomial products in ### the two dimensional list p.p.products ### p.p.functions <- lapply( 1:np1, by.column.functions, p.p.products ) ### ### get the rule table for the order np1 polynomial ### rules <- chebyshev.c.quadrature.rules( np1 ) order.np1.rule <- rules[[np1]] ### ### construct the square symmetric matrix containing ### the definite integrals over the default limits ### corresponding to the two dimensional list of ### polynomial functions ### p.p.integrals <- sapply( 1:np1, by.column.integrals, p.p.functions ) ### ### construct the diagonal matrix with the inner products ### of the orthogonal polynomials on the diagonal ### p.p.inner.products <- diag( chebyshev.c.inner.products( n ) ) print( "Integral of cross products for the orthogonal polynomials " ) print( apply( p.p.integrals, 2, round, digits=5 ) ) print( apply( p.p.inner.products, 2, round, digits=5 ) ) ### ### construct a list of the Chebyshev C orthonormal polynomials ### p.list <- chebyshev.c.polynomials( n, TRUE ) ### ### construct the two dimensional list of pair products ### of polynomials ### p.p.products <- lapply( 1:np1, by.column.products, p.list ) ### ### compute the two dimensional list of functions ### corresponding to the polynomial products in ### the two dimensional list p.p.products ### p.p.functions <- lapply( 1:np1, by.column.functions, p.p.products ) ### ### get the rule table for the order np1 polynomial ### rules <- chebyshev.c.quadrature.rules( np1, TRUE ) order.np1.rule <- rules[[np1]] ### ### construct the square symmetric matrix containing ### the definite integrals over the default limits ### corresponding to the two dimensional list of ### polynomial functions ### p.p.integrals <- sapply( 1:np1, by.column.integrals, p.p.functions ) ### ### display the matrix of integrals ### print( "Integral of cross products for the orthonormal polynomials " ) print(apply( p.p.integrals, 2, round, digits=5 ) )
This function returns a list with elements containing
the order
quadrature rule data frame for
the Chebyshev C polynomial
for orders
.
chebyshev.c.quadrature.rules(n,normalized=FALSE)
chebyshev.c.quadrature.rules(n,normalized=FALSE)
n |
integer value for the highest order |
normalized |
boolean value. if TRUE rules are for orthonormal polynomials, otherwise they are for orthgonal polynomials |
An order quadrature data frame is a named data frame that contains
the roots and abscissa values of the corresponding order
orthogonal polynomial.
The column with name
x
contains the roots or zeros and
the column with name w
contains the weights.
A list with elements each of which is a data frame
1 |
Quadrature rule data frame for the order 1 Chebyshev polynomial |
2 |
Quadrature rule data frame for the order 2 Chebyshev polynomial |
...
n |
Quadrature rule data frame for the order |
Frederick Novomestky [email protected]
Abramowitz, M. and I. A. Stegun, 1968. Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables, Dover Publications, Inc., New York.
Press, W. H., S. A. Teukolsky, W. T. Vetterling, and B. P. Flannery, 1992. Numerical Recipes in C, Cambridge University Press, Cambridge, U.K.
Stroud, A. H., and D. Secrest, 1966. Gaussian Quadrature Formulas, Prentice-Hall, Englewood Cliffs, NJ.
quadrature.rules
,
chebyshev.c.quadrature
### ### construct the list of quadrature rules for ### the Chebyshev orthogonal polynomials ### of orders 1 to 5 ### orthogonal.rules <- chebyshev.c.quadrature.rules( 5 ) print( orthogonal.rules ) ### ### construct the list of quadrature rules for ### the Chebyshev orthonormal polynomials ### of orders 1 to 5 ### orthonormal.rules <- chebyshev.c.quadrature.rules( 5, TRUE ) print( orthonormal.rules )
### ### construct the list of quadrature rules for ### the Chebyshev orthogonal polynomials ### of orders 1 to 5 ### orthogonal.rules <- chebyshev.c.quadrature.rules( 5 ) print( orthogonal.rules ) ### ### construct the list of quadrature rules for ### the Chebyshev orthonormal polynomials ### of orders 1 to 5 ### orthonormal.rules <- chebyshev.c.quadrature.rules( 5, TRUE ) print( orthonormal.rules )
This function evaluates the integral of the given function between the lower and upper limits using the weight and abscissa values specified in the rule data frame. The quadrature formula uses the weight function for Chebyshev S polynomials.
chebyshev.s.quadrature(functn, rule, lower = -2, upper = 2, weighted = TRUE, ...)
chebyshev.s.quadrature(functn, rule, lower = -2, upper = 2, weighted = TRUE, ...)
functn |
an R function which should take a numeric argument x and possibly some parameters. The function returns a numerical vector value for the given argument x. |
rule |
a data frame containing the order |
lower |
numeric value for the lower limit of the integral with a default value of -2 |
upper |
numeric value for the upper limit of the integral with a default value of +2 |
weighted |
boolean value which if true causes the Chebyshev weight function to be included in the integrand |
... |
other arguments passed to the give function |
The rule argument corresponds to an order Chebyshev polynomial,
weight function and interval
.
The lower and upper limits of the integral must be finite.
The value of definite integral evaluated using Gauss Chebyshev quadrature
Frederick Novomestky [email protected]
Abramowitz, M. and I. A. Stegun, 1968. Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables, Dover Publications, Inc., New York.
Press, W. H., S. A. Teukolsky, W. T. Vetterling, and B. P. Flannery, 1992. Numerical Recipes in C, Cambridge University Press, Cambridge, U.K.
Stroud, A. H., and D. Secrest, 1966. Gaussian Quadrature Formulas, Prentice-Hall, Englewood Cliffs, NJ.
### ### this example evaluates the quadrature function for ### the Chebyshev S polynomials. it computes the integral ### of the product for all pairs of orthogonal polynomials ### from order 0 to order 16. the results are compared to ### the diagonal matrix of the inner products for the ### polynomials. it also computes the integral of the product ### of all pairs of orthonormal polynomials from order 0 ### to order 16. the resultant matrix should be an identity matrix ### ### ### set the value for the maximum polynomial order ### n <- 16 ### ### maximum order plus 1 ### np1 <- n + 1 ### ### function to construct the polynomial products by column ### by.column.products <- function( c, p.list, p.p.list ) { ### ### function to construct the polynomial products by row ### by.row.products <- function( r, c, p.list ) { row.column.product <- p.list[[r]] * p.list[[c]] return (row.column.product ) } np1 <- length( p.list ) row.list <- lapply( 1:np1, by.row.products, c, p.list ) return( row.list ) } ### ### function construct the polynomial functions by column ### by.column.functions <- function( c, p.p.products ) { ### ### function to construct the polynomial functions by row ### by.row.functions <- function( r, c, p.p.products ) { row.column.function <- as.function( p.p.products[[r]][[c]] ) return( row.column.function ) } np1 <- length( p.p.products[[1]] ) row.list <- lapply( 1:np1, by.row.functions, c, p.p.products ) return( row.list ) } ### ### function to compute the integral of the polynomials by column ### by.column.integrals <- function( c, p.p.functions ) { ### ### function to compute the integral of the polynomials by row ### by.row.integrals <- function( r, c, p.p.functions ) { row.column.integral <- chebyshev.s.quadrature( p.p.functions[[r]][[c]], order.np1.rule ) return( row.column.integral ) } np1 <- length( p.p.functions[[1]] ) row.vector <- sapply( 1:np1, by.row.integrals, c, p.p.functions ) return( row.vector ) } ### ### construct a list of the Chebyshev S orthogonal polynomials ### p.list <- chebyshev.s.polynomials( n ) ### ### construct the two dimensional list of pair products ### of polynomials ### p.p.products <- lapply( 1:np1, by.column.products, p.list ) ### ### compute the two dimensional list of functions ### corresponding to the polynomial products in ### the two dimensional list p.p.products ### p.p.functions <- lapply( 1:np1, by.column.functions, p.p.products ) ### ### get the rule table for the order np1 polynomial ### rules <- chebyshev.s.quadrature.rules( np1 ) order.np1.rule <- rules[[np1]] ### ### construct the square symmetric matrix containing ### the definite integrals over the default limits ### corresponding to the two dimensional list of ### polynomial functions ### p.p.integrals <- sapply( 1:np1, by.column.integrals, p.p.functions ) ### ### construct the diagonal matrix with the inner products ### of the orthogonal polynomials on the diagonal ### p.p.inner.products <- diag( chebyshev.s.inner.products( n ) ) print( "Integral of cross products for the orthogonal polynomials " ) print( apply( p.p.integrals, 2, round, digits=5 ) ) print( apply( p.p.inner.products, 2, round, digits=5 ) ) ### ### construct a list of the Chebyshev S orthonormal polynomials ### p.list <- chebyshev.s.polynomials( n, TRUE ) ### ### construct the two dimensional list of pair products ### of polynomials ### p.p.products <- lapply( 1:np1, by.column.products, p.list ) ### ### compute the two dimensional list of functions ### corresponding to the polynomial products in ### the two dimensional list p.p.products ### p.p.functions <- lapply( 1:np1, by.column.functions, p.p.products ) ### ### get the rule table for the order np1 polynomial ### rules <- chebyshev.s.quadrature.rules( np1, TRUE ) order.np1.rule <- rules[[np1]] ### ### construct the square symmetric matrix containing ### the definite integrals over the default limits ### corresponding to the two dimensional list of ### polynomial functions ### p.p.integrals <- sapply( 1:np1, by.column.integrals, p.p.functions ) ### ### display the matrix of integrals ### print( "Integral of cross products for the orthonormal polynomials " ) print(apply( p.p.integrals, 2, round, digits=5 ) )
### ### this example evaluates the quadrature function for ### the Chebyshev S polynomials. it computes the integral ### of the product for all pairs of orthogonal polynomials ### from order 0 to order 16. the results are compared to ### the diagonal matrix of the inner products for the ### polynomials. it also computes the integral of the product ### of all pairs of orthonormal polynomials from order 0 ### to order 16. the resultant matrix should be an identity matrix ### ### ### set the value for the maximum polynomial order ### n <- 16 ### ### maximum order plus 1 ### np1 <- n + 1 ### ### function to construct the polynomial products by column ### by.column.products <- function( c, p.list, p.p.list ) { ### ### function to construct the polynomial products by row ### by.row.products <- function( r, c, p.list ) { row.column.product <- p.list[[r]] * p.list[[c]] return (row.column.product ) } np1 <- length( p.list ) row.list <- lapply( 1:np1, by.row.products, c, p.list ) return( row.list ) } ### ### function construct the polynomial functions by column ### by.column.functions <- function( c, p.p.products ) { ### ### function to construct the polynomial functions by row ### by.row.functions <- function( r, c, p.p.products ) { row.column.function <- as.function( p.p.products[[r]][[c]] ) return( row.column.function ) } np1 <- length( p.p.products[[1]] ) row.list <- lapply( 1:np1, by.row.functions, c, p.p.products ) return( row.list ) } ### ### function to compute the integral of the polynomials by column ### by.column.integrals <- function( c, p.p.functions ) { ### ### function to compute the integral of the polynomials by row ### by.row.integrals <- function( r, c, p.p.functions ) { row.column.integral <- chebyshev.s.quadrature( p.p.functions[[r]][[c]], order.np1.rule ) return( row.column.integral ) } np1 <- length( p.p.functions[[1]] ) row.vector <- sapply( 1:np1, by.row.integrals, c, p.p.functions ) return( row.vector ) } ### ### construct a list of the Chebyshev S orthogonal polynomials ### p.list <- chebyshev.s.polynomials( n ) ### ### construct the two dimensional list of pair products ### of polynomials ### p.p.products <- lapply( 1:np1, by.column.products, p.list ) ### ### compute the two dimensional list of functions ### corresponding to the polynomial products in ### the two dimensional list p.p.products ### p.p.functions <- lapply( 1:np1, by.column.functions, p.p.products ) ### ### get the rule table for the order np1 polynomial ### rules <- chebyshev.s.quadrature.rules( np1 ) order.np1.rule <- rules[[np1]] ### ### construct the square symmetric matrix containing ### the definite integrals over the default limits ### corresponding to the two dimensional list of ### polynomial functions ### p.p.integrals <- sapply( 1:np1, by.column.integrals, p.p.functions ) ### ### construct the diagonal matrix with the inner products ### of the orthogonal polynomials on the diagonal ### p.p.inner.products <- diag( chebyshev.s.inner.products( n ) ) print( "Integral of cross products for the orthogonal polynomials " ) print( apply( p.p.integrals, 2, round, digits=5 ) ) print( apply( p.p.inner.products, 2, round, digits=5 ) ) ### ### construct a list of the Chebyshev S orthonormal polynomials ### p.list <- chebyshev.s.polynomials( n, TRUE ) ### ### construct the two dimensional list of pair products ### of polynomials ### p.p.products <- lapply( 1:np1, by.column.products, p.list ) ### ### compute the two dimensional list of functions ### corresponding to the polynomial products in ### the two dimensional list p.p.products ### p.p.functions <- lapply( 1:np1, by.column.functions, p.p.products ) ### ### get the rule table for the order np1 polynomial ### rules <- chebyshev.s.quadrature.rules( np1, TRUE ) order.np1.rule <- rules[[np1]] ### ### construct the square symmetric matrix containing ### the definite integrals over the default limits ### corresponding to the two dimensional list of ### polynomial functions ### p.p.integrals <- sapply( 1:np1, by.column.integrals, p.p.functions ) ### ### display the matrix of integrals ### print( "Integral of cross products for the orthonormal polynomials " ) print(apply( p.p.integrals, 2, round, digits=5 ) )
This function returns a list with elements containing
the order
quadrature rule data frame for
the Chebyshev S polynomial
for orders
.
chebyshev.s.quadrature.rules(n,normalized=FALSE)
chebyshev.s.quadrature.rules(n,normalized=FALSE)
n |
integer value for the highest order |
normalized |
boolean value. if TRUE rules are for orthonormal polynomials, otherwise they are for orthgonal polynomials |
An order quadrature data frame is a named data frame that contains
the roots and abscissa values of the corresponding order
orthogonal polynomial.
The column with name
x
contains the roots or zeros and
the column with name w
contains the weights.
A list with elements each of which is a data frame
1 |
Quadrature rule data frame for the order 1 Chebyshev polynomial |
2 |
Quadrature rule data frame for the order 2 Chebyshev polynomial |
...
n |
Quadrature rule data frame for the order |
Frederick Novomestky [email protected]
Abramowitz, M. and I. A. Stegun, 1968. Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables, Dover Publications, Inc., New York.
Press, W. H., S. A. Teukolsky, W. T. Vetterling, and B. P. Flannery, 1992. Numerical Recipes in C, Cambridge University Press, Cambridge, U.K.
Stroud, A. H., and D. Secrest, 1966. Gaussian Quadrature Formulas, Prentice-Hall, Englewood Cliffs, NJ.
quadrature.rules
,
chebyshev.s.quadrature
### ### generate a list of quadrature rules for ### the Chebyshev S orthogonal polynomials ### for orders 1 to 5 ### orthogonal.rules <- chebyshev.s.quadrature.rules( 5 ) print( orthogonal.rules ) ### ### generate a list of quadrature rules for ### the Chebyshev S orthogonal polynomials ### for orders 1 to 5 ### orthonormal.rules <- chebyshev.s.quadrature.rules( 5, TRUE ) print( orthonormal.rules )
### ### generate a list of quadrature rules for ### the Chebyshev S orthogonal polynomials ### for orders 1 to 5 ### orthogonal.rules <- chebyshev.s.quadrature.rules( 5 ) print( orthogonal.rules ) ### ### generate a list of quadrature rules for ### the Chebyshev S orthogonal polynomials ### for orders 1 to 5 ### orthonormal.rules <- chebyshev.s.quadrature.rules( 5, TRUE ) print( orthonormal.rules )
This function evaluates the integral of the given function between the lower and upper limits using the weight and abscissa values specified in the rule data frame. The quadrature formula uses the weight function for Chebyshev T polynomials.
chebyshev.t.quadrature(functn, rule, lower = -1, upper = 1, weighted = TRUE, ...)
chebyshev.t.quadrature(functn, rule, lower = -1, upper = 1, weighted = TRUE, ...)
functn |
an R function which should take a numeric argument x and possibly some parameters. The function returns a numerical vector value for the given argument x. |
rule |
a data frame containing the order |
lower |
numeric value for the lower limit of the integral with a default value of -1 |
upper |
numeric value for the upper limit of the integral with a default value of +1 |
weighted |
boolean value which if true causes the Chebyshev weight function to be included in the integrand |
... |
other arguments passed to the given function |
The rule argument corresponds to an order Chebyshev polynomial,
weight function and interval
.
The lower and upper limits of the integral must be finite.
The value of definite integral evaluated using Gauss Chebyshev quadrature
Frederick Novomestky [email protected]
Abramowitz, M. and I. A. Stegun, 1968. Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables, Dover Publications, Inc., New York.
Press, W. H., S. A. Teukolsky, W. T. Vetterling, and B. P. Flannery, 1992. Numerical Recipes in C, Cambridge University Press, Cambridge, U.K.
Stroud, A. H., and D. Secrest, 1966. Gaussian Quadrature Formulas, Prentice-Hall, Englewood Cliffs, NJ.
### ### this example evaluates the quadrature function for ### the Chebyshev T polynomials. it computes the integral ### of the product for all pairs of orthogonal polynomials ### from order 0 to order 20. the results are compared to ### the diagonal matrix of the inner products for the ### polynomials. it also computes the integral of the product ### of all pairs of orthonormal polynomials from order 0 ### to order 20. the resultant matrix should be an identity matrix ### ### ### set the value for the maximum polynomial order ### n <- 20 ### ### maximum order plus 1 ### np1 <- n + 1 ### ### function to construct the polynomial products by column ### by.column.products <- function( c, p.list, p.p.list ) { ### ### function to construct the polynomial products by row ### by.row.products <- function( r, c, p.list ) { row.column.product <- p.list[[r]] * p.list[[c]] return (row.column.product ) } np1 <- length( p.list ) row.list <- lapply( 1:np1, by.row.products, c, p.list ) return( row.list ) } ### ### function construct the polynomial functions by column ### by.column.functions <- function( c, p.p.products ) { ### ### function to construct the polynomial functions by row ### by.row.functions <- function( r, c, p.p.products ) { row.column.function <- as.function( p.p.products[[r]][[c]] ) return( row.column.function ) } np1 <- length( p.p.products[[1]] ) row.list <- lapply( 1:np1, by.row.functions, c, p.p.products ) return( row.list ) } ### ### function to compute the integral of the polynomials by column ### by.column.integrals <- function( c, p.p.functions ) { ### ### function to compute the integral of the polynomials by row ### by.row.integrals <- function( r, c, p.p.functions ) { row.column.integral <- chebyshev.t.quadrature( p.p.functions[[r]][[c]], order.np1.rule ) return( row.column.integral ) } np1 <- length( p.p.functions[[1]] ) row.vector <- sapply( 1:np1, by.row.integrals, c, p.p.functions ) return( row.vector ) } ### ### construct a list of the Chebyshev T orthogonal polynomials ### p.list <- chebyshev.t.polynomials( n ) ### ### construct the two dimensional list of pair products ### of polynomials ### p.p.products <- lapply( 1:np1, by.column.products, p.list ) ### ### compute the two dimensional list of functions ### corresponding to the polynomial products in ### the two dimensional list p.p.products ### p.p.functions <- lapply( 1:np1, by.column.functions, p.p.products ) ### ### get the rule table for the order np1 polynomial ### rules <- chebyshev.t.quadrature.rules( np1 ) order.np1.rule <- rules[[np1]] ### ### construct the square symmetric matrix containing ### the definite integrals over the default limits ### corresponding to the two dimensional list of ### polynomial functions ### p.p.integrals <- sapply( 1:np1, by.column.integrals, p.p.functions ) ### ### construct the diagonal matrix with the inner products ### of the orthogonal polynomials on the diagonal ### p.p.inner.products <- diag( chebyshev.t.inner.products( n ) ) print( "Integral of cross products for the orthogonal polynomials " ) print( apply( p.p.integrals, 2, round, digits=5 ) ) print( apply( p.p.inner.products, 2, round, digits=5 ) ) ### ### construct a list of the Chebyshev T orthonormal polynomials ### p.list <- chebyshev.t.polynomials( n, TRUE ) ### ### construct the two dimensional list of pair products ### of polynomials ### p.p.products <- lapply( 1:np1, by.column.products, p.list ) ### ### compute the two dimensional list of functions ### corresponding to the polynomial products in ### the two dimensional list p.p.products ### p.p.functions <- lapply( 1:np1, by.column.functions, p.p.products ) ### ### get the rule table for the order np1 polynomial ### rules <- chebyshev.t.quadrature.rules( np1, TRUE ) order.np1.rule <- rules[[np1]] ### ### construct the square symmetric matrix containing ### the definite integrals over the default limits ### corresponding to the two dimensional list of ### polynomial functions ### p.p.integrals <- sapply( 1:np1, by.column.integrals, p.p.functions ) ### ### display the matrix of integrals ### print( "Integral of cross products for the orthonormal polynomials " ) print(apply( p.p.integrals, 2, round, digits=5 ) )
### ### this example evaluates the quadrature function for ### the Chebyshev T polynomials. it computes the integral ### of the product for all pairs of orthogonal polynomials ### from order 0 to order 20. the results are compared to ### the diagonal matrix of the inner products for the ### polynomials. it also computes the integral of the product ### of all pairs of orthonormal polynomials from order 0 ### to order 20. the resultant matrix should be an identity matrix ### ### ### set the value for the maximum polynomial order ### n <- 20 ### ### maximum order plus 1 ### np1 <- n + 1 ### ### function to construct the polynomial products by column ### by.column.products <- function( c, p.list, p.p.list ) { ### ### function to construct the polynomial products by row ### by.row.products <- function( r, c, p.list ) { row.column.product <- p.list[[r]] * p.list[[c]] return (row.column.product ) } np1 <- length( p.list ) row.list <- lapply( 1:np1, by.row.products, c, p.list ) return( row.list ) } ### ### function construct the polynomial functions by column ### by.column.functions <- function( c, p.p.products ) { ### ### function to construct the polynomial functions by row ### by.row.functions <- function( r, c, p.p.products ) { row.column.function <- as.function( p.p.products[[r]][[c]] ) return( row.column.function ) } np1 <- length( p.p.products[[1]] ) row.list <- lapply( 1:np1, by.row.functions, c, p.p.products ) return( row.list ) } ### ### function to compute the integral of the polynomials by column ### by.column.integrals <- function( c, p.p.functions ) { ### ### function to compute the integral of the polynomials by row ### by.row.integrals <- function( r, c, p.p.functions ) { row.column.integral <- chebyshev.t.quadrature( p.p.functions[[r]][[c]], order.np1.rule ) return( row.column.integral ) } np1 <- length( p.p.functions[[1]] ) row.vector <- sapply( 1:np1, by.row.integrals, c, p.p.functions ) return( row.vector ) } ### ### construct a list of the Chebyshev T orthogonal polynomials ### p.list <- chebyshev.t.polynomials( n ) ### ### construct the two dimensional list of pair products ### of polynomials ### p.p.products <- lapply( 1:np1, by.column.products, p.list ) ### ### compute the two dimensional list of functions ### corresponding to the polynomial products in ### the two dimensional list p.p.products ### p.p.functions <- lapply( 1:np1, by.column.functions, p.p.products ) ### ### get the rule table for the order np1 polynomial ### rules <- chebyshev.t.quadrature.rules( np1 ) order.np1.rule <- rules[[np1]] ### ### construct the square symmetric matrix containing ### the definite integrals over the default limits ### corresponding to the two dimensional list of ### polynomial functions ### p.p.integrals <- sapply( 1:np1, by.column.integrals, p.p.functions ) ### ### construct the diagonal matrix with the inner products ### of the orthogonal polynomials on the diagonal ### p.p.inner.products <- diag( chebyshev.t.inner.products( n ) ) print( "Integral of cross products for the orthogonal polynomials " ) print( apply( p.p.integrals, 2, round, digits=5 ) ) print( apply( p.p.inner.products, 2, round, digits=5 ) ) ### ### construct a list of the Chebyshev T orthonormal polynomials ### p.list <- chebyshev.t.polynomials( n, TRUE ) ### ### construct the two dimensional list of pair products ### of polynomials ### p.p.products <- lapply( 1:np1, by.column.products, p.list ) ### ### compute the two dimensional list of functions ### corresponding to the polynomial products in ### the two dimensional list p.p.products ### p.p.functions <- lapply( 1:np1, by.column.functions, p.p.products ) ### ### get the rule table for the order np1 polynomial ### rules <- chebyshev.t.quadrature.rules( np1, TRUE ) order.np1.rule <- rules[[np1]] ### ### construct the square symmetric matrix containing ### the definite integrals over the default limits ### corresponding to the two dimensional list of ### polynomial functions ### p.p.integrals <- sapply( 1:np1, by.column.integrals, p.p.functions ) ### ### display the matrix of integrals ### print( "Integral of cross products for the orthonormal polynomials " ) print(apply( p.p.integrals, 2, round, digits=5 ) )
This function returns a list with elements containing
the order
quadrature rule data frame for
the Chebyshev T polynomial
for orders
.
chebyshev.t.quadrature.rules(n,normalized=FALSE)
chebyshev.t.quadrature.rules(n,normalized=FALSE)
n |
integer value for the highest order |
normalized |
boolean value. if TRUE rules are for orthonormal polynomials, otherwise they are for orthgonal polynomials |
An order quadrature data frame is a named data frame that contains
the roots and abscissa values of the corresponding order
orthogonal polynomial.
The column with name
x
contains the roots or zeros and
the column with name w
contains the weights.
A list with elements each of which is a data frame
1 |
Quadrature rule data frame for the order 1 Chebyshev polynomial |
2 |
Quadrature rule data frame for the order 2 Chebyshev polynomial |
...
n |
Quadrature rule data frame for the order |
Frederick Novomestky [email protected]
Abramowitz, M. and I. A. Stegun, 1968. Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables, Dover Publications, Inc., New York.
Press, W. H., S. A. Teukolsky, W. T. Vetterling, and B. P. Flannery, 1992. Numerical Recipes in C, Cambridge University Press, Cambridge, U.K.
Stroud, A. H., and D. Secrest, 1966. Gaussian Quadrature Formulas, Prentice-Hall, Englewood Cliffs, NJ.
quadrature.rules
,
chebyshev.t.quadrature
### ### generate the list of quadrature rules for ### the orthogonal Chebyshev polynomials ### for orders 1 to 5 ### orthogonal.rules <- chebyshev.t.quadrature.rules( 5 ) print( orthogonal.rules ) ### ### generate the list of quadrature rules for ### the orthonormal Chebyshev polynomials ### for orders 1 to 5 ### orthonormal.rules <- chebyshev.t.quadrature.rules( 5, normalized=TRUE ) print( orthonormal.rules )
### ### generate the list of quadrature rules for ### the orthogonal Chebyshev polynomials ### for orders 1 to 5 ### orthogonal.rules <- chebyshev.t.quadrature.rules( 5 ) print( orthogonal.rules ) ### ### generate the list of quadrature rules for ### the orthonormal Chebyshev polynomials ### for orders 1 to 5 ### orthonormal.rules <- chebyshev.t.quadrature.rules( 5, normalized=TRUE ) print( orthonormal.rules )
This function evaluates the integral of the given function between the lower and upper limits using the weight and abscissa values specified in the rule data frame. The quadrature formula uses the weight function for Chebyshev U polynomials.
chebyshev.u.quadrature(functn, rule, lower = -1, upper = 1, weighted = TRUE, ...)
chebyshev.u.quadrature(functn, rule, lower = -1, upper = 1, weighted = TRUE, ...)
functn |
an R function which should take a numeric argument x and possibly some parameters. The function returns a numerical vector value for the given argument x. |
rule |
a data frame containing the order |
lower |
numeric value for the lower limit of the integral with a default value of -1 |
upper |
numeric value for the upper limit of the integral with a default value of +1 |
weighted |
a boolean value which if true causes the Chebyshev weight function to be included in the integrand |
... |
other arguments passed to the give function |
The rule argument corresponds to an order Chebyshev polynomial,
weight function and interval
.
The lower and upper limits of the integral must be finite.
The value of definite integral evaluated using Gauss Chebyshev quadrature
Frederick Novomestky [email protected]
Abramowitz, M. and I. A. Stegun, 1968. Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables, Dover Publications, Inc., New York.
Press, W. H., S. A. Teukolsky, W. T. Vetterling, and B. P. Flannery, 1992. Numerical Recipes in C, Cambridge University Press, Cambridge, U.K.
Stroud, A. H., and D. Secrest, 1966. Gaussian Quadrature Formulas, Prentice-Hall, Englewood Cliffs, NJ.
### ### this example evaluates the quadrature function for ### the Chebyshev U polynomials. it computes the integral ### of the product for all pairs of orthogonal polynomials ### from order 0 to order 20. the results are compared to ### the diagonal matrix of the inner products for the ### polynomials. it also computes the integral of the product ### of all pairs of orthonormal polynomials from order 0 ### to order 20. the resultant matrix should be an identity matrix ### ### ### set the value for the maximum polynomial order ### n <- 20 ### ### maximum order plus 1 ### np1 <- n + 1 ### ### function to construct the polynomial products by column ### by.column.products <- function( c, p.list, p.p.list ) { ### ### function to construct the polynomial products by row ### by.row.products <- function( r, c, p.list ) { row.column.product <- p.list[[r]] * p.list[[c]] return (row.column.product ) } np1 <- length( p.list ) row.list <- lapply( 1:np1, by.row.products, c, p.list ) return( row.list ) } ### ### function construct the polynomial functions by column ### by.column.functions <- function( c, p.p.products ) { ### ### function to construct the polynomial functions by row ### by.row.functions <- function( r, c, p.p.products ) { row.column.function <- as.function( p.p.products[[r]][[c]] ) return( row.column.function ) } np1 <- length( p.p.products[[1]] ) row.list <- lapply( 1:np1, by.row.functions, c, p.p.products ) return( row.list ) } ### ### function to compute the integral of the polynomials by column ### by.column.integrals <- function( c, p.p.functions ) { ### ### function to compute the integral of the polynomials by row ### by.row.integrals <- function( r, c, p.p.functions ) { row.column.integral <- chebyshev.u.quadrature( p.p.functions[[r]][[c]], order.np1.rule ) return( row.column.integral ) } np1 <- length( p.p.functions[[1]] ) row.vector <- sapply( 1:np1, by.row.integrals, c, p.p.functions ) return( row.vector ) } ### ### construct a list of the Chebyshev U orthogonal polynomials ### p.list <- chebyshev.u.polynomials( n ) ### ### construct the two dimensional list of pair products ### of polynomials ### p.p.products <- lapply( 1:np1, by.column.products, p.list ) ### ### compute the two dimensional list of functions ### corresponding to the polynomial products in ### the two dimensional list p.p.products ### p.p.functions <- lapply( 1:np1, by.column.functions, p.p.products ) ### ### get the rule table for the order np1 polynomial ### rules <- chebyshev.u.quadrature.rules( np1 ) order.np1.rule <- rules[[np1]] ### ### construct the square symmetric matrix containing ### the definite integrals over the default limits ### corresponding to the two dimensional list of ### polynomial functions ### p.p.integrals <- sapply( 1:np1, by.column.integrals, p.p.functions ) ### ### construct the diagonal matrix with the inner products ### of the orthogonal polynomials on the diagonal ### p.p.inner.products <- diag( chebyshev.u.inner.products( n ) ) print( "Integral of cross products for the orthogonal polynomials " ) print( apply( p.p.integrals, 2, round, digits=5 ) ) print( apply( p.p.inner.products, 2, round, digits=5 ) ) ### ### construct a list of the Chebyshev U orthonormal polynomials ### p.list <- chebyshev.u.polynomials( n, TRUE ) ### ### construct the two dimensional list of pair products ### of polynomials ### p.p.products <- lapply( 1:np1, by.column.products, p.list ) ### ### compute the two dimensional list of functions ### corresponding to the polynomial products in ### the two dimensional list p.p.products ### p.p.functions <- lapply( 1:np1, by.column.functions, p.p.products ) ### ### get the rule table for the order np1 polynomial ### rules <- chebyshev.u.quadrature.rules( np1, TRUE ) order.np1.rule <- rules[[np1]] ### ### construct the square symmetric matrix containing ### the definite integrals over the default limits ### corresponding to the two dimensional list of ### polynomial functions ### p.p.integrals <- sapply( 1:np1, by.column.integrals, p.p.functions ) ### ### display the matrix of integrals ### print( "Integral of cross products for the orthonormal polynomials " ) print(apply( p.p.integrals, 2, round, digits=5 ) )
### ### this example evaluates the quadrature function for ### the Chebyshev U polynomials. it computes the integral ### of the product for all pairs of orthogonal polynomials ### from order 0 to order 20. the results are compared to ### the diagonal matrix of the inner products for the ### polynomials. it also computes the integral of the product ### of all pairs of orthonormal polynomials from order 0 ### to order 20. the resultant matrix should be an identity matrix ### ### ### set the value for the maximum polynomial order ### n <- 20 ### ### maximum order plus 1 ### np1 <- n + 1 ### ### function to construct the polynomial products by column ### by.column.products <- function( c, p.list, p.p.list ) { ### ### function to construct the polynomial products by row ### by.row.products <- function( r, c, p.list ) { row.column.product <- p.list[[r]] * p.list[[c]] return (row.column.product ) } np1 <- length( p.list ) row.list <- lapply( 1:np1, by.row.products, c, p.list ) return( row.list ) } ### ### function construct the polynomial functions by column ### by.column.functions <- function( c, p.p.products ) { ### ### function to construct the polynomial functions by row ### by.row.functions <- function( r, c, p.p.products ) { row.column.function <- as.function( p.p.products[[r]][[c]] ) return( row.column.function ) } np1 <- length( p.p.products[[1]] ) row.list <- lapply( 1:np1, by.row.functions, c, p.p.products ) return( row.list ) } ### ### function to compute the integral of the polynomials by column ### by.column.integrals <- function( c, p.p.functions ) { ### ### function to compute the integral of the polynomials by row ### by.row.integrals <- function( r, c, p.p.functions ) { row.column.integral <- chebyshev.u.quadrature( p.p.functions[[r]][[c]], order.np1.rule ) return( row.column.integral ) } np1 <- length( p.p.functions[[1]] ) row.vector <- sapply( 1:np1, by.row.integrals, c, p.p.functions ) return( row.vector ) } ### ### construct a list of the Chebyshev U orthogonal polynomials ### p.list <- chebyshev.u.polynomials( n ) ### ### construct the two dimensional list of pair products ### of polynomials ### p.p.products <- lapply( 1:np1, by.column.products, p.list ) ### ### compute the two dimensional list of functions ### corresponding to the polynomial products in ### the two dimensional list p.p.products ### p.p.functions <- lapply( 1:np1, by.column.functions, p.p.products ) ### ### get the rule table for the order np1 polynomial ### rules <- chebyshev.u.quadrature.rules( np1 ) order.np1.rule <- rules[[np1]] ### ### construct the square symmetric matrix containing ### the definite integrals over the default limits ### corresponding to the two dimensional list of ### polynomial functions ### p.p.integrals <- sapply( 1:np1, by.column.integrals, p.p.functions ) ### ### construct the diagonal matrix with the inner products ### of the orthogonal polynomials on the diagonal ### p.p.inner.products <- diag( chebyshev.u.inner.products( n ) ) print( "Integral of cross products for the orthogonal polynomials " ) print( apply( p.p.integrals, 2, round, digits=5 ) ) print( apply( p.p.inner.products, 2, round, digits=5 ) ) ### ### construct a list of the Chebyshev U orthonormal polynomials ### p.list <- chebyshev.u.polynomials( n, TRUE ) ### ### construct the two dimensional list of pair products ### of polynomials ### p.p.products <- lapply( 1:np1, by.column.products, p.list ) ### ### compute the two dimensional list of functions ### corresponding to the polynomial products in ### the two dimensional list p.p.products ### p.p.functions <- lapply( 1:np1, by.column.functions, p.p.products ) ### ### get the rule table for the order np1 polynomial ### rules <- chebyshev.u.quadrature.rules( np1, TRUE ) order.np1.rule <- rules[[np1]] ### ### construct the square symmetric matrix containing ### the definite integrals over the default limits ### corresponding to the two dimensional list of ### polynomial functions ### p.p.integrals <- sapply( 1:np1, by.column.integrals, p.p.functions ) ### ### display the matrix of integrals ### print( "Integral of cross products for the orthonormal polynomials " ) print(apply( p.p.integrals, 2, round, digits=5 ) )
This function returns a list with elements containing
the order
quadrature rule data frame for
the Chebyshev U polynomial
for orders
.
chebyshev.u.quadrature.rules(n,normalized=FALSE)
chebyshev.u.quadrature.rules(n,normalized=FALSE)
n |
integer value for the highest order |
normalized |
boolean value. if TRUE rules are for orthonormal polynomials, otherwise they are for orthgonal polynomials |
An order quadrature data frame is a named data frame that contains
the roots and abscissa values of the corresponding order
orthogonal polynomial.
The column with name
x
contains the roots or zeros and
the column with name w
contains the weights.
A list with elements each of which is a data frame
1 |
Quadrature rule data frame for the order 1 Chebyshev polynomial |
2 |
Quadrature rule data frame for the order 2 Chebyshev polynomial |
...
n |
Quadrature rule data frame for the order |
Frederick Novomestky [email protected]
Abramowitz, M. and I. A. Stegun, 1968. Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables, Dover Publications, Inc., New York.
Press, W. H., S. A. Teukolsky, W. T. Vetterling, and B. P. Flannery, 1992. Numerical Recipes in C, Cambridge University Press, Cambridge, U.K.
Stroud, A. H., and D. Secrest, 1966. Gaussian Quadrature Formulas, Prentice-Hall, Englewood Cliffs, NJ.
quadrature.rules
,
chebyshev.u.quadrature
### ### generate the list of quadrature rules for ### the Chebyshev U orthogonal polynomials for ### orders 1 to 5 ### orthogonal.rules <- chebyshev.u.quadrature.rules( 5 ) print( orthogonal.rules ) ### ### generate the list of quadrature rules for ### the Chebyshev U orthonormal polynomials for ### orders 1 to 5 ### orthonormal.rules <- chebyshev.u.quadrature.rules( 5, TRUE ) print( orthonormal.rules )
### ### generate the list of quadrature rules for ### the Chebyshev U orthogonal polynomials for ### orders 1 to 5 ### orthogonal.rules <- chebyshev.u.quadrature.rules( 5 ) print( orthogonal.rules ) ### ### generate the list of quadrature rules for ### the Chebyshev U orthonormal polynomials for ### orders 1 to 5 ### orthonormal.rules <- chebyshev.u.quadrature.rules( 5, TRUE ) print( orthonormal.rules )
This function evaluates the integral of the given function between the lower and upper limits using the weight and abscissa values specified in the rule data frame. The quadrature formula uses the weight function for Gegenbauer polynomials.
gegenbauer.quadrature(functn, rule, alpha = 0, lower = -1, upper = 1, weighted = TRUE, ...)
gegenbauer.quadrature(functn, rule, alpha = 0, lower = -1, upper = 1, weighted = TRUE, ...)
functn |
an R function which should take a numeric argument x and possibly some parameters. The function returns a numerical vector value for the given argument x. |
rule |
a data frame containing the order |
alpha |
numeric value for the Gegenbauer polynomial parameter |
lower |
numeric value for the lower limit of the integral with a default value of -1 |
upper |
numeric value the upper limit of the integral with a default value of 1 |
weighted |
boolean value which if true causes the Gegenbauer weight function to be included in the integrand |
... |
other arguments passed to the give function |
The rule argument corresponds to an order Gegenbauer polynomial,
weight function and interval
.
The lower and upper limits of the integral must be finite.
The value of definite integral evaluated using Gauss Gegenbauer quadrature
Frederick Novomestky [email protected]
Abramowitz, M. and I. A. Stegun, 1968. Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables, Dover Publications, Inc., New York.
Press, W. H., S. A. Teukolsky, W. T. Vetterling, and B. P. Flannery, 1992. Numerical Recipes in C, Cambridge University Press, Cambridge, U.K.
Stroud, A. H., and D. Secrest, 1966. Gaussian Quadrature Formulas, Prentice-Hall, Englewood Cliffs, NJ.
gegenbauer.quadrature.rules
,
ultraspherical.quadrature
### ### this example evaluates the quadrature function for ### the Gegenbauer polynomials. it computes the integral ### of the product for all pairs of orthogonal polynomials ### from order 0 to order 16. the results are compared to ### the diagonal matrix of the inner products for the ### polynomials. it also computes the integral of the product ### of all pairs of orthonormal polynomials from order 0 ### to order 16. the resultant matrix should be an identity matrix ### ### ### set the polynomial parameter ### alpha <- 0.25 ### ### set the value for the maximum polynomial order ### n <- 16 ### ### maximum order plus 1 ### np1 <- n + 1 ### ### function to construct the polynomial products by column ### by.column.products <- function( c, p.list, p.p.list ) { ### ### function to construct the polynomial products by row ### by.row.products <- function( r, c, p.list ) { row.column.product <- p.list[[r]] * p.list[[c]] return (row.column.product ) } np1 <- length( p.list ) row.list <- lapply( 1:np1, by.row.products, c, p.list ) return( row.list ) } ### ### function construct the polynomial functions by column ### by.column.functions <- function( c, p.p.products ) { ### ### function to construct the polynomial functions by row ### by.row.functions <- function( r, c, p.p.products ) { row.column.function <- as.function( p.p.products[[r]][[c]] ) return( row.column.function ) } np1 <- length( p.p.products[[1]] ) row.list <- lapply( 1:np1, by.row.functions, c, p.p.products ) return( row.list ) } ### ### function to compute the integral of the polynomials by column ### by.column.integrals <- function( c, p.p.functions ) { ### ### function to compute the integral of the polynomials by row ### by.row.integrals <- function( r, c, p.p.functions ) { row.column.integral <- gegenbauer.quadrature( p.p.functions[[r]][[c]], order.np1.rule, alpha ) return( row.column.integral ) } np1 <- length( p.p.functions[[1]] ) row.vector <- sapply( 1:np1, by.row.integrals, c, p.p.functions ) return( row.vector ) } ### ### construct a list of the Gegenbauer orthogonal polynomials ### p.list <- gegenbauer.polynomials( n, alpha ) ### ### construct the two dimensional list of pair products ### of polynomials ### p.p.products <- lapply( 1:np1, by.column.products, p.list ) ### ### compute the two dimensional list of functions ### corresponding to the polynomial products in ### the two dimensional list p.p.products ### p.p.functions <- lapply( 1:np1, by.column.functions, p.p.products ) ### ### get the rule table for the order np1 polynomial ### rules <- gegenbauer.quadrature.rules( np1, alpha ) order.np1.rule <- rules[[np1]] ### ### construct the square symmetric matrix containing ### the definite integrals over the default limits ### corresponding to the two dimensional list of ### polynomial functions ### p.p.integrals <- sapply( 1:np1, by.column.integrals, p.p.functions ) ### ### construct the diagonal matrix with the inner products ### of the orthogonal polynomials on the diagonal ### p.p.inner.products <- diag( gegenbauer.inner.products( n,alpha ) ) print( "Integral of cross products for the orthogonal polynomials " ) print( apply( p.p.integrals, 2, round, digits=6 ) ) print( apply( p.p.inner.products, 2, round, digits=6 ) ) ### ### construct a list of the Gegenbauer orthonormal polynomials ### p.list <- gegenbauer.polynomials( n, alpha, TRUE ) ### ### construct the two dimensional list of pair products ### of polynomials ### p.p.products <- lapply( 1:np1, by.column.products, p.list ) ### ### compute the two dimensional list of functions ### corresponding to the polynomial products in ### the two dimensional list p.p.products ### p.p.functions <- lapply( 1:np1, by.column.functions, p.p.products ) ### ### get the rule table for the order np1 polynomial ### rules <- gegenbauer.quadrature.rules( np1, alpha, TRUE ) order.np1.rule <- rules[[np1]] ### ### construct the square symmetric matrix containing ### the definite integrals over the default limits ### corresponding to the two dimensional list of ### polynomial functions ### p.p.integrals <- sapply( 1:np1, by.column.integrals, p.p.functions ) ### ### display the matrix of integrals ### print( "Integral of cross products for the orthonormal polynomials " ) print(apply( p.p.integrals, 2, round, digits=6 ) )
### ### this example evaluates the quadrature function for ### the Gegenbauer polynomials. it computes the integral ### of the product for all pairs of orthogonal polynomials ### from order 0 to order 16. the results are compared to ### the diagonal matrix of the inner products for the ### polynomials. it also computes the integral of the product ### of all pairs of orthonormal polynomials from order 0 ### to order 16. the resultant matrix should be an identity matrix ### ### ### set the polynomial parameter ### alpha <- 0.25 ### ### set the value for the maximum polynomial order ### n <- 16 ### ### maximum order plus 1 ### np1 <- n + 1 ### ### function to construct the polynomial products by column ### by.column.products <- function( c, p.list, p.p.list ) { ### ### function to construct the polynomial products by row ### by.row.products <- function( r, c, p.list ) { row.column.product <- p.list[[r]] * p.list[[c]] return (row.column.product ) } np1 <- length( p.list ) row.list <- lapply( 1:np1, by.row.products, c, p.list ) return( row.list ) } ### ### function construct the polynomial functions by column ### by.column.functions <- function( c, p.p.products ) { ### ### function to construct the polynomial functions by row ### by.row.functions <- function( r, c, p.p.products ) { row.column.function <- as.function( p.p.products[[r]][[c]] ) return( row.column.function ) } np1 <- length( p.p.products[[1]] ) row.list <- lapply( 1:np1, by.row.functions, c, p.p.products ) return( row.list ) } ### ### function to compute the integral of the polynomials by column ### by.column.integrals <- function( c, p.p.functions ) { ### ### function to compute the integral of the polynomials by row ### by.row.integrals <- function( r, c, p.p.functions ) { row.column.integral <- gegenbauer.quadrature( p.p.functions[[r]][[c]], order.np1.rule, alpha ) return( row.column.integral ) } np1 <- length( p.p.functions[[1]] ) row.vector <- sapply( 1:np1, by.row.integrals, c, p.p.functions ) return( row.vector ) } ### ### construct a list of the Gegenbauer orthogonal polynomials ### p.list <- gegenbauer.polynomials( n, alpha ) ### ### construct the two dimensional list of pair products ### of polynomials ### p.p.products <- lapply( 1:np1, by.column.products, p.list ) ### ### compute the two dimensional list of functions ### corresponding to the polynomial products in ### the two dimensional list p.p.products ### p.p.functions <- lapply( 1:np1, by.column.functions, p.p.products ) ### ### get the rule table for the order np1 polynomial ### rules <- gegenbauer.quadrature.rules( np1, alpha ) order.np1.rule <- rules[[np1]] ### ### construct the square symmetric matrix containing ### the definite integrals over the default limits ### corresponding to the two dimensional list of ### polynomial functions ### p.p.integrals <- sapply( 1:np1, by.column.integrals, p.p.functions ) ### ### construct the diagonal matrix with the inner products ### of the orthogonal polynomials on the diagonal ### p.p.inner.products <- diag( gegenbauer.inner.products( n,alpha ) ) print( "Integral of cross products for the orthogonal polynomials " ) print( apply( p.p.integrals, 2, round, digits=6 ) ) print( apply( p.p.inner.products, 2, round, digits=6 ) ) ### ### construct a list of the Gegenbauer orthonormal polynomials ### p.list <- gegenbauer.polynomials( n, alpha, TRUE ) ### ### construct the two dimensional list of pair products ### of polynomials ### p.p.products <- lapply( 1:np1, by.column.products, p.list ) ### ### compute the two dimensional list of functions ### corresponding to the polynomial products in ### the two dimensional list p.p.products ### p.p.functions <- lapply( 1:np1, by.column.functions, p.p.products ) ### ### get the rule table for the order np1 polynomial ### rules <- gegenbauer.quadrature.rules( np1, alpha, TRUE ) order.np1.rule <- rules[[np1]] ### ### construct the square symmetric matrix containing ### the definite integrals over the default limits ### corresponding to the two dimensional list of ### polynomial functions ### p.p.integrals <- sapply( 1:np1, by.column.integrals, p.p.functions ) ### ### display the matrix of integrals ### print( "Integral of cross products for the orthonormal polynomials " ) print(apply( p.p.integrals, 2, round, digits=6 ) )
This function returns a list with elements containing
the order
quadrature rule data frame for
the Gegenbauer polynomials
for orders
.
gegenbauer.quadrature.rules(n,alpha,normalized=FALSE)
gegenbauer.quadrature.rules(n,alpha,normalized=FALSE)
n |
integer value for the highest order |
alpha |
polynomial parameter |
normalized |
boolean value. if TRUE rules are for orthonormal polynomials, otherwise they are for orthgonal polynomials |
An order quadrature data frame is a named data frame that contains
the roots and abscissa values of the corresponding order
orthogonal polynomial.
The column with name
x
contains the roots or zeros and
the column with name w
contains the weights.
A list with elements each of which is a data frame
1 |
Quadrature rule data frame for the order 1 Gegenbauer polynomial |
2 |
Quadrature rule data frame for the order 2 Gegenbauer polynomial |
...
n |
Quadrature rule data frame for the order |
Frederick Novomestky [email protected]
Abramowitz, M. and I. A. Stegun, 1968. Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables, Dover Publications, Inc., New York.
Press, W. H., S. A. Teukolsky, W. T. Vetterling, and B. P. Flannery, 1992. Numerical Recipes in C, Cambridge University Press, Cambridge, U.K.
Stroud, A. H., and D. Secrest, 1966. Gaussian Quadrature Formulas, Prentice-Hall, Englewood Cliffs, NJ.
quadrature.rules
,
gegenbauer.quadrature
### ### generate the list of quadrature rule data frames for ### the orthogonal Gegenbauer polynomials ### of orders 1 to 5 ### polynomial parameter alpha is 1.0 ### orthogonal.rules <- gegenbauer.quadrature.rules( 5, 1 ) print( orthogonal.rules ) ### ### generate the list of quadrature rule data frames for ### the orthonormal Gegenbauer polynomials ### of orders 1 to 5 ### polynomial parameter alpha is 1.0 ### orthonormal.rules <- gegenbauer.quadrature.rules( 5, 1, TRUE ) print( orthonormal.rules )
### ### generate the list of quadrature rule data frames for ### the orthogonal Gegenbauer polynomials ### of orders 1 to 5 ### polynomial parameter alpha is 1.0 ### orthogonal.rules <- gegenbauer.quadrature.rules( 5, 1 ) print( orthogonal.rules ) ### ### generate the list of quadrature rule data frames for ### the orthonormal Gegenbauer polynomials ### of orders 1 to 5 ### polynomial parameter alpha is 1.0 ### orthonormal.rules <- gegenbauer.quadrature.rules( 5, 1, TRUE ) print( orthonormal.rules )
This function evaluates the integral of the given function between the lower and upper limits using the weight and abscissa values specified in the rule data frame. The quadrature formula uses the weight function for generalized Hermite polynomials.
ghermite.h.quadrature(functn, rule, mu = 0, lower = -Inf, upper = Inf, weighted = TRUE, ...)
ghermite.h.quadrature(functn, rule, mu = 0, lower = -Inf, upper = Inf, weighted = TRUE, ...)
functn |
an R function which should take a numeric argument x and possibly some parameters. The function returns a numerical vector value for the given argument x. |
rule |
a data frame containing the order |
mu |
numeric value for the parameter for the generalized Hermite polynomials |
lower |
numeric value for the lower limit of the integral with a default value of |
upper |
numeric value for the upper limit of the integral with a default value of |
weighted |
a boolean value which if true causes the Hermite weight function to be included in the integrand |
... |
other arguments passed to the give function |
The rule argument corresponds to an order generalized Hermite polynomial,
weight function and interval
.
The lower and upper limits of the integral must be infinite.
The value of definite integral evaluated using Gauss Hermite quadrature
Frederick Novomestky [email protected]
Abramowitz, M. and I. A. Stegun, 1968. Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables, Dover Publications, Inc., New York.
Press, W. H., S. A. Teukolsky, W. T. Vetterling, and B. P. Flannery, 1992. Numerical Recipes in C, Cambridge University Press, Cambridge, U.K.
Stroud, A. H., and D. Secrest, 1966. Gaussian Quadrature Formulas, Prentice-Hall, Englewood Cliffs, NJ.
### ### this example evaluates the quadrature function for ### the generalized Hermite H polynomials. it computes the integral ### of the product for all pairs of orthogonal polynomials ### from order 0 to order 10. the results are compared to ### the diagonal matrix of the inner products for the ### polynomials. it also computes the integral of the product ### of all pairs of orthonormal polynomials from order 0 ### to order 10. the resultant matrix should be an identity matrix ### ### ### set the polynomial parameter ### mu <- 1 ### ### set the value for the maximum polynomial order ### n <- 10 ### ### maximum order plus 1 ### np1 <- n + 1 ### ### function to construct the polynomial products by column ### by.column.products <- function( c, p.list, p.p.list ) { ### ### function to construct the polynomial products by row ### by.row.products <- function( r, c, p.list ) { row.column.product <- p.list[[r]] * p.list[[c]] return (row.column.product ) } np1 <- length( p.list ) row.list <- lapply( 1:np1, by.row.products, c, p.list ) return( row.list ) } ### ### function construct the polynomial functions by column ### by.column.functions <- function( c, p.p.products ) { ### ### function to construct the polynomial functions by row ### by.row.functions <- function( r, c, p.p.products ) { row.column.function <- as.function( p.p.products[[r]][[c]] ) return( row.column.function ) } np1 <- length( p.p.products[[1]] ) row.list <- lapply( 1:np1, by.row.functions, c, p.p.products ) return( row.list ) } ### ### function to compute the integral of the polynomials by column ### by.column.integrals <- function( c, p.p.functions ) { ### ### function to compute the integral of the polynomials by row ### by.row.integrals <- function( r, c, p.p.functions ) { row.column.integral <- ghermite.h.quadrature( p.p.functions[[r]][[c]], order.np1.rule, mu ) return( row.column.integral ) } np1 <- length( p.p.functions[[1]] ) row.vector <- sapply( 1:np1, by.row.integrals, c, p.p.functions ) return( row.vector ) } ### ### construct a list of the generalized Hermite H orthogonal polynomials ### p.list <- ghermite.h.polynomials( n, mu ) ### ### construct the two dimensional list of pair products ### of polynomials ### p.p.products <- lapply( 1:np1, by.column.products, p.list ) ### ### compute the two dimensional list of functions ### corresponding to the polynomial products in ### the two dimensional list p.p.products ### p.p.functions <- lapply( 1:np1, by.column.functions, p.p.products ) ### ### get the rule table for the order np1 polynomial ### rules <- ghermite.h.quadrature.rules( np1, mu ) order.np1.rule <- rules[[np1]] ### ### construct the square symmetric matrix containing ### the definite integrals over the default limits ### corresponding to the two dimensional list of ### polynomial functions ### p.p.integrals <- sapply( 1:np1, by.column.integrals, p.p.functions ) ### ### construct the diagonal matrix with the inner products ### of the orthogonal polynomials on the diagonal ### p.p.inner.products <- diag( ghermite.h.inner.products( n, mu ) ) print( "Integral of cross products for the orthogonal polynomials " ) print( apply( p.p.integrals, 2, round, digits=5 ) ) print( apply( p.p.inner.products, 2, round, digits=5 ) ) ### ### construct a list of the Hermite H orthonormal polynomials ### p.list <- ghermite.h.polynomials( n, mu, TRUE ) ### ### construct the two dimensional list of pair products ### of polynomials ### p.p.products <- lapply( 1:np1, by.column.products, p.list ) ### ### compute the two dimensional list of functions ### corresponding to the polynomial products in ### the two dimensional list p.p.products ### p.p.functions <- lapply( 1:np1, by.column.functions, p.p.products ) ### ### get the rule table for the order np1 polynomial ### rules <- ghermite.h.quadrature.rules( np1, mu, TRUE ) order.np1.rule <- rules[[np1]] ### ### construct the square symmetric matrix containing ### the definite integrals over the default limits ### corresponding to the two dimensional list of ### polynomial functions ### p.p.integrals <- sapply( 1:np1, by.column.integrals, p.p.functions ) ### ### display the matrix of integrals ### print( "Integral of cross products for the orthonormal polynomials " ) print(apply( p.p.integrals, 2, round, digits=5 ) )
### ### this example evaluates the quadrature function for ### the generalized Hermite H polynomials. it computes the integral ### of the product for all pairs of orthogonal polynomials ### from order 0 to order 10. the results are compared to ### the diagonal matrix of the inner products for the ### polynomials. it also computes the integral of the product ### of all pairs of orthonormal polynomials from order 0 ### to order 10. the resultant matrix should be an identity matrix ### ### ### set the polynomial parameter ### mu <- 1 ### ### set the value for the maximum polynomial order ### n <- 10 ### ### maximum order plus 1 ### np1 <- n + 1 ### ### function to construct the polynomial products by column ### by.column.products <- function( c, p.list, p.p.list ) { ### ### function to construct the polynomial products by row ### by.row.products <- function( r, c, p.list ) { row.column.product <- p.list[[r]] * p.list[[c]] return (row.column.product ) } np1 <- length( p.list ) row.list <- lapply( 1:np1, by.row.products, c, p.list ) return( row.list ) } ### ### function construct the polynomial functions by column ### by.column.functions <- function( c, p.p.products ) { ### ### function to construct the polynomial functions by row ### by.row.functions <- function( r, c, p.p.products ) { row.column.function <- as.function( p.p.products[[r]][[c]] ) return( row.column.function ) } np1 <- length( p.p.products[[1]] ) row.list <- lapply( 1:np1, by.row.functions, c, p.p.products ) return( row.list ) } ### ### function to compute the integral of the polynomials by column ### by.column.integrals <- function( c, p.p.functions ) { ### ### function to compute the integral of the polynomials by row ### by.row.integrals <- function( r, c, p.p.functions ) { row.column.integral <- ghermite.h.quadrature( p.p.functions[[r]][[c]], order.np1.rule, mu ) return( row.column.integral ) } np1 <- length( p.p.functions[[1]] ) row.vector <- sapply( 1:np1, by.row.integrals, c, p.p.functions ) return( row.vector ) } ### ### construct a list of the generalized Hermite H orthogonal polynomials ### p.list <- ghermite.h.polynomials( n, mu ) ### ### construct the two dimensional list of pair products ### of polynomials ### p.p.products <- lapply( 1:np1, by.column.products, p.list ) ### ### compute the two dimensional list of functions ### corresponding to the polynomial products in ### the two dimensional list p.p.products ### p.p.functions <- lapply( 1:np1, by.column.functions, p.p.products ) ### ### get the rule table for the order np1 polynomial ### rules <- ghermite.h.quadrature.rules( np1, mu ) order.np1.rule <- rules[[np1]] ### ### construct the square symmetric matrix containing ### the definite integrals over the default limits ### corresponding to the two dimensional list of ### polynomial functions ### p.p.integrals <- sapply( 1:np1, by.column.integrals, p.p.functions ) ### ### construct the diagonal matrix with the inner products ### of the orthogonal polynomials on the diagonal ### p.p.inner.products <- diag( ghermite.h.inner.products( n, mu ) ) print( "Integral of cross products for the orthogonal polynomials " ) print( apply( p.p.integrals, 2, round, digits=5 ) ) print( apply( p.p.inner.products, 2, round, digits=5 ) ) ### ### construct a list of the Hermite H orthonormal polynomials ### p.list <- ghermite.h.polynomials( n, mu, TRUE ) ### ### construct the two dimensional list of pair products ### of polynomials ### p.p.products <- lapply( 1:np1, by.column.products, p.list ) ### ### compute the two dimensional list of functions ### corresponding to the polynomial products in ### the two dimensional list p.p.products ### p.p.functions <- lapply( 1:np1, by.column.functions, p.p.products ) ### ### get the rule table for the order np1 polynomial ### rules <- ghermite.h.quadrature.rules( np1, mu, TRUE ) order.np1.rule <- rules[[np1]] ### ### construct the square symmetric matrix containing ### the definite integrals over the default limits ### corresponding to the two dimensional list of ### polynomial functions ### p.p.integrals <- sapply( 1:np1, by.column.integrals, p.p.functions ) ### ### display the matrix of integrals ### print( "Integral of cross products for the orthonormal polynomials " ) print(apply( p.p.integrals, 2, round, digits=5 ) )
This function returns list with n elements containing
the order
quadrature rule data frame for
the generalized Hermite polynomial
for orders
.
ghermite.h.quadrature.rules(n, mu, normalized=FALSE)
ghermite.h.quadrature.rules(n, mu, normalized=FALSE)
n |
integer value for the highest integer order |
mu |
numeric value for the parameter of the generalized Hermite polynomial |
normalized |
boolean value. if TRUE rules are for orthonormal polynomials, otherwise they are for orthgonal polynomials |
An order quadrature data frame is a named data frame that contains
the roots and abscissa values of the corresponding order
orthogonal polynomial.
The column with name
x
contains the roots or zeros and
the column with name w
contains the weights.
A list with elements each of which is a data frame
1 |
Quadrature rule data frame for the order 1 generalized Hermite polynomial |
2 |
Quadrature rule data frame for the order 2 generalized Hermite polynomial |
...
n |
Quadrature rule data frame for the order |
Frederick Novomestky [email protected]
Abramowitz, M. and I. A. Stegun, 1968. Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables, Dover Publications, Inc., New York.
Press, W. H., S. A. Teukolsky, W. T. Vetterling, and B. P. Flannery, 1992. Numerical Recipes in C, Cambridge University Press, Cambridge, U.K.
Stroud, A. H., and D. Secrest, 1966. Gaussian Quadrature Formulas, Prentice-Hall, Englewood Cliffs, NJ.
quadrature.rules
,
schebyshev.t.quadrature
### ### generate a list of quadrature rule data frames for ### the generalized orthogonal Hermite polynomial ### of orders 1 to 5. ### polynomial parameter mu is 1.0 ### orthogonal.rules <- ghermite.h.quadrature.rules( 5, 1 ) print( orthogonal.rules ) ### ### generate a list of quadrature rule data frames for ### the generalized orthonormal Hermite polynomial ### of orders 1 to 5. ### polynomial parameter mu is 1.0 ### orthonormal.rules <- ghermite.h.quadrature.rules( 5, 1, TRUE ) print( orthonormal.rules )
### ### generate a list of quadrature rule data frames for ### the generalized orthogonal Hermite polynomial ### of orders 1 to 5. ### polynomial parameter mu is 1.0 ### orthogonal.rules <- ghermite.h.quadrature.rules( 5, 1 ) print( orthogonal.rules ) ### ### generate a list of quadrature rule data frames for ### the generalized orthonormal Hermite polynomial ### of orders 1 to 5. ### polynomial parameter mu is 1.0 ### orthonormal.rules <- ghermite.h.quadrature.rules( 5, 1, TRUE ) print( orthonormal.rules )
This function evaluates the integral of the given function between the lower and upper limits using the weight and abscissa values specified in the rule data frame. The quadrature formula uses the weight function for generalized Laguerre polynomials.
glaguerre.quadrature(functn, rule, alpha = 0, lower = 0, upper = Inf, weighted = TRUE, ...)
glaguerre.quadrature(functn, rule, alpha = 0, lower = 0, upper = Inf, weighted = TRUE, ...)
functn |
an R function which should take a numeric argument x and possibly some parameters. The function returns a numerical vector value for the given argument x. |
rule |
a data frame containing the order |
alpha |
numeric value for the generalized Laguerre polynomial parameter |
lower |
numeric value for the lower limit of the integral with a default value of 0 |
upper |
numeric value for the upper limit of the integral with a default value of Inf |
weighted |
a boolean value which if true causes the generalized Laguerre weight function to be included in the integrand |
... |
other arguments passed to the give function |
The rule argument corresponds to an order generalized Laguerre polynomial,
weight function and interval
.
The one limit of the integral must be finite and the other must be infinite.
The value of definite integral evaluated using Gauss Laguerre quadrature
Frederick Novomestky [email protected]
Abramowitz, M. and I. A. Stegun, 1968. Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables, Dover Publications, Inc., New York.
Press, W. H., S. A. Teukolsky, W. T. Vetterling, and B. P. Flannery, 1992. Numerical Recipes in C, Cambridge University Press, Cambridge, U.K.
Stroud, A. H., and D. Secrest, 1966. Gaussian Quadrature Formulas, Prentice-Hall, Englewood Cliffs, NJ.
### ### this example evaluates the quadrature function for ### the generalized Laguerre polynomials. it computes the integral ### of the product for all pairs of orthogonal polynomials ### from order 0 to order 12. the results are compared to ### the diagonal matrix of the inner products for the ### polynomials. it also computes the integral of the product ### of all pairs of orthonormal polynomials from order 0 ### to order 12. the resultant matrix should be an identity matrix ### ### ### set the polynomial parameter ### alpha <- 1 ### ### set the value for the maximum polynomial order ### n <- 12 ### ### maximum order plus 1 ### np1 <- n + 1 ### ### function to construct the polynomial products by column ### by.column.products <- function( c, p.list, p.p.list ) { ### ### function to construct the polynomial products by row ### by.row.products <- function( r, c, p.list ) { row.column.product <- p.list[[r]] * p.list[[c]] return (row.column.product ) } np1 <- length( p.list ) row.list <- lapply( 1:np1, by.row.products, c, p.list ) return( row.list ) } ### ### function construct the polynomial functions by column ### by.column.functions <- function( c, p.p.products ) { ### ### function to construct the polynomial functions by row ### by.row.functions <- function( r, c, p.p.products ) { row.column.function <- as.function( p.p.products[[r]][[c]] ) return( row.column.function ) } np1 <- length( p.p.products[[1]] ) row.list <- lapply( 1:np1, by.row.functions, c, p.p.products ) return( row.list ) } ### ### function to compute the integral of the polynomials by column ### by.column.integrals <- function( c, p.p.functions ) { ### ### function to compute the integral of the polynomials by row ### by.row.integrals <- function( r, c, p.p.functions ) { row.column.integral <- glaguerre.quadrature( p.p.functions[[r]][[c]], order.np1.rule, alpha ) return( row.column.integral ) } np1 <- length( p.p.functions[[1]] ) row.vector <- sapply( 1:np1, by.row.integrals, c, p.p.functions ) return( row.vector ) } ### ### construct a list of the generalized Laguerre orthogonal polynomials ### p.list <- glaguerre.polynomials( n, alpha ) ### ### construct the two dimensional list of pair products ### of polynomials ### p.p.products <- lapply( 1:np1, by.column.products, p.list ) ### ### compute the two dimensional list of functions ### corresponding to the polynomial products in ### the two dimensional list p.p.products ### p.p.functions <- lapply( 1:np1, by.column.functions, p.p.products ) ### ### get the rule table for the order np1 polynomial ### rules <- glaguerre.quadrature.rules( np1, alpha ) order.np1.rule <- rules[[np1]] ### ### construct the square symmetric matrix containing ### the definite integrals over the default limits ### corresponding to the two dimensional list of ### polynomial functions ### p.p.integrals <- sapply( 1:np1, by.column.integrals, p.p.functions ) ### ### construct the diagonal matrix with the inner products ### of the orthogonal polynomials on the diagonal ### p.p.inner.products <- diag( glaguerre.inner.products( n,alpha ) ) print( "Integral of cross products for the orthogonal polynomials " ) print( apply( p.p.integrals, 2, round, digits=6 ) ) print( apply( p.p.inner.products, 2, round, digits=6 ) ) ### ### construct a list of theg generalized Laguerre orthonormal polynomials ### p.list <- glaguerre.polynomials( n, alpha, TRUE ) ### ### construct the two dimensional list of pair products ### of polynomials ### p.p.products <- lapply( 1:np1, by.column.products, p.list ) ### ### compute the two dimensional list of functions ### corresponding to the polynomial products in ### the two dimensional list p.p.products ### p.p.functions <- lapply( 1:np1, by.column.functions, p.p.products ) ### ### get the rule table for the order np1 polynomial ### rules <- glaguerre.quadrature.rules( np1, alpha, TRUE ) order.np1.rule <- rules[[np1]] ### ### construct the square symmetric matrix containing ### the definite integrals over the default limits ### corresponding to the two dimensional list of ### polynomial functions ### p.p.integrals <- sapply( 1:np1, by.column.integrals, p.p.functions ) ### ### display the matrix of integrals ### print( "Integral of cross products for the orthonormal polynomials " ) print(apply( p.p.integrals, 2, round, digits=6 ) )
### ### this example evaluates the quadrature function for ### the generalized Laguerre polynomials. it computes the integral ### of the product for all pairs of orthogonal polynomials ### from order 0 to order 12. the results are compared to ### the diagonal matrix of the inner products for the ### polynomials. it also computes the integral of the product ### of all pairs of orthonormal polynomials from order 0 ### to order 12. the resultant matrix should be an identity matrix ### ### ### set the polynomial parameter ### alpha <- 1 ### ### set the value for the maximum polynomial order ### n <- 12 ### ### maximum order plus 1 ### np1 <- n + 1 ### ### function to construct the polynomial products by column ### by.column.products <- function( c, p.list, p.p.list ) { ### ### function to construct the polynomial products by row ### by.row.products <- function( r, c, p.list ) { row.column.product <- p.list[[r]] * p.list[[c]] return (row.column.product ) } np1 <- length( p.list ) row.list <- lapply( 1:np1, by.row.products, c, p.list ) return( row.list ) } ### ### function construct the polynomial functions by column ### by.column.functions <- function( c, p.p.products ) { ### ### function to construct the polynomial functions by row ### by.row.functions <- function( r, c, p.p.products ) { row.column.function <- as.function( p.p.products[[r]][[c]] ) return( row.column.function ) } np1 <- length( p.p.products[[1]] ) row.list <- lapply( 1:np1, by.row.functions, c, p.p.products ) return( row.list ) } ### ### function to compute the integral of the polynomials by column ### by.column.integrals <- function( c, p.p.functions ) { ### ### function to compute the integral of the polynomials by row ### by.row.integrals <- function( r, c, p.p.functions ) { row.column.integral <- glaguerre.quadrature( p.p.functions[[r]][[c]], order.np1.rule, alpha ) return( row.column.integral ) } np1 <- length( p.p.functions[[1]] ) row.vector <- sapply( 1:np1, by.row.integrals, c, p.p.functions ) return( row.vector ) } ### ### construct a list of the generalized Laguerre orthogonal polynomials ### p.list <- glaguerre.polynomials( n, alpha ) ### ### construct the two dimensional list of pair products ### of polynomials ### p.p.products <- lapply( 1:np1, by.column.products, p.list ) ### ### compute the two dimensional list of functions ### corresponding to the polynomial products in ### the two dimensional list p.p.products ### p.p.functions <- lapply( 1:np1, by.column.functions, p.p.products ) ### ### get the rule table for the order np1 polynomial ### rules <- glaguerre.quadrature.rules( np1, alpha ) order.np1.rule <- rules[[np1]] ### ### construct the square symmetric matrix containing ### the definite integrals over the default limits ### corresponding to the two dimensional list of ### polynomial functions ### p.p.integrals <- sapply( 1:np1, by.column.integrals, p.p.functions ) ### ### construct the diagonal matrix with the inner products ### of the orthogonal polynomials on the diagonal ### p.p.inner.products <- diag( glaguerre.inner.products( n,alpha ) ) print( "Integral of cross products for the orthogonal polynomials " ) print( apply( p.p.integrals, 2, round, digits=6 ) ) print( apply( p.p.inner.products, 2, round, digits=6 ) ) ### ### construct a list of theg generalized Laguerre orthonormal polynomials ### p.list <- glaguerre.polynomials( n, alpha, TRUE ) ### ### construct the two dimensional list of pair products ### of polynomials ### p.p.products <- lapply( 1:np1, by.column.products, p.list ) ### ### compute the two dimensional list of functions ### corresponding to the polynomial products in ### the two dimensional list p.p.products ### p.p.functions <- lapply( 1:np1, by.column.functions, p.p.products ) ### ### get the rule table for the order np1 polynomial ### rules <- glaguerre.quadrature.rules( np1, alpha, TRUE ) order.np1.rule <- rules[[np1]] ### ### construct the square symmetric matrix containing ### the definite integrals over the default limits ### corresponding to the two dimensional list of ### polynomial functions ### p.p.integrals <- sapply( 1:np1, by.column.integrals, p.p.functions ) ### ### display the matrix of integrals ### print( "Integral of cross products for the orthonormal polynomials " ) print(apply( p.p.integrals, 2, round, digits=6 ) )
This function returns a list with elements containing
the order
quadrature rule data frame for
the generalized Laguerre polynomials
for orders
.
glaguerre.quadrature.rules(n,alpha,normalized=FALSE)
glaguerre.quadrature.rules(n,alpha,normalized=FALSE)
n |
integer value for the highest order |
alpha |
numeric value for the polynomial parameter |
normalized |
boolean value. if TRUE rules are for orthonormal polynomials, otherwise they are for orthgonal polynomials |
An order quadrature data frame is a named data frame that contains
the roots and abscissa values of the corresponding order
orthogonal polynomial.
The column with name
x
contains the roots or zeros and
the column with name w
contains the weights.
A list with elements each of which is a quadrature rule data frame
1 |
Quadrature rule for the order 1 generalized Laguerre polynomial |
2 |
Quadrature rule for the order 2 generalized Laguerre polynomial |
...
n |
Quadrature rule for the order |
Frederick Novomestky [email protected]
Abramowitz, M. and I. A. Stegun, 1968. Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables, Dover Publications, Inc., New York.
Press, W. H., S. A. Teukolsky, W. T. Vetterling, and B. P. Flannery, 1992. Numerical Recipes in C, Cambridge University Press, Cambridge, U.K.
Stroud, A. H., and D. Secrest, 1966. Gaussian Quadrature Formulas, Prentice-Hall, Englewood Cliffs, NJ.
quadrature.rules
,
glaguerre.quadrature
### ### generate a list of quadrature rule data frames for ### the generalized orthogonal Laguerre polynomials ### of orders 1 to 5 ### polynomial parameter is 1.0 ### orthogonal.rules <- glaguerre.quadrature.rules( 5, 1 ) print( orthogonal.rules ) ### ### generate a list of quadrature rule data frames for ### the generalized orthonormal Laguerre polynomials ### of orders 1 to 5 ### polynomial parameter is 1.0 ### orthonormal.rules <- glaguerre.quadrature.rules( 5, 1, TRUE ) print( orthonormal.rules )
### ### generate a list of quadrature rule data frames for ### the generalized orthogonal Laguerre polynomials ### of orders 1 to 5 ### polynomial parameter is 1.0 ### orthogonal.rules <- glaguerre.quadrature.rules( 5, 1 ) print( orthogonal.rules ) ### ### generate a list of quadrature rule data frames for ### the generalized orthonormal Laguerre polynomials ### of orders 1 to 5 ### polynomial parameter is 1.0 ### orthonormal.rules <- glaguerre.quadrature.rules( 5, 1, TRUE ) print( orthonormal.rules )
This function evaluates the integral of the given function between the lower and upper limits using the weight and abscissa values specified in the rule data frame. The quadrature formula uses the weight function for Hermite H polynomials.
hermite.h.quadrature(functn, rule, lower = -Inf, upper = Inf, weighted = TRUE, ...)
hermite.h.quadrature(functn, rule, lower = -Inf, upper = Inf, weighted = TRUE, ...)
functn |
an R function which should take a numeric argument x and possibly some parameters. The function returns a numerical vector value for the given argument x. |
rule |
a data frame containing the order |
lower |
numeric value for the lower limit of the integral with a default value of |
upper |
numeric value for the upper limit of the integral with a default value of |
weighted |
boolean value which if true causes the Hermite weight function to be included in the integrand |
... |
other arguments passed to the give function |
The rule argument corresponds to an order Hermite polynomial,
weight function and interval
The lower and upper limits of the integral must be infinite.
The value of definite integral evaluated using Gauss Hermite quadrature
Frederick Novomestky [email protected]
Abramowitz, M. and I. A. Stegun, 1968. Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables, Dover Publications, Inc., New York.
Press, W. H., S. A. Teukolsky, W. T. Vetterling, and B. P. Flannery, 1992. Numerical Recipes in C, Cambridge University Press, Cambridge, U.K.
Stroud, A. H., and D. Secrest, 1966. Gaussian Quadrature Formulas, Prentice-Hall, Englewood Cliffs, NJ.
### ### this example evaluates the quadrature function for ### the Hermite H polynomials. it computes the integral ### of the product for all pairs of orthogonal polynomials ### from order 0 to order 8. the results are compared to ### the diagonal matrix of the inner products for the ### polynomials. it also computes the integral of the product ### of all pairs of orthonormal polynomials from order 0 ### to order 8. the resultant matrix should be an identity matrix ### ### ### set the value for the maximum polynomial order ### n <- 8 ### ### maximum order plus 1 ### np1 <- n + 1 ### ### function to construct the polynomial products by column ### by.column.products <- function( c, p.list, p.p.list ) { ### ### function to construct the polynomial products by row ### by.row.products <- function( r, c, p.list ) { row.column.product <- p.list[[r]] * p.list[[c]] return (row.column.product ) } np1 <- length( p.list ) row.list <- lapply( 1:np1, by.row.products, c, p.list ) return( row.list ) } ### ### function construct the polynomial functions by column ### by.column.functions <- function( c, p.p.products ) { ### ### function to construct the polynomial functions by row ### by.row.functions <- function( r, c, p.p.products ) { row.column.function <- as.function( p.p.products[[r]][[c]] ) return( row.column.function ) } np1 <- length( p.p.products[[1]] ) row.list <- lapply( 1:np1, by.row.functions, c, p.p.products ) return( row.list ) } ### ### function to compute the integral of the polynomials by column ### by.column.integrals <- function( c, p.p.functions ) { ### ### function to compute the integral of the polynomials by row ### by.row.integrals <- function( r, c, p.p.functions ) { row.column.integral <- hermite.h.quadrature( p.p.functions[[r]][[c]], order.np1.rule ) return( row.column.integral ) } np1 <- length( p.p.functions[[1]] ) row.vector <- sapply( 1:np1, by.row.integrals, c, p.p.functions ) return( row.vector ) } ### ### construct a list of the Hermite H orthogonal polynomials ### p.list <- hermite.h.polynomials( n ) ### ### construct the two dimensional list of pair products ### of polynomials ### p.p.products <- lapply( 1:np1, by.column.products, p.list ) ### ### compute the two dimensional list of functions ### corresponding to the polynomial products in ### the two dimensional list p.p.products ### p.p.functions <- lapply( 1:np1, by.column.functions, p.p.products ) ### ### get the rule table for the order np1 polynomial ### rules <- hermite.h.quadrature.rules( np1 ) order.np1.rule <- rules[[np1]] ### ### construct the square symmetric matrix containing ### the definite integrals over the default limits ### corresponding to the two dimensional list of ### polynomial functions ### p.p.integrals <- sapply( 1:np1, by.column.integrals, p.p.functions ) ### ### construct the diagonal matrix with the inner products ### of the orthogonal polynomials on the diagonal ### p.p.inner.products <- diag( hermite.h.inner.products( n ) ) print( "Integral of cross products for the orthogonal polynomials " ) print( apply( p.p.integrals, 2, round, digits=5 ) ) print( apply( p.p.inner.products, 2, round, digits=5 ) ) ### ### construct a list of the Hermite H orthonormal polynomials ### p.list <- hermite.h.polynomials( n, TRUE ) ### ### construct the two dimensional list of pair products ### of polynomials ### p.p.products <- lapply( 1:np1, by.column.products, p.list ) ### ### compute the two dimensional list of functions ### corresponding to the polynomial products in ### the two dimensional list p.p.products ### p.p.functions <- lapply( 1:np1, by.column.functions, p.p.products ) ### ### get the rule table for the order np1 polynomial ### rules <- hermite.h.quadrature.rules( np1, TRUE ) order.np1.rule <- rules[[np1]] ### ### construct the square symmetric matrix containing ### the definite integrals over the default limits ### corresponding to the two dimensional list of ### polynomial functions ### p.p.integrals <- sapply( 1:np1, by.column.integrals, p.p.functions ) ### ### display the matrix of integrals ### print( "Integral of cross products for the orthonormal polynomials " ) print(apply( p.p.integrals, 2, round, digits=5 ) )
### ### this example evaluates the quadrature function for ### the Hermite H polynomials. it computes the integral ### of the product for all pairs of orthogonal polynomials ### from order 0 to order 8. the results are compared to ### the diagonal matrix of the inner products for the ### polynomials. it also computes the integral of the product ### of all pairs of orthonormal polynomials from order 0 ### to order 8. the resultant matrix should be an identity matrix ### ### ### set the value for the maximum polynomial order ### n <- 8 ### ### maximum order plus 1 ### np1 <- n + 1 ### ### function to construct the polynomial products by column ### by.column.products <- function( c, p.list, p.p.list ) { ### ### function to construct the polynomial products by row ### by.row.products <- function( r, c, p.list ) { row.column.product <- p.list[[r]] * p.list[[c]] return (row.column.product ) } np1 <- length( p.list ) row.list <- lapply( 1:np1, by.row.products, c, p.list ) return( row.list ) } ### ### function construct the polynomial functions by column ### by.column.functions <- function( c, p.p.products ) { ### ### function to construct the polynomial functions by row ### by.row.functions <- function( r, c, p.p.products ) { row.column.function <- as.function( p.p.products[[r]][[c]] ) return( row.column.function ) } np1 <- length( p.p.products[[1]] ) row.list <- lapply( 1:np1, by.row.functions, c, p.p.products ) return( row.list ) } ### ### function to compute the integral of the polynomials by column ### by.column.integrals <- function( c, p.p.functions ) { ### ### function to compute the integral of the polynomials by row ### by.row.integrals <- function( r, c, p.p.functions ) { row.column.integral <- hermite.h.quadrature( p.p.functions[[r]][[c]], order.np1.rule ) return( row.column.integral ) } np1 <- length( p.p.functions[[1]] ) row.vector <- sapply( 1:np1, by.row.integrals, c, p.p.functions ) return( row.vector ) } ### ### construct a list of the Hermite H orthogonal polynomials ### p.list <- hermite.h.polynomials( n ) ### ### construct the two dimensional list of pair products ### of polynomials ### p.p.products <- lapply( 1:np1, by.column.products, p.list ) ### ### compute the two dimensional list of functions ### corresponding to the polynomial products in ### the two dimensional list p.p.products ### p.p.functions <- lapply( 1:np1, by.column.functions, p.p.products ) ### ### get the rule table for the order np1 polynomial ### rules <- hermite.h.quadrature.rules( np1 ) order.np1.rule <- rules[[np1]] ### ### construct the square symmetric matrix containing ### the definite integrals over the default limits ### corresponding to the two dimensional list of ### polynomial functions ### p.p.integrals <- sapply( 1:np1, by.column.integrals, p.p.functions ) ### ### construct the diagonal matrix with the inner products ### of the orthogonal polynomials on the diagonal ### p.p.inner.products <- diag( hermite.h.inner.products( n ) ) print( "Integral of cross products for the orthogonal polynomials " ) print( apply( p.p.integrals, 2, round, digits=5 ) ) print( apply( p.p.inner.products, 2, round, digits=5 ) ) ### ### construct a list of the Hermite H orthonormal polynomials ### p.list <- hermite.h.polynomials( n, TRUE ) ### ### construct the two dimensional list of pair products ### of polynomials ### p.p.products <- lapply( 1:np1, by.column.products, p.list ) ### ### compute the two dimensional list of functions ### corresponding to the polynomial products in ### the two dimensional list p.p.products ### p.p.functions <- lapply( 1:np1, by.column.functions, p.p.products ) ### ### get the rule table for the order np1 polynomial ### rules <- hermite.h.quadrature.rules( np1, TRUE ) order.np1.rule <- rules[[np1]] ### ### construct the square symmetric matrix containing ### the definite integrals over the default limits ### corresponding to the two dimensional list of ### polynomial functions ### p.p.integrals <- sapply( 1:np1, by.column.integrals, p.p.functions ) ### ### display the matrix of integrals ### print( "Integral of cross products for the orthonormal polynomials " ) print(apply( p.p.integrals, 2, round, digits=5 ) )
This function returns a list with elements containing
the order
quadrature rule data frame for
the Hermite polynomials
for orders
.
hermite.h.quadrature.rules(n,normalized=FALSE)
hermite.h.quadrature.rules(n,normalized=FALSE)
n |
integer highest order |
normalized |
boolean value. if TRUE rules are for orthonormal polynomials, otherwise they are for orthgonal polynomials |
An order quadrature data frame is a named data frame that contains
the roots and abscissa values of the corresponding order
orthogonal polynomial.
The column with name
x
contains the roots or zeros and
the column with name w
contains the weights.
A list with elements each of which is a data frame
1 |
Quadrature rule data frame for the order 1 Hermite polynomial |
2 |
Quadrature rule data frame for the order 2 Hermite polynomial |
...
n |
Quadrature rule data frame for the order |
Frederick Novomestky [email protected]
Abramowitz, M. and I. A. Stegun, 1968. Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables, Dover Publications, Inc., New York.
Press, W. H., S. A. Teukolsky, W. T. Vetterling, and B. P. Flannery, 1992. Numerical Recipes in C, Cambridge University Press, Cambridge, U.K.
Stroud, A. H., and D. Secrest, 1966. Gaussian Quadrature Formulas, Prentice-Hall, Englewood Cliffs, NJ.
quadrature.rules
,
hermite.h.quadrature
### ### generate the list of quadrature rules for ### the Hermite orthogonal polynomials ### of orders 1 to 5 ### orthogonal.rules <- hermite.h.quadrature.rules( 5 ) print( orthogonal.rules ) ### ### generate the list of quadrature rules for ### the Hermite orthonormal polynomials ### of orders 1 to 5 ### orthonormal.rules <- hermite.h.quadrature.rules( 5, TRUE ) print( orthonormal.rules )
### ### generate the list of quadrature rules for ### the Hermite orthogonal polynomials ### of orders 1 to 5 ### orthogonal.rules <- hermite.h.quadrature.rules( 5 ) print( orthogonal.rules ) ### ### generate the list of quadrature rules for ### the Hermite orthonormal polynomials ### of orders 1 to 5 ### orthonormal.rules <- hermite.h.quadrature.rules( 5, TRUE ) print( orthonormal.rules )
This function evaluates the integral of the given function between the lower and upper limits using the weight and abscissa values specified in the rule data frame. The quadrature formula uses the weight function for hermite He polynomials.
hermite.he.quadrature(functn, rule, lower = -Inf, upper = Inf, weighted = TRUE, ...)
hermite.he.quadrature(functn, rule, lower = -Inf, upper = Inf, weighted = TRUE, ...)
functn |
an R function which should take a numeric argument x and possibly some parameters. The function returns a numerical vector value for the given argument x. |
rule |
a data frame containing the order |
lower |
the lower limit of the integral with a default value of |
upper |
the upper limit of the integral with a default value of |
weighted |
a boolean value which if true causes the Hermite weight function to be included in the integrand |
... |
other arguments passed to the give function |
The rule argument corresponds to an order Hermite polynomial,
weight function and interval
The lower and upper limits of the integral must be infinite.
The value of definite integral evaluated using Gauss Hermite quadrature
Frederick Novomestky [email protected]
Abramowitz, M. and I. A. Stegun, 1968. Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables, Dover Publications, Inc., New York.
Press, W. H., S. A. Teukolsky, W. T. Vetterling, and B. P. Flannery, 1992. Numerical Recipes in C, Cambridge University Press, Cambridge, U.K.
Stroud, A. H., and D. Secrest, 1966. Gaussian Quadrature Formulas, Prentice-Hall, Englewood Cliffs, NJ.
### ### this example evaluates the quadrature function for ### the scaled Hermite He polynomials. it computes the integral ### of the product for all pairs of orthogonal polynomials ### from order 0 to order 16. the results are compared to ### the diagonal matrix of the inner products for the ### polynomials. it also computes the integral of the product ### of all pairs of orthonormal polynomials from order 0 ### to order 16. the resultant matrix should be an identity matrix ### ### ### set the value for the maximum polynomial order ### n <- 12 ### ### maximum order plus 1 ### np1 <- n + 1 ### ### function to construct the polynomial products by column ### by.column.products <- function( c, p.list, p.p.list ) { ### ### function to construct the polynomial products by row ### by.row.products <- function( r, c, p.list ) { row.column.product <- p.list[[r]] * p.list[[c]] return (row.column.product ) } np1 <- length( p.list ) row.list <- lapply( 1:np1, by.row.products, c, p.list ) return( row.list ) } ### ### function construct the polynomial functions by column ### by.column.functions <- function( c, p.p.products ) { ### ### function to construct the polynomial functions by row ### by.row.functions <- function( r, c, p.p.products ) { row.column.function <- as.function( p.p.products[[r]][[c]] ) return( row.column.function ) } np1 <- length( p.p.products[[1]] ) row.list <- lapply( 1:np1, by.row.functions, c, p.p.products ) return( row.list ) } ### ### function to compute the integral of the polynomials by column ### by.column.integrals <- function( c, p.p.functions ) { ### ### function to compute the integral of the polynomials by row ### by.row.integrals <- function( r, c, p.p.functions ) { row.column.integral <- hermite.h.quadrature( p.p.functions[[r]][[c]], order.np1.rule ) return( row.column.integral ) } np1 <- length( p.p.functions[[1]] ) row.vector <- sapply( 1:np1, by.row.integrals, c, p.p.functions ) return( row.vector ) } ### ### construct a list of the scaled Hermite He orthogonal polynomials ### p.list <- hermite.he.polynomials( n ) ### ### construct the two dimensional list of pair products ### of polynomials ### p.p.products <- lapply( 1:np1, by.column.products, p.list ) ### ### compute the two dimensional list of functions ### corresponding to the polynomial products in ### the two dimensional list p.p.products ### p.p.functions <- lapply( 1:np1, by.column.functions, p.p.products ) ### ### get the rule table for the order np1 polynomial ### rules <- hermite.he.quadrature.rules( np1 ) order.np1.rule <- rules[[np1]] ### ### construct the square symmetric matrix containing ### the definite integrals over the default limits ### corresponding to the two dimensional list of ### polynomial functions ### p.p.integrals <- sapply( 1:np1, by.column.integrals, p.p.functions ) ### ### construct the diagonal matrix with the inner products ### of the orthogonal polynomials on the diagonal ### p.p.inner.products <- diag( hermite.he.inner.products( n ) ) print( "Integral of cross products for the orthogonal polynomials " ) print( apply( p.p.integrals, 2, round, digits=5 ) ) print( apply( p.p.inner.products, 2, round, digits=5 ) ) ### ### construct a list of the scaled Hermite H orthonormal polynomials ### p.list <- hermite.he.polynomials( n, TRUE ) ### ### construct the two dimensional list of pair products ### of polynomials ### p.p.products <- lapply( 1:np1, by.column.products, p.list ) ### ### compute the two dimensional list of functions ### corresponding to the polynomial products in ### the two dimensional list p.p.products ### p.p.functions <- lapply( 1:np1, by.column.functions, p.p.products ) ### ### get the rule table for the order np1 polynomial ### rules <- hermite.he.quadrature.rules( np1, TRUE ) order.np1.rule <- rules[[np1]] ### ### construct the square symmetric matrix containing ### the definite integrals over the default limits ### corresponding to the two dimensional list of ### polynomial functions ### p.p.integrals <- sapply( 1:np1, by.column.integrals, p.p.functions ) ### ### display the matrix of integrals ### print( "Integral of cross products for the orthonormal polynomials " ) print(apply( p.p.integrals, 2, round, digits=5 ) )
### ### this example evaluates the quadrature function for ### the scaled Hermite He polynomials. it computes the integral ### of the product for all pairs of orthogonal polynomials ### from order 0 to order 16. the results are compared to ### the diagonal matrix of the inner products for the ### polynomials. it also computes the integral of the product ### of all pairs of orthonormal polynomials from order 0 ### to order 16. the resultant matrix should be an identity matrix ### ### ### set the value for the maximum polynomial order ### n <- 12 ### ### maximum order plus 1 ### np1 <- n + 1 ### ### function to construct the polynomial products by column ### by.column.products <- function( c, p.list, p.p.list ) { ### ### function to construct the polynomial products by row ### by.row.products <- function( r, c, p.list ) { row.column.product <- p.list[[r]] * p.list[[c]] return (row.column.product ) } np1 <- length( p.list ) row.list <- lapply( 1:np1, by.row.products, c, p.list ) return( row.list ) } ### ### function construct the polynomial functions by column ### by.column.functions <- function( c, p.p.products ) { ### ### function to construct the polynomial functions by row ### by.row.functions <- function( r, c, p.p.products ) { row.column.function <- as.function( p.p.products[[r]][[c]] ) return( row.column.function ) } np1 <- length( p.p.products[[1]] ) row.list <- lapply( 1:np1, by.row.functions, c, p.p.products ) return( row.list ) } ### ### function to compute the integral of the polynomials by column ### by.column.integrals <- function( c, p.p.functions ) { ### ### function to compute the integral of the polynomials by row ### by.row.integrals <- function( r, c, p.p.functions ) { row.column.integral <- hermite.h.quadrature( p.p.functions[[r]][[c]], order.np1.rule ) return( row.column.integral ) } np1 <- length( p.p.functions[[1]] ) row.vector <- sapply( 1:np1, by.row.integrals, c, p.p.functions ) return( row.vector ) } ### ### construct a list of the scaled Hermite He orthogonal polynomials ### p.list <- hermite.he.polynomials( n ) ### ### construct the two dimensional list of pair products ### of polynomials ### p.p.products <- lapply( 1:np1, by.column.products, p.list ) ### ### compute the two dimensional list of functions ### corresponding to the polynomial products in ### the two dimensional list p.p.products ### p.p.functions <- lapply( 1:np1, by.column.functions, p.p.products ) ### ### get the rule table for the order np1 polynomial ### rules <- hermite.he.quadrature.rules( np1 ) order.np1.rule <- rules[[np1]] ### ### construct the square symmetric matrix containing ### the definite integrals over the default limits ### corresponding to the two dimensional list of ### polynomial functions ### p.p.integrals <- sapply( 1:np1, by.column.integrals, p.p.functions ) ### ### construct the diagonal matrix with the inner products ### of the orthogonal polynomials on the diagonal ### p.p.inner.products <- diag( hermite.he.inner.products( n ) ) print( "Integral of cross products for the orthogonal polynomials " ) print( apply( p.p.integrals, 2, round, digits=5 ) ) print( apply( p.p.inner.products, 2, round, digits=5 ) ) ### ### construct a list of the scaled Hermite H orthonormal polynomials ### p.list <- hermite.he.polynomials( n, TRUE ) ### ### construct the two dimensional list of pair products ### of polynomials ### p.p.products <- lapply( 1:np1, by.column.products, p.list ) ### ### compute the two dimensional list of functions ### corresponding to the polynomial products in ### the two dimensional list p.p.products ### p.p.functions <- lapply( 1:np1, by.column.functions, p.p.products ) ### ### get the rule table for the order np1 polynomial ### rules <- hermite.he.quadrature.rules( np1, TRUE ) order.np1.rule <- rules[[np1]] ### ### construct the square symmetric matrix containing ### the definite integrals over the default limits ### corresponding to the two dimensional list of ### polynomial functions ### p.p.integrals <- sapply( 1:np1, by.column.integrals, p.p.functions ) ### ### display the matrix of integrals ### print( "Integral of cross products for the orthonormal polynomials " ) print(apply( p.p.integrals, 2, round, digits=5 ) )
This function returns a list with elements containing
the order
quadrature rule data frame for
the Hermite polynomials
for orders
.
hermite.he.quadrature.rules(n,normalized=FALSE)
hermite.he.quadrature.rules(n,normalized=FALSE)
n |
integer value for the highest order |
normalized |
boolean value. if TRUE rules are for orthonormal polynomials, otherwise they are for orthgonal polynomials |
An order quadrature data frame is a named data frame that contains
the roots and abscissa values of the corresponding order
orthogonal polynomial.
The column with name
x
contains the roots or zeros and
the column with name w
contains the weights.
A list with elements each of which is a data frame
1 |
Quadrature rule data frame for the order 1 Hermite polynomial |
2 |
Quadrature rule data frame for the order 2 Hermite polynomial |
...
n |
Quadrature rule data frame for the order |
Frederick Novomestky [email protected]
Abramowitz, M. and I. A. Stegun, 1968. Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables, Dover Publications, Inc., New York.
Press, W. H., S. A. Teukolsky, W. T. Vetterling, and B. P. Flannery, 1992. Numerical Recipes in C, Cambridge University Press, Cambridge, U.K.
Stroud, A. H., and D. Secrest, 1966. Gaussian Quadrature Formulas, Prentice-Hall, Englewood Cliffs, NJ.
quadrature.rules
,
hermite.he.quadrature
### ### generate a list of quadrature rule frames for ### the Hermite orthogonal polynomials ### of orders 1 to 5 ### orthogonal.rules <- hermite.he.quadrature.rules( 5 ) print( orthogonal.rules ) ### ### generate a list of quadrature rule frames for ### the Hermite orthonormal polynomials ### of orders 1 to 5 ### orthonormal.rules <- hermite.he.quadrature.rules( 5, TRUE ) print( orthonormal.rules )
### ### generate a list of quadrature rule frames for ### the Hermite orthogonal polynomials ### of orders 1 to 5 ### orthogonal.rules <- hermite.he.quadrature.rules( 5 ) print( orthogonal.rules ) ### ### generate a list of quadrature rule frames for ### the Hermite orthonormal polynomials ### of orders 1 to 5 ### orthonormal.rules <- hermite.he.quadrature.rules( 5, TRUE ) print( orthonormal.rules )
This function evaluates the integral of the given function between the lower and upper limits using the weight and abscissa values specified in the rule data frame. The quadrature formula uses the weight function for Jacobi G polynomials.
jacobi.g.quadrature(functn, rule, p = 1, q = 1, lower = 0, upper = 1, weighted = TRUE, ...)
jacobi.g.quadrature(functn, rule, p = 1, q = 1, lower = 0, upper = 1, weighted = TRUE, ...)
functn |
an R function which should take a numeric argument x and possibly some parameters. The function returns a numerical vector value for the given argument x. |
rule |
a data frame containing the order |
p |
numeric value for the first Jacobi polynomial parameter |
q |
numeric value for the second Jacobi polynomial parameter |
lower |
numeric value for the lower limit of the integral with a default value of 0 |
upper |
numeric value for the upper limit of the integral with a default value of 1 |
weighted |
boolean value which if true causes the ultraspherical weight function to be included in the integrand |
... |
other arguments passed to the give function |
The rule argument corresponds to an order Jacobi polynomial,
weight function and interval
.
The lower and upper limits of the integral must be finite.
The value of definite integral evaluated using Gauss Jacobi quadrature
Frederick Novomestky [email protected]
Abramowitz, M. and I. A. Stegun, 1968. Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables, Dover Publications, Inc., New York.
Press, W. H., S. A. Teukolsky, W. T. Vetterling, and B. P. Flannery, 1992. Numerical Recipes in C, Cambridge University Press, Cambridge, U.K.
Stroud, A. H., and D. Secrest, 1966. Gaussian Quadrature Formulas, Prentice-Hall, Englewood Cliffs, NJ.
### ### this example evaluates the quadrature function for ### the Jacobi G polynomials. it computes the integral ### of the product for all pairs of orthogonal polynomials ### from order 0 to order 10. the results are compared to ### the diagonal matrix of the inner products for the ### polynomials. it also computes the integral of the product ### of all pairs of orthonormal polynomials from order 0 ### to order 10. the resultant matrix should be an identity matrix ### ### ### set the polynomial parameter ### p <- 3 q <- 2 ### ### set the value for the maximum polynomial order ### n <- 10 ### ### maximum order plus 1 ### np1 <- n + 1 ### ### function to construct the polynomial products by column ### by.column.products <- function( c, p.list, p.p.list ) { ### ### function to construct the polynomial products by row ### by.row.products <- function( r, c, p.list ) { row.column.product <- p.list[[r]] * p.list[[c]] return (row.column.product ) } np1 <- length( p.list ) row.list <- lapply( 1:np1, by.row.products, c, p.list ) return( row.list ) } ### ### function construct the polynomial functions by column ### by.column.functions <- function( c, p.p.products ) { ### ### function to construct the polynomial functions by row ### by.row.functions <- function( r, c, p.p.products ) { row.column.function <- as.function( p.p.products[[r]][[c]] ) return( row.column.function ) } np1 <- length( p.p.products[[1]] ) row.list <- lapply( 1:np1, by.row.functions, c, p.p.products ) return( row.list ) } ### ### function to compute the integral of the polynomials by column ### by.column.integrals <- function( c, p.p.functions ) { ### ### function to compute the integral of the polynomials by row ### by.row.integrals <- function( r, c, p.p.functions ) { row.column.integral <- jacobi.g.quadrature( p.p.functions[[r]][[c]], order.np1.rule, p, q ) return( row.column.integral ) } np1 <- length( p.p.functions[[1]] ) row.vector <- sapply( 1:np1, by.row.integrals, c, p.p.functions ) return( row.vector ) } ### ### construct a list of the Jacobi G orthogonal polynomials ### p.list <- jacobi.g.polynomials( n, p, q ) ### ### construct the two dimensional list of pair products ### of polynomials ### p.p.products <- lapply( 1:np1, by.column.products, p.list ) ### ### compute the two dimensional list of functions ### corresponding to the polynomial products in ### the two dimensional list p.p.products ### p.p.functions <- lapply( 1:np1, by.column.functions, p.p.products ) ### ### get the rule table for the order np1 polynomial ### rules <- jacobi.g.quadrature.rules( np1, p, q ) order.np1.rule <- rules[[np1]] ### ### construct the square symmetric matrix containing ### the definite integrals over the default limits ### corresponding to the two dimensional list of ### polynomial functions ### p.p.integrals <- sapply( 1:np1, by.column.integrals, p.p.functions ) ### ### construct the diagonal matrix with the inner products ### of the orthogonal polynomials on the diagonal ### p.p.inner.products <- diag( jacobi.g.inner.products( n,p, q ) ) print( "Integral of cross products for the orthogonal polynomials " ) print( apply( p.p.integrals, 2, round, digits=5 ) ) print( apply( p.p.inner.products, 2, round, digits=5 ) ) ### ### construct a list of the Jacobi G orthonormal polynomials ### p.list <- jacobi.g.polynomials( n, p, q, TRUE ) ### ### construct the two dimensional list of pair products ### of polynomials ### p.p.products <- lapply( 1:np1, by.column.products, p.list ) ### ### compute the two dimensional list of functions ### corresponding to the polynomial products in ### the two dimensional list p.p.products ### p.p.functions <- lapply( 1:np1, by.column.functions, p.p.products ) ### ### get the rule table for the order np1 polynomial ### rules <- jacobi.g.quadrature.rules( np1, p, q, TRUE ) order.np1.rule <- rules[[np1]] ### ### construct the square symmetric matrix containing ### the definite integrals over the default limits ### corresponding to the two dimensional list of ### polynomial functions ### p.p.integrals <- sapply( 1:np1, by.column.integrals, p.p.functions ) ### ### display the matrix of integrals ### print( "Integral of cross products for the orthonormal polynomials " ) print(apply( p.p.integrals, 2, round, digits=5 ) )
### ### this example evaluates the quadrature function for ### the Jacobi G polynomials. it computes the integral ### of the product for all pairs of orthogonal polynomials ### from order 0 to order 10. the results are compared to ### the diagonal matrix of the inner products for the ### polynomials. it also computes the integral of the product ### of all pairs of orthonormal polynomials from order 0 ### to order 10. the resultant matrix should be an identity matrix ### ### ### set the polynomial parameter ### p <- 3 q <- 2 ### ### set the value for the maximum polynomial order ### n <- 10 ### ### maximum order plus 1 ### np1 <- n + 1 ### ### function to construct the polynomial products by column ### by.column.products <- function( c, p.list, p.p.list ) { ### ### function to construct the polynomial products by row ### by.row.products <- function( r, c, p.list ) { row.column.product <- p.list[[r]] * p.list[[c]] return (row.column.product ) } np1 <- length( p.list ) row.list <- lapply( 1:np1, by.row.products, c, p.list ) return( row.list ) } ### ### function construct the polynomial functions by column ### by.column.functions <- function( c, p.p.products ) { ### ### function to construct the polynomial functions by row ### by.row.functions <- function( r, c, p.p.products ) { row.column.function <- as.function( p.p.products[[r]][[c]] ) return( row.column.function ) } np1 <- length( p.p.products[[1]] ) row.list <- lapply( 1:np1, by.row.functions, c, p.p.products ) return( row.list ) } ### ### function to compute the integral of the polynomials by column ### by.column.integrals <- function( c, p.p.functions ) { ### ### function to compute the integral of the polynomials by row ### by.row.integrals <- function( r, c, p.p.functions ) { row.column.integral <- jacobi.g.quadrature( p.p.functions[[r]][[c]], order.np1.rule, p, q ) return( row.column.integral ) } np1 <- length( p.p.functions[[1]] ) row.vector <- sapply( 1:np1, by.row.integrals, c, p.p.functions ) return( row.vector ) } ### ### construct a list of the Jacobi G orthogonal polynomials ### p.list <- jacobi.g.polynomials( n, p, q ) ### ### construct the two dimensional list of pair products ### of polynomials ### p.p.products <- lapply( 1:np1, by.column.products, p.list ) ### ### compute the two dimensional list of functions ### corresponding to the polynomial products in ### the two dimensional list p.p.products ### p.p.functions <- lapply( 1:np1, by.column.functions, p.p.products ) ### ### get the rule table for the order np1 polynomial ### rules <- jacobi.g.quadrature.rules( np1, p, q ) order.np1.rule <- rules[[np1]] ### ### construct the square symmetric matrix containing ### the definite integrals over the default limits ### corresponding to the two dimensional list of ### polynomial functions ### p.p.integrals <- sapply( 1:np1, by.column.integrals, p.p.functions ) ### ### construct the diagonal matrix with the inner products ### of the orthogonal polynomials on the diagonal ### p.p.inner.products <- diag( jacobi.g.inner.products( n,p, q ) ) print( "Integral of cross products for the orthogonal polynomials " ) print( apply( p.p.integrals, 2, round, digits=5 ) ) print( apply( p.p.inner.products, 2, round, digits=5 ) ) ### ### construct a list of the Jacobi G orthonormal polynomials ### p.list <- jacobi.g.polynomials( n, p, q, TRUE ) ### ### construct the two dimensional list of pair products ### of polynomials ### p.p.products <- lapply( 1:np1, by.column.products, p.list ) ### ### compute the two dimensional list of functions ### corresponding to the polynomial products in ### the two dimensional list p.p.products ### p.p.functions <- lapply( 1:np1, by.column.functions, p.p.products ) ### ### get the rule table for the order np1 polynomial ### rules <- jacobi.g.quadrature.rules( np1, p, q, TRUE ) order.np1.rule <- rules[[np1]] ### ### construct the square symmetric matrix containing ### the definite integrals over the default limits ### corresponding to the two dimensional list of ### polynomial functions ### p.p.integrals <- sapply( 1:np1, by.column.integrals, p.p.functions ) ### ### display the matrix of integrals ### print( "Integral of cross products for the orthonormal polynomials " ) print(apply( p.p.integrals, 2, round, digits=5 ) )
This function returns a list with elements containing
the order
quadrature rule data frame for
the Jacobi G polynomial
for orders
.
jacobi.g.quadrature.rules(n,p,q,normalized=FALSE)
jacobi.g.quadrature.rules(n,p,q,normalized=FALSE)
n |
integer value for the highest order |
p |
numeric value for the first polynomial parameter |
q |
numeric value for the second polynomial parameter |
normalized |
boolean value. if TRUE rules are for orthonormal polynomials, otherwise they are for orthgonal polynomials |
An order quadrature data frame is a named data frame that contains
the roots and abscissa values of the corresponding order
orthogonal polynomial.
The column with name
x
contains the roots or zeros and
the column with name w
contains the weights.
A list with elements each of which is a data frame
1 |
Quadrature rule data frame for the order 1 Jacobi polynomial |
2 |
Quadrature rule data frame for the order 2 Jacobi polynomial |
...
n |
Quadrature rule data frame for the order |
Frederick Novomestky [email protected]
Abramowitz, M. and I. A. Stegun, 1968. Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables, Dover Publications, Inc., New York.
Press, W. H., S. A. Teukolsky, W. T. Vetterling, and B. P. Flannery, 1992. Numerical Recipes in C, Cambridge University Press, Cambridge, U.K.
Stroud, A. H., and D. Secrest, 1966. Gaussian Quadrature Formulas, Prentice-Hall, Englewood Cliffs, NJ.
### ### generate the list of quadrature rule data frames for ### the orthogonal Jacobi G polynomial ### of orders 1 to 5 ### parameter p is 3 and parameter q is 2 ### orthogonal.rules <- jacobi.g.quadrature.rules( 5, 3, 2 ) print( orthogonal.rules ) ### ### generate the list of quadrature rule data frames for ### the orthonormal Jacobi G polynomial ### of orders 1 to 5 ### parameter p is 3 and parameter q is 2 ### orthonormal.rules <- jacobi.g.quadrature.rules( 5, 3, 2, TRUE ) print( orthonormal.rules )
### ### generate the list of quadrature rule data frames for ### the orthogonal Jacobi G polynomial ### of orders 1 to 5 ### parameter p is 3 and parameter q is 2 ### orthogonal.rules <- jacobi.g.quadrature.rules( 5, 3, 2 ) print( orthogonal.rules ) ### ### generate the list of quadrature rule data frames for ### the orthonormal Jacobi G polynomial ### of orders 1 to 5 ### parameter p is 3 and parameter q is 2 ### orthonormal.rules <- jacobi.g.quadrature.rules( 5, 3, 2, TRUE ) print( orthonormal.rules )
This function evaluates the integral of the given function between the lower and upper limits using the weight and abscissa values specified in the rule data frame. The quadrature formula uses the weight function for Jacobi P polynomials.
jacobi.p.quadrature(functn, rule, alpha = 0, beta = 0, lower = -1, upper = 1, weighted = TRUE, ...)
jacobi.p.quadrature(functn, rule, alpha = 0, beta = 0, lower = -1, upper = 1, weighted = TRUE, ...)
functn |
an R function which should take a numeric argument x and possibly some parameters. The function returns a numerical vector value for the given argument x. |
rule |
a data frame containing the order |
alpha |
numeric value for the first Jacobi polynomial parameter |
beta |
numeric value for the second Jacobi polynomial parameter |
lower |
numeric value for the lower limit of the integral with a default value of -1 |
upper |
numeric value for the upper limit of the integral with a default value of 1 |
weighted |
a boolean value which if true causes the ultraspherical weight function to be included in the integrand |
... |
other arguments passed to the give function |
The rule argument corresponds to an order Jacobi polynomial,
weight function and interval
.
The lower and upper limits of the integral must be finite.
The value of definite integral evaluated using Gauss Jacobi quadrature
Frederick Novomestky [email protected]
Abramowitz, M. and I. A. Stegun, 1968. Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables, Dover Publications, Inc., New York.
Press, W. H., S. A. Teukolsky, W. T. Vetterling, and B. P. Flannery, 1992. Numerical Recipes in C, Cambridge University Press, Cambridge, U.K.
Stroud, A. H., and D. Secrest, 1966. Gaussian Quadrature Formulas, Prentice-Hall, Englewood Cliffs, NJ.
### ### this example evaluates the quadrature function for ### the Jacobi P polynomials. it computes the integral ### of the product for all pairs of orthogonal polynomials ### from order 0 to order 12. the results are compared to ### the diagonal matrix of the inner products for the ### polynomials. it also computes the integral of the product ### of all pairs of orthonormal polynomials from order 0 ### to order 12. the resultant matrix should be an identity matrix ### ### ### set the polynomial parameter ### alpha <- 1 beta <- -0.6 ### ### set the value for the maximum polynomial order ### n <- 12 ### ### maximum order plus 1 ### np1 <- n + 1 ### ### function to construct the polynomial products by column ### by.column.products <- function( c, p.list, p.p.list ) { ### ### function to construct the polynomial products by row ### by.row.products <- function( r, c, p.list ) { row.column.product <- p.list[[r]] * p.list[[c]] return (row.column.product ) } np1 <- length( p.list ) row.list <- lapply( 1:np1, by.row.products, c, p.list ) return( row.list ) } ### ### function construct the polynomial functions by column ### by.column.functions <- function( c, p.p.products ) { ### ### function to construct the polynomial functions by row ### by.row.functions <- function( r, c, p.p.products ) { row.column.function <- as.function( p.p.products[[r]][[c]] ) return( row.column.function ) } np1 <- length( p.p.products[[1]] ) row.list <- lapply( 1:np1, by.row.functions, c, p.p.products ) return( row.list ) } ### ### function to compute the integral of the polynomials by column ### by.column.integrals <- function( c, p.p.functions ) { ### ### function to compute the integral of the polynomials by row ### by.row.integrals <- function( r, c, p.p.functions ) { row.column.integral <- jacobi.p.quadrature( p.p.functions[[r]][[c]], order.np1.rule, alpha, beta ) return( row.column.integral ) } np1 <- length( p.p.functions[[1]] ) row.vector <- sapply( 1:np1, by.row.integrals, c, p.p.functions ) return( row.vector ) } ### ### construct a list of the Jacobi P orthogonal polynomials ### p.list <- jacobi.p.polynomials( n, alpha, beta ) ### ### construct the two dimensional list of pair products ### of polynomials ### p.p.products <- lapply( 1:np1, by.column.products, p.list ) ### ### compute the two dimensional list of functions ### corresponding to the polynomial products in ### the two dimensional list p.p.products ### p.p.functions <- lapply( 1:np1, by.column.functions, p.p.products ) ### ### get the rule table for the order np1 polynomial ### rules <- jacobi.p.quadrature.rules( np1, alpha, beta ) order.np1.rule <- rules[[np1]] ### ### construct the square symmetric matrix containing ### the definite integrals over the default limits ### corresponding to the two dimensional list of ### polynomial functions ### p.p.integrals <- sapply( 1:np1, by.column.integrals, p.p.functions ) ### ### construct the diagonal matrix with the inner products ### of the orthogonal polynomials on the diagonal ### p.p.inner.products <- diag( jacobi.p.inner.products( n,alpha, beta ) ) print( "Integral of cross products for the orthogonal polynomials " ) print( apply( p.p.integrals, 2, round, digits=6 ) ) print( apply( p.p.inner.products, 2, round, digits=6 ) ) ### ### construct a list of the Jacobi P orthonormal polynomials ### p.list <- jacobi.p.polynomials( n, alpha, beta, TRUE ) ### ### construct the two dimensional list of pair products ### of polynomials ### p.p.products <- lapply( 1:np1, by.column.products, p.list ) ### ### compute the two dimensional list of functions ### corresponding to the polynomial products in ### the two dimensional list p.p.products ### p.p.functions <- lapply( 1:np1, by.column.functions, p.p.products ) ### ### get the rule table for the order np1 polynomial ### rules <- jacobi.p.quadrature.rules( np1, alpha, beta, TRUE ) order.np1.rule <- rules[[np1]] ### ### construct the square symmetric matrix containing ### the definite integrals over the default limits ### corresponding to the two dimensional list of ### polynomial functions ### p.p.integrals <- sapply( 1:np1, by.column.integrals, p.p.functions ) ### ### display the matrix of integrals ### print( "Integral of cross products for the orthonormal polynomials " ) print(apply( p.p.integrals, 2, round, digits=6 ) )
### ### this example evaluates the quadrature function for ### the Jacobi P polynomials. it computes the integral ### of the product for all pairs of orthogonal polynomials ### from order 0 to order 12. the results are compared to ### the diagonal matrix of the inner products for the ### polynomials. it also computes the integral of the product ### of all pairs of orthonormal polynomials from order 0 ### to order 12. the resultant matrix should be an identity matrix ### ### ### set the polynomial parameter ### alpha <- 1 beta <- -0.6 ### ### set the value for the maximum polynomial order ### n <- 12 ### ### maximum order plus 1 ### np1 <- n + 1 ### ### function to construct the polynomial products by column ### by.column.products <- function( c, p.list, p.p.list ) { ### ### function to construct the polynomial products by row ### by.row.products <- function( r, c, p.list ) { row.column.product <- p.list[[r]] * p.list[[c]] return (row.column.product ) } np1 <- length( p.list ) row.list <- lapply( 1:np1, by.row.products, c, p.list ) return( row.list ) } ### ### function construct the polynomial functions by column ### by.column.functions <- function( c, p.p.products ) { ### ### function to construct the polynomial functions by row ### by.row.functions <- function( r, c, p.p.products ) { row.column.function <- as.function( p.p.products[[r]][[c]] ) return( row.column.function ) } np1 <- length( p.p.products[[1]] ) row.list <- lapply( 1:np1, by.row.functions, c, p.p.products ) return( row.list ) } ### ### function to compute the integral of the polynomials by column ### by.column.integrals <- function( c, p.p.functions ) { ### ### function to compute the integral of the polynomials by row ### by.row.integrals <- function( r, c, p.p.functions ) { row.column.integral <- jacobi.p.quadrature( p.p.functions[[r]][[c]], order.np1.rule, alpha, beta ) return( row.column.integral ) } np1 <- length( p.p.functions[[1]] ) row.vector <- sapply( 1:np1, by.row.integrals, c, p.p.functions ) return( row.vector ) } ### ### construct a list of the Jacobi P orthogonal polynomials ### p.list <- jacobi.p.polynomials( n, alpha, beta ) ### ### construct the two dimensional list of pair products ### of polynomials ### p.p.products <- lapply( 1:np1, by.column.products, p.list ) ### ### compute the two dimensional list of functions ### corresponding to the polynomial products in ### the two dimensional list p.p.products ### p.p.functions <- lapply( 1:np1, by.column.functions, p.p.products ) ### ### get the rule table for the order np1 polynomial ### rules <- jacobi.p.quadrature.rules( np1, alpha, beta ) order.np1.rule <- rules[[np1]] ### ### construct the square symmetric matrix containing ### the definite integrals over the default limits ### corresponding to the two dimensional list of ### polynomial functions ### p.p.integrals <- sapply( 1:np1, by.column.integrals, p.p.functions ) ### ### construct the diagonal matrix with the inner products ### of the orthogonal polynomials on the diagonal ### p.p.inner.products <- diag( jacobi.p.inner.products( n,alpha, beta ) ) print( "Integral of cross products for the orthogonal polynomials " ) print( apply( p.p.integrals, 2, round, digits=6 ) ) print( apply( p.p.inner.products, 2, round, digits=6 ) ) ### ### construct a list of the Jacobi P orthonormal polynomials ### p.list <- jacobi.p.polynomials( n, alpha, beta, TRUE ) ### ### construct the two dimensional list of pair products ### of polynomials ### p.p.products <- lapply( 1:np1, by.column.products, p.list ) ### ### compute the two dimensional list of functions ### corresponding to the polynomial products in ### the two dimensional list p.p.products ### p.p.functions <- lapply( 1:np1, by.column.functions, p.p.products ) ### ### get the rule table for the order np1 polynomial ### rules <- jacobi.p.quadrature.rules( np1, alpha, beta, TRUE ) order.np1.rule <- rules[[np1]] ### ### construct the square symmetric matrix containing ### the definite integrals over the default limits ### corresponding to the two dimensional list of ### polynomial functions ### p.p.integrals <- sapply( 1:np1, by.column.integrals, p.p.functions ) ### ### display the matrix of integrals ### print( "Integral of cross products for the orthonormal polynomials " ) print(apply( p.p.integrals, 2, round, digits=6 ) )
This function returns a list with n elements containing
the order quadrature rule data frame for
the Jacobi P polynomial
for orders
.
jacobi.p.quadrature.rules(n,alpha,beta,normalized=FALSE)
jacobi.p.quadrature.rules(n,alpha,beta,normalized=FALSE)
n |
integer value for the highest order |
alpha |
numeric value for the first polynomial parameter |
beta |
numeric value for the second polynomial parameter |
normalized |
boolean value. if TRUE rules are for orthonormal polynomials, otherwise they are for orthgonal polynomials |
An order quadrature data frame is a named data frame that contains
the roots and abscissa values of the corresponding order
orthogonal polynomial.
The column with name
x
contains the roots or zeros and
the column with name w
contains the weights.
A list with elements each of which is a quadrature rule data frame
1 |
Quadrature rule for the order 1 Jacobi polynomial |
2 |
Quadrature rule for the order 2 Jacobi polynomial |
...
n |
Quadrature rule for the order |
Frederick Novomestky [email protected]
Abramowitz, M. and I. A. Stegun, 1968. Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables, Dover Publications, Inc., New York.
Press, W. H., S. A. Teukolsky, W. T. Vetterling, and B. P. Flannery, 1992. Numerical Recipes in C, Cambridge University Press, Cambridge, U.K.
Stroud, A. H., and D. Secrest, 1966. Gaussian Quadrature Formulas, Prentice-Hall, Englewood Cliffs, NJ.
### ### construct the list of quadrature rules for ### the Jacobi orthogonal polynomials ### of orders 1 to 5 ### alpha = 3 and beta = 2 ### orthogonal.rules <- jacobi.p.quadrature.rules( 5, 3, 2 ) print( orthogonal.rules ) ### ### construct the list of quadrature rules for ### the Jacobi orthonormal polynomials ### of orders 1 to 5 ### alpha = 3 and beta = 2 ### orthonormal.rules <- jacobi.p.quadrature.rules( 5, 3, 2, TRUE ) print( orthonormal.rules )
### ### construct the list of quadrature rules for ### the Jacobi orthogonal polynomials ### of orders 1 to 5 ### alpha = 3 and beta = 2 ### orthogonal.rules <- jacobi.p.quadrature.rules( 5, 3, 2 ) print( orthogonal.rules ) ### ### construct the list of quadrature rules for ### the Jacobi orthonormal polynomials ### of orders 1 to 5 ### alpha = 3 and beta = 2 ### orthonormal.rules <- jacobi.p.quadrature.rules( 5, 3, 2, TRUE ) print( orthonormal.rules )
This function evaluates the integral of the given function between the lower and upper limits using the weight and abscissa values specified in the rule data frame. The quadrature formula uses the weight function for Laguerre polynomials.
laguerre.quadrature(functn, rule, lower = 0, upper = Inf, weighted = TRUE, ...)
laguerre.quadrature(functn, rule, lower = 0, upper = Inf, weighted = TRUE, ...)
functn |
an R function which should take a numeric argument x and possibly some parameters. The function returns a numerical vector value for the given argument x. |
rule |
a data frame containing the order |
lower |
numeric value for the lower limit of the integral with a default value of 0 |
upper |
numeric value for the upper limit of the integral with a default value of Inf |
weighted |
boolean value which if true causes the Laguerre weight function to be included in the integrand |
... |
other arguments passed to the give function |
The rule argument corresponds to an order Laguerre polynomial,
weight function and interval
.
The one limit of the integral must be finite and the other must be infinite.
The value of definite integral evaluated using Gauss Laguerre quadrature
Frederick Novomestky [email protected]
Abramowitz, M. and I. A. Stegun, 1968. Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables, Dover Publications, Inc., New York.
Press, W. H., S. A. Teukolsky, W. T. Vetterling, and B. P. Flannery, 1992. Numerical Recipes in C, Cambridge University Press, Cambridge, U.K.
Stroud, A. H., and D. Secrest, 1966. Gaussian Quadrature Formulas, Prentice-Hall, Englewood Cliffs, NJ.
### ### this example evaluates the quadrature function for ### the Laguerre polynomials. it computes the integral ### of the product for all pairs of orthogonal polynomials ### from order 0 to order 12. the results are compared to ### the diagonal matrix of the inner products for the ### polynomials. it also computes the integral of the product ### of all pairs of orthonormal polynomials from order 0 ### to order 12. the resultant matrix should be an identity matrix ### ### ### set the value for the maximum polynomial order ### n <- 12 ### ### maximum order plus 1 ### np1 <- n + 1 ### ### function to construct the polynomial products by column ### by.column.products <- function( c, p.list, p.p.list ) { ### ### function to construct the polynomial products by row ### by.row.products <- function( r, c, p.list ) { row.column.product <- p.list[[r]] * p.list[[c]] return (row.column.product ) } np1 <- length( p.list ) row.list <- lapply( 1:np1, by.row.products, c, p.list ) return( row.list ) } ### ### function construct the polynomial functions by column ### by.column.functions <- function( c, p.p.products ) { ### ### function to construct the polynomial functions by row ### by.row.functions <- function( r, c, p.p.products ) { row.column.function <- as.function( p.p.products[[r]][[c]] ) return( row.column.function ) } np1 <- length( p.p.products[[1]] ) row.list <- lapply( 1:np1, by.row.functions, c, p.p.products ) return( row.list ) } ### ### function to compute the integral of the polynomials by column ### by.column.integrals <- function( c, p.p.functions ) { ### ### function to compute the integral of the polynomials by row ### by.row.integrals <- function( r, c, p.p.functions ) { row.column.integral <- laguerre.quadrature( p.p.functions[[r]][[c]], order.np1.rule ) return( row.column.integral ) } np1 <- length( p.p.functions[[1]] ) row.vector <- sapply( 1:np1, by.row.integrals, c, p.p.functions ) return( row.vector ) } ### ### construct a list of the Laguerre orthogonal polynomials ### p.list <- laguerre.polynomials( n ) ### ### construct the two dimensional list of pair products ### of polynomials ### p.p.products <- lapply( 1:np1, by.column.products, p.list ) ### ### compute the two dimensional list of functions ### corresponding to the polynomial products in ### the two dimensional list p.p.products ### p.p.functions <- lapply( 1:np1, by.column.functions, p.p.products ) ### ### get the rule table for the order np1 polynomial ### rules <- laguerre.quadrature.rules( np1 ) order.np1.rule <- rules[[np1]] ### ### construct the square symmetric matrix containing ### the definite integrals over the default limits ### corresponding to the two dimensional list of ### polynomial functions ### p.p.integrals <- sapply( 1:np1, by.column.integrals, p.p.functions ) ### ### construct the diagonal matrix with the inner products ### of the orthogonal polynomials on the diagonal ### p.p.inner.products <- diag( laguerre.inner.products( n ) ) print( "Integral of cross products for the orthogonal polynomials " ) print( apply( p.p.integrals, 2, round, digits=6 ) ) print( apply( p.p.inner.products, 2, round, digits=6 ) ) ### ### construct a list of the Laguerre orthonormal polynomials ### p.list <- laguerre.polynomials( n, TRUE ) ### ### construct the two dimensional list of pair products ### of polynomials ### p.p.products <- lapply( 1:np1, by.column.products, p.list ) ### ### compute the two dimensional list of functions ### corresponding to the polynomial products in ### the two dimensional list p.p.products ### p.p.functions <- lapply( 1:np1, by.column.functions, p.p.products ) ### ### get the rule table for the order np1 polynomial ### rules <- laguerre.quadrature.rules( np1, TRUE ) order.np1.rule <- rules[[np1]] ### ### construct the square symmetric matrix containing ### the definite integrals over the default limits ### corresponding to the two dimensional list of ### polynomial functions ### p.p.integrals <- sapply( 1:np1, by.column.integrals, p.p.functions ) ### ### display the matrix of integrals ### print( "Integral of cross products for the orthonormal polynomials " ) print(apply( p.p.integrals, 2, round, digits=6 ) )
### ### this example evaluates the quadrature function for ### the Laguerre polynomials. it computes the integral ### of the product for all pairs of orthogonal polynomials ### from order 0 to order 12. the results are compared to ### the diagonal matrix of the inner products for the ### polynomials. it also computes the integral of the product ### of all pairs of orthonormal polynomials from order 0 ### to order 12. the resultant matrix should be an identity matrix ### ### ### set the value for the maximum polynomial order ### n <- 12 ### ### maximum order plus 1 ### np1 <- n + 1 ### ### function to construct the polynomial products by column ### by.column.products <- function( c, p.list, p.p.list ) { ### ### function to construct the polynomial products by row ### by.row.products <- function( r, c, p.list ) { row.column.product <- p.list[[r]] * p.list[[c]] return (row.column.product ) } np1 <- length( p.list ) row.list <- lapply( 1:np1, by.row.products, c, p.list ) return( row.list ) } ### ### function construct the polynomial functions by column ### by.column.functions <- function( c, p.p.products ) { ### ### function to construct the polynomial functions by row ### by.row.functions <- function( r, c, p.p.products ) { row.column.function <- as.function( p.p.products[[r]][[c]] ) return( row.column.function ) } np1 <- length( p.p.products[[1]] ) row.list <- lapply( 1:np1, by.row.functions, c, p.p.products ) return( row.list ) } ### ### function to compute the integral of the polynomials by column ### by.column.integrals <- function( c, p.p.functions ) { ### ### function to compute the integral of the polynomials by row ### by.row.integrals <- function( r, c, p.p.functions ) { row.column.integral <- laguerre.quadrature( p.p.functions[[r]][[c]], order.np1.rule ) return( row.column.integral ) } np1 <- length( p.p.functions[[1]] ) row.vector <- sapply( 1:np1, by.row.integrals, c, p.p.functions ) return( row.vector ) } ### ### construct a list of the Laguerre orthogonal polynomials ### p.list <- laguerre.polynomials( n ) ### ### construct the two dimensional list of pair products ### of polynomials ### p.p.products <- lapply( 1:np1, by.column.products, p.list ) ### ### compute the two dimensional list of functions ### corresponding to the polynomial products in ### the two dimensional list p.p.products ### p.p.functions <- lapply( 1:np1, by.column.functions, p.p.products ) ### ### get the rule table for the order np1 polynomial ### rules <- laguerre.quadrature.rules( np1 ) order.np1.rule <- rules[[np1]] ### ### construct the square symmetric matrix containing ### the definite integrals over the default limits ### corresponding to the two dimensional list of ### polynomial functions ### p.p.integrals <- sapply( 1:np1, by.column.integrals, p.p.functions ) ### ### construct the diagonal matrix with the inner products ### of the orthogonal polynomials on the diagonal ### p.p.inner.products <- diag( laguerre.inner.products( n ) ) print( "Integral of cross products for the orthogonal polynomials " ) print( apply( p.p.integrals, 2, round, digits=6 ) ) print( apply( p.p.inner.products, 2, round, digits=6 ) ) ### ### construct a list of the Laguerre orthonormal polynomials ### p.list <- laguerre.polynomials( n, TRUE ) ### ### construct the two dimensional list of pair products ### of polynomials ### p.p.products <- lapply( 1:np1, by.column.products, p.list ) ### ### compute the two dimensional list of functions ### corresponding to the polynomial products in ### the two dimensional list p.p.products ### p.p.functions <- lapply( 1:np1, by.column.functions, p.p.products ) ### ### get the rule table for the order np1 polynomial ### rules <- laguerre.quadrature.rules( np1, TRUE ) order.np1.rule <- rules[[np1]] ### ### construct the square symmetric matrix containing ### the definite integrals over the default limits ### corresponding to the two dimensional list of ### polynomial functions ### p.p.integrals <- sapply( 1:np1, by.column.integrals, p.p.functions ) ### ### display the matrix of integrals ### print( "Integral of cross products for the orthonormal polynomials " ) print(apply( p.p.integrals, 2, round, digits=6 ) )
This function returns a list with elements containing
the order
quadrature rule data frame for
the Laguerre polynomial
for orders
.
laguerre.quadrature.rules(n,normalized=FALSE)
laguerre.quadrature.rules(n,normalized=FALSE)
n |
integer value for the highest order |
normalized |
boolean value. if TRUE rules are for orthonormal polynomials, otherwise they are for orthgonal polynomials |
An order quadrature data frame is a named data frame that contains
the roots and abscissa values of the corresponding order
orthogonal polynomial.
The column with name
x
contains the roots or zeros and
the column with name w
contains the weights.
A list with elements each of which is a data frame
1 |
Quadrature rule data frame for the order 1 Laguerre polynomial |
2 |
Quadrature rule data frame for the order 2 Laguerre polynomial |
...
n |
Quadrature rule data frame for the order |
Frederick Novomestky [email protected]
Abramowitz, M. and I. A. Stegun, 1968. Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables, Dover Publications, Inc., New York.
Press, W. H., S. A. Teukolsky, W. T. Vetterling, and B. P. Flannery, 1992. Numerical Recipes in C, Cambridge University Press, Cambridge, U.K.
Stroud, A. H., and D. Secrest, 1966. Gaussian Quadrature Formulas, Prentice-Hall, Englewood Cliffs, NJ.
quadrature.rules
,
laguerre.quadrature
### ### generate a list of the quadrature rule frames for ### the orthogonal Laguerre polynomials ### of orders 1 to 5 ### orthogonal.rules <- laguerre.quadrature.rules( 5 ) print( orthogonal.rules ) ### ### generate a list of the quadrature rule frames for ### the orthonormal Laguerre polynomials ### of orders 1 to 5 ### orthonormal.rules <- laguerre.quadrature.rules( 5, TRUE ) print( orthonormal.rules )
### ### generate a list of the quadrature rule frames for ### the orthogonal Laguerre polynomials ### of orders 1 to 5 ### orthogonal.rules <- laguerre.quadrature.rules( 5 ) print( orthogonal.rules ) ### ### generate a list of the quadrature rule frames for ### the orthonormal Laguerre polynomials ### of orders 1 to 5 ### orthonormal.rules <- laguerre.quadrature.rules( 5, TRUE ) print( orthonormal.rules )
This function evaluates the integral of the given function between the lower and upper limits using the weight and abscissa values specified in the rule data frame. The quadrature formula uses the weight function for Legendre polynomials.
legendre.quadrature(functn, rule, lower=-1, upper=1, weighted = TRUE, ...)
legendre.quadrature(functn, rule, lower=-1, upper=1, weighted = TRUE, ...)
functn |
an R function which should take a numeric argument x and possibly some parameters. The function returns a numerical vector value for the given argument x. |
rule |
a data frame containing the order |
lower |
numeric value for the lower limit of the integral |
upper |
numeric value for the upper limit of the integral |
weighted |
boolean value which if true causes the Legendre weight function to be included in the integrand |
... |
other arguments passed to the give function |
The rule argument corresponds to an order Legendre polynomial,
weight function and interval
.
The lower and upper limits of the integral must be finite.
The value of definite integral evaluated using Gauss Legendre quadrature
Frederick Novomestky [email protected]
Abramowitz, M. and I. A. Stegun, 1968. Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables, Dover Publications, Inc., New York.
Press, W. H., S. A. Teukolsky, W. T. Vetterling, and B. P. Flannery, 1992. Numerical Recipes in C, Cambridge University Press, Cambridge, U.K.
Stroud, A. H., and D. Secrest, 1966. Gaussian Quadrature Formulas, Prentice-Hall, Englewood Cliffs, NJ.
Szego, G., 1939. Orthogonal Polynomials, 23, American Mathematical Society Colloquium Publications, Providence, RI.
### ### this example evaluates the quadrature function for ### the Legendre polynomials. it computes the integral ### of the product for all pairs of orthogonal polynomials ### from order 0 to order 20. the results are compared to ### the diagonal matrix of the inner products for the ### polynomials. it also computes the integral of the product ### of all pairs of orthonormal polynomials from order 0 ### to order 20. the resultant matrix should be an identity matrix ### ### ### set the value for the maximum polynomial order ### n <- 20 ### ### maximum order plus 1 ### np1 <- n + 1 ### ### function to construct the polynomial products by column ### by.column.products <- function( c, p.list, p.p.list ) { ### ### function to construct the polynomial products by row ### by.row.products <- function( r, c, p.list ) { row.column.product <- p.list[[r]] * p.list[[c]] return (row.column.product ) } np1 <- length( p.list ) row.list <- lapply( 1:np1, by.row.products, c, p.list ) return( row.list ) } ### ### function construct the polynomial functions by column ### by.column.functions <- function( c, p.p.products ) { ### ### function to construct the polynomial functions by row ### by.row.functions <- function( r, c, p.p.products ) { row.column.function <- as.function( p.p.products[[r]][[c]] ) return( row.column.function ) } np1 <- length( p.p.products[[1]] ) row.list <- lapply( 1:np1, by.row.functions, c, p.p.products ) return( row.list ) } ### ### function to compute the integral of the polynomials by column ### by.column.integrals <- function( c, p.p.functions ) { ### ### function to compute the integral of the polynomials by row ### by.row.integrals <- function( r, c, p.p.functions ) { row.column.integral <- legendre.quadrature( p.p.functions[[r]][[c]], order.np1.rule ) return( row.column.integral ) } np1 <- length( p.p.functions[[1]] ) row.vector <- sapply( 1:np1, by.row.integrals, c, p.p.functions ) return( row.vector ) } ### ### construct a list of the Legendre orthogonal polynomials ### p.list <- legendre.polynomials( n ) ### ### construct the two dimensional list of pair products ### of polynomials ### p.p.products <- lapply( 1:np1, by.column.products, p.list ) ### ### compute the two dimensional list of functions ### corresponding to the polynomial products in ### the two dimensional list p.p.products ### p.p.functions <- lapply( 1:np1, by.column.functions, p.p.products ) ### ### get the rule table for the order np1 polynomial ### rules <- legendre.quadrature.rules( np1 ) order.np1.rule <- rules[[np1]] ### ### construct the square symmetric matrix containing ### the definite integrals over the default limits ### corresponding to the two dimensional list of ### polynomial functions ### p.p.integrals <- sapply( 1:np1, by.column.integrals, p.p.functions ) ### ### construct the diagonal matrix with the inner products ### of the orthogonal polynomials on the diagonal ### p.p.inner.products <- diag( legendre.inner.products( n ) ) print( "Integral of cross products for the orthogonal polynomials " ) print( apply( p.p.integrals, 2, round, digits=5 ) ) print( apply( p.p.inner.products, 2, round, digits=5 ) ) ### ### construct a list of the Legendre orthonormal polynomials ### p.list <- legendre.polynomials( n, TRUE ) ### ### construct the two dimensional list of pair products ### of polynomials ### p.p.products <- lapply( 1:np1, by.column.products, p.list ) ### ### compute the two dimensional list of functions ### corresponding to the polynomial products in ### the two dimensional list p.p.products ### p.p.functions <- lapply( 1:np1, by.column.functions, p.p.products ) ### ### get the rule table for the order np1 polynomial ### rules <- legendre.quadrature.rules( np1, TRUE ) order.np1.rule <- rules[[np1]] ### ### construct the square symmetric matrix containing ### the definite integrals over the default limits ### corresponding to the two dimensional list of ### polynomial functions ### p.p.integrals <- sapply( 1:np1, by.column.integrals, p.p.functions ) ### ### display the matrix of integrals ### print( "Integral of cross products for the orthonormal polynomials " ) print(apply( p.p.integrals, 2, round, digits=5 ) )
### ### this example evaluates the quadrature function for ### the Legendre polynomials. it computes the integral ### of the product for all pairs of orthogonal polynomials ### from order 0 to order 20. the results are compared to ### the diagonal matrix of the inner products for the ### polynomials. it also computes the integral of the product ### of all pairs of orthonormal polynomials from order 0 ### to order 20. the resultant matrix should be an identity matrix ### ### ### set the value for the maximum polynomial order ### n <- 20 ### ### maximum order plus 1 ### np1 <- n + 1 ### ### function to construct the polynomial products by column ### by.column.products <- function( c, p.list, p.p.list ) { ### ### function to construct the polynomial products by row ### by.row.products <- function( r, c, p.list ) { row.column.product <- p.list[[r]] * p.list[[c]] return (row.column.product ) } np1 <- length( p.list ) row.list <- lapply( 1:np1, by.row.products, c, p.list ) return( row.list ) } ### ### function construct the polynomial functions by column ### by.column.functions <- function( c, p.p.products ) { ### ### function to construct the polynomial functions by row ### by.row.functions <- function( r, c, p.p.products ) { row.column.function <- as.function( p.p.products[[r]][[c]] ) return( row.column.function ) } np1 <- length( p.p.products[[1]] ) row.list <- lapply( 1:np1, by.row.functions, c, p.p.products ) return( row.list ) } ### ### function to compute the integral of the polynomials by column ### by.column.integrals <- function( c, p.p.functions ) { ### ### function to compute the integral of the polynomials by row ### by.row.integrals <- function( r, c, p.p.functions ) { row.column.integral <- legendre.quadrature( p.p.functions[[r]][[c]], order.np1.rule ) return( row.column.integral ) } np1 <- length( p.p.functions[[1]] ) row.vector <- sapply( 1:np1, by.row.integrals, c, p.p.functions ) return( row.vector ) } ### ### construct a list of the Legendre orthogonal polynomials ### p.list <- legendre.polynomials( n ) ### ### construct the two dimensional list of pair products ### of polynomials ### p.p.products <- lapply( 1:np1, by.column.products, p.list ) ### ### compute the two dimensional list of functions ### corresponding to the polynomial products in ### the two dimensional list p.p.products ### p.p.functions <- lapply( 1:np1, by.column.functions, p.p.products ) ### ### get the rule table for the order np1 polynomial ### rules <- legendre.quadrature.rules( np1 ) order.np1.rule <- rules[[np1]] ### ### construct the square symmetric matrix containing ### the definite integrals over the default limits ### corresponding to the two dimensional list of ### polynomial functions ### p.p.integrals <- sapply( 1:np1, by.column.integrals, p.p.functions ) ### ### construct the diagonal matrix with the inner products ### of the orthogonal polynomials on the diagonal ### p.p.inner.products <- diag( legendre.inner.products( n ) ) print( "Integral of cross products for the orthogonal polynomials " ) print( apply( p.p.integrals, 2, round, digits=5 ) ) print( apply( p.p.inner.products, 2, round, digits=5 ) ) ### ### construct a list of the Legendre orthonormal polynomials ### p.list <- legendre.polynomials( n, TRUE ) ### ### construct the two dimensional list of pair products ### of polynomials ### p.p.products <- lapply( 1:np1, by.column.products, p.list ) ### ### compute the two dimensional list of functions ### corresponding to the polynomial products in ### the two dimensional list p.p.products ### p.p.functions <- lapply( 1:np1, by.column.functions, p.p.products ) ### ### get the rule table for the order np1 polynomial ### rules <- legendre.quadrature.rules( np1, TRUE ) order.np1.rule <- rules[[np1]] ### ### construct the square symmetric matrix containing ### the definite integrals over the default limits ### corresponding to the two dimensional list of ### polynomial functions ### p.p.integrals <- sapply( 1:np1, by.column.integrals, p.p.functions ) ### ### display the matrix of integrals ### print( "Integral of cross products for the orthonormal polynomials " ) print(apply( p.p.integrals, 2, round, digits=5 ) )
This function returns a list with elements containing
the order
quadrature rule data frame for
the Legendre polynomial
for orders
.
legendre.quadrature.rules(n,normalized=FALSE)
legendre.quadrature.rules(n,normalized=FALSE)
n |
integer value for the highest order |
normalized |
boolean value. if TRUE rules are for orthonormal polynomials, otherwise they are for orthgonal polynomials |
An order quadrature data frame is a named data frame that contains
the roots and abscissa values of the corresponding order
orthogonal polynomial.
The column with name
x
contains the roots or zeros and
the column with name w
contains the weights.
A list with $n$ elements each of which is a data frame
1 |
Quadrature rule data frame for the order 1 Legendre polynomial |
2 |
Quadrature rule data frame for the order 2 Legendre polynomial |
...
n |
Quadrature rule data frame for the order $n$ Legendre polynomial |
Frederick Novomestky [email protected]
Abramowitz and Stegun (1968), Press et. al. (1992)
### ### generate a list of quadrature rule frames for ### the orthogonal Legendre polynomials ### of orders 1 to 5 ### orthogonal.rules <- legendre.quadrature.rules( 5 ) print( orthogonal.rules ) ### ### generate a list of quadrature rule frames for ### the orthonormal Legendre polynomials ### of orders 1 to 5 ### orthonormal.rules <- legendre.quadrature.rules( 5, TRUE ) print( orthonormal.rules )
### ### generate a list of quadrature rule frames for ### the orthogonal Legendre polynomials ### of orders 1 to 5 ### orthogonal.rules <- legendre.quadrature.rules( 5 ) print( orthogonal.rules ) ### ### generate a list of quadrature rule frames for ### the orthonormal Legendre polynomials ### of orders 1 to 5 ### orthonormal.rules <- legendre.quadrature.rules( 5, TRUE ) print( orthonormal.rules )
This function returns a column-named data frame with the given quadrature rules combined into a single object
quadrature.rule.table(rules)
quadrature.rule.table(rules)
rules |
A list of quadrature rule data frames |
The column-named data frame has four columns. The first column is called d
and
it contains the degree of the orthogonal polynomial. The second column is called i
and
it contains the index of the rule for the given polynomial order. The third column is called x
and
it contains the abscissas, roots or zeros of the polynomial of given order.
The fourth column is called w
and it contains the weights associated with the abscissas.
A data frame with the quadrature rules.
Frederick Novomestky [email protected]
Abramowitz, M. and I. A. Stegun, 1968. Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables, Dover Publications, Inc., New York.
Press, W. H., S. A. Teukolsky, W. T. Vetterling, and B. P. Flannery, 1992. Numerical Recipes in C, Cambridge University Press, Cambridge, U.K.
Stroud, A. H., and D. Secrest, 1966. Gaussian Quadrature Formulas, Prentice-Hall, Englewood Cliffs, NJ.
### ### generate the list of quadrature rules for ### the Chebyshev T polynomials ### of orders 1 to 5 ### rules <- chebyshev.t.quadrature.rules( 5 ) ### ### construct the rule table ### rule.table <- quadrature.rule.table( rules ) print( rule.table )
### ### generate the list of quadrature rules for ### the Chebyshev T polynomials ### of orders 1 to 5 ### rules <- chebyshev.t.quadrature.rules( 5 ) ### ### construct the rule table ### rule.table <- quadrature.rule.table( rules ) print( rule.table )
This function returns a list with elements containing
the order $k$ quadrature rule data frames
for orders
.
quadrature.rules(recurrences, inner.products)
quadrature.rules(recurrences, inner.products)
recurrences |
a data frame with the recurrence parameters of a particular orthogonal polynomial |
inner.products |
a numeric vector of normed squared values of the orthogonal polynomials |
An order quadrature data frame is a named data frame that contains
the roots and abscissa values for the quadrature rule based on
an order
orthgonal polynomial.
A list with elements each of which is a quadrature rule data frame
1 |
Quadrature rule for the order 1 orthogonal polynomial |
2 |
Quadrature rule for the order 2 orthogonal polynomial |
...
n |
Quadrature rule for the order |
Frederick Novomestky [email protected]
Abramwitz and Stegun (1968)
### ### get recurrences the Chebyshev T orthgonal polynomials ### of orders 0 to 6\5 ### recurrences <- chebyshev.t.recurrences( 5 ) ### ### get the inner products of these polynomials ### inner.products <- chebyshev.t.inner.products( 5 ) ### ### get the quadrature rules ### rules <- quadrature.rules( recurrences, inner.products ) print( rules )
### ### get recurrences the Chebyshev T orthgonal polynomials ### of orders 0 to 6\5 ### recurrences <- chebyshev.t.recurrences( 5 ) ### ### get the inner products of these polynomials ### inner.products <- chebyshev.t.inner.products( 5 ) ### ### get the quadrature rules ### rules <- quadrature.rules( recurrences, inner.products ) print( rules )
This function evaluates the integral of the given function between the lower and upper limits using the weight and abscissa values specified in the rule data frame. The quadrature formula uses the weight function for shifted Chebyshev T polynomials.
schebyshev.t.quadrature(functn, rule, lower = 0, upper = 1, weighted = TRUE, ...)
schebyshev.t.quadrature(functn, rule, lower = 0, upper = 1, weighted = TRUE, ...)
functn |
an R function which should take a numeric argument x and possibly some parameters. The function returns a numerical vector value for the given argument x. |
rule |
a data frame containing the order |
lower |
numeric value for the lower limit of the integral with a default value of 0 |
upper |
numeric value for the upper limit of the integral with a default value of 1 |
weighted |
boolean value which if true causes the Chebyshev weight function to be included in the integrand |
... |
other arguments passed to the give function |
The rule argument corresponds to an order shifted Chebyshev polynomial,
weight function and interval
.
The lower and upper limits of the integral must be finite.
The value of definite integral evaluated using Gauss Chebyshev quadrature
Frederick Novomestky [email protected]
Abramowitz, M. and I. A. Stegun, 1968. Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables, Dover Publications, Inc., New York.
Press, W. H., S. A. Teukolsky, W. T. Vetterling, and B. P. Flannery, 1992. Numerical Recipes in C, Cambridge University Press, Cambridge, U.K.
Stroud, A. H., and D. Secrest, 1966. Gaussian Quadrature Formulas, Prentice-Hall, Englewood Cliffs, NJ.
### ### this example evaluates the quadrature function for ### the shifted Chebyshev T polynomials. it computes the integral ### of the product for all pairs of orthogonal polynomials ### from order 0 to order 10. the results are compared to ### the diagonal matrix of the inner products for the ### polynomials. it also computes the integral of the product ### of all pairs of orthonormal polynomials from order 0 ### to order 10. the resultant matrix should be an identity matrix ### ### ### set the value for the maximum polynomial order ### n <- 10 ### ### maximum order plus 1 ### np1 <- n + 1 ### ### function to construct the polynomial products by column ### by.column.products <- function( c, p.list, p.p.list ) { ### ### function to construct the polynomial products by row ### by.row.products <- function( r, c, p.list ) { row.column.product <- p.list[[r]] * p.list[[c]] return (row.column.product ) } np1 <- length( p.list ) row.list <- lapply( 1:np1, by.row.products, c, p.list ) return( row.list ) } ### ### function construct the polynomial functions by column ### by.column.functions <- function( c, p.p.products ) { ### ### function to construct the polynomial functions by row ### by.row.functions <- function( r, c, p.p.products ) { row.column.function <- as.function( p.p.products[[r]][[c]] ) return( row.column.function ) } np1 <- length( p.p.products[[1]] ) row.list <- lapply( 1:np1, by.row.functions, c, p.p.products ) return( row.list ) } ### ### function to compute the integral of the polynomials by column ### by.column.integrals <- function( c, p.p.functions ) { ### ### function to compute the integral of the polynomials by row ### by.row.integrals <- function( r, c, p.p.functions ) { row.column.integral <- schebyshev.t.quadrature( p.p.functions[[r]][[c]], order.np1.rule ) return( row.column.integral ) } np1 <- length( p.p.functions[[1]] ) row.vector <- sapply( 1:np1, by.row.integrals, c, p.p.functions ) return( row.vector ) } ### ### construct a list of the shifted Chebyshev T orthogonal polynomials ### p.list <- schebyshev.t.polynomials( n ) ### ### construct the two dimensional list of pair products ### of polynomials ### p.p.products <- lapply( 1:np1, by.column.products, p.list ) ### ### compute the two dimensional list of functions ### corresponding to the polynomial products in ### the two dimensional list p.p.products ### p.p.functions <- lapply( 1:np1, by.column.functions, p.p.products ) ### ### get the rule table for the order np1 polynomial ### rules <- schebyshev.t.quadrature.rules( np1 ) order.np1.rule <- rules[[np1]] ### ### construct the square symmetric matrix containing ### the definite integrals over the default limits ### corresponding to the two dimensional list of ### polynomial functions ### p.p.integrals <- sapply( 1:np1, by.column.integrals, p.p.functions ) ### ### construct the diagonal matrix with the inner products ### of the orthogonal polynomials on the diagonal ### p.p.inner.products <- diag( schebyshev.t.inner.products( n ) ) print( "Integral of cross products for the orthogonal polynomials " ) print( apply( p.p.integrals, 2, round, digits=4 ) ) print( apply( p.p.inner.products, 2, round, digits=4 ) ) ### ### construct a list of the shifted Chebyshev T orthonormal polynomials ### p.list <- schebyshev.t.polynomials( n, TRUE ) ### ### construct the two dimensional list of pair products ### of polynomials ### p.p.products <- lapply( 1:np1, by.column.products, p.list ) ### ### compute the two dimensional list of functions ### corresponding to the polynomial products in ### the two dimensional list p.p.products ### p.p.functions <- lapply( 1:np1, by.column.functions, p.p.products ) ### ### get the rule table for the order np1 polynomial ### rules <- schebyshev.t.quadrature.rules( np1, TRUE ) order.np1.rule <- rules[[np1]] ### ### construct the square symmetric matrix containing ### the definite integrals over the default limits ### corresponding to the two dimensional list of ### polynomial functions ### p.p.integrals <- sapply( 1:np1, by.column.integrals, p.p.functions ) ### ### display the matrix of integrals ### print( "Integral of cross products for the orthonormal polynomials " ) print(apply( p.p.integrals, 2, round, digits=4 ) )
### ### this example evaluates the quadrature function for ### the shifted Chebyshev T polynomials. it computes the integral ### of the product for all pairs of orthogonal polynomials ### from order 0 to order 10. the results are compared to ### the diagonal matrix of the inner products for the ### polynomials. it also computes the integral of the product ### of all pairs of orthonormal polynomials from order 0 ### to order 10. the resultant matrix should be an identity matrix ### ### ### set the value for the maximum polynomial order ### n <- 10 ### ### maximum order plus 1 ### np1 <- n + 1 ### ### function to construct the polynomial products by column ### by.column.products <- function( c, p.list, p.p.list ) { ### ### function to construct the polynomial products by row ### by.row.products <- function( r, c, p.list ) { row.column.product <- p.list[[r]] * p.list[[c]] return (row.column.product ) } np1 <- length( p.list ) row.list <- lapply( 1:np1, by.row.products, c, p.list ) return( row.list ) } ### ### function construct the polynomial functions by column ### by.column.functions <- function( c, p.p.products ) { ### ### function to construct the polynomial functions by row ### by.row.functions <- function( r, c, p.p.products ) { row.column.function <- as.function( p.p.products[[r]][[c]] ) return( row.column.function ) } np1 <- length( p.p.products[[1]] ) row.list <- lapply( 1:np1, by.row.functions, c, p.p.products ) return( row.list ) } ### ### function to compute the integral of the polynomials by column ### by.column.integrals <- function( c, p.p.functions ) { ### ### function to compute the integral of the polynomials by row ### by.row.integrals <- function( r, c, p.p.functions ) { row.column.integral <- schebyshev.t.quadrature( p.p.functions[[r]][[c]], order.np1.rule ) return( row.column.integral ) } np1 <- length( p.p.functions[[1]] ) row.vector <- sapply( 1:np1, by.row.integrals, c, p.p.functions ) return( row.vector ) } ### ### construct a list of the shifted Chebyshev T orthogonal polynomials ### p.list <- schebyshev.t.polynomials( n ) ### ### construct the two dimensional list of pair products ### of polynomials ### p.p.products <- lapply( 1:np1, by.column.products, p.list ) ### ### compute the two dimensional list of functions ### corresponding to the polynomial products in ### the two dimensional list p.p.products ### p.p.functions <- lapply( 1:np1, by.column.functions, p.p.products ) ### ### get the rule table for the order np1 polynomial ### rules <- schebyshev.t.quadrature.rules( np1 ) order.np1.rule <- rules[[np1]] ### ### construct the square symmetric matrix containing ### the definite integrals over the default limits ### corresponding to the two dimensional list of ### polynomial functions ### p.p.integrals <- sapply( 1:np1, by.column.integrals, p.p.functions ) ### ### construct the diagonal matrix with the inner products ### of the orthogonal polynomials on the diagonal ### p.p.inner.products <- diag( schebyshev.t.inner.products( n ) ) print( "Integral of cross products for the orthogonal polynomials " ) print( apply( p.p.integrals, 2, round, digits=4 ) ) print( apply( p.p.inner.products, 2, round, digits=4 ) ) ### ### construct a list of the shifted Chebyshev T orthonormal polynomials ### p.list <- schebyshev.t.polynomials( n, TRUE ) ### ### construct the two dimensional list of pair products ### of polynomials ### p.p.products <- lapply( 1:np1, by.column.products, p.list ) ### ### compute the two dimensional list of functions ### corresponding to the polynomial products in ### the two dimensional list p.p.products ### p.p.functions <- lapply( 1:np1, by.column.functions, p.p.products ) ### ### get the rule table for the order np1 polynomial ### rules <- schebyshev.t.quadrature.rules( np1, TRUE ) order.np1.rule <- rules[[np1]] ### ### construct the square symmetric matrix containing ### the definite integrals over the default limits ### corresponding to the two dimensional list of ### polynomial functions ### p.p.integrals <- sapply( 1:np1, by.column.integrals, p.p.functions ) ### ### display the matrix of integrals ### print( "Integral of cross products for the orthonormal polynomials " ) print(apply( p.p.integrals, 2, round, digits=4 ) )
This function returns a list with elements containing
the order
quadrature rule data frame for
the shifted Chebyshev T polynomial
for orders
.
schebyshev.t.quadrature.rules(n,normalized=FALSE)
schebyshev.t.quadrature.rules(n,normalized=FALSE)
n |
integer value for the highest order |
normalized |
boolean value. if TRUE rules are for orthonormal polynomials, otherwise they are for orthgonal polynomials |
An order quadrature data frame is a named data frame that contains
the roots and abscissa values of the corresponding order
orthogonal polynomial.
The column with name
x
contains the roots or zeros and
the column with name w
contains the weights.
A list with elements each of which is a data frame
1 |
Quadrature rule data frame for the order 1 shifted Chebyshev polynomial |
2 |
Quadrature rule data frame for the order 2 shifted Chebyshev polynomial |
...
n |
Quadrature rule data frame for the order |
Frederick Novomestky [email protected]
Abramowitz, M. and I. A. Stegun, 1968. Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables, Dover Publications, Inc., New York.
Press, W. H., S. A. Teukolsky, W. T. Vetterling, and B. P. Flannery, 1992. Numerical Recipes in C, Cambridge University Press, Cambridge, U.K.
Stroud, A. H., and D. Secrest, 1966. Gaussian Quadrature Formulas, Prentice-Hall, Englewood Cliffs, NJ.
quadrature.rules
,
schebyshev.t.quadrature
### ### construct a list of quadrature rule data frames for ### the shifted orthogonal Chebyshev T polynomials ### of orders 1 to 5 ### orthogonal.rules <- schebyshev.t.quadrature.rules( 5 ) print( orthogonal.rules ) ### ### construct a list of quadrature rule data frames for ### the shifted orthonormal Chebyshev T polynomials ### of orders 1 to 5 ### orthonormal.rules <- schebyshev.t.quadrature.rules( 5, TRUE ) print( orthonormal.rules )
### ### construct a list of quadrature rule data frames for ### the shifted orthogonal Chebyshev T polynomials ### of orders 1 to 5 ### orthogonal.rules <- schebyshev.t.quadrature.rules( 5 ) print( orthogonal.rules ) ### ### construct a list of quadrature rule data frames for ### the shifted orthonormal Chebyshev T polynomials ### of orders 1 to 5 ### orthonormal.rules <- schebyshev.t.quadrature.rules( 5, TRUE ) print( orthonormal.rules )
This function evaluates the integral of the given function between the lower and upper limits using the weight and abscissa values specified in the rule data frame. The quadrature formula uses the weight function for shifted Chebyshev U polynomials.
schebyshev.u.quadrature(functn, rule, lower = 0, upper = 1, weighted = TRUE, ...)
schebyshev.u.quadrature(functn, rule, lower = 0, upper = 1, weighted = TRUE, ...)
functn |
an R function which should take a numeric argument x and possibly some parameters. The function returns a numerical vector value for the given argument x. |
rule |
a data frame containing the order |
lower |
numeric value for the lower limit of the integral with a default value of 0 |
upper |
numeric value for the upper limit of the integral with a default value of 1 |
weighted |
a boolean value which if true causes the Chebyshev weight function to be included in the integrand |
... |
other arguments passed to the give function |
The rule argument corresponds to an order shifted Chebyshev polynomial,
weight function and interval
.
The lower and upper limits of the integral must be finite.
The value of definite integral evaluated using Gauss shifted Chebyshev quadrature
Frederick Novomestky [email protected]
Abramowitz, M. and I. A. Stegun, 1968. Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables, Dover Publications, Inc., New York.
Press, W. H., S. A. Teukolsky, W. T. Vetterling, and B. P. Flannery, 1992. Numerical Recipes in C, Cambridge University Press, Cambridge, U.K.
Stroud, A. H., and D. Secrest, 1966. Gaussian Quadrature Formulas, Prentice-Hall, Englewood Cliffs, NJ.
### ### this example evaluates the quadrature function for ### the shifted Chebyshev U polynomials. it computes the integral ### of the product for all pairs of orthogonal polynomials ### from order 0 to order 10. the results are compared to ### the diagonal matrix of the inner products for the ### polynomials. it also computes the integral of the product ### of all pairs of orthonormal polynomials from order 0 ### to order 10. the resultant matrix should be an identity matrix ### ### ### set the value for the maximum polynomial order ### n <- 10 ### ### maximum order plus 1 ### np1 <- n + 1 ### ### function to construct the polynomial products by column ### by.column.products <- function( c, p.list, p.p.list ) { ### ### function to construct the polynomial products by row ### by.row.products <- function( r, c, p.list ) { row.column.product <- p.list[[r]] * p.list[[c]] return (row.column.product ) } np1 <- length( p.list ) row.list <- lapply( 1:np1, by.row.products, c, p.list ) return( row.list ) } ### ### function construct the polynomial functions by column ### by.column.functions <- function( c, p.p.products ) { ### ### function to construct the polynomial functions by row ### by.row.functions <- function( r, c, p.p.products ) { row.column.function <- as.function( p.p.products[[r]][[c]] ) return( row.column.function ) } np1 <- length( p.p.products[[1]] ) row.list <- lapply( 1:np1, by.row.functions, c, p.p.products ) return( row.list ) } ### ### function to compute the integral of the polynomials by column ### by.column.integrals <- function( c, p.p.functions ) { ### ### function to compute the integral of the polynomials by row ### by.row.integrals <- function( r, c, p.p.functions ) { row.column.integral <- schebyshev.u.quadrature( p.p.functions[[r]][[c]], order.np1.rule ) return( row.column.integral ) } np1 <- length( p.p.functions[[1]] ) row.vector <- sapply( 1:np1, by.row.integrals, c, p.p.functions ) return( row.vector ) } ### ### construct a list of the shifted Chebyshev U orthogonal polynomials ### p.list <- schebyshev.u.polynomials( n ) ### ### construct the two dimensional list of pair products ### of polynomials ### p.p.products <- lapply( 1:np1, by.column.products, p.list ) ### ### compute the two dimensional list of functions ### corresponding to the polynomial products in ### the two dimensional list p.p.products ### p.p.functions <- lapply( 1:np1, by.column.functions, p.p.products ) ### ### get the rule table for the order np1 polynomial ### rules <- schebyshev.u.quadrature.rules( np1 ) order.np1.rule <- rules[[np1]] ### ### construct the square symmetric matrix containing ### the definite integrals over the default limits ### corresponding to the two dimensional list of ### polynomial functions ### p.p.integrals <- sapply( 1:np1, by.column.integrals, p.p.functions ) ### ### construct the diagonal matrix with the inner products ### of the orthogonal polynomials on the diagonal ### p.p.inner.products <- diag( schebyshev.u.inner.products( n ) ) print( "Integral of cross products for the orthogonal polynomials " ) print( apply( p.p.integrals, 2, round, digits=4 ) ) print( apply( p.p.inner.products, 2, round, digits=4 ) ) ### ### construct a list of the shifted Chebyshev U orthonormal polynomials ### p.list <- schebyshev.u.polynomials( n, TRUE ) ### ### construct the two dimensional list of pair products ### of polynomials ### p.p.products <- lapply( 1:np1, by.column.products, p.list ) ### ### compute the two dimensional list of functions ### corresponding to the polynomial products in ### the two dimensional list p.p.products ### p.p.functions <- lapply( 1:np1, by.column.functions, p.p.products ) ### ### get the rule table for the order np1 polynomial ### rules <- schebyshev.u.quadrature.rules( np1, TRUE ) order.np1.rule <- rules[[np1]] ### ### construct the square symmetric matrix containing ### the definite integrals over the default limits ### corresponding to the two dimensional list of ### polynomial functions ### p.p.integrals <- sapply( 1:np1, by.column.integrals, p.p.functions ) ### ### display the matrix of integrals ### print( "Integral of cross products for the orthonormal polynomials " ) print(apply( p.p.integrals, 2, round, digits=4 ) )
### ### this example evaluates the quadrature function for ### the shifted Chebyshev U polynomials. it computes the integral ### of the product for all pairs of orthogonal polynomials ### from order 0 to order 10. the results are compared to ### the diagonal matrix of the inner products for the ### polynomials. it also computes the integral of the product ### of all pairs of orthonormal polynomials from order 0 ### to order 10. the resultant matrix should be an identity matrix ### ### ### set the value for the maximum polynomial order ### n <- 10 ### ### maximum order plus 1 ### np1 <- n + 1 ### ### function to construct the polynomial products by column ### by.column.products <- function( c, p.list, p.p.list ) { ### ### function to construct the polynomial products by row ### by.row.products <- function( r, c, p.list ) { row.column.product <- p.list[[r]] * p.list[[c]] return (row.column.product ) } np1 <- length( p.list ) row.list <- lapply( 1:np1, by.row.products, c, p.list ) return( row.list ) } ### ### function construct the polynomial functions by column ### by.column.functions <- function( c, p.p.products ) { ### ### function to construct the polynomial functions by row ### by.row.functions <- function( r, c, p.p.products ) { row.column.function <- as.function( p.p.products[[r]][[c]] ) return( row.column.function ) } np1 <- length( p.p.products[[1]] ) row.list <- lapply( 1:np1, by.row.functions, c, p.p.products ) return( row.list ) } ### ### function to compute the integral of the polynomials by column ### by.column.integrals <- function( c, p.p.functions ) { ### ### function to compute the integral of the polynomials by row ### by.row.integrals <- function( r, c, p.p.functions ) { row.column.integral <- schebyshev.u.quadrature( p.p.functions[[r]][[c]], order.np1.rule ) return( row.column.integral ) } np1 <- length( p.p.functions[[1]] ) row.vector <- sapply( 1:np1, by.row.integrals, c, p.p.functions ) return( row.vector ) } ### ### construct a list of the shifted Chebyshev U orthogonal polynomials ### p.list <- schebyshev.u.polynomials( n ) ### ### construct the two dimensional list of pair products ### of polynomials ### p.p.products <- lapply( 1:np1, by.column.products, p.list ) ### ### compute the two dimensional list of functions ### corresponding to the polynomial products in ### the two dimensional list p.p.products ### p.p.functions <- lapply( 1:np1, by.column.functions, p.p.products ) ### ### get the rule table for the order np1 polynomial ### rules <- schebyshev.u.quadrature.rules( np1 ) order.np1.rule <- rules[[np1]] ### ### construct the square symmetric matrix containing ### the definite integrals over the default limits ### corresponding to the two dimensional list of ### polynomial functions ### p.p.integrals <- sapply( 1:np1, by.column.integrals, p.p.functions ) ### ### construct the diagonal matrix with the inner products ### of the orthogonal polynomials on the diagonal ### p.p.inner.products <- diag( schebyshev.u.inner.products( n ) ) print( "Integral of cross products for the orthogonal polynomials " ) print( apply( p.p.integrals, 2, round, digits=4 ) ) print( apply( p.p.inner.products, 2, round, digits=4 ) ) ### ### construct a list of the shifted Chebyshev U orthonormal polynomials ### p.list <- schebyshev.u.polynomials( n, TRUE ) ### ### construct the two dimensional list of pair products ### of polynomials ### p.p.products <- lapply( 1:np1, by.column.products, p.list ) ### ### compute the two dimensional list of functions ### corresponding to the polynomial products in ### the two dimensional list p.p.products ### p.p.functions <- lapply( 1:np1, by.column.functions, p.p.products ) ### ### get the rule table for the order np1 polynomial ### rules <- schebyshev.u.quadrature.rules( np1, TRUE ) order.np1.rule <- rules[[np1]] ### ### construct the square symmetric matrix containing ### the definite integrals over the default limits ### corresponding to the two dimensional list of ### polynomial functions ### p.p.integrals <- sapply( 1:np1, by.column.integrals, p.p.functions ) ### ### display the matrix of integrals ### print( "Integral of cross products for the orthonormal polynomials " ) print(apply( p.p.integrals, 2, round, digits=4 ) )
This function returns a list with elements containing
the order
quadrature rule data frame for
the shifted Chebyshev U polynomial of the first kind
for orders
.
schebyshev.u.quadrature.rules(n,normalized=FALSE)
schebyshev.u.quadrature.rules(n,normalized=FALSE)
n |
integer value for the highest order |
normalized |
boolean value. if TRUE rules are for orthonormal polynomials, otherwise they are for orthgonal polynomials |
An order quadrature data frame is a named data frame that contains
the roots and abscissa values of the corresponding order
orthogonal polynomial.
The column with name
x
contains the roots or zeros and
the column with name w
contains the weights.
A list with elements each of which is a data frame
1 |
Quadrature rule data frame for the order 1 shifted Chebyshev polynomial |
2 |
Quadrature rule data frame for the order 2 shifted Chebyshev polynomial |
...
n |
Quadrature rule data frame for the order |
Frederick Novomestky [email protected]
Abramowitz, M. and I. A. Stegun, 1968. Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables, Dover Publications, Inc., New York.
Press, W. H., S. A. Teukolsky, W. T. Vetterling, and B. P. Flannery, 1992. Numerical Recipes in C, Cambridge University Press, Cambridge, U.K.
Stroud, A. H., and D. Secrest, 1966. Gaussian Quadrature Formulas, Prentice-Hall, Englewood Cliffs, NJ.
quadrature.rules
,
schebyshev.u.quadrature
### ### generate the quadrature rules for ### the shifted Chebyshev U orthogonal polynomials ### of orders 1 to 5 ### orthogonal.rules <- schebyshev.u.quadrature.rules( 5 ) print( orthogonal.rules ) ### ### generate the quadrature rules for ### the shifted Chebyshev U orthonormal polynomials ### of orders 1 to 5 ### orthonormal.rules <- schebyshev.u.quadrature.rules( 5 ) print( orthonormal.rules )
### ### generate the quadrature rules for ### the shifted Chebyshev U orthogonal polynomials ### of orders 1 to 5 ### orthogonal.rules <- schebyshev.u.quadrature.rules( 5 ) print( orthogonal.rules ) ### ### generate the quadrature rules for ### the shifted Chebyshev U orthonormal polynomials ### of orders 1 to 5 ### orthonormal.rules <- schebyshev.u.quadrature.rules( 5 ) print( orthonormal.rules )
This function evaluates the integral of the given function between the lower and upper limits using the weight and abscissa values specified in the rule data frame. The quadrature formula uses the weight function for shifted Legendre polynomials.
slegendre.quadrature(functn, rule, lower = 0, upper = 1, weighted = TRUE, ...)
slegendre.quadrature(functn, rule, lower = 0, upper = 1, weighted = TRUE, ...)
functn |
an R FUnction which should take a numeric argument x and possibly some parameters. The function returns a numerical vector value for the given argument x. |
rule |
a data frame containing the order |
lower |
a numeric value for the lower limit of the integral with a default value of 0 |
upper |
a numeric value for the upper limit of the integral with a default value of 1 |
weighted |
a boolean value which if true causes the shifted Legendre weight function to be included in the integrand |
... |
other arguments passed to the give function |
The rule argument corresponds to an order shifted Legendre polynomial,
weight function and interval
.
The lower and upper limits of the integral must be finite.
The value of definite integral evaluated using Gauss Legendre quadrature
Frederick Novomestky [email protected]
Abramowitz, M. and I. A. Stegun, 1968. Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables, Dover Publications, Inc., New York.
Press, W. H., S. A. Teukolsky, W. T. Vetterling, and B. P. Flannery, 1992. Numerical Recipes in C, Cambridge University Press, Cambridge, U.K.
Stroud, A. H., and D. Secrest, 1966. Gaussian Quadrature Formulas, Prentice-Hall, Englewood Cliffs, NJ.
### ### this example evaluates the quadrature function for ### the shifted Legendre polynomials. it computes the integral ### of the product for all pairs of orthogonal polynomials ### from order 0 to order 10. the results are compared to ### the diagonal matrix of the inner products for the ### polynomials. it also computes the integral of the product ### of all pairs of orthonormal polynomials from order 0 ### to order 10. the resultant matrix should be an identity matrix ### ### ### set the value for the maximum polynomial order ### n <- 10 ### ### maximum order plus 1 ### np1 <- n + 1 ### ### function to construct the polynomial products by column ### by.column.products <- function( c, p.list, p.p.list ) { ### ### function to construct the polynomial products by row ### by.row.products <- function( r, c, p.list ) { row.column.product <- p.list[[r]] * p.list[[c]] return (row.column.product ) } np1 <- length( p.list ) row.list <- lapply( 1:np1, by.row.products, c, p.list ) return( row.list ) } ### ### function construct the polynomial functions by column ### by.column.functions <- function( c, p.p.products ) { ### ### function to construct the polynomial functions by row ### by.row.functions <- function( r, c, p.p.products ) { row.column.function <- as.function( p.p.products[[r]][[c]] ) return( row.column.function ) } np1 <- length( p.p.products[[1]] ) row.list <- lapply( 1:np1, by.row.functions, c, p.p.products ) return( row.list ) } ### ### function to compute the integral of the polynomials by column ### by.column.integrals <- function( c, p.p.functions ) { ### ### function to compute the integral of the polynomials by row ### by.row.integrals <- function( r, c, p.p.functions ) { row.column.integral <- slegendre.quadrature( p.p.functions[[r]][[c]], order.np1.rule ) return( row.column.integral ) } np1 <- length( p.p.functions[[1]] ) row.vector <- sapply( 1:np1, by.row.integrals, c, p.p.functions ) return( row.vector ) } ### ### construct a list of the shifted Legendre orthogonal polynomials ### p.list <- slegendre.polynomials( n ) ### ### construct the two dimensional list of pair products ### of polynomials ### p.p.products <- lapply( 1:np1, by.column.products, p.list ) ### ### compute the two dimensional list of functions ### corresponding to the polynomial products in ### the two dimensional list p.p.products ### p.p.functions <- lapply( 1:np1, by.column.functions, p.p.products ) ### ### get the rule table for the order np1 polynomial ### rules <- slegendre.quadrature.rules( np1 ) order.np1.rule <- rules[[np1]] ### ### construct the square symmetric matrix containing ### the definite integrals over the default limits ### corresponding to the two dimensional list of ### polynomial functions ### p.p.integrals <- sapply( 1:np1, by.column.integrals, p.p.functions ) ### ### construct the diagonal matrix with the inner products ### of the orthogonal polynomials on the diagonal ### p.p.inner.products <- diag( slegendre.inner.products( n ) ) print( "Integral of cross products for the orthogonal polynomials " ) print( apply( p.p.integrals, 2, round, digits=5 ) ) print( apply( p.p.inner.products, 2, round, digits=5 ) ) ### ### construct a list of the shifted Legendre orthonormal polynomials ### p.list <- slegendre.polynomials( n, TRUE ) ### ### construct the two dimensional list of pair products ### of polynomials ### p.p.products <- lapply( 1:np1, by.column.products, p.list ) ### ### compute the two dimensional list of functions ### corresponding to the polynomial products in ### the two dimensional list p.p.products ### p.p.functions <- lapply( 1:np1, by.column.functions, p.p.products ) ### ### get the rule table for the order np1 polynomial ### rules <- slegendre.quadrature.rules( np1, TRUE ) order.np1.rule <- rules[[np1]] ### ### construct the square symmetric matrix containing ### the definite integrals over the default limits ### corresponding to the two dimensional list of ### polynomial functions ### p.p.integrals <- sapply( 1:np1, by.column.integrals, p.p.functions ) ### ### display the matrix of integrals ### print( "Integral of cross products for the orthonormal polynomials " ) print(apply( p.p.integrals, 2, round, digits=5 ) )
### ### this example evaluates the quadrature function for ### the shifted Legendre polynomials. it computes the integral ### of the product for all pairs of orthogonal polynomials ### from order 0 to order 10. the results are compared to ### the diagonal matrix of the inner products for the ### polynomials. it also computes the integral of the product ### of all pairs of orthonormal polynomials from order 0 ### to order 10. the resultant matrix should be an identity matrix ### ### ### set the value for the maximum polynomial order ### n <- 10 ### ### maximum order plus 1 ### np1 <- n + 1 ### ### function to construct the polynomial products by column ### by.column.products <- function( c, p.list, p.p.list ) { ### ### function to construct the polynomial products by row ### by.row.products <- function( r, c, p.list ) { row.column.product <- p.list[[r]] * p.list[[c]] return (row.column.product ) } np1 <- length( p.list ) row.list <- lapply( 1:np1, by.row.products, c, p.list ) return( row.list ) } ### ### function construct the polynomial functions by column ### by.column.functions <- function( c, p.p.products ) { ### ### function to construct the polynomial functions by row ### by.row.functions <- function( r, c, p.p.products ) { row.column.function <- as.function( p.p.products[[r]][[c]] ) return( row.column.function ) } np1 <- length( p.p.products[[1]] ) row.list <- lapply( 1:np1, by.row.functions, c, p.p.products ) return( row.list ) } ### ### function to compute the integral of the polynomials by column ### by.column.integrals <- function( c, p.p.functions ) { ### ### function to compute the integral of the polynomials by row ### by.row.integrals <- function( r, c, p.p.functions ) { row.column.integral <- slegendre.quadrature( p.p.functions[[r]][[c]], order.np1.rule ) return( row.column.integral ) } np1 <- length( p.p.functions[[1]] ) row.vector <- sapply( 1:np1, by.row.integrals, c, p.p.functions ) return( row.vector ) } ### ### construct a list of the shifted Legendre orthogonal polynomials ### p.list <- slegendre.polynomials( n ) ### ### construct the two dimensional list of pair products ### of polynomials ### p.p.products <- lapply( 1:np1, by.column.products, p.list ) ### ### compute the two dimensional list of functions ### corresponding to the polynomial products in ### the two dimensional list p.p.products ### p.p.functions <- lapply( 1:np1, by.column.functions, p.p.products ) ### ### get the rule table for the order np1 polynomial ### rules <- slegendre.quadrature.rules( np1 ) order.np1.rule <- rules[[np1]] ### ### construct the square symmetric matrix containing ### the definite integrals over the default limits ### corresponding to the two dimensional list of ### polynomial functions ### p.p.integrals <- sapply( 1:np1, by.column.integrals, p.p.functions ) ### ### construct the diagonal matrix with the inner products ### of the orthogonal polynomials on the diagonal ### p.p.inner.products <- diag( slegendre.inner.products( n ) ) print( "Integral of cross products for the orthogonal polynomials " ) print( apply( p.p.integrals, 2, round, digits=5 ) ) print( apply( p.p.inner.products, 2, round, digits=5 ) ) ### ### construct a list of the shifted Legendre orthonormal polynomials ### p.list <- slegendre.polynomials( n, TRUE ) ### ### construct the two dimensional list of pair products ### of polynomials ### p.p.products <- lapply( 1:np1, by.column.products, p.list ) ### ### compute the two dimensional list of functions ### corresponding to the polynomial products in ### the two dimensional list p.p.products ### p.p.functions <- lapply( 1:np1, by.column.functions, p.p.products ) ### ### get the rule table for the order np1 polynomial ### rules <- slegendre.quadrature.rules( np1, TRUE ) order.np1.rule <- rules[[np1]] ### ### construct the square symmetric matrix containing ### the definite integrals over the default limits ### corresponding to the two dimensional list of ### polynomial functions ### p.p.integrals <- sapply( 1:np1, by.column.integrals, p.p.functions ) ### ### display the matrix of integrals ### print( "Integral of cross products for the orthonormal polynomials " ) print(apply( p.p.integrals, 2, round, digits=5 ) )
This function returns a list with elements containing
the order
quadrature rule data frame for
the shifted Legendre polynomials
for orders
.
slegendre.quadrature.rules(n,normalized=FALSE)
slegendre.quadrature.rules(n,normalized=FALSE)
n |
integer value for the highest order |
normalized |
boolean value. if TRUE rules are for orthonormal polynomials, otherwise they are for orthgonal polynomials |
An order quadrature data frame is a named data frame that contains
the roots and abscissa values of the corresponding order
orthogonal polynomial.
The column with name
x
contains the roots or zeros and
the column with name w
contains the weights.
A list with elements each of which is a data frame
1 |
Quadrature rule data frame for the order 1 shifted Legendre polynomial |
2 |
Quadrature rule data frame for the order 2 shifted Legendre polynomial |
...
n |
Quadrature rule data frame for the order |
Frederick Novomestky [email protected]
Abramowitz, M. and I. A. Stegun, 1968. Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables, Dover Publications, Inc., New York.
Press, W. H., S. A. Teukolsky, W. T. Vetterling, and B. P. Flannery, 1992. Numerical Recipes in C, Cambridge University Press, Cambridge, U.K.
Stroud, A. H., and D. Secrest, 1966. Gaussian Quadrature Formulas, Prentice-Hall, Englewood Cliffs, NJ.
quadrature.rules
,
slegendre.quadrature
### ### generate the list of shifted Legendre quadrature rules ### for orders 1 to 5 for the orthogonal polynomials ### orthogonal.rules <- slegendre.quadrature.rules( 5 ) print( orthogonal.rules ) ### ### generate the list of shifted Legendre quadrature rules ### for orders 1 to 5 for the orthonormal polynomials ### orthonormal.rules <- slegendre.quadrature.rules( 5, TRUE ) print( orthonormal.rules )
### ### generate the list of shifted Legendre quadrature rules ### for orders 1 to 5 for the orthogonal polynomials ### orthogonal.rules <- slegendre.quadrature.rules( 5 ) print( orthogonal.rules ) ### ### generate the list of shifted Legendre quadrature rules ### for orders 1 to 5 for the orthonormal polynomials ### orthonormal.rules <- slegendre.quadrature.rules( 5, TRUE ) print( orthonormal.rules )
This function evaluates the integral of the given function between the lower and upper limits using the weight and abscissa values specified in the rule data frame. The quadrature formula uses the weight function for spherical polynomials.
spherical.quadrature(functn, rule, lower = -1, upper = 1, weighted = TRUE, ...)
spherical.quadrature(functn, rule, lower = -1, upper = 1, weighted = TRUE, ...)
functn |
an R function which should take a numeric argument x and possibly some parameters. The function returns a numerical vector value for the given argument x. |
rule |
a data frame containing the order |
lower |
numeric value for the lower limit of the integral with a default value of -1 |
upper |
numeric value for the upper limit of the integral with a default value of +1 |
weighted |
boolean value which if true causes the Legendre weight function to be included in the integrand |
... |
other arguments passed to the give function |
The rule argument corresponds to an order spherical polynomial,
weight function and interval
.
The lower and upper limits of the integral must be finite.
The value of definite integral evaluated using Gauss Legendre quadrature
Frederick Novomestky [email protected]
Abramowitz, M. and I. A. Stegun, 1968. Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables, Dover Publications, Inc., New York.
Press, W. H., S. A. Teukolsky, W. T. Vetterling, and B. P. Flannery, 1992. Numerical Recipes in C, Cambridge University Press, Cambridge, U.K.
Stroud, A. H., and D. Secrest, 1966. Gaussian Quadrature Formulas, Prentice-Hall, Englewood Cliffs, NJ.
### ### this example evaluates the quadrature function for ### the Chebyshev C polynomials. it computes the integral ### of the product for all pairs of orthogonal polynomials ### from order 0 to order 16. the results are compared to ### the diagonal matrix of the inner products for the ### polynomials. it also computes the integral of the product ### of all pairs of orthonormal polynomials from order 0 ### to order 16. the resultant matrix should be an identity matrix ### ### ### set the value for the maximum polynomial order ### n <- 16 ### ### maximum order plus 1 ### np1 <- n + 1 ### ### function to construct the polynomial products by column ### by.column.products <- function( c, p.list, p.p.list ) { ### ### function to construct the polynomial products by row ### by.row.products <- function( r, c, p.list ) { row.column.product <- p.list[[r]] * p.list[[c]] return (row.column.product ) } np1 <- length( p.list ) row.list <- lapply( 1:np1, by.row.products, c, p.list ) return( row.list ) } ### ### function construct the polynomial functions by column ### by.column.functions <- function( c, p.p.products ) { ### ### function to construct the polynomial functions by row ### by.row.functions <- function( r, c, p.p.products ) { row.column.function <- as.function( p.p.products[[r]][[c]] ) return( row.column.function ) } np1 <- length( p.p.products[[1]] ) row.list <- lapply( 1:np1, by.row.functions, c, p.p.products ) return( row.list ) } ### ### function to compute the integral of the polynomials by column ### by.column.integrals <- function( c, p.p.functions ) { ### ### function to compute the integral of the polynomials by row ### by.row.integrals <- function( r, c, p.p.functions ) { row.column.integral <- chebyshev.c.quadrature( p.p.functions[[r]][[c]], order.np1.rule ) return( row.column.integral ) } np1 <- length( p.p.functions[[1]] ) row.vector <- sapply( 1:np1, by.row.integrals, c, p.p.functions ) return( row.vector ) } ### ### construct a list of the Chebyshev C orthogonal polynomials ### p.list <- chebyshev.c.polynomials( n ) ### ### construct the two dimensional list of pair products ### of polynomials ### p.p.products <- lapply( 1:np1, by.column.products, p.list ) ### ### compute the two dimensional list of functions ### corresponding to the polynomial products in ### the two dimensional list p.p.products ### p.p.functions <- lapply( 1:np1, by.column.functions, p.p.products ) ### ### get the rule table for the order np1 polynomial ### rules <- chebyshev.c.quadrature.rules( np1 ) order.np1.rule <- rules[[np1]] ### ### construct the square symmetric matrix containing ### the definite integrals over the default limits ### corresponding to the two dimensional list of ### polynomial functions ### p.p.integrals <- sapply( 1:np1, by.column.integrals, p.p.functions ) ### ### construct the diagonal matrix with the inner products ### of the orthogonal polynomials on the diagonal ### p.p.inner.products <- diag( chebyshev.c.inner.products( n ) ) print( "Integral of cross products for the orthogonal polynomials " ) print( apply( p.p.integrals, 2, round, digits=5 ) ) print( apply( p.p.inner.products, 2, round, digits=5 ) ) ### ### construct a list of the Chebyshev C orthonormal polynomials ### p.list <- chebyshev.c.polynomials( n, TRUE ) ### ### construct the two dimensional list of pair products ### of polynomials ### p.p.products <- lapply( 1:np1, by.column.products, p.list ) ### ### compute the two dimensional list of functions ### corresponding to the polynomial products in ### the two dimensional list p.p.products ### p.p.functions <- lapply( 1:np1, by.column.functions, p.p.products ) ### ### get the rule table for the order np1 polynomial ### rules <- chebyshev.c.quadrature.rules( np1, TRUE ) order.np1.rule <- rules[[np1]] ### ### construct the square symmetric matrix containing ### the definite integrals over the default limits ### corresponding to the two dimensional list of ### polynomial functions ### p.p.integrals <- sapply( 1:np1, by.column.integrals, p.p.functions ) ### ### display the matrix of integrals ### print( "Integral of cross products for the orthonormal polynomials " ) print(apply( p.p.integrals, 2, round, digits=5 ) )
### ### this example evaluates the quadrature function for ### the Chebyshev C polynomials. it computes the integral ### of the product for all pairs of orthogonal polynomials ### from order 0 to order 16. the results are compared to ### the diagonal matrix of the inner products for the ### polynomials. it also computes the integral of the product ### of all pairs of orthonormal polynomials from order 0 ### to order 16. the resultant matrix should be an identity matrix ### ### ### set the value for the maximum polynomial order ### n <- 16 ### ### maximum order plus 1 ### np1 <- n + 1 ### ### function to construct the polynomial products by column ### by.column.products <- function( c, p.list, p.p.list ) { ### ### function to construct the polynomial products by row ### by.row.products <- function( r, c, p.list ) { row.column.product <- p.list[[r]] * p.list[[c]] return (row.column.product ) } np1 <- length( p.list ) row.list <- lapply( 1:np1, by.row.products, c, p.list ) return( row.list ) } ### ### function construct the polynomial functions by column ### by.column.functions <- function( c, p.p.products ) { ### ### function to construct the polynomial functions by row ### by.row.functions <- function( r, c, p.p.products ) { row.column.function <- as.function( p.p.products[[r]][[c]] ) return( row.column.function ) } np1 <- length( p.p.products[[1]] ) row.list <- lapply( 1:np1, by.row.functions, c, p.p.products ) return( row.list ) } ### ### function to compute the integral of the polynomials by column ### by.column.integrals <- function( c, p.p.functions ) { ### ### function to compute the integral of the polynomials by row ### by.row.integrals <- function( r, c, p.p.functions ) { row.column.integral <- chebyshev.c.quadrature( p.p.functions[[r]][[c]], order.np1.rule ) return( row.column.integral ) } np1 <- length( p.p.functions[[1]] ) row.vector <- sapply( 1:np1, by.row.integrals, c, p.p.functions ) return( row.vector ) } ### ### construct a list of the Chebyshev C orthogonal polynomials ### p.list <- chebyshev.c.polynomials( n ) ### ### construct the two dimensional list of pair products ### of polynomials ### p.p.products <- lapply( 1:np1, by.column.products, p.list ) ### ### compute the two dimensional list of functions ### corresponding to the polynomial products in ### the two dimensional list p.p.products ### p.p.functions <- lapply( 1:np1, by.column.functions, p.p.products ) ### ### get the rule table for the order np1 polynomial ### rules <- chebyshev.c.quadrature.rules( np1 ) order.np1.rule <- rules[[np1]] ### ### construct the square symmetric matrix containing ### the definite integrals over the default limits ### corresponding to the two dimensional list of ### polynomial functions ### p.p.integrals <- sapply( 1:np1, by.column.integrals, p.p.functions ) ### ### construct the diagonal matrix with the inner products ### of the orthogonal polynomials on the diagonal ### p.p.inner.products <- diag( chebyshev.c.inner.products( n ) ) print( "Integral of cross products for the orthogonal polynomials " ) print( apply( p.p.integrals, 2, round, digits=5 ) ) print( apply( p.p.inner.products, 2, round, digits=5 ) ) ### ### construct a list of the Chebyshev C orthonormal polynomials ### p.list <- chebyshev.c.polynomials( n, TRUE ) ### ### construct the two dimensional list of pair products ### of polynomials ### p.p.products <- lapply( 1:np1, by.column.products, p.list ) ### ### compute the two dimensional list of functions ### corresponding to the polynomial products in ### the two dimensional list p.p.products ### p.p.functions <- lapply( 1:np1, by.column.functions, p.p.products ) ### ### get the rule table for the order np1 polynomial ### rules <- chebyshev.c.quadrature.rules( np1, TRUE ) order.np1.rule <- rules[[np1]] ### ### construct the square symmetric matrix containing ### the definite integrals over the default limits ### corresponding to the two dimensional list of ### polynomial functions ### p.p.integrals <- sapply( 1:np1, by.column.integrals, p.p.functions ) ### ### display the matrix of integrals ### print( "Integral of cross products for the orthonormal polynomials " ) print(apply( p.p.integrals, 2, round, digits=5 ) )
This function returns a list with elements containing
the order
quadrature rule data frame for
the shperical polynomial
for orders
.
spherical.quadrature.rules(n,normalized=FALSE)
spherical.quadrature.rules(n,normalized=FALSE)
n |
integer value for the highest order |
normalized |
boolean value. if TRUE rules are for orthonormal polynomials, otherwise they are for orthgonal polynomials |
An order quadrature data frame is a named data frame that contains
the roots and abscissa values of the corresponding order
orthogonal polynomial.
The column with name
x
contains the roots or zeros and
the column with name w
contains the weights.
A list with elements each of which is a data frame
1 |
Quadrature rule data frame for the order 1 spherical polynomial |
2 |
Quadrature rule data frame for the order 2 spherical polynomial |
...
n |
Quadrature rule data frame for the order |
Frederick Novomestky [email protected]
Abramowitz, M. and I. A. Stegun, 1968. Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables, Dover Publications, Inc., New York.
Press, W. H., S. A. Teukolsky, W. T. Vetterling, and B. P. Flannery, 1992. Numerical Recipes in C, Cambridge University Press, Cambridge, U.K.
Stroud, A. H., and D. Secrest, 1966. Gaussian Quadrature Formulas, Prentice-Hall, Englewood Cliffs, NJ.
quadrature.rules
,
spherical.quadrature
### ### generate a list of quadrature rule data frames for ### the orthogonal spherical polynomials ### of orders 1 to 5 ### orthogonal.rules <- spherical.quadrature.rules( 5 ) print( orthogonal.rules ) ### ### generate a list of quadrature rule data frames for ### the orthonormal spherical polynomials ### of orders 1 to 5 ### orthonormal.rules <- spherical.quadrature.rules( 5, TRUE ) print( orthonormal.rules )
### ### generate a list of quadrature rule data frames for ### the orthogonal spherical polynomials ### of orders 1 to 5 ### orthogonal.rules <- spherical.quadrature.rules( 5 ) print( orthogonal.rules ) ### ### generate a list of quadrature rule data frames for ### the orthonormal spherical polynomials ### of orders 1 to 5 ### orthonormal.rules <- spherical.quadrature.rules( 5, TRUE ) print( orthonormal.rules )
This function evaluates the integral of the given function between the lower and upper limits using the weight and abscissa values specified in the rule data frame. The quadrature formula uses the weight function for ultraspherical polynomials.
ultraspherical.quadrature(functn, rule, alpha = 0, lower = -1, upper = 1, weighted = TRUE, ...)
ultraspherical.quadrature(functn, rule, alpha = 0, lower = -1, upper = 1, weighted = TRUE, ...)
functn |
an R function which should take a numeric argument x and possibly some parameters. The function returns a numerical vector value for the given argument x. |
rule |
a data frame containing the order |
alpha |
a numeric value for the ultraspherical polynomial parameter |
lower |
a numeric value for the lower limit of the integral with a default value of -1 |
upper |
a numeric value for the upper limit of the integral with a default value of 1 |
weighted |
a boolean value which if true causes the ultraspherical weight function to be included in the integrand |
... |
other arguments passed to the give function |
The rule argument corresponds to an order ultraspherical polynomial,
weight function and interval
.
The lower and upper limits of the integral must be finite.
The value of definite integral evaluated using Gauss Gegenbauer quadrature
Frederick Novomestky [email protected]
Abramowitz, M. and I. A. Stegun, 1968. Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables, Dover Publications, Inc., New York.
Press, W. H., S. A. Teukolsky, W. T. Vetterling, and B. P. Flannery, 1992. Numerical Recipes in C, Cambridge University Press, Cambridge, U.K.
Stroud, A. H., and D. Secrest, 1966. Gaussian Quadrature Formulas, Prentice-Hall, Englewood Cliffs, NJ.
ultraspherical.quadrature.rules
### ### this example evaluates the quadrature function for ### the ultraspherical polynomials. it computes the integral ### of the product for all pairs of orthogonal polynomials ### from order 0 to order 16. the results are compared to ### the diagonal matrix of the inner products for the ### polynomials. it also computes the integral of the product ### of all pairs of orthonormal polynomials from order 0 ### to order 16. the resultant matrix should be an identity matrix ### ### ### set the polynomial parameter ### alpha <- 0.25 ### ### set the value for the maximum polynomial order ### n <- 16 ### ### maximum order plus 1 ### np1 <- n + 1 ### ### function to construct the polynomial products by column ### by.column.products <- function( c, p.list, p.p.list ) { ### ### function to construct the polynomial products by row ### by.row.products <- function( r, c, p.list ) { row.column.product <- p.list[[r]] * p.list[[c]] return (row.column.product ) } np1 <- length( p.list ) row.list <- lapply( 1:np1, by.row.products, c, p.list ) return( row.list ) } ### ### function construct the polynomial functions by column ### by.column.functions <- function( c, p.p.products ) { ### ### function to construct the polynomial functions by row ### by.row.functions <- function( r, c, p.p.products ) { row.column.function <- as.function( p.p.products[[r]][[c]] ) return( row.column.function ) } np1 <- length( p.p.products[[1]] ) row.list <- lapply( 1:np1, by.row.functions, c, p.p.products ) return( row.list ) } ### ### function to compute the integral of the polynomials by column ### by.column.integrals <- function( c, p.p.functions ) { ### ### function to compute the integral of the polynomials by row ### by.row.integrals <- function( r, c, p.p.functions ) { row.column.integral <- ultraspherical.quadrature( p.p.functions[[r]][[c]], order.np1.rule, alpha ) return( row.column.integral ) } np1 <- length( p.p.functions[[1]] ) row.vector <- sapply( 1:np1, by.row.integrals, c, p.p.functions ) return( row.vector ) } ### ### construct a list of the ultraspherical orthogonal polynomials ### p.list <- ultraspherical.polynomials( n, alpha ) ### ### construct the two dimensional list of pair products ### of polynomials ### p.p.products <- lapply( 1:np1, by.column.products, p.list ) ### ### compute the two dimensional list of functions ### corresponding to the polynomial products in ### the two dimensional list p.p.products ### p.p.functions <- lapply( 1:np1, by.column.functions, p.p.products ) ### ### get the rule table for the order np1 polynomial ### rules <- ultraspherical.quadrature.rules( np1, alpha ) order.np1.rule <- rules[[np1]] ### ### construct the square symmetric matrix containing ### the definite integrals over the default limits ### corresponding to the two dimensional list of ### polynomial functions ### p.p.integrals <- sapply( 1:np1, by.column.integrals, p.p.functions ) ### ### construct the diagonal matrix with the inner products ### of the orthogonal polynomials on the diagonal ### p.p.inner.products <- diag( ultraspherical.inner.products( n,alpha ) ) print( "Integral of cross products for the orthogonal polynomials " ) print( apply( p.p.integrals, 2, round, digits=6 ) ) print( apply( p.p.inner.products, 2, round, digits=6 ) ) ### ### construct a list of the ultraspherical orthonormal polynomials ### p.list <- ultraspherical.polynomials( n, alpha, TRUE ) ### ### construct the two dimensional list of pair products ### of polynomials ### p.p.products <- lapply( 1:np1, by.column.products, p.list ) ### ### compute the two dimensional list of functions ### corresponding to the polynomial products in ### the two dimensional list p.p.products ### p.p.functions <- lapply( 1:np1, by.column.functions, p.p.products ) ### ### get the rule table for the order np1 polynomial ### rules <- gegenbauer.quadrature.rules( np1, alpha, TRUE ) order.np1.rule <- rules[[np1]] ### ### construct the square symmetric matrix containing ### the definite integrals over the default limits ### corresponding to the two dimensional list of ### polynomial functions ### p.p.integrals <- sapply( 1:np1, by.column.integrals, p.p.functions ) ### ### display the matrix of integrals ### print( "Integral of cross products for the orthonormal polynomials " ) print(apply( p.p.integrals, 2, round, digits=6 ) )
### ### this example evaluates the quadrature function for ### the ultraspherical polynomials. it computes the integral ### of the product for all pairs of orthogonal polynomials ### from order 0 to order 16. the results are compared to ### the diagonal matrix of the inner products for the ### polynomials. it also computes the integral of the product ### of all pairs of orthonormal polynomials from order 0 ### to order 16. the resultant matrix should be an identity matrix ### ### ### set the polynomial parameter ### alpha <- 0.25 ### ### set the value for the maximum polynomial order ### n <- 16 ### ### maximum order plus 1 ### np1 <- n + 1 ### ### function to construct the polynomial products by column ### by.column.products <- function( c, p.list, p.p.list ) { ### ### function to construct the polynomial products by row ### by.row.products <- function( r, c, p.list ) { row.column.product <- p.list[[r]] * p.list[[c]] return (row.column.product ) } np1 <- length( p.list ) row.list <- lapply( 1:np1, by.row.products, c, p.list ) return( row.list ) } ### ### function construct the polynomial functions by column ### by.column.functions <- function( c, p.p.products ) { ### ### function to construct the polynomial functions by row ### by.row.functions <- function( r, c, p.p.products ) { row.column.function <- as.function( p.p.products[[r]][[c]] ) return( row.column.function ) } np1 <- length( p.p.products[[1]] ) row.list <- lapply( 1:np1, by.row.functions, c, p.p.products ) return( row.list ) } ### ### function to compute the integral of the polynomials by column ### by.column.integrals <- function( c, p.p.functions ) { ### ### function to compute the integral of the polynomials by row ### by.row.integrals <- function( r, c, p.p.functions ) { row.column.integral <- ultraspherical.quadrature( p.p.functions[[r]][[c]], order.np1.rule, alpha ) return( row.column.integral ) } np1 <- length( p.p.functions[[1]] ) row.vector <- sapply( 1:np1, by.row.integrals, c, p.p.functions ) return( row.vector ) } ### ### construct a list of the ultraspherical orthogonal polynomials ### p.list <- ultraspherical.polynomials( n, alpha ) ### ### construct the two dimensional list of pair products ### of polynomials ### p.p.products <- lapply( 1:np1, by.column.products, p.list ) ### ### compute the two dimensional list of functions ### corresponding to the polynomial products in ### the two dimensional list p.p.products ### p.p.functions <- lapply( 1:np1, by.column.functions, p.p.products ) ### ### get the rule table for the order np1 polynomial ### rules <- ultraspherical.quadrature.rules( np1, alpha ) order.np1.rule <- rules[[np1]] ### ### construct the square symmetric matrix containing ### the definite integrals over the default limits ### corresponding to the two dimensional list of ### polynomial functions ### p.p.integrals <- sapply( 1:np1, by.column.integrals, p.p.functions ) ### ### construct the diagonal matrix with the inner products ### of the orthogonal polynomials on the diagonal ### p.p.inner.products <- diag( ultraspherical.inner.products( n,alpha ) ) print( "Integral of cross products for the orthogonal polynomials " ) print( apply( p.p.integrals, 2, round, digits=6 ) ) print( apply( p.p.inner.products, 2, round, digits=6 ) ) ### ### construct a list of the ultraspherical orthonormal polynomials ### p.list <- ultraspherical.polynomials( n, alpha, TRUE ) ### ### construct the two dimensional list of pair products ### of polynomials ### p.p.products <- lapply( 1:np1, by.column.products, p.list ) ### ### compute the two dimensional list of functions ### corresponding to the polynomial products in ### the two dimensional list p.p.products ### p.p.functions <- lapply( 1:np1, by.column.functions, p.p.products ) ### ### get the rule table for the order np1 polynomial ### rules <- gegenbauer.quadrature.rules( np1, alpha, TRUE ) order.np1.rule <- rules[[np1]] ### ### construct the square symmetric matrix containing ### the definite integrals over the default limits ### corresponding to the two dimensional list of ### polynomial functions ### p.p.integrals <- sapply( 1:np1, by.column.integrals, p.p.functions ) ### ### display the matrix of integrals ### print( "Integral of cross products for the orthonormal polynomials " ) print(apply( p.p.integrals, 2, round, digits=6 ) )
This function returns a list with elements containing
the order
quadrature rule data frame for
the ultraspherical polynomial
for orders
.
ultraspherical.quadrature.rules(n,alpha,normalized=FALSE)
ultraspherical.quadrature.rules(n,alpha,normalized=FALSE)
n |
integer value for the highest order |
alpha |
numeric value for the polynomial parameter |
normalized |
boolean value. if TRUE rules are for orthonormal polynomials, otherwise they are for orthgonal polynomials |
An order quadrature data frame is a named data frame that contains
the roots and abscissa values of the corresponding order
orthogonal polynomial.
The column with name
x
contains the roots or zeros and
the column with name w
contains the weights.
A list with elements each of which is a data frame
1 |
Quadrature rule data frame for the order 1 ultraspherical polynomial |
2 |
Quadrature rule data frame for the order 2 ultraspherical polynomial |
...
n |
Quadrature rule data frame for the order |
Frederick Novomestky [email protected]
Abramowitz, M. and I. A. Stegun, 1968. Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables, Dover Publications, Inc., New York.
Press, W. H., S. A. Teukolsky, W. T. Vetterling, and B. P. Flannery, 1992. Numerical Recipes in C, Cambridge University Press, Cambridge, U.K.
Stroud, A. H., and D. Secrest, 1966. Gaussian Quadrature Formulas, Prentice-Hall, Englewood Cliffs, NJ.
quadrature.rules
,
ultraspherical.quadrature
### ### generate a list of quadrature rules for ### the orthogonal ultraspherical polynomial ### of orders 1 to 5 ### the polynomial parameter value alpha is 1.0 ### orthogonal.rules <- ultraspherical.quadrature.rules( 5, 1 ) print( orthogonal.rules ) ### ### generate a list of quadrature rules for ### the orthonormal ultraspherical polynomial ### of orders 1 to 5 ### the polynomial parameter value alpha is 1.0 ### orthonormal.rules <- ultraspherical.quadrature.rules( 5, 1, TRUE ) print( orthonormal.rules )
### ### generate a list of quadrature rules for ### the orthogonal ultraspherical polynomial ### of orders 1 to 5 ### the polynomial parameter value alpha is 1.0 ### orthogonal.rules <- ultraspherical.quadrature.rules( 5, 1 ) print( orthogonal.rules ) ### ### generate a list of quadrature rules for ### the orthonormal ultraspherical polynomial ### of orders 1 to 5 ### the polynomial parameter value alpha is 1.0 ### orthonormal.rules <- ultraspherical.quadrature.rules( 5, 1, TRUE ) print( orthonormal.rules )