(x)
evaluates the sine of an interval
evaluates the sine of an interval
evaluates the sine of an interval
def sin(x):
    """evaluates the sine of an interval"""
    np = import_module('numpy')
    if isinstance(x, (int, float)):
        return interval(np.sin(x))
    elif isinstance(x, interval):
        if not x.is_valid:
            return interval(-1, 1, is_valid=x.is_valid)
        na, __ = divmod(x.start, np.pi / 2.0)
        nb, __ = divmod(x.end, np.pi / 2.0)
        start = min(np.sin(x.start), np.sin(x.end))
        end = max(np.sin(x.start), np.sin(x.end))
        if nb - na > 4:
            return interval(-1, 1, is_valid=x.is_valid)
        elif na == nb:
            return interval(start, end, is_valid=x.is_valid)
        else:
            if (na - 1) // 4 != (nb - 1) // 4:
                #sin has max
                end = 1
            if (na - 3) // 4 != (nb - 3) // 4:
                #sin has min
                start = -1
            return interval(start, end)
    else:
        raise NotImplementedError
def sin ( x ) : np = import_module ( 'numpy' ) if isinstance ( x , ( int , float ) ) : return interval ( np . sin ( x ) ) elif isinstance ( x , interval ) : if not x . is_valid : return interval ( - 1 , 1 , is_valid = x . is_valid ) na , __ = divmod ( x . start , np . pi / 2.0 ) nb , __ = divmod ( x . end , np . pi / 2.0 ) start = min ( np . sin ( x . start ) , np . sin ( x . end ) ) end = max ( np . sin ( x . start ) , np . sin ( x . end ) ) if nb - na > 4 : return interval ( - 1 , 1 , is_valid = x . is_valid ) elif na == nb : return interval ( start , end , is_valid = x . is_valid ) else : if ( na - 1 ) // 4 != ( nb - 1 ) // 4 : #sin has max end = 1 if ( na - 3 ) // 4 != ( nb - 3 ) // 4 : #sin has min start = - 1 return interval ( start , end ) else : raise NotImplementedError