# Path: systemVariables.py
# def     fuzzyEquals(A, B):
#     """
#     true if A = B to within the current comparison tolerance
#     """
#     return operator.le(math.fabs(operator.sub(A, B)),
#                        operator.mul(_CT.python(), max(math.fabs(A), math.fabs(B))))
# 
# def     fuzzyInteger(B):
#     """
#     B but, if B is within comparison toleranace of an integer, the integer
#     """
#     if isinstance(B, int):
#         return B
# 
#     if B > 0:
#         I = int(B+0.5)
#     elif B < 0:
#         I = int(B-0.5)
#     else:
#         I = 0
# 
#     if fuzzyEquals(I, B):
#         return I
# 
#     return B
# 
# def     confirmBoolean(B):
#     """
#     the Boolean-domain value of B (if within comparison tolerance - else throw DOMAIN ERROR)
#     """
#     try:
#         B = fuzzyInteger(B)
# 
#         if B == 0:
#             return 0
#         if B == 1:
#             return 1
#     except TypeError:
#         pass
# 
#     assertError("DOMAIN ERROR")
# 
# def     confirmInteger(B):
#     """
#     the integer-domain value of B (if within comparison tolerance - else throw DOMAIN ERROR)
#     """
#     try:
#         B = fuzzyInteger(B)
# 
#         if isinstance(B, int):
#             return B
#     except TypeError:
#         pass
# 
#     assertError("DOMAIN ERROR")
# 
# Path: aplError.py
# class   aplException(Exception):
#     """
#     A simple APL Exception Class
#     """
#     def __init__(self, message, expr=None):
#         Exception.__init__(self)
#         self.message = message
#         self.expr = expr
# 
# def     assertError(message):
#     """
#     raise an exception so aborting the current operation
#     """
#     raise aplException(message)


import operator
import math
import random
import mpmath
from systemVariables import fuzzyEquals, fuzzyInteger, confirmBoolean, confirmInteger
from aplError import aplException, assertError
    A is valid in the range [-12, +12].  The following are implemented:

    ¯7  atanh(B)
    ¯6  acosh(B)
    ¯5  asinh(B)
    ¯4  sqrt(B**2-1)
    ¯3  atan(B)
    ¯2  acos(B)
    ¯1  asin(B)
     0  sqrt(1-B**2)
     1  sin(B)
     2  cos(B)
     3  tan(B)
     4  sqrt(B**2+1)
     5  sinh(B)
     6  cosh(B)
     7  tanh(B)
    """
    A = confirmInteger(A)

    if A <= -12 or A >= 12:
        assertError("DOMAIN ERROR")

    function = _CircularFunctions[A+12]
    if function is None:
        assertError("FUNCTION NOT YET IMPLEMENTED")

    try:
        return function(B)
    except ValueError:

# Path: systemVariables.py
# def     fuzzyEquals(A, B):
#     """
#     true if A = B to within the current comparison tolerance
#     """
#     return operator.le(math.fabs(operator.sub(A, B)),
#                        operator.mul(_CT.python(), max(math.fabs(A), math.fabs(B))))
# 
# def     fuzzyInteger(B):
#     """
#     B but, if B is within comparison toleranace of an integer, the integer
#     """
#     if isinstance(B, int):
#         return B
# 
#     if B > 0:
#         I = int(B+0.5)
#     elif B < 0:
#         I = int(B-0.5)
#     else:
#         I = 0
# 
#     if fuzzyEquals(I, B):
#         return I
# 
#     return B
# 
# def     confirmBoolean(B):
#     """
#     the Boolean-domain value of B (if within comparison tolerance - else throw DOMAIN ERROR)
#     """
#     try:
#         B = fuzzyInteger(B)
# 
#         if B == 0:
#             return 0
#         if B == 1:
#             return 1
#     except TypeError:
#         pass
# 
#     assertError("DOMAIN ERROR")
# 
# def     confirmInteger(B):
#     """
#     the integer-domain value of B (if within comparison tolerance - else throw DOMAIN ERROR)
#     """
#     try:
#         B = fuzzyInteger(B)
# 
#         if isinstance(B, int):
#             return B
#     except TypeError:
#         pass
# 
#     assertError("DOMAIN ERROR")
# 
# Path: aplError.py
# class   aplException(Exception):
#     """
#     A simple APL Exception Class
#     """
#     def __init__(self, message, expr=None):
#         Exception.__init__(self)
#         self.message = message
#         self.expr = expr
# 
# def     assertError(message):
#     """
#     raise an exception so aborting the current operation
#     """
#     raise aplException(message)


# Path: dyadicFunctions.py
import operator
import math
import random
import mpmath
from systemVariables import fuzzyEquals, fuzzyInteger, confirmBoolean, confirmInteger
from aplError import aplException, assertError

    A is valid in the range [-12, +12].  The following are implemented:

    ¯7  atanh(B)
    ¯6  acosh(B)
    ¯5  asinh(B)
    ¯4  sqrt(B**2-1)
    ¯3  atan(B)
    ¯2  acos(B)
    ¯1  asin(B)
     0  sqrt(1-B**2)
     1  sin(B)
     2  cos(B)
     3  tan(B)
     4  sqrt(B**2+1)
     5  sinh(B)
     6  cosh(B)
     7  tanh(B)
    """
    A = confirmInteger(A)

    if A <= -12 or A >= 12:
        assertError("DOMAIN ERROR")

    function = _CircularFunctions[A+12]
    if function is None:
        assertError("FUNCTION NOT YET IMPLEMENTED")

    try:
        return function(B)
    except ValueError:

        assertError("DOMAIN ERROR")