[R] legendre quadrature
Enrico Schumann
es at enricoschumann.net
Thu May 1 14:04:48 CEST 2014
On Thu, 01 May 2014, pari hesabi <statistics84 at hotmail.com> writes:
> Hello everybody
> I need to approximate the amount of integral by using
> legendre quadrature. I have written a program which doesn't give me a
> logical answer; Can anybody help me and send the correct program? For
> example the approximated amount of integral of ( x ^2) on (-1,1) based
> on legendre quad rule.
>
One possibility:
require("NMOF")
xw <-xwGauss(10, "legendre")
fun <- function(x)
x^2
sum(fun(xw$nodes) * xw$weights)
>
>
> integrand<-function(x) {x^2}
> rules <- legendre.quadrature.rules( 50 )
Error: object 'legendre.quadrature.rules' not found
PLEASE "provide commented, minimal, self-contained, reproducible code".
> order.rule <- rules[[50]]
> chebyshev.c.quadrature(integrand, order.rule, lower = -1, upper = 1)
>
> Thank you
> Diba
--
Enrico Schumann
Lucerne, Switzerland
http://enricoschumann.net
More information about the R-help
mailing list