## Usage

 `1` ```quad(f, xa, xb, tol = .Machine\$double.eps^0.5, trace = FALSE, ...) ```

## Arguments

 `f` a one-dimensional function; needs to be vectorized. `xa` lower limit of integration; must be finite `xb` upper limit of integration; must be finite `tol` accuracy requested. `trace` logical; shall a trace be printed? `...` additional arguments to be passed to `f`.

## Details

The function `f` needs to be vectorized though this could be changed easily. `quad` is not suitable for functions with singularities in the interval or at end points.

## Value

A single numeric value, the computed integral.

## Note

More modern adaptive methods based on Gauss-Kronrod or Clenshaw-Curtis quadrature are now generally preferred.

## Author(s)

Copyright (c) 1998 Walter Gautschi for the Matlab version published as part of the referenced article. R implementation by Hans W Borchers 2011.

## References

Gander, W. and W. Gautschi (2000). “Adaptive Quadrature — Revisited”. BIT, Vol. 40, 2000, pp. 84-101.

`integrate`, `quadl`

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13``` ```# options(digits=15) f <- function(x) x * cos(0.1*exp(x)) * sin(0.1*pi*exp(x)) quad(f, 0, 4) # 1.2821290747821 quad(f, 0, 4, tol=10^-15) # 1.2821290743501 integrate(f, 0, 4) # 1.28212907435010 with absolute error < 4.1e-06 ## Not run: xx <- seq(0, 4, length.out = 200) yy <- f(xx) plot(xx, yy, type = 'l') grid() ## End(Not run) ```

### Example output

```[1] 1.282129
[1] 1.282129
1.282129 with absolute error < 4.1e-06
```

pracma documentation built on Dec. 11, 2021, 9:57 a.m.