This has been added to SymPy and merged.

In [1]: X = MatrixSymbol('X', n, n)

In [2]: with assuming(Q.orthogonal(X)):
   ...:     print refine(X * X.T)
   ...:
I  # identity matrix



On Tue, Mar 18, 2014 at 4:32 PM, Chris <[email protected]> wrote:

> Hi Matt,
>
>
> awesome, I'll take a look and see how far I get.
>
> Thanks for your help!
> Chris
>
> On Monday, March 17, 2014 8:41:21 PM UTC-7, Matthew wrote:
>
>> I added a bunch more refine handlers.
>>
>> Chris, if you wanted to play around with this branch and see if it does
>> what you need that'd be helpful.  Even better, maybe after looking at the
>> diff in the PR you could add some logic yourself?  The pattern of how to do
>> this should be pretty easy to pick out.
>>
>>
>> On Mon, Mar 17, 2014 at 7:37 PM, Matthew Rocklin <[email protected]>wrote:
>>
>>> Well, on the simplify/refine side I think we only need to call ask.  At
>>> some stage this might be wired back into `is_foo`
>>>
>>> I implemented this particular refinement in https://github.com/sympy/
>>> sympy/pull/7296 just to see how it felt.
>>>
>>> BTW, refine could totally use a better dispatching system.  If only,
>>> ahem, someone had built such a thing....
>>>
>>>
>>> On Mon, Mar 17, 2014 at 6:16 PM, Aaron Meurer <[email protected]> wrote:
>>>
>>>> I'm not clear what the plan should be regarding auto-evaluation and
>>>> refine and the new assumptions. I feel that it hasn't been heavily
>>>> thought out yet. We have to somehow balance the pain of having to call
>>>> all sorts of with assuming() and refine() just to get things to
>>>> simplify and the performance issues if they do it automatically (and
>>>> also the issues of potentially not wanting it to always happen
>>>> automatically).
>>>>
>>>> Aaron Meurer
>>>>
>>>> On Mon, Mar 17, 2014 at 7:12 PM, Matthew Rocklin <[email protected]>
>>>> wrote:
>>>> > Hi Chris,
>>>> >
>>>> > Thanks for the kind words.
>>>> >
>>>> > At the moment Matrix Expressions in the main branch do not use
>>>> assumptions
>>>> > while simplifying.  IIRC they actually used to but I removed it so
>>>> that I
>>>> > could approach this more cleanly.  One lofty reason for this was so
>>>> that
>>>> > this could be used as a model for the rest of sympy when it
>>>> eventually jumps
>>>> > over to the new assumptions system.
>>>> >
>>>> > If other devs see this e-mail - what are your thoughts on `refine`,
>>>> the
>>>> > simplify API suggested (but rarely used) by new assumptions?  Should
>>>> we
>>>> > start using this?  Should we roll it into simplify?  In general at
>>>> what
>>>> > point should we appeal to new assumptions?  At expression creation
>>>> time?  At
>>>> > simplify time?  At another simplify-like api time (e.g. refine time)?
>>>>  I
>>>> > decided not to call upon new assumptions while creating expressions
>>>> (e.g.
>>>> > X.T creates a Transpose(X) even if X is symmetric).  I think that my
>>>> > reasoning at the time was performance.
>>>> >
>>>> > Chris, in general what you're asking for is easy for us to add.  I
>>>> would
>>>> > like to make sure that we add it correctly.
>>>> >
>>>> > Also, it's been some time since this was all in my head.  I may have
>>>> said
>>>> > some untrue things.
>>>> >
>>>> > Best,
>>>> > -Matthew
>>>> >
>>>> >
>>>> >
>>>> >
>>>> > On Mon, Mar 17, 2014 at 4:57 PM, Chris <[email protected]> wrote:
>>>> >>
>>>> >> Hi all,
>>>> >>
>>>> >>
>>>> >> I stumbled upon the discussion on matrix assumptions and the bit of
>>>> >> history behind this sympy module:
>>>> >>
>>>> >> http://scicomp.stackexchange.com/questions/74/symbolic-
>>>> software-packages-for-matrix-expressions
>>>> >>
>>>> >> First off all, thank you Matt, this is incredibly cool stuff!
>>>> >>
>>>> >> Now, I'm trying to do some matrix algebra while encoding knowledge
>>>> about
>>>> >> the matrices involved. For instance, say my matrix U is unitary,
>>>> i.e. U *
>>>> >> U.T = I. I've looked around in the documentation and source code, but
>>>> >> couldn't figure out, if the new assumption system can be used to
>>>> simplify
>>>> >> matrix expressions.
>>>> >>
>>>> >> I was trying to exploit this using sympy as follows:
>>>> >>
>>>> >>     from sympy import Q, symbols, MatrixSymbol, ask, simplify
>>>> >>     from sympy.assumptions.assume import global_assumptions
>>>> >>
>>>> >>     n = symbols('n', integer=True)
>>>> >>     U = MatrixSymbol('U', n, n)
>>>> >>
>>>> >>     global_assumptions.add(Q.unitary(U))
>>>> >>
>>>> >>     UU = U * U.T
>>>> >>
>>>> >>     print UU
>>>> >>
>>>> >>     simpleUU = simplify(UU)
>>>> >>     print simpleUU
>>>> >>
>>>> >>
>>>> >> I was hoping that the second print would output the Identity, but
>>>> somehow
>>>> >> this didn't work. Any suggestions, pointers, hints?
>>>> >>
>>>> >>
>>>> >> Cheers,
>>>> >> Chris
>>>> >>
>>>> >> --
>>>> >> 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.
>>>> >> To view this discussion on the web visit
>>>> >> https://groups.google.com/d/msgid/sympy/31aaea36-675d-
>>>> 40b0-8d77-aec8828f6c31%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 [email protected].
>>>> > To post to this group, send email to [email protected].
>>>>
>>>> > 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/CAJ8oX-
>>>> F0tjgppY2Am3zxy43gWKGfESjYDkVRwd%2BFfBgCgXw_2Q%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 [email protected].
>>>> To post to this group, send email to [email protected].
>>>>
>>>> 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%3D6Lxudmr8qrXnqrmKyL2a80GRaFLj
>>>> AVoThqx5pqc9k%2BD5Q%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 [email protected].
> To post to this group, send email to [email protected].
> 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/b0bce5fc-cad6-4b49-8fa4-4d89532ab42b%40googlegroups.com<https://groups.google.com/d/msgid/sympy/b0bce5fc-cad6-4b49-8fa4-4d89532ab42b%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 [email protected].
To post to this group, send email to [email protected].
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/CAJ8oX-Hxy90vGFh%2BsB8uKj9xBd4rMohgSveS1QuCGho%2BsCn_Vg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to