本文整理汇总了Python中sympy.plotting.intervalmath.interval函数的典型用法代码示例。如果您正苦于以下问题:Python interval函数的具体用法?Python interval怎么用?Python interval使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了interval函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: cosh
def cosh(x):
"""Evaluates the hyperbolic cos of an interval"""
if isinstance(x, (int, float)):
return interval(np.cosh(x), np.cosh(x))
elif isinstance(x, interval):
#both signs
if x.start < 0 and x.end > 0:
end = max(np.cosh(x.start), np.cosh(x.end))
return interval(1, end, is_valid=x.is_valid)
else:
#Monotonic
start = np.cosh(x.start)
end = np.cosh(x.end)
return interval(start, end, is_valid=x.is_valid)
else:
raise NotImplementedError
开发者ID:Acebulf,项目名称:sympy,代码行数:16,代码来源:lib_interval.py
示例17: test_floor
def test_floor():
a = floor(interval(0.2, 0.5))
assert a.start == 0
assert a.end == 0
a = floor(interval(0.5, 1.5))
assert a.start == 0
assert a.end == 1
assert a.is_valid is None
a = floor(interval(-5, 5))
assert a.is_valid is None
a = floor(5.4)
assert a.start == 5
assert a.end == 5
开发者ID:KonstantinTogoi,项目名称:sympy,代码行数:16,代码来源:test_interval_functions.py
示例18: test_ceil
def test_ceil():
a = ceil(interval(0.2, 0.5))
assert a.start == 1
assert a.end == 1
a = ceil(interval(0.5, 1.5))
assert a.start == 1
assert a.end == 2
assert a.is_valid is None
a = ceil(interval(-5, 5))
assert a.is_valid is None
a = ceil(5.4)
assert a.start == 6
assert a.end == 6
开发者ID:KonstantinTogoi,项目名称:sympy,代码行数:16,代码来源:test_interval_functions.py
示例19: test_atan
def test_atan():
a = atan(interval(0, 1))
assert a.start == np.arctan(0)
assert a.end == np.arctan(1)
a = atan(1)
assert a.start == np.arctan(1)
assert a.end == np.arctan(1)
开发者ID:KonstantinTogoi,项目名称:sympy,代码行数:7,代码来源:test_interval_functions.py
示例20: test_tanh
def test_tanh():
a = tanh(interval(-3, 3))
assert a.start == np.tanh(-3)
assert a.end == np.tanh(3)
a = tanh(3)
assert a.start == np.tanh(3)
assert a.end == np.tanh(3)
开发者ID:KonstantinTogoi,项目名称:sympy,代码行数:8,代码来源:test_interval_functions.py
注:本文中的sympy.plotting.intervalmath.interval函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论