Here is a simpler example of the behavior I would like:
   (2) variables x,y,z
   (3) e1 = x*(y+z)^.5
-> (4) e1 = x*(y+z)^0.5

   (5) e2 = x*y*(y+z)^0.5
-> (6) e2 = x*y*(y+z)^0.5

   (7) e1+e2
 Result = x*(1+y)*(y+z)^0.5
   (7)

In the simplest case of an Add with two terms, it seems like if:
1) Both Add terms (a1 and a2, say) are Mul instances and
(set(a1.args) & set(a2.args)) != set([])
or
2) One Mul (a1) and one Symbol (a2) and
(set(a1.args) & set(a2)) != set([])
then they have common factors and could be combined.

Any thoughts?

~Luke


On Aug 14, 9:49 pm, Luke <hazelnu...@gmail.com> wrote:
> I am trying to get the following two expressions to combine under addition:
> e1 = rf*(1 - (c5*s2 + c2*s4*s5)**2)**(-0.5)
> e2 = rf*(-c5*s2 - c2*s4*s5)*(1 - (c5*s2 + c2*s4*s5)**2)**(-0.5)
>
> Is there a way to make the add combine these to obtain the result:
> rf*(1 - (c5*s2 + c2*s4*s5))*(1 - (c5*s2 + c2*s4*s5))**(-0.5)
>
> which would automatically simpify even further to:
> rf*(1 - (c5*s2 + c2*s4*s5))**(0.5)
>
> It seems like this could be made automatic if Add could look at the
> hash of each of the arguments of its arguments, and if any of them
> were equal, they could be made to combine 'automatically'.
>
> It is interesting that Mul can auto combine things like: rf*(1 -
> (c5*s2 + c2*s4*s5))*(1 - (c5*s2 + c2*s4*s5))**(-0.5), but Add does
> not.
>
> Would this be hard to implement in Add?
>
> Thanks,
> ~Luke
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to sympy@googlegroups.com
To unsubscribe from this group, send email to sympy+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sympy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to