def test_derivative1(): x, y = map(Symbol, 'xy') p, q = map(Wild, 'pq') f = Function('f', nargs=1) fd = Derivative(f(x), x) assert fd.match(p) == {p: fd} assert (fd + 1).match(p + 1) == {p: fd} assert (fd).match(fd) == {} assert (3 * fd).match(p * fd) is not None assert (3 * fd - 1).match(p * fd + q) == {p: 3, q: -1}
def test_derivative1(): x, y = map(Symbol, 'xy') p, q = map(Wild, 'pq') f = Function('f', nargs=1) fd = Derivative(f(x), x) assert fd.match(p) == {p: fd} assert (fd + 1).match(p + 1) == {p: fd} assert (fd).match(fd) == {} assert (3*fd).match(p*fd) is not None assert (3*fd - 1).match(p*fd + q) == {p: 3, q: -1}
def test_derivative1(): x,y = map(Symbol, 'xy') p,q = map(Wild, 'pq') f = Function('f',nargs=1) fd = Derivative(f(x), x) assert fd.match(p) == {p: fd} assert (fd+1).match(p+1) == {p: fd} assert (fd).match(fd) == {} assert (3*fd).match(p*fd) != None p = Wild("p", exclude=[x]) q = Wild("q", exclude=[x]) assert (3*fd-1).match(p*fd + q) == {p: 3, q: -1}
def test_derivative1(): x, y = map(Symbol, 'xy') p, q = map(Wild, 'pq') f = Function('f', nargs=1) fd = Derivative(f(x), x) assert fd.match(p) == {p: fd} assert (fd + 1).match(p + 1) == {p: fd} assert (fd).match(fd) == {} assert (3 * fd).match(p * fd) != None p = Wild("p", exclude=[x]) q = Wild("q", exclude=[x]) assert (3 * fd - 1).match(p * fd + q) == {p: 3, q: -1}
def test_derivative2(): f = Function("f") x = Symbol("x") a = Wild("a", exclude=[f, x]) b = Wild("b", exclude=[f]) e = Derivative(f(x), x) assert e.match(Derivative(f(x), x)) == {} assert e.match(Derivative(f(x), x, x)) is None e = Derivative(f(x), x, x) assert e.match(Derivative(f(x), x)) is None assert e.match(Derivative(f(x), x, x)) == {} e = Derivative(f(x), x) + x**2 assert e.match(a * Derivative(f(x), x) + b) == {a: 1, b: x**2} assert e.match(a * Derivative(f(x), x, x) + b) is None e = Derivative(f(x), x, x) + x**2 assert e.match(a * Derivative(f(x), x) + b) is None assert e.match(a * Derivative(f(x), x, x) + b) == {a: 1, b: x**2}
def test_derivative2(): f = Function("f") x = Symbol("x") a = Wild("a", exclude=[f, x]) b = Wild("b", exclude=[f]) e = Derivative(f(x), x) assert e.match(Derivative(f(x), x)) == {} assert e.match(Derivative(f(x), x, x)) == None e = Derivative(f(x), x, x) assert e.match(Derivative(f(x), x)) == None assert e.match(Derivative(f(x), x, x)) == {} e = Derivative(f(x), x)+x**2 assert e.match(a*Derivative(f(x), x) + b) == {a: 1, b: x**2} assert e.match(a*Derivative(f(x), x, x) + b) == None e = Derivative(f(x), x, x)+x**2 assert e.match(a*Derivative(f(x), x) + b) == None assert e.match(a*Derivative(f(x), x, x) + b) == {a: 1, b: x**2}