def test_trig(self): m = ConcreteModel() m.x = Var(bounds=(pi / 4, pi / 2), initialize=pi / 4) mc_expr = mc(tan(atan((m.x)))) self.assertAlmostEqual(mc_expr.lower(), pi / 4) self.assertAlmostEqual(mc_expr.upper(), pi / 2) m.y = Var(bounds=(0, sin(pi / 4)), initialize=0) mc_expr = mc(asin((m.y))) self.assertEqual(mc_expr.lower(), 0) self.assertAlmostEqual(mc_expr.upper(), pi / 4) m.z = Var(bounds=(0, cos(pi / 4)), initialize=0) mc_expr = mc(acos((m.z))) self.assertAlmostEqual(mc_expr.lower(), pi / 4) self.assertAlmostEqual(mc_expr.upper(), pi / 2)
_operatorMap = { sympy.Add: _sum, sympy.Mul: _prod, sympy.Pow: lambda x, y: x**y, sympy.exp: lambda x: core.exp(x), sympy.log: lambda x: core.log(x), sympy.sin: lambda x: core.sin(x), sympy.asin: lambda x: core.asin(x), sympy.sinh: lambda x: core.sinh(x), sympy.asinh: lambda x: core.asinh(x), sympy.cos: lambda x: core.cos(x), sympy.acos: lambda x: core.acos(x), sympy.cosh: lambda x: core.cosh(x), sympy.acosh: lambda x: core.acosh(x), sympy.tan: lambda x: core.tan(x), sympy.atan: lambda x: core.atan(x), sympy.tanh: lambda x: core.tanh(x), sympy.atanh: lambda x: core.atanh(x), sympy.ceiling: lambda x: core.ceil(x), sympy.floor: lambda x: core.floor(x), sympy.Derivative: _nondifferentiable, } except ImportError: #pragma:nocover _sympy_available = False # A "public" attribute indicating that differentiate() can be called # ... this provides a bit of future-proofing for alternative approaches # to symbolic differentiation. differentiate_available = _sympy_available