cosh function

dynamic cosh(
  1. dynamic x
)

Returns the hyperbolic cosine of a number.

Example:

print(cosh(1));  // Output: 1.5430806348152437

Example 2:

print(cosh(Complex(1, 2))); // Output: -0.64214812471552 + 1.0686074213827783i

Example 3:

print(cosh(Matrix.identity(2))); // Output: [[1.0, 0.0], [0.0, 1.0]]

Implementation

dynamic cosh(dynamic x) {
  if (x is num) {
    return (exp(x) + exp(-x)) / 2;
  } else if (x is Complex) {
    return x.cosh();
  } else if (x is Matrix) {
    return MatrixFunctions(x).cosh();
  } else {
    throw ArgumentError('Input should be either num or Complex');
  }
}