scipy.special.fresnel#

scipy.special.fresnel(z, out=None) = <wrapped_ufunc 'fresnel'>#

Fresnel integrals.

The Fresnel integrals are defined as

\[\begin{split}S(z) &= \int_0^z \sin(\pi t^2 /2) dt, \\ C(z) &= \int_0^z \cos(\pi t^2 /2) dt.\end{split}\]

See [dlmf] for details.

Parameters:
zarray_like

Real or complex valued argument

out2-tuple of ndarrays, optional

Optional output arrays for the function results

Returns:
S, C2-tuple of scalar or ndarray

Values of the Fresnel integrals

See also

fresnel_zeros

zeros of the Fresnel integrals

Notes

Array API Standard Support

fresnel 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. fresnel does not currently support out for the PyTorch backend.

See Support for the array API standard for more information.

References

[dlmf]

NIST Digital Library of Mathematical Functions https://dlmf.nist.gov/7.2#iii

Examples

>>> import numpy as np
>>> from scipy.special import fresnel, erf

First, we verify the following limits:

\[\lim_{z \to \infty} S(z) = \lim_{z \to \infty} C(z) = 1/2.\]
>>> S, C = fresnel([0.1, 1, 10, 100, np.inf])
>>> S
array([0.00052359, 0.43825915, 0.46816998, 0.4968169 , 0.5       ])
>>> C
array([0.09999753, 0.7798934 , 0.49989869, 0.4999999 , 0.5       ])

Next, we verify the following relation to the error function:

\[C(z) + i S(z) = \frac{1 + i}{2} \operatorname{erf}\left(\frac{\sqrt{\pi}(1 - i)}{2} z\right).\]
>>> z = np.linspace(-10, 10)
>>> S, C = fresnel(z)
>>> RHS = (1 + 1j)/2 * erf((np.sqrt(np.pi)*(1 - 1j))/2*z)
>>> np.allclose(C + 1j*S, RHS)
True

Finally, we plot \(C(z)\) against \(S(z)\) to get the Euler or Cornu spiral.

>>> import matplotlib.pyplot as plt
>>> z = np.linspace(-10, 10, num=1000)
>>> S, C = fresnel(z)
>>> fig, ax = plt.subplots()
>>> ax.plot(C, S)
>>> ax.set_aspect('equal')
>>> ax.set_xlabel('$C(z)$')
>>> ax.set_ylabel('$S(z)$')
>>> plt.show()
../../_images/scipy-special-fresnel-1.png