当前位置: 首页>>代码示例>>Python>>正文


Python intervalmath.interval函数代码示例

本文整理汇总了Python中sympy.plotting.intervalmath.interval函数的典型用法代码示例。如果您正苦于以下问题:Python interval函数的具体用法?Python interval怎么用?Python interval使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了interval函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: cos

def cos(x):
    """Evaluates the cos of an interval"""
    if isinstance(x, (int, float)):
        return interval(np.sin(x))
    elif isinstance(x, interval):
        if not (np.isfinite(x.start) and np.isfinite(x.end)):
            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.cos(x.start), np.cos(x.end))
        end = max(np.cos(x.start), np.cos(x.end))
        if nb - na > 4:
            #differ more than 2*pi
            return interval(-1, 1, is_valid=x.is_valid)
        elif na == nb:
            #in the same quadarant
            return interval(start, end, is_valid=x.is_valid)
        else:
            if (na) // 4 != (nb) // 4:
                #cos has max
                end = 1
            if (na - 2) // 4 != (nb - 2) // 4:
                #cos has min
                start = -1
            return interval(start, end, is_valid=x.is_valid)
    else:
        raise NotImplementedError
开发者ID:Acebulf,项目名称:sympy,代码行数:27,代码来源:lib_interval.py

示例2: sin

def sin(x):
    """evaluates the sine of an interval"""
    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
开发者ID:Acebulf,项目名称:sympy,代码行数:25,代码来源:lib_interval.py

示例3: test_tan

def test_tan():
    a = tan(interval(0, np.pi / 4))
    assert a.start == 0
    assert a.end == np.tan(np.pi / 4)

    a = tan(interval(np.pi / 4, 3 * np.pi / 4))
    #discontinuity
    assert a.is_valid is None
开发者ID:aeberspaecher,项目名称:sympy,代码行数:8,代码来源:test_interval_functions.py

示例4: exp

def exp(x):
    """evaluates the exponential of an interval"""
    if isinstance(x, (int, float)):
        return interval(np.exp(x), np.exp(x))
    elif isinstance(x, interval):
        return interval(np.exp(x.start), np.exp(x.end), is_valid=x.is_valid)
    else:
        raise NotImplementedError
开发者ID:Acebulf,项目名称:sympy,代码行数:8,代码来源:lib_interval.py

示例5: tanh

def tanh(x):
    """Evaluates the hyperbolic tan of an interval"""
    if isinstance(x, (int, float)):
        return interval(np.tanh(x), np.tanh(x))
    elif isinstance(x, interval):
        return interval(np.tanh(x.start), np.tanh(x.end), is_valid=x.is_valid)
    else:
        raise NotImplementedError
开发者ID:Acebulf,项目名称:sympy,代码行数:8,代码来源:lib_interval.py

示例6: test_tan

def test_tan():
    a = tan(interval(0, np.pi / 4))
    assert a.start == 0
    # must match lib_interval definition of tan:
    assert a.end == np.sin(np.pi / 4)/np.cos(np.pi / 4)

    a = tan(interval(np.pi / 4, 3 * np.pi / 4))
    #discontinuity
    assert a.is_valid is None
开发者ID:KonstantinTogoi,项目名称:sympy,代码行数:9,代码来源:test_interval_functions.py

示例7: sinh

def sinh(x):
    """Evaluates the hyperbolic sine of an interval"""
    np = import_module('numpy')
    if isinstance(x, (int, float)):
        return interval(np.sinh(x), np.sinh(x))
    elif isinstance(x, interval):
        return interval(np.sinh(x.start), np.sinh(x.end), is_valid=x.is_valid)
    else:
        raise NotImplementedError
开发者ID:abhishekkumawat23,项目名称:sympy,代码行数:9,代码来源:lib_interval.py

示例8: atan

def atan(x):
    """evaluates the tan inverse of an interval"""
    if isinstance(x, (int, float)):
        return interval(np.arctan(x))
    elif isinstance(x, interval):
        start = np.arctan(x.start)
        end = np.arctan(x.end)
        return interval(start, end, is_valid=x.is_valid)
    else:
        raise NotImplementedError
