function fresnelc( x ) {
	var x2;
	var xa;
	var C;
	var f;
	var g;
	var t;
	var u;

	xa = abs( x );
	x2 = xa * xa;
	if ( x2 < 2.5625 ) {
		t = x2 * x2;
		C = xa * polyC( t );
	} else if ( xa > 36974.0 ) {
		C = 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;
		C = 0.5 + ( ( (f*sc[0]) - (g*sc[1]) ) / t );
	}
	if ( x < 0.0 ) {
		C = -C;
	}
	return C;
}
Computes the Fresnel integral C(x).

## Method

Evaluates the Fresnel integral

```tex
\operatorname{C}(x) = \int_0^x \cos\left(\frac{\pi}{2} t^2\right)\,\mathrm{d}t.
```

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

```tex
\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).
```

## Notes

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

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

@param {number} x - input value
@returns {number} C(x)

@example
var v = fresnelc( 0.0 );
// returns 0.0

@example
var v = fresnelc( 1.0 );
// returns ~0.780

@example
var v = fresnelc( Infinity );
// returns ~0.5

@example
var v = fresnelc( -Infinity );
// returns ~-0.5

@example
var v = fresnelc( NaN );
// returns NaN