sici: Sine and Cosine Integral Functions

Si, CiR Documentation

Sine and Cosine Integral Functions

Description

Computes the sine and cosine integrals through approximations.

Usage

Si(x)
Ci(x)

Arguments

x

Scalar or vector of real numbers.

Details

The sine and cosine integrals are defined as

Si(x) = \int_0^x \frac{\sin(t)}{t} dt

Ci(x) = - \int_x^\infty \frac{\cos(t)}{t} dt = \gamma + \log(x) + \int_0^x \frac{\cos(t)-1}{t} dt

where \gamma is the Euler-Mascheroni constant.

Value

Returns a scalar of sine resp. cosine integrals applied to each element of the scalar/vector. The value Ci(x) is not correct, it should be Ci(x)+pi*i, only the real part is returned!

The function is not truely vectorized, for vectors the values are calculated in a for-loop. The accuracy is about 10^-13 and better in a reasonable range of input values.

References

Zhang, S., and J. Jin (1996). Computation of Special Functions. Wiley-Interscience.

See Also

sinc, expint

Examples

x <- c(-3:3) * pi
Si(x); Ci(x)

## Not run: 
xs <- linspace(0, 10*pi, 200)
ysi <- Si(xs); yci <- Ci(xs)
plot(c(0, 35), c(-1.5, 2.0), type = 'n', xlab = '', ylab = '',
     main = "Sine and cosine integral functions")
lines(xs, ysi, col = "darkred",  lwd = 2)
lines(xs, yci, col = "darkblue", lwd = 2)
lines(c(0, 10*pi), c(pi/2, pi/2), col = "gray")
lines(xs, cos(xs), col = "gray")
grid()
## End(Not run)

pracma documentation built on Nov. 10, 2023, 1:14 a.m.