# Expanding and simplifying expressions

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:= Expand[(-a^3 (-1 + b^2) - 3 a b^2 (2 + b^2) d c)/(b^2 (d c)^(3/2))]

Out= -((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:= Simplify[-((a^3 Sqrt[c d])/(c^2 d^2)), {a > 0, b > 0, c > 0,
d > 0}]

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

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

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

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

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

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

Out= -((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:= 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= (-a^3 (-1 + b^2) - 3 a b^2 (2 + b^2) c d)/(b^2 (c d)^(3/2))

In:= 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= (-a^3 (-1 + b^2) - 3 a b^2 (2 + b^2) c d)/(b^2 (c d)^(3/2))


## 2 Answers

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 • 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. – wiktoria Mar 26 '16 at 20:24
• 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. – wiktoria Mar 26 '16 at 21:52
• @wiktoria, that is why I've used Map (/@). To apply the function to every element... – garej Mar 26 '16 at 21:54
• 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. – wiktoria Mar 26 '16 at 21:58
• The problem is that my expressions contain hundreds of elements... That's why I was looking for automatical solution. – wiktoria Mar 26 '16 at 22:05

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]]]

• that is the same as Simplify[#, {a > 0, b > 0, c > 0}] & /@ Expand@expr – garej Mar 26 '16 at 22:32