2
$\begingroup$

I have some complicated expression, for example:

(-a^3 (-1 + b^2) - 3 a b^2 (2 + b^2) d c)/(b^2 (d c)^(3/2))

All variables are positive. I want to expand it and simplify each element of sum separately. So, I use the function Expand, then I apply the function Simplify to each element of the expanded sum and at the end I obtain a final result by copying and pasting partial results of each simplification. It looks like that:

In[80]:= Expand[(-a^3 (-1 + b^2) - 3 a b^2 (2 + b^2) d c)/(b^2 (d c)^(3/2))]

Out[80]= -((a^3 Sqrt[c d])/(c^2 d^2)) + (a^3 Sqrt[c d])/(b^2 c^2 d^2) - (6 a Sqrt[c d])/(c d) - (3 a b^2 Sqrt[c d])/(c d)

In[82]:= Simplify[-((a^3 Sqrt[c d])/(c^2 d^2)), {a > 0, b > 0, c > 0, 
  d > 0}]

Out[82]= -(a^3/(c d)^(3/2))

In[83]:= Simplify[(a^3 Sqrt[c d])/(b^2 c^2 d^2), {a > 0, b > 0, c > 0, d > 0}]

Out[83]= a^3/(b^2 (c d)^(3/2))

In[84]:= Simplify[-((6 a Sqrt[c d])/(c d)), {a > 0, b > 0, c > 0, 
  d > 0}]

Out[84]= -((6 a)/Sqrt[c d])

In[85]:= Simplify[-((3 a b^2 Sqrt[c d])/(c d)), {a > 0, b > 0, c > 0, 
  d > 0}]

Out[85]= -((3 a b^2)/Sqrt[c d])

The final result in this case is of course:

-(a^3/(c d)^(3/2)) + a^3/(b^2 (c d)^(3/2)) - (6 a)/Sqrt[c d] -((3 a b^2)/Sqrt[c d])

My question is: is it possible to do the same in more automatical way, without using copy-paste methods? Applying succesively Expand and Simplify does not work, because each of them removes effects of the other:

In[89]:= Simplify[
 Expand[(-a^3 (-1 + b^2) - 3 a b^2 (2 + b^2) d c)/(b^2 (d c)^(3/2)), {a > 0, b > 0, c > 0, d > 0}], {a > 0, b > 0, 
  c > 0, d > 0}]

Out[89]= (-a^3 (-1 + b^2) - 3 a b^2 (2 + b^2) c d)/(b^2 (c d)^(3/2))

In[90]:= Expand[
 Simplify[(-a^3 (-1 + b^2) - 3 a b^2 (2 + b^2) d c)/(b^2 (d c)^(3/2)), {a > 0, b > 0, c > 0, d > 0}], {a > 0, b > 0, 
  c > 0, d > 0}]

Out[90]= (-a^3 (-1 + b^2) - 3 a b^2 (2 + b^2) c d)/(b^2 (c d)^(3/2))
$\endgroup$
3
$\begingroup$
Simplify /@ Expand @ expr /. Sqrt[c d] / (c d)^2 -> 1/(c d)^(3/2),

where expr = (-a^3 (-1 + b^2) - 3 a b^2 (2 + b^2) d c)/(b^2 (d c)^(3/2))

Result

enter image description here

$\endgroup$
  • $\begingroup$ Ok, but this works for this particular example. And I have many more expressions like that which need simplifying. Some of them are sums of hundreds elements. Therefore I'm looking for something more automatic. $\endgroup$ – wiktoria Mar 26 '16 at 20:24
  • $\begingroup$ I want to simplify each element of a given sum separately. And I want to do it automatically, not by copying each element and applying to it the function Simplify. After applying the function Simplify to a whole sum it collapses to one expression with single denominator. $\endgroup$ – wiktoria Mar 26 '16 at 21:52
  • $\begingroup$ @wiktoria, that is why I've used Map (/@). To apply the function to every element... $\endgroup$ – garej Mar 26 '16 at 21:54
  • $\begingroup$ But you used also Sqrt[c d] / (c d)^2 -> 1/(c d)^(3/2) and this condition will be different for another sum, which contains another elements. If it is possible to accomodate the assumption that all variables are positive, Sqrt[c d] / (c d)^2 will be reduced automatically. $\endgroup$ – wiktoria Mar 26 '16 at 21:58
  • $\begingroup$ The problem is that my expressions contain hundreds of elements... That's why I was looking for automatical solution. $\endgroup$ – wiktoria Mar 26 '16 at 22:05
0
$\begingroup$

Ok, I've found a solution:

expression = (-a^3 (-1 + b^2) - 3 a b^2 (2 + b^2) d c)/(b^2 (d c)^(3/2))
Assuming[{a > 0, b > 0, c > 0,}, Map[Simplify][Expand[expression]]]
$\endgroup$
  • $\begingroup$ that is the same as Simplify[#, {a > 0, b > 0, c > 0}] & /@ Expand@expr $\endgroup$ – garej Mar 26 '16 at 22:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.