Q is just a namespace for the assumptions, like Q.positive or Q.real. refine() simplifies things based on assumptions. This example returns x - y, because sqrt((x - y)**2) is equal to x - y if x - y is positive (but not in general).
What kinds of simplifications are you expecting to get out of your constraints? Aaron Meurer On Mon, Nov 10, 2014 at 5:42 PM, Andrew Spielberg <aespielb...@gmail.com> wrote: > Hi Aaron, > > Thanks for the speedy reply. I'm not sure I fully understand what this > example does, or how. Could you perhaps elaborate? What is Q? What is > the difference between refine and simplify? > > I should note that the entirety of my constraints will be linear, so if > the current functionality can do that, that's enough. > > -Andy S. > > On Mon, Nov 10, 2014 at 5:06 PM, Aaron Meurer <asmeu...@gmail.com> wrote: > >> There is a framework to do this with refine, like refine(sqrt((x - >> y)**2), Q.positive(x - y)), but not much is implemented yet, so the >> simplifications possible are quite limited (in fact, there's not much more >> than the one that I just showed that is implemented). >> >> Aaron Meurer >> >> On Mon, Nov 10, 2014 at 3:58 PM, Andrew Spielberg <aespielb...@gmail.com> >> wrote: >> >>> Hi all, >>> >>> When creating variables, I know you can provide certain constraints on >>> the domain of that variable. For instance, one could say that a certain >>> variable, x, is positive, real, rational, etc. These constraints affect >>> the way the simplify function behaves. >>> >>> I am wondering, without creating auxiliary variables, can add other >>> constraints? For example, if I have a variable x that always must be >>> greater than another variable y, can I specify: >>> >>> x > y >>> >>> in some way, and have the simplifier intelligently know how to handle >>> it? I know I could change my representation to be a = (x - y) and do >>> everything in terms of my variable a, and set a positive, but this is less >>> than ideal and will not work in a lot of my cases. >>> >>> If there is no way to set these assumptions, is there some other >>> recommended way to do intelligent simplification in some way? >>> >>> -Andy S. >>> >>> -- >>> 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 http://groups.google.com/group/sympy. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/sympy/80f87d8d-1504-40f6-b6d4-efb08cdcc824%40googlegroups.com >>> <https://groups.google.com/d/msgid/sympy/80f87d8d-1504-40f6-b6d4-efb08cdcc824%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> -- >> 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 http://groups.google.com/group/sympy. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/sympy/CAKgW%3D6L3OorvtGQaXp7RUg2RGtVweSgUk2XNQ_tDs%2BqYB5-iMg%40mail.gmail.com >> <https://groups.google.com/d/msgid/sympy/CAKgW%3D6L3OorvtGQaXp7RUg2RGtVweSgUk2XNQ_tDs%2BqYB5-iMg%40mail.gmail.com?utm_medium=email&utm_source=footer> >> . >> >> For more options, visit https://groups.google.com/d/optout. >> > > -- > 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 http://groups.google.com/group/sympy. > To view this discussion on the web visit > https://groups.google.com/d/msgid/sympy/CAM6e1JdxBKnfSxEMPxJnUqkd7XwOdkU4fddaqPRQmqGAaMZO-A%40mail.gmail.com > <https://groups.google.com/d/msgid/sympy/CAM6e1JdxBKnfSxEMPxJnUqkd7XwOdkU4fddaqPRQmqGAaMZO-A%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > > For more options, visit https://groups.google.com/d/optout. > -- 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 http://groups.google.com/group/sympy. To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/CAKgW%3D6%2Bn0vvxOd3H%2B-4rRdQOh4Std7uCfjzFudvbs9gQzOM5yQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.