x = symbols('x')
expr = (x + 1) * (x + 2)
expr.subs(x, 3)
will result in 12
(the factors are combined), while expr.subs(x, 'y')
will result in (y + 1) * (y + 2)
(the factors are left uncombined). --
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+un...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/sympy/fec1e0d2-a271-4cea-8cd0-ab4c216ef721n%40googlegroups.com.
Hi Oscar,
Thanks for your reply. So the (double) Schubert polynomials just form a different basis for the regular multivariable polynomial ring, so in quantity they are infinite (indexed by permutations, which I created my own class for layered on top of the sympy Permutation class because it's not quite suitable for what I need) but like the ordinary monomials you only use finitely many at a time, and they're just regular polynomials. So I should be able to just add a normal algebraic combination of variables to it. What Poly would do, as far as I understand, is convert anything to a poly that you add to it. This can be done with the Schubert polynomials, but it's an extremely expensive operation, and you would only want to do it on purpose.
To be a little clearer, let me show an.example with my implementation.
from IPython.display import display
from sympy import init_session, init_printing
from schubmult import *
init_session(order='old',use_latex=True,pretty_print=True)
display(DSx([3,4,1,2]).expand())
$\displaystyle 2 x_{1} x_{2} y_{1} y_{2} + x_{1}^{2} x_{2}^{2} + y_{1}^{2} y_{2}^{2} + x_{1} x_{2} y_{1}^{2} + x_{1} x_{2} y_{2}^{2} + y_{1} y_{2} x_{1}^{2} + y_{1} y_{2} x_{2}^{2} - x_{1} y_{1} x_{2}^{2} - x_{1} y_{1} y_{2}^{2} - x_{1} y_{2} x_{2}^{2} - x_{1} y_{2} y_{1}^{2} - x_{2} y_{1} x_{1}^{2} - x_{2} y_{1} y_{2}^{2} - x_{2} y_{2} x_{1}^{2} - x_{2} y_{2} y_{1}^{2}$
This is substitutible, so if I plug in "z" rather than the default y variable I get
$\displaystyle 2 x_{1} x_{2} z_{1} z_{2} + x_{1}^{2} x_{2}^{2} + z_{1}^{2} z_{2}^{2} + x_{1} x_{2} z_{1}^{2} + x_{1} x_{2} z_{2}^{2} + z_{1} z_{2} x_{1}^{2} + z_{1} z_{2} x_{2}^{2} - x_{1} z_{1} x_{2}^{2} - x_{1} z_{1} z_{2}^{2} - x_{1} z_{2} x_{2}^{2} - x_{1} z_{2} z_{1}^{2} - x_{2} z_{1} x_{1}^{2} - x_{2} z_{1} z_{2}^{2} - x_{2} z_{2} x_{1}^{2} - x_{2} z_{2} z_{1}^{2}$
The polynomial ring is in the indexed x variables, and another set of indexed symbols that are considered constant and part of the "double" Schubert polynomials (DSx), which are arbitrary. But only two sets of variables are required to express everything, so if I include both y and z, I don't have a basis anymore and it's difficult to test equality, but it's a valid operation, which is why it makes sense to leave it as an uncombined sympy.Add.
The coefficients of the double Schubert polynomials can also themselves be polynomials, and I want to leave those as Expr because sometimes I want to express them in a certain way that it's not obvious they can be expressed in if you expand them into monomials, and the expression is not in terms of a basis, and it's extremely expensive to compute. For example,
--
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+un...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/sympy/CAHVvXxSYsJ_YNEn1O38DcJbFx4g7ojtmg%3D_xp6qHGhCbWyeGPQ%40mail.gmail.com.
To view this discussion visit https://groups.google.com/d/msgid/sympy/CAF%2B7YfG91iSNELEQmDctbxZdA_3%3DP%2Bgrxifb3njW7GOfBSPV4A%40mail.gmail.com.
Hi Matt,When I say "something more like Poly rather than Expr" I don't necessarily mean that you should use Poly. The difference between these is that:- Expr is a general representation of expressions as trees.- Poly is a specialised data structure that represents polynomials in a canonical form over some domain.
Generally if you are doing any significant computational work it is better to use a specialised data structure and/or canonical representation rather than expression trees. I don't
understand exactly what sort of calculations you want to do with the Schubert polynomials but I imagine that if I was doing it I would make a special (non-Expr) data structure for the main calculations and then separately have an .as_expr() method (like Poly does) for converting to Expr if there are situations where that is useful.
It is possible that some existing things in SymPy would provide the data structure that you need but I don't know because I'm a bit unclear what it is you need to do with it. One possibility for example is that it could make sense to wrap your Schubert polynomials up as a "domain" so that you could have a Poly whose coefficients are Schubert polynomials. Another possibility is that you could choose a finite basis for a calculation and use matrices to represent e.g. linear combinations of Schubert polynomials.
To view this discussion visit https://groups.google.com/d/msgid/sympy/CAHVvXxTThndRoBbUZ7hi_16RiAKKc18BoaRY%2Bte7Merjr0GVYg%40mail.gmail.com.
To view this discussion visit https://groups.google.com/d/msgid/sympy/CAF%2B7YfGi%3DJg9ChjJ1KqKh76_qT12S6LxXg5NtRH1QvheWwiX7w%40mail.gmail.com.
To view this discussion visit https://groups.google.com/d/msgid/sympy/CAF%2B7YfGi%3DJg9ChjJ1KqKh76_qT12S6LxXg5NtRH1QvheWwiX7w%40mail.gmail.com.
To view this discussion visit https://groups.google.com/d/msgid/sympy/CAHVvXxR%2B7hCdGesGJ%3DFu3rpTDEQX6JA4BPb3kY4077jO6MpFAw%40mail.gmail.com.
To view this discussion visit https://groups.google.com/d/msgid/sympy/CAF%2B7YfGp04tt_-RwDu9BmfUF%3DUz-etj58j5yhU8FeoWdJPh66g%40mail.gmail.com.