cos method
Cosine
Compute the cosine of this complex number.
Implements the formula:
cos(a + bi) = cos(a)cosh(b) - sin(a)sinh(b)i
where the (real) functions on the right-hand side are math.sin, math.cos, fastmath.cosh and fastmath.sinh.
Returns nan
if either real or imaginary part of the
input argument is NaN
.
Infinite values in real or imaginary parts of the input may result in
infinite or NaN
values returned in parts of the result.
Examples:
cos(1 ± INFINITY i) = 1 ∓ INFINITY i
cos(±INFINITY + i) = NaN + NaN i
cos(±INFINITY ± INFINITY i) = NaN + NaN i
Implementation
Complex cos() {
if (isNaN) return Complex.nan;
final _real = math.cos(real) * fastmath.cosh(imaginary);
final _imag = -math.sin(real) * fastmath.sinh(imaginary);
return Cartesian(_real, _imag);
}