Note that if you want to kill all abs in your expression, there's an easier way. expr.replace(Abs, Id)
Aaron Meurer On Fri, Nov 14, 2014 at 5:02 PM, Aaron Meurer <asmeu...@gmail.com> wrote: > As I said, it's *very* proof of concept. Many advanced things don't work. > > In this case, I think the issue is with the assumptions in general. They > can't deduce from the facts And(Q.positive(-beamwidth), > Q.positive(-length), Q.positive(0.9*beamwidth - length)) > that 0.866025403784438*beamwidth - length is positive. I'm not even > sure what algorithms need to be implemented to make this work. > > Why are your beamwidth and length variables negative? From the variable > names, they sound like they should be positive? > > Aaron Meurer > > On Wed, Nov 12, 2014 at 9:44 PM, Andrew Spielberg <aespielb...@gmail.com> > wrote: > >> refine_abs isn't doing the trick here either. Am I using this module >> incorrectly? >> >> On Tue, Nov 11, 2014 at 6:09 PM, Andrew Spielberg <aespielb...@gmail.com> >> wrote: >> >>> Thanks guys. This seems to be mostly working so far. >>> >>> Any idea why this wouldn't be, though? >>> >>> In [1]: assumptions >>> Out[1]: And(Q.positive(-beamwidth), Q.positive(-length), >>> Q.positive(0.9*beamwidth - length)) >>> >>> In [2]: exp >>> Out[2]: 0.866025403784439*beamwidth*(0.866025403784438*beamwidth - >>> length)/Abs(0.866025403784438*beamwidth - length) >>> >>> In [3]: math.refine(exp, assumptions) >>> Out[3]: 0.866025403784439*beamwidth*(0.866025403784438*beamwidth - >>> length)/Abs(0.866025403784438*beamwidth - length) >>> >>> (math is my sympy module) >>> >>> A little confused here as to why the fraction wouldn't simplify out. >>> (0.866025403784438*beamwidth - length)/Abs(0.866025403784438*beamwidth - >>> length) should be 1. >>> >>> -Andy S. >>> >>> >>> On Tue, Nov 11, 2014 at 3:16 AM, Mateusz Paprocki <matt...@gmail.com> >>> wrote: >>> >>>> Hi, >>>> >>>> On 11 November 2014 01:13, Aaron Meurer <asmeu...@gmail.com> wrote: >>>> > Q is just a namespace for the assumptions, like Q.positive or Q.real. >>>> > >>>> > refine() simplifies things based on assumptions. >>>> >>>> I think we shouldn't use "refine()" and "simplifies" together as this >>>> only can increase confusion. Simplification implies that there is an >>>> optimisation procedure applied. refine() just transforms an expression >>>> given some facts about it. >>>> >>>> Mateusz >>>> >>>> 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 >>>> . >>>> >>>> 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 >>>> . >>>> >>> >>>> >>> 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 >>>> . >>>> >> >>>> >> 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. >>>> >>>> -- >>>> 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/CAGBZUCY_dQUZ095a2Gw8bXZZ3y%3D4co2vMvijApVCivw5yNNiAw%40mail.gmail.com >>>> . >>>> 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/CAM6e1JfXy2vdW5Hgq_ZFwjAsML29K1UerEqt_xjsevDcBhRRjQ%40mail.gmail.com >> <https://groups.google.com/d/msgid/sympy/CAM6e1JfXy2vdW5Hgq_ZFwjAsML29K1UerEqt_xjsevDcBhRRjQ%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%3D6KUCB7Lg3x2TnXXRj__0O2FtYZ9K3BxLp6esoWJhRHpmA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.