Skip to contents

This function estimates the integral using the trapezoidal rule. It creates a set of evenly spaced `u_ij` values and computes the average of the integrand at the boundaries and at the intermediate points.

Usage

trapezoidal_integral(
  period = c(0, 1),
  y_tilde,
  v_tilde,
  tau_tilde,
  n_intervals = 1000,
  epsilon = 1e-06
)

Arguments

period

Numeric vector, the integration interval, default is `c(0, 1)`.

y_tilde

Numeric, parameter for the exponential function in the integrand.

v_tilde

Numeric, parameter for the exponential function in the integrand.

tau_tilde

Numeric, parameter for the exponential function in the integrand.

n_intervals

Integer, the number of intervals for the trapezoidal rule.

epsilon

Numeric, small value to avoid sampling at the boundaries (0 or 1).

Value

A list containing: - `integral_estimate`: Estimated integral using the trapezoidal rule. - `time_avg`: Time taken to perform the calculation.