def test_custom_math_functions(self, printer, x): assert printer.doprint(acos_(x)) == 'acos(x)' assert printer.doprint(cos_(x)) == 'cos(x)' assert printer.doprint(exp_(x)) == 'exp(x)' assert printer.doprint(sin_(x)) == 'sin(x)' assert printer.doprint(sqrt_(x)) == 'sqrt(x)' assert printer.doprint(abs_(x)) == 'abs(x)'
def test_sin_(x, expr): assert sin_(x).is_real assert sin_(x).diff() == cos_(x) assert sin_(expr).diff() == expr.diff() * cos_(expr)
def test_substitute_math_func_(x, expr): expr2 = (expr * exp_(x) + abs_(1 - 2) + acos_(0) * sin_(pi / 2) * cos_(0)) / sqrt_(x) expr_placeholders_replaced = subs_math_func_placeholders(expr2) assert expr_placeholders_replaced == (expr * exp(x) + Abs(1 - 2) + acos(0) * sin(pi / 2) * cos(0)) / sqrt(x)
def test_cos_(x, expr): assert cos_(x).is_real assert cos_(x).diff() == -sin_(x) assert cos_(expr).diff() == expr.diff() * - sin_(expr)