If expr is the first part of the expression, you could just do

Omega**2*expand(expr/Omega**2)

I don't see how Omega**2*(1 + M_b*e*x_GB/I_beta + k_beta/(I_beta*Omega**2))
is more useful than just Omega**2*(1 + M_b*e*x_GB/I_beta) + k_beta/I_beta.
 If you want the latter, look at collect() and rcollect().

Aaron Meurer


On Mon, Dec 2, 2013 at 3:10 PM, Juan Luis Cano <[email protected]> wrote:

> Hello all,
>
> I have this expression here:
>
> In [50]: print(eqyB_lin)
>
> (Omega**2 + M_b*Omega**2*e*x_GB/I_beta + k_beta/I_beta)*beta(t) + 
> Derivative(beta(t), t, t) == 0
>
>
> which in LaTeX gets rendered like this:
>
>
> <https://lh5.googleusercontent.com/-Nask81SFlBc/Up0CU_C0NXI/AAAAAAAAASk/sAZJ6UylAEg/s1600/2013-12-02-225634_1366x768_scrot.png>
>
> I'd like to collect Omega squared in the first factor so I can later do a
> substitution. The point is that I'd need an Omega in the denominator of
> k_beta / I_beta. What's the best way to do this in SymPy? Of course I could
> just copy and paste the expression and write it in the way I want but
> that's not what I'm looking for.
>
> One solution I can envision is to traverse the SymPy expression tree, and
> I found this:
>
> http://docs.sympy.org/latest/tutorial/manipulation.html#walking-the-tree
> However I cannot think of a way to visit the nodes (the args in this
> case), eventually modify some of them in place and then rebuilding the
> resulting expression. Any pointers on this? Or is there maybe a simpler way?
>
> Thanks in advance, regards
>
> Juan Luis
>
> --
> 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.

Reply via email to