excsc function

dynamic excsc(
  1. dynamic x
)

Excosecant function

The excosecant or excsc of an angle is csc(θ) - 1. It's rarely used in modern mathematics.

Example:

print(excsc(math.pi / 2));  // Output: 0.0

The output is 0.0 because the excosecant of π/2 (or 90 degrees) is 0 (as csc(π/2) is 1).

Example 2:

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

Implementation

dynamic excsc(dynamic x) {
  if (x is num || x is Complex) {
    return x is num ? 1 / sin(x) - 1 : Complex.one() / sin(x) - Complex.one();
  } else if (x is Matrix) {
    return MatrixFunctions(x).excsc();
  } else {
    throw ArgumentError('Input should be either num or Complex');
  }
}