function fresnel( x, out, stride, offset ) {
	var x2;
	var xa;
	var f;
	var g;
	var t;
	var u;

	xa = abs( x );
	x2 = xa * xa;
	if ( x2 < 2.5625 ) {
		t = x2 * x2;
		out[ offset ] = xa * x2 * polyS( t );
		out[ offset+stride ] = xa * polyC( t );
	} else if ( xa > 36974.0 ) {
		out[ offset+stride ] = 0.5;
		out[ offset ] = 0.5;
	} else {
		// Asymptotic power series auxiliary functions for large arguments...
		x2 = xa * xa;
		t = PI * x2;
		u = 1.0 / (t * t);
		t = 1.0 / t;
		f = 1.0 - ( u * polyF( u ) );
		g = t * polyG( u );
		t = HALF_PI * x2;
		sincos( t, sc, 1, 0 );
		t = PI * xa;
		out[ offset+stride ] = 0.5 + ( ( (f*sc[0]) - (g*sc[1]) ) / t );
		out[ offset ] = 0.5 - ( ( (f*sc[1]) + (g*sc[0]) ) / t );
	}
	if ( x < 0.0 ) {
		out[ offset+stride ] = -out[ offset+stride ];
		out[ offset ] = -out[ offset ];
	}
	return out;
}
Computes the Fresnel integrals S(x) and C(x) and assigns results to a provided output array.

## Method

Evaluates the Fresnel integrals

```tex
\begin{align*}
\operatorname{S}(x) &= \int_0^x \sin\left(\frac{\pi}{2} t^2\right)\,\mathrm{d}t, \\
\operatorname{C}(x) &= \int_0^x \cos\left(\frac{\pi}{2} t^2\right)\,\mathrm{d}t.
\end{align*}
```

The integrals are evaluated by a power series for \\( x < 1 \\). For \\( x >= 1 \\) auxiliary functions \\( f(x) \\) and \\( g(x) \\) are employed such that

```tex
\begin{align*}
\operatorname{C}(x) &= \frac{1}{2} + f(x) \sin\left( \frac{\pi}{2} x^2 \right) - g(x) \cos\left( \frac{\pi}{2} x^2 \right), \\
\operatorname{S}(x) &= \frac{1}{2} - f(x) \cos\left( \frac{\pi}{2} x^2 \right) - g(x) \sin\left( \frac{\pi}{2} x^2 \right).
\end{align*}
```

## Notes

-   Relative error on test interval \\( \[0,10\] \\):

    | arithmetic | function | # trials | peak    | rms     |
    |:----------:|:--------:|:--------:|:-------:|:-------:|
    | IEEE       | S(x)     | 10000    | 2.0e-15 | 3.2e-16 |
    | IEEE       | C(x)     | 10000    | 1.8e-15 | 3.3e-16 |

@private
@param {number} x - input value
@param {Collection} out - output array
@param {integer} stride - output array stride
@param {NonNegativeInteger} offset - output array index offset
@returns {Collection} S(x) and C(x)

@example
var v = fresnel( 0.0, [ 0.0, 0.0 ], 1, 0 );
// returns [ 0.0, 0.0 ]

@example
var v = fresnel( 1.0, [ 0.0, 0.0 ], 1, 0 );
// returns [ ~0.438, ~0.780 ]

@example
var v = fresnel( Infinity, [ 0.0, 0.0 ], 1, 0 );
// returns [ ~0.5, ~0.5 ]

@example
var v = fresnel( -Infinity, [ 0.0, 0.0 ], 1, 0 );
// returns [ ~-0.5, ~-0.5 ]

@example
var v = fresnel( NaN, [ 0.0, 0.0 ], 1, 0 );
// returns [ NaN, NaN ]