Exemple #1
0
 def test_GetMaxCoef(self):
     print "######## test_GetMaxCoef ##########"
     expr1 = A*B*X + C**2 - X
     expr2 = Y*Z - B
     self.assertEqual(symoro.get_max_coef(expr1*X + expr2, X), expr1)
     expr3 = -A**3*B**2*X**5*(X-Y)**7
     expr3x = -A**3*B**2*X**5*(-X-Y)**7
     expr3y = -A**3*B**2*X**5*(-X+Y)**7
     expr4 = B*X**2*(X-Y)**3
     self.assertEqual(symoro.get_max_coef(expr3*expr4, expr4), expr3)
     self.assertEqual(symoro.get_max_coef(expr3x, expr4), symoro.ZERO)
     res = symoro.get_max_coef(expr3y, expr4)*expr4-expr3y
     self.assertEqual(res.expand(), symoro.ZERO)
Exemple #2
0
def _get_coefs(eq, A1, A2, *xs):
    eqe = eq.expand()
    X = get_max_coef(eqe, A1)
    eqe = eqe.xreplace({A1: ZERO})
    Y = get_max_coef(eqe, A2)
    Z = eqe.xreplace({A2: ZERO})
    #    is_ok = not X.has(A2) and not X.has(A1) and not Y.has(A2)
    is_ok = True
    is_ok &= _check_const((X, Y, Z), *xs)
    #    if is_ok != is_ok2:
    #        print 'GET COEF333333333333333333333333333333333333333333333"'
    #        print X, Y, Z, is_ok
    #        print eq, 'i', A1, 'i', A2
    #        print xs
    return X, Y, Z, is_ok
Exemple #3
0
def _try_solve_0(symo, eq_sys, known):
    res = False
    for eq, [r], th_names in eq_sys:
        X = get_max_coef(eq, r)
        if X != 0:
            Y = X * r - eq
            print "type 1"
            X = symo.replace(symo.CS12_simp(X), "X", r)
            Y = symo.replace(symo.CS12_simp(Y), "Y", r)
            symo.add_to_dict(r, Y / X)
            known.add(r)
            res = True
    return res