Hi David,
I agree entirely. Neither gives a sensible result in 1.5 and both will
give errors in 1.6.
The Equation class I showed handles all of these though:
In [27]: x, y = symbols('x, y', real=True)
In [28]: eq = Equation(x, y)
In [29]: eq
Out[29]: x = y
In [30]: eq + 1
Out[30]: x + 1 = y + 1
In [31]: eq + eq
Out[31]: 2*x = 2*y
In [32]: eq1 = Equation(exp(I*x), cos(x)+I*sin(x))
In [33]: eq1
Out[33]: exp(I*x) = I*sin(x) + cos(x)
In [34]: eq2 = eq1.applyfunc(conjugate)
In [35]: eq2
Out[35]: exp(-I*x) = -I*sin(x) + cos(x)
In [36]: (eq1 - eq2)/2
Out[36]: exp(I*x)/2 - exp(-I*x)/2 = I*sin(x)
In [37]: (eq1 + eq2)/2
Out[37]: exp(I*x)/2 + exp(-I*x)/2 = cos(x)
--
Oscar
On Thu, 30 Apr 2020 at 23:29, David Bailey <[email protected]> wrote:
>
> On 30/04/2020 19:18, Oscar Benjamin wrote:
>
> In 1.5 it just gives a nonsense object:
>
> In [1]: Eq(x, y) + Eq(z, t)
> Out[1]: (x = y) + (z = t)
>
> However, it should surely be valid to add an equation to an expression:
>
> >>> Eq(a-3,b-3)+3
>
> 3 + Eq(a-3,b-3)
>
> >>> simplify(3 + Eq(a - 3, b - 3))
>
> 3 + Eq(a - 3, b - 3)
>
> Obviously I thought that would produce Eq(a,b)
>
> At 1.5 the addition happens but the result doesn't simplify in the obvious
> way. Is there a rational to that? From what you say, I suspect this construct
> will also be banned at 1.6, but it seems perfectly meaningful.
>
> David
>
> --
> 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 [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sympy/645e3ca5-267d-5368-b0e8-9837a7e47598%40dbailey.co.uk.
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/sympy/CAHVvXxQS4XeNKUOhVx-wr_wh_gs0b61xjXF9KWxRpDeYgdUs_A%40mail.gmail.com.