Si, Ci | R Documentation |
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^\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.
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.
sinc
, expint
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.