Example #1
0
def test_primitive_valid():
    x, Y, Z = map(Symbol, 'x Y Z'.split())
    assert primitive_valid(log(x), 1/x, x)

    integrand = 1/((Y-x)*(Z-x))
    primitive_attempt = 1/(Y-Z)*log((Y-x)/(Z-x))
    assert primitive_valid(primitive_attempt, integrand, x)
Example #2
0
def test_primitive_valid():
    x, Y, Z = map(Symbol, 'x Y Z'.split())
    assert primitive_valid(log(x), 1 / x, x)

    integrand = 1 / ((Y - x) * (Z - x))
    primitive_attempt = 1 / (Y - Z) * log((Y - x) / (Z - x))
    assert primitive_valid(primitive_attempt, integrand, x)
Example #3
0
    4*a*c > b**2,
]

C = symbols('C')
gen_integral_eq = Eq(Integral(gen_integrand,x), Piecewise(*zip([p+C for p in primitives], conds)))

for i, (prim, cond) in enumerate(zip(primitives, conds)):
    if i == 0:
        _a, _b, _c = 2, 3, 1
    elif i == 1:
        _a, _b, _c = 2, 4, 2
    else:
        _a, _b, _c = 3, 2, 4
    subsd = {a: _a, b: _b, c: _c}
    assert cond.subs(subsd) == True
    assert primitive_valid(prim, gen_integrand, x, subsd)


#inte_eq_lhs = Integral(gen_integrand.subs({x: chi}), (chi,0,x))
inte_eq_lhs = Integral((1/rate_expr).subs({x: chi}), (chi,0,x))
inte_eq_rhs = Integral(1, (tau,0,t))
inte_eq = Eq(inte_eq_lhs, inte_eq_rhs)
eqs.append(inte_eq)

eqs.append({k: subs[k] for k in [a, b, c]})
P_ = sqrt(b**2-4*a*c)
subs[P] = P_
eqs.append(Eq(P, P_))

candid = 1/P*log((2*a*x+b-P)/(2*a*x+b+P))
assert primitive_valid(candid.subs({P: P_}), gen_integrand, x)
Example #4
0
    4*a*c > b**2,
]

C = symbols('C')
gen_integral_eq = Eq(Integral(gen_integrand,x), Piecewise(*zip([p+C for p in primitives], conds)))

for i, (prim, cond) in enumerate(zip(primitives, conds)):
    if i == 0:
        _a, _b, _c = 2, 3, 1
    elif i == 1:
        _a, _b, _c = 2, 4, 2
    else:
        _a, _b, _c = 3, 2, 4
    subsd = {a: _a, b: _b, c: _c}
    assert cond.subs(subsd) == True
    assert primitive_valid(prim, gen_integrand, x, subsd)


#inte_eq_lhs = Integral(gen_integrand.subs({x: chi}), (chi,0,x))
inte_eq_lhs = Integral((1/rate_expr).subs({x: chi}), (chi,0,x))
inte_eq_rhs = Integral(1, (tau,0,t))
inte_eq = Eq(inte_eq_lhs, inte_eq_rhs)
eqs.append(inte_eq)

eqs.append({k: subs[k] for k in [a, b, c]})
P_ = sqrt(b**2-4*a*c)
subs[P] = P_
eqs.append(Eq(P, P_))

candid = 1/P*log((2*a*x+b-P)/(2*a*x+b+P))
assert primitive_valid(candid.subs({P: P_}), gen_integrand, x)