Python. Sympy. Как решить неравенство с логарифмами? solve не помогает

Требуется решить уравнение: log(3*x-1, 1/3)<log(3-x, 1/3) Написала вот такой код:

from sympy import *

init_printing()

y, x, z = symbols('y x z')
y1, y2 = var('y1 y2')

y1 = log(3*x-1, 1/3)
y2 = log(3-x, 1/3)


y = y1-y2
y = simplify(y)
pprint(y)

print("Найденные решения:")
pprint(solve(y<0,x))

На что компилятор мне выдает ошибку на команде solve(y<0,x):

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/sympy/polys/polyutils.py", line 211, in _parallel_dict_from_expr_if_gens
    monom[indices[base]] = exp
KeyError: log(3 - _x)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/sympy/solvers/inequalities.py", line 815, in _solve_inequality
    p = Poly(expr, s)
  File "/usr/local/lib/python3.6/dist-packages/sympy/polys/polytools.py", line 159, in __new__
    return cls._from_expr(rep, opt)
  File "/usr/local/lib/python3.6/dist-packages/sympy/polys/polytools.py", line 288, in _from_expr
    rep, opt = _dict_from_expr(rep, opt)
  File "/usr/local/lib/python3.6/dist-packages/sympy/polys/polyutils.py", line 368, in _dict_from_expr
    rep, gens = _dict_from_expr_if_gens(expr, opt)
  File "/usr/local/lib/python3.6/dist-packages/sympy/polys/polyutils.py", line 307, in _dict_from_expr_if_gens
    (poly,), gens = _parallel_dict_from_expr_if_gens((expr,), opt)
  File "/usr/local/lib/python3.6/dist-packages/sympy/polys/polyutils.py", line 217, in _parallel_dict_from_expr_if_gens
    "the set of generators." % factor)
sympy.polys.polyerrors.PolynomialError: log(3 - _x) contains an element of the set of generators.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/sympy/polys/polyutils.py", line 211, in _parallel_dict_from_expr_if_gens
    monom[indices[base]] = exp
KeyError: log(3 - _x)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/sympy/solvers/inequalities.py", line 251, in reduce_rational_inequalities
    (numer, denom), gen)
  File "/usr/local/lib/python3.6/dist-packages/sympy/polys/polytools.py", line 4312, in parallel_poly_from_expr
    return _parallel_poly_from_expr(exprs, opt)
  File "/usr/local/lib/python3.6/dist-packages/sympy/polys/polytools.py", line 4365, in _parallel_poly_from_expr
    reps, opt = _parallel_dict_from_expr(exprs, opt)
  File "/usr/local/lib/python3.6/dist-packages/sympy/polys/polyutils.py", line 332, in _parallel_dict_from_expr
    reps, gens = _parallel_dict_from_expr_if_gens(exprs, opt)
  File "/usr/local/lib/python3.6/dist-packages/sympy/polys/polyutils.py", line 217, in _parallel_dict_from_expr_if_gens
    "the set of generators." % factor)
sympy.polys.polyerrors.PolynomialError: log(3 - _x) contains an element of the set of generators.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/sympy/solvers/inequalities.py", line 824, in _solve_inequality
    rv = reduce_rational_inequalities([[ie]], s)
  File "/usr/local/lib/python3.6/dist-packages/sympy/solvers/inequalities.py", line 256, in reduce_rational_inequalities
    '''))
sympy.polys.polyerrors.PolynomialError: 
only polynomials and rational functions are supported in this context.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/sympy/solvers/inequalities.py", line 524, in solve_univariate_inequality
    solns = solvify(e, gen, domain)
  File "/usr/local/lib/python3.6/dist-packages/sympy/solvers/solveset.py", line 2151, in solvify
    raise NotImplementedError('solveset is unable to solve this equation.')
NotImplementedError: solveset is unable to solve this equation.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/lizard/Документы/geophys_prog/task_4/4.6(не сделано).py", line 18, in <module>
    pprint(solve(y<0,x))
  File "/usr/local/lib/python3.6/dist-packages/sympy/solvers/solvers.py", line 908, in solve
    return reduce_inequalities(f, symbols=symbols)
  File "/usr/local/lib/python3.6/dist-packages/sympy/solvers/inequalities.py", line 993, in reduce_inequalities
    rv = _reduce_inequalities(inequalities, symbols)
  File "/usr/local/lib/python3.6/dist-packages/sympy/solvers/inequalities.py", line 924, in _reduce_inequalities
    other.append(_solve_inequality(Relational(expr, 0, rel), gen))
  File "/usr/local/lib/python3.6/dist-packages/sympy/solvers/inequalities.py", line 826, in _solve_inequality
    rv = solve_univariate_inequality(ie, s)
  File "/usr/local/lib/python3.6/dist-packages/sympy/solvers/inequalities.py", line 534, in solve_univariate_inequality
    ''' % expr.subs(gen, Symbol('x'))))
NotImplementedError: 
The inequality, 0.910239226626837*log(3 - x) -
0.910239226626837*log(3*x - 1) < 0, cannot be solved using
solve_univariate_inequality.

Process finished with exit code 1

Есть ли другой метод, который сможет решить это неравенство? Если есть, то какой?


Ответы (0 шт):