I need to write a very general function that will work whatever values and assumptions you plug into it - the (0,1) example is just a simple case that I wanted to check to make sure it's actually possible to do. Thank you for your help, I will keep looking for different solutions!
On Wed, Oct 16, 2013 at 1:12 AM, Aaron Meurer <[email protected]> wrote: > If you know the ordering is total (i.e., for any two expressions one is > greater than the other in your given domain), you could just evaluate at > some value in (0, 1) and sort by that. > > By the way, how general are your expressions? Do they have symbolic > constants (more than one symbol)? Are they always polynomials or rational > functions? > > Aaron Meurer > > On Oct 15, 2013, at 6:08 PM, BR <[email protected]> wrote: > > Unfortunately, the example is just a basic case of the functionality I'd > want to use - I need a reliable way of sorting symbolic values like that. > Other software I've tried struggles with this a lot, so I thought SymPy > would work better - unfortunately not! Thank you for your reply anyway. > > > On Wednesday, 16 October 2013 00:45:38 UTC+1, Aaron Meurer wrote: >> >> I think the logic you want isn't implemented. Right now, the >> assumptions module doesn't really do anything with interval type >> assumptions, like 0 < x < 1. It only knows about assumptions like >> positive or negative. >> >> Of course, if all you want to do is sort symbols by their exponent, >> that is not too difficult to do, especially if you know for sure that >> each element of your list is a power of that symbol. You just need to >> define an appropriate key function and use it when sorting. >> >> Aaron Meurer >> >> On Tue, Oct 15, 2013 at 3:47 PM, BR <[email protected]> wrote: >> > Hey, >> > >> > I've been trying to find some information online on SymPy's assumptions >> > module and unfortunately I can't find an answer to my question. Is it >> > possible to declare symbols with assumptions in such a way that they >> are >> > respected when sorting them? For instance, is it possible to declare a >> > symbol x with the assumption that 0<x<1, so that sorting [w, w**2, >> w**3] >> > gives [w**3, w**2, w]? >> > >> > Thanks. >> > >> > -- >> > 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 post to this group, send email to [email protected]. >> > Visit this group at http://groups.google.com/group/sympy. >> > For more options, visit https://groups.google.com/groups/opt_out. >> > -- > 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 post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/sympy. > For more options, visit https://groups.google.com/groups/opt_out. > > -- > You received this message because you are subscribed to a topic in the > Google Groups "sympy" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/sympy/v_J3MYJsJTs/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/sympy. > For more options, visit https://groups.google.com/groups/opt_out. > -- 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 post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sympy. For more options, visit https://groups.google.com/groups/opt_out.