开发者ID:Acebulf,项目名称:sympy,代码行数:10,代码来源:lib_interval.py

示例9: asinh

def asinh(x):
    """Evaluates the inverse hyperbolic sine of an interval"""
    if isinstance(x, (int, float)):
        return interval(np.arcsinh(x))
    elif isinstance(x, interval):
        start = np.arcsinh(x.start)
        end = np.arcsinh(x.end)
        return interval(start, end, is_valid=x.is_valid)
    else:
        return NotImplementedError
开发者ID:Acebulf,项目名称:sympy,代码行数:10,代码来源:lib_interval.py

示例10: test_exp

def test_exp():
    a = exp(interval(-np.inf, 0))
    assert a.start == np.exp(-np.inf)
    assert a.end == np.exp(0)
    a = exp(interval(1, 2))
    assert a.start == np.exp(1)
    assert a.end == np.exp(2)
    a = exp(1)
    assert a.start == np.exp(1)
    assert a.end == np.exp(1)
开发者ID:KonstantinTogoi,项目名称:sympy,代码行数:10,代码来源:test_interval_functions.py

示例11: Abs

def Abs(x):
    if isinstance(x, (int, float)):
        return interval(abs(x))
    elif isinstance(x, interval):
        if x.start < 0 and x.end > 0:
            return interval(0, max(abs(x.start), abs(x.end)), is_valid=x.is_valid)
        else:
            return interval(abs(x.start), abs(x.end))
    else:
        raise NotImplementedError
开发者ID:Acebulf,项目名称:sympy,代码行数:10,代码来源:lib_interval.py

示例12: test_log10

def test_log10():
    a = log10(interval(1, 2))
    assert a.start == 0
    assert a.end == np.log10(2)
    a = log10(interval(-1, 1))
    assert a.is_valid is None
    a = log10(interval(-3, -1))
    assert a.is_valid is False
    a = log10(-3)
    assert a.is_valid is False
    a = log10(2)
    assert a.start == np.log10(2)
    assert a.end == np.log10(2)
开发者ID:KonstantinTogoi,项目名称:sympy,代码行数:13,代码来源:test_interval_functions.py

示例13: test_hashable

def test_hashable():
    '''
    test that interval objects are hashable.
    this is required in order to be able to put them into the cache, which
    appears to be necessary for plotting in py3k. For details, see:

    https://github.com/sympy/sympy/pull/2101
    https://github.com/sympy/sympy/issues/6533
    '''
    hash(interval(1, 1))
    hash(interval(1, 1, is_valid=True))
    hash(interval(-4, -0.5))
    hash(interval(-2, -0.5))
    hash(interval(0.25, 8.0))
开发者ID:A-turing-machine,项目名称:sympy,代码行数:14,代码来源:test_intervalmath.py

示例14: test_cosh

def test_cosh():
    a = cosh(interval(1, 2))
    assert a.start == np.cosh(1)
    assert a.end == np.cosh(2)
    a = cosh(interval(-2, -1))
    assert a.start == np.cosh(-1)
    assert a.end == np.cosh(-2)

    a = cosh(interval(-2, 1))
    assert a.start == 1
    assert a.end == np.cosh(-2)

    a = cosh(1)
    assert a.start == np.cosh(1)
    assert a.end == np.cosh(1)
开发者ID:KonstantinTogoi,项目名称:sympy,代码行数:15,代码来源:test_interval_functions.py

示例15: test_acosh

def test_acosh():
    a = acosh(interval(3, 5))
    assert a.start == np.arccosh(3)
    assert a.end == np.arccosh(5)

    a = acosh(interval(0, 3))
    assert a.is_valid is None
    a = acosh(interval(-3, 0.5))
    assert a.is_valid is False

    a = acosh(0.5)
    assert a.is_valid is False

    a = acosh(2)
    assert a.start == np.arccosh(2)
    assert a.end == np.arccosh(2)
开发者ID:KonstantinTogoi,项目名称:sympy,代码行数:16,代码来源:test_interval_functions.py


注:本文中的sympy.plotting.intervalmath.interval函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。