scipy.special.sici#

scipy.special.sici(x, out=None) = <wrapped_ufunc 'sici'>#

Sine and cosine integrals.

The sine integral is

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

and the cosine integral is

\[\operatorname{Ci}(x) = \gamma + \log(x) + \int_0^x \frac{\cos{t} - 1}{t} dt\]

where \(\gamma\) is Euler’s constant and \(\log\) is the principal branch of the logarithm [1] (see also [2]).

Parameters:
xarray_like

Real or complex points at which to compute the sine and cosine integrals.

outtuple of ndarray, optional

Optional output arrays for the function results.

Returns:
siscalar or ndarray

Sine integral at x.

ciscalar or ndarray

Cosine integral at x.

See also

shichi

Hyperbolic sine and cosine integrals.

exp1

Exponential integral E1.

expi

Exponential integral Ei.

Notes

For real arguments with x < 0, ci is the real part of the cosine integral. For such points, ci(x) and ci(x + 0j) differ by 1j*pi.

For real arguments the function is computed by calling Cephes’ [3] sici routine. For complex arguments the algorithm is based on mpmath’s [4] si and ci routines.

Array API Standard Support

sici has support for Python Array API Standard compatible backends in addition to NumPy. The following combinations of backend and device (or other capability) are supported.

Library

CPU

GPU

NumPy

✅

n/a

CuPy

n/a

✅

PyTorch

✅

⛔

JAX

✅

⛔

Dask

⛔

n/a

For the NumPy backend, this function supports all NumPy ufunc keyword arguments. Other backends may support out, but typically none of the other ufunc kwargs. out is typically supported for CuPy and PyTorch, but not currently in cases where SciPy relies on a generic Array API implementation or, for PyTorch on CPU, falls back to the NumPy backend. out is never supported for JAX because JAX arrays are immutable. sici does not currently support out for the PyTorch backend.

See Array API coverage for more information.

References

[1] (1,2)

Milton Abramowitz and Irene A. Stegun, eds. Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables. New York: Dover, 1972. (See Section 5.2.)

[2]

NIST Digital Library of Mathematical Functions https://dlmf.nist.gov/6.2.E9, https://dlmf.nist.gov/6.2.E12, and https://dlmf.nist.gov/6.2.E13

[3]

Cephes Mathematical Functions Library, https://netlib.org/cephes/

[4]

Fredrik Johansson and others. “mpmath: a Python library for arbitrary-precision floating-point arithmetic” (Version 0.19) https://mpmath.org/

Examples

>>> import numpy as np
>>> import matplotlib.pyplot as plt
>>> from scipy.special import sici, exp1

sici accepts real or complex input:

>>> sici(2.5)
(1.7785201734438267, 0.2858711963653835)
>>> sici(2.5 + 3j)
((4.505735874563953+0.06863305018999577j),
(0.0793644206906966-2.935510262937543j))

For \(z\) in the right half plane, the sine and cosine integrals are related to the exponential integral \(E_1\) (implemented in SciPy as scipy.special.exp1) by

\[\begin{split}\operatorname{Si}(z) &= \frac{E_1(iz) - E_1(-iz)}{2i} + \frac{\pi}{2}, \\ \operatorname{Ci}(z) &= -\frac{E_1(iz) + E_1(-iz)}{2}.\end{split}\]

See [1] (equations 5.2.21 and 5.2.23).

We can verify these relations:

>>> z = 2 - 3j
>>> sici(z)
((4.54751388956229-1.3991965806460565j),
(1.408292501520851+2.9836177420296055j))
>>> (exp1(1j*z) - exp1(-1j*z))/2j + np.pi/2  # Same as sine integral
(4.54751388956229-1.3991965806460565j)
>>> -(exp1(1j*z) + exp1(-1j*z))/2            # Same as cosine integral
(1.408292501520851+2.9836177420296055j)

Plot the functions evaluated on the real axis; the dotted horizontal lines are at \(\pi/2\) and \(-\pi/2\):

>>> x = np.linspace(-16, 16, 150)
>>> si, ci = sici(x)
>>> fig, ax = plt.subplots()
>>> ax.plot(x, si, label='Si(x)')
>>> ax.plot(x, ci, '--', label='Ci(x)')
>>> ax.legend(shadow=True, framealpha=1, loc='upper left')
>>> ax.set_xlabel('x')
>>> ax.set_title('Sine and Cosine Integrals')
>>> ax.axhline(np.pi/2, linestyle=':', alpha=0.5, color='k')
>>> ax.axhline(-np.pi/2, linestyle=':', alpha=0.5, color='k')
>>> ax.grid(True)
>>> plt.show()
../../_images/scipy-special-sici-1.png