Hi all,

I find the behaviour of operations involving Eq strange. I would
really like to be able to use Eqs for algebra but they don't seem to
do anything useful. Is this behaviour intentional or is it something
that could be improved?

Setup:
>>> from sympy import *
>>> x = Symbol('x')
>>> y = Symbol('y')
>>> eq = Eq(x, y)
>>> eq
Eq(x, y)
>>> pprint(eq)
x = y

I don't understand what any of these mean:
>>> pprint(2*eq)
2⋅(x = y)
>>> pprint((2*eq).expand())
2⋅(x = y)
>>> exp(eq)
exp(Eq(x, y))
>>> pprint(abs(eq))
│x = y│
>>> eq - 1
-1 + Eq(x, y)
>>> pprint(eq - 1)
-1 + (x = y)

Integration works but differentiation doesn't:
>>> pprint(integrate(eq, x))
⌠        ⌠
⎮ x dx = ⎮ y dx
⌡        ⌡
>>> pprint(integrate(eq, x).doit())
 2
x
── = x⋅y
2
>>> diff(eq, x)
Derivative(Eq(x, y), x)
>>> pprint(diff(eq, x))
∂
──(x = y)
∂x
>>> pprint(diff(eq, x).doit())
∂
──(x = y)
∂x

Functions of Eq raise errors:
>>> sin(eq)
...
TypeError: cannot determine truth value of Relational

It looks as if I can chain equations and inequalities but does it
actually mean what it looks like mathematically?
>>> eq < 3
Eq(x, y) < 3
>>> pprint(eq < 3)
x = y < 3

Apart from the inequality example at the end I would like it if all of
the above operations acted on both lhs and rhs separately as in the
case of integration e.g.:

>>> eq
x = y
>>> 2*eq
2*x = 2*y
>>> sin(eq)
sin(x) = sin(y)

The other thing that I don't understand although it is clearly
documented is this:
>>> Eq(1, 1)
True
>>> Eq(1, 0)
False

These True/False values are annoying if you are building up Eqs
programatically e.g. to pass to solve:
>>> solve([Eq(1, 1), Eq(x, y), Eq(x, 1)], [x, y])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/enojb/current/sympy/sympy/sympy/solvers/solvers.py",
line 980, in solve
    return reduce_inequalities(f, symbols=symbols)
  File "/Users/enojb/current/sympy/sympy/sympy/solvers/inequalities.py",
line 987, in reduce_inequalities
    rv = _reduce_inequalities(inequalities, symbols)
  File "/Users/enojb/current/sympy/sympy/sympy/solvers/inequalities.py",
line 907, in _reduce_inequalities
    '''))
NotImplementedError:
inequality has more than one symbol of interest.

You can solve this last problem with evaluate=False but I really don't
understand why any evaluation is desirable here. I think that solve
has probably gotten confused here for the same reason that any other
code would: the True/False objects don't have any of the same
attributes that an Eq would have:

>>> Eq(0, 1).lhs
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'BooleanFalse' object has no attribute 'lhs'


--
Oscar

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To post to this group, send email to sympy@googlegroups.com.
Visit this group at https://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/CAHVvXxRgh9Wb7sfvzUtrmH5iYCWY4V%3D1thxtaiQQda%3DMbaw-iw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to