acoth function

dynamic acoth(
  1. dynamic x
)

Returns the inverse hyperbolic cotangent (acoth) of x.

Example 1:

print(acoth(2)); // prints: 0.5493061443340549

Example 2:

print(acoth(Complex(1, 2))); // Output: 0.2290726832688049 - 0.39269908169872414i

Example 3:

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

Implementation

dynamic acoth(dynamic x) {
  if (x is num) {
    if (x.abs() <= 1) {
      throw ArgumentError(
          'Invalid input for acoth: absolute value of input must be > 1');
    }
    return 0.5 * log((x + 1) / (x - 1));
  } else if (x is Complex) {
    return atanh(Complex(1, 0) / x);
  } else if (x is Matrix) {
    return MatrixFunctions(x).acoth();
  } else {
    throw ArgumentError('Input should be either num or Complex');
  }
}