def test_cosec(): assert Expression("(cosec x)").differentiate(wrt="x").toString() in ("((-(cosec x))*(cot x))","(-((cosec x)*(cot x)))")
def test_cot(): assert Expression("(cot x)").differentiate(wrt="x").toString() == "(-((cosec x)^2.0))"
def test_tan(): assert Expression("(tan x)").differentiate(wrt="x").toString() == "((sec x)^2.0)"
def test_sec(): assert Expression("(sec x)").differentiate(wrt="x").toString() == "((sec x)*(tan x))"
def test_01(): assert Expression("(ln (sin x))").differentiate( wrt="x").toString() in ("((cos x)*(1.0/(sin x))", "((1.0/(sin x)*(cos x))", "((cos x)/(sin x))", "(cot x)")
def test_cos(): assert Expression("(cos x)").differentiate(wrt="x").toString() == "(-(sin x))"
def test_multiply(): assert Expression("(x*x)").differentiate(wrt="x").toString() == "(x+x)"
def test_diffvar(): assert Expression("m").differentiate(wrt="x").toString() == "0.0"
def test_add(): assert Expression("(x+x)").differentiate(wrt="x").toString() == "(1.0+1.0)"
def test_subtract(): assert Expression("(x-x)").differentiate(wrt="x").toString() == "(1.0-1.0)"
from Differentiate import Expression EXPR = [ "((((x^2.0)+4.0)/x)^((x*(2.0*m))-24.0))", "((x*2.0)*(((x^2.0)+6.0)/m))", "(((x^3.0)+(5.0*x))^((sin x)^2.0))" ] WRT = ["x", "m"] for wrt in WRT: for expr in EXPR: print("Input :\n" + expr) e = Expression(expr) f = e.differentiate(wrt=wrt) print("Output : (w.r.t. " + wrt + ")") res = f.toString(echo=True) print() print()
def test_cot(): assert Expression("(cot x)").differentiate(wrt="x").toString(allow_unary_minus=False) == "(0.0-((cosec x)^2.0))"
def test_var(): assert Expression("(0.0-x)").differentiate(wrt="x").toString(allow_unary_minus=False) == "(0.0-1.0)"
def test_ln(): assert Expression("(ln x)").differentiate(wrt="x").toString() == "(1.0/x)"
def test_constant(): assert Expression("2008.0").differentiate(wrt="x").toString() == "0.0"
def test_pow(): assert Expression("(x^2.0)").differentiate(wrt="x").toString() == "(2.0*x)"
def test_multiply(): assert Expression("(x/x)").differentiate(wrt="x").toString() == "((x-x)/(x^2.0))"
def test_variable(): assert Expression("x").differentiate(wrt="x").toString() == "1.0"
def test_00(): assert Expression("(sin (2.0*x))").differentiate( wrt="x").toString() in ("(2.0*(cos (2.0*x)))", "((cos (2.0*x))*2.0)")