Thanks for the suggestions.

The noncommutative option is probably too strict since `<a,b><c, d> != 
<c,d><a,b>` then. Or can I make only some multiplications noncommutative?

> You might need to write a naive factor 

Is there any documentation on this?

Cheers,
Nico


On Monday, February 27, 2017 at 9:44:45 PM UTC+1, Aaron Meurer wrote:
>
> Actually, I think you can just convert the symbols to multiplications, 
> but set them all as commutative=False so that they don't get 
> rearranged. Then you can apply factor() (which I believe basically 
> does the above algorithm for noncommutatives), and to convert back to 
> dot products, convert each multiplication pairwise, like a*b*c*d -> 
> <a, b>*<c, d> (also accounting for powers, like e1**2 == <e1, e1>). 
> I'm not 100% sure this won't produce a wrong answer, so it's worth 
> double checking it somehow (perhaps numerically). 
>
> This won't catch simplifications that require rearranging the inner 
> products, like <a, b> = <b, a> (or <a, b> = conjugate(<b, a>) as the 
> case may be). 
>
> Aaron Meurer 
>
> On Mon, Feb 27, 2017 at 3:39 PM, Aaron Meurer <[email protected] 
> <javascript:>> wrote: 
> > The function that does the simplification you want is factor(): 
> > 
> > In [22]: var('a b c d') 
> > Out[22]: (a, b, c, d) 
> > 
> > In [23]: factor(a*c + b*d - a*d - b*c) 
> > Out[23]: (a - b)⋅(c - d) 
> > 
> > However, I'm not sure how to apply it here. You can't just convert 
> > your dot products to multiplications because it isn't true that <a, 
> > b>*<c, d> = <a, c>*<b, d>. 
> > 
> > You might need to write a naive factor that recursively collects terms 
> > with the same coefficient. For instance 
> > 
> > <a, c> + <b,d> - <b,c> - <a, d> 
> > 
> > -> <a, c - d> + <b, d - c> 
> > -> <a - b, c - d> 
> > 
> > This also needs to recognize that c - d = -(d - c). 
> > could_extract_minus_sign is useful for this. 
> > 
> > I don't recall if something like this is already written in SymPy. 
> > 
> > Aaron Meurer 
> > 
> > 
> > On Mon, Feb 27, 2017 at 12:44 PM, Nico Schlömer 
> > <[email protected] <javascript:>> wrote: 
> >> Thanks for the reply. 
> >> 
> >>>  I assume e0, e1, and e2 are arbitrary vectors. 
> >> 
> >> Indeed, they can be anything. (I'm looking at 3 dimensions here but 
> given 
> >> the fact that everything is a dot product I assume that doesn't play 
> much of 
> >> a role.) 
> >> 
> >> Cheers, 
> >> Nico 
> >> 
> >> 
> >> 
> >> On Monday, February 27, 2017 at 6:37:59 PM UTC+1, brombo wrote: 
> >>> 
> >>> How the expression zeta obtained.  Do input the expression you show or 
> is 
> >>> it obtained by vector algebraic operations on vector expressions.  I 
> assume 
> >>> e0, e1, and e2 are arbitrary vectors. 
> >>> 
> >>> On Mon, Feb 27, 2017 at 12:04 PM, Nico Schlömer <[email protected]> 
>
> >>> wrote: 
> >>>> 
> >>>> I have a somewhat large expression in inner products, 
> >>>> ``` 
> >>>>           zeta = ( 
> >>>>               - <e0, e0> * <e1, e1> * <e2, e2> 
> >>>>               + 4 * <e0, e1> * <e1, e2> * <e2, e0> 
> >>>>               + ( 
> >>>>                   + <e0, e0> * <e1, e2> 
> >>>>                   + <e1, e1> * <e2, e0> 
> >>>>                   + <e2, e2> * <e0, e1> 
> >>>>               ) * ( 
> >>>>                   + <e0, e0> + <e1, e1> + <e2, e2> 
> >>>>                   - <e0, e1> - <e1, e2> - <e2, e0> 
> >>>>                   ) 
> >>>>               - <e0, e0>**2 * <e1, e2> 
> >>>>               - <e1, e1>**2 * <e2, e0> 
> >>>>               - <e2, e2>**2 * <e0, e1> 
> >>>>               ) 
> >>>> ``` 
> >>>> and the symmetry in the expression has me suspect that it can be 
> further 
> >>>> simplified. Is sympy capable of simplifying vector/dot product 
> expressions? 
> >>>> A small example that, for example, takes 
> >>>> ``` 
> >>>> <a, c> + <b,d> - <b,c> - <a, d> 
> >>>> ``` 
> >>>> and spits out 
> >>>> ``` 
> >>>> <a-b, c-d> 
> >>>> ``` 
> >>>> would be great. 
> >>>> 
> >>>> -- 
> >>>> 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 https://groups.google.com/group/sympy. 
> >>>> To view this discussion on the web visit 
> >>>> 
> https://groups.google.com/d/msgid/sympy/2cb85a5e-2b5f-402f-82cb-fd4e2f738d93%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] <javascript:>. 
> >> To post to this group, send email to [email protected] 
> <javascript:>. 
> >> Visit this group at https://groups.google.com/group/sympy. 
> >> To view this discussion on the web visit 
> >> 
> https://groups.google.com/d/msgid/sympy/232c66f6-19a3-4672-8507-88631357e9c2%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 https://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/8b71de13-95d8-410d-9f1e-d73f3c555aac%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to