TRAPEX#
Name#
TRAPEX
Purpose#
Integrates an exponentially varying function given values on increasing grid of x-points, using the trapeziodal rule in log space. More accurate than linear trapezoidal integration for such a case.
Calling Sequence#
fint = trapex(f, x [, lratmin = , /vector, /delta_vector, /error_check])
Inputs#
fint, float, or double array(Nf)Function values at points
x, must be all positive.xint, float, or double array(Nf)Independent variable values.
Optional Inputs#
lratminint, float, or double scalarIf the absolute value of the log of adjacent
fratios is less thanlratminthen regular trapeziodal rule is used, otherwise assume exponential type of variation. (Default =0.1)vectorflagIf set, returns a vector of cumulative definite integrals.
delta_vectorflagIf set, returns a vector of non-cumulative definite integrals over the intervals between the
xvalues.error_checkflagIf set, all inputs are checked for errors. Otherwise, all inputs are assumed to be of correct format.
Output#
fintfloat or double scalar or array(Nf)Approximate integral(s). The size of
fintis determined if one of the optional inputs,vectorordelta_vector, is set. If one is set, thenfintis an array. Otherwise, it is a scalar.
Modification History#
1988/01/01: Created (Frank Varosi)
2021/03/21: Standardized parameter names (Keith Doore)
2021/03/21: Updated documentation (Keith Doore)
2021/03/21: Corrected indexing to brackets from parentheses (Keith Doore)
2021/03/21: Added error handling (Keith Doore)
2022/04/08: Allowed for inputs to have degenerate dimensions (Keith Doore)
2022/04/08: Allowed integer inputs (Keith Doore)
2022/05/17: Added
error_checkkeyword to do error handling (Keith Doore)