Example #1
0
def test_cosec():
	assert Expression("(cosec x)").differentiate(wrt="x").toString() in ("((-(cosec x))*(cot x))","(-((cosec x)*(cot x)))")
Example #2
0
def test_cot():
	assert Expression("(cot x)").differentiate(wrt="x").toString() == "(-((cosec x)^2.0))"
Example #3
0
def test_tan():
	assert Expression("(tan x)").differentiate(wrt="x").toString() == "((sec x)^2.0)"
Example #4
0
def test_sec():
	assert Expression("(sec x)").differentiate(wrt="x").toString() == "((sec x)*(tan x))"
Example #5
0
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)")
Example #6
0
def test_cos():
	assert Expression("(cos x)").differentiate(wrt="x").toString() == "(-(sin x))"
Example #7
0
def test_multiply():
	assert Expression("(x*x)").differentiate(wrt="x").toString() == "(x+x)"
Example #8
0
def test_diffvar():
	assert Expression("m").differentiate(wrt="x").toString() == "0.0"
Example #9
0
def test_add():
	assert Expression("(x+x)").differentiate(wrt="x").toString() == "(1.0+1.0)"
Example #10
0
def test_subtract():
	assert Expression("(x-x)").differentiate(wrt="x").toString() == "(1.0-1.0)"
Example #11
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)"
Example #14
0
def test_ln():
	assert Expression("(ln x)").differentiate(wrt="x").toString() == "(1.0/x)"
Example #15
0
def test_constant():
	assert Expression("2008.0").differentiate(wrt="x").toString() == "0.0"
Example #16
0
def test_pow():
	assert Expression("(x^2.0)").differentiate(wrt="x").toString() == "(2.0*x)"
Example #17
0
def test_multiply():
	assert Expression("(x/x)").differentiate(wrt="x").toString() == "((x-x)/(x^2.0))"
Example #18
0
def test_variable():
	assert Expression("x").differentiate(wrt="x").toString() == "1.0"
Example #19
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)")