Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Consider a toy expression:

expr = Sin[x (a + b)]/(y (z + c))

I would like to expand all parentheses to get something like:

Sin[a x + b x]/(c y + y z)

I have been able to expand the argument of the Sin term using:

(* Out[] = Sin[a x + b x]/(y (c + z)) *)

However, this leaves the denominator unexpanded. Is there a way to expand the entire expression?

share|improve this question
ExpandAll will do this. – Daniel Lichtblau May 29 '12 at 21:24
@DanielLichtblau Yeah, I found that function like 2 seconds after I posted the question. Any idea why regular Expand won't do it? – Eli Lansey May 29 '12 at 21:25
Best I recall it was only meant to handle polynomial-like things. Before my time, really. – Daniel Lichtblau May 29 '12 at 21:44
@DanielLichtblau "Before my time" whaa? Aren't you a dinosaur at WRI? – R. M. May 29 '12 at 23:08
No, just a mastodon. Mastodanny, actually, but they are cousin species. – Daniel Lichtblau May 29 '12 at 23:09
up vote 8 down vote accepted

I just found the ExpandDenominator function which, as the name implies, expands the denominator of the expression. Then, Expand and ExpandDenominator can be cobbled together using:

ExpandDenominator //@ Expand //@ expr

(Thanks Mr. Wizard for the improved cleanliness.) However, there is also a related built-in function that does this all in one shot:

(* Out[] = Sin[a x + b x]/(c y + y z) *)
share|improve this answer
The first line looks better (to my eye) as: ExpandDenominator //@ Expand //@ expr – Mr.Wizard May 30 '12 at 2:18
@Mr.Wizard Good call. Edited the post to clean up that expression. – Eli Lansey May 31 '12 at 13:36

It seems that an expression like 1/((a + b) x) is totally deceiving. It doesn't remain unevaluated, it evaluates to something, but that other something is formatted in the same way as the original.

1/((a + b) x) // FullForm // HoldForm

Times[1, Power[Times[Plus[a, b], x], -1]]

1/((a + b) x) // FullForm

Times[Power[Plus[a, b], -1], Power[x, -1]]

So, as you can see, it evaluates to something that should look like 1/(a+b) 1/x That's why Expand never gets mapped to a polynomial denominator.

Try, for example

Expand//@Unevaluated[Sin[x (a + b)]/(y (z + c))]

Sin[a x + b x]/(c y + y z)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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