Sine and Cosine Integral Functions
Computes the sine and cosine integrals through approximations.
Si(x) Ci(x)
x |
Scalar or vector of real numbers. |
The sine and cosine integrals are defined as
Si(x) = \int_0^x \frac{\sin(t)}{t} dt
Ci(x) = - \int_x^∞ \frac{\cos(t)}{t} dt = γ + \log(x) + \int_0^x \frac{\cos(t)-1}{t} dt
where γ is the Euler-Mascheroni constant.
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.
Zhang, S., and J. Jin (1996). Computation of Special Functions. Wiley-Interscience.
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)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.