integrate                package:base                R Documentation

_I_n_t_e_g_r_a_t_i_o_n _o_f _O_n_e-_D_i_m_e_n_s_i_o_n_a_l _F_u_n_c_t_i_o_n_s

_D_e_s_c_r_i_p_t_i_o_n:

     Adaptive quadrature of functions of one variable over a finite or
     infinite interval.

_U_s_a_g_e:

     integrate(f, lower, upper, subdivisions=100,
               rel.tol = .Machine$double.eps^0.25, abs.tol = rel.tol,
               stop.on.error = TRUE, keep.xy = FALSE, aux = NULL, ...)

_A_r_g_u_m_e_n_t_s:

       f: An R function taking a numeric first argument and returning a
          numeric vector the same length. Returning a non-finite
          element will generate an error.

lower, upper: The limits of integration. Can be infinite.

subdivisions: the maximum number of subintervals.

 rel.tol: relative accuracy requested.

 abs.tol: absolute accuracy requested.

stop.on.error: logical. If true (the default) an error stops the
          function.  If false some errors will give a result with a
          warning in the `message' component.

 keep.xy: unused. For compatibility with S.

     aux: unused. For compatibility with S.

     ...: additional arguments to be passes to `f'.

_D_e_t_a_i_l_s:

     If one or both limits are infinite, the infinite range is mapped
     onto a finite interval.

     For a finite interval, globally adaptive interval subdivision is
     used in connection with extrapolation by the Epsilon algorithm.

     `rel.tol' cannot be less than `max(50*.Machine$double.eps,
     0.5e-28)' if `abs.tol <= 0'.

_V_a_l_u_e:

     A list of class `"integrate"' with components 

   value: the final estimate of the integral.

abs.error: estimate of the modulus of the absolute error.

subdivisions: the number of subintervals produced in the subdivision
          process.

 message: `"OK"' or a character string giving the error message.

    call: the matched call.

_R_e_f_e_r_e_n_c_e_s:

     Based on QUADPACK routines `dqags' and `dqagi' by R. Piessens and
     E. deDoncker-Kapenga, available from Netlib.

     See
     R. Piessens, E. deDoncker-Kapenga, C. Uberhuber, D. Kahaner (1983)
     Quadpack: a Subroutine Package for Automatic Integration; Springer
     Verlag.

_S_e_e _A_l_s_o:

     The function `adapt' in the `adapt' package on CRAN, for
     multivariate integration.

_E_x_a_m_p_l_e_s:

     integrate(dnorm, -1.96, 1.96)
     integrate(dnorm, -Inf, Inf)


     ## a slowly-convergent integral
     integrand <- function(x) {1/((x+1)*sqrt(x))}
     integrate(integrand, lower = 0, upper = Inf)

     integrate(integrand, lower = 0, upper = 10)
     integrate(integrand, lower = 0, upper = 100000)
     integrate(integrand, lower = 0, upper = 1000000, stop.on.error = FALSE)

     try(integrate(function(x) 2, 0, 1))  ## no vectorizable function
     integrate(function(x) rep(2, length(x)), 0, 1)  ## correct

