Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have two expressions:

w1 = (a+b)/c^2;

w2 = (a^3 + 3 a^2 b + 3 a b^2 + b^3)/c^6;

How can I ask Mathematica to try to find an alternative expression for w2 that just uses the variable w1 ? In the above example, for instance, we can write: w2 == w1^3, however, its not always so obvious how to proceed in general instances where one is asked to rewrite one expression ONLY in terms of a variable representing another expression (or to check if this is possible).

[6-5-2014] I've read through Replace expressions with symbols, and its still confusing exactly how to ask Mathematica to do what I'm specifying in my positing. It would really be helpful to see how to do something like my specific example.

share|improve this question

marked as duplicate by Szabolcs, rasher, m_goldberg, RunnyKine, Mr.Wizard Jun 6 at 11:57

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
See also mathematica.stackexchange.com/q/33457/12 –  Szabolcs Jun 5 at 18:13
    
For me it's "immediately obvious" that the assumption is wrong –  eldo Jun 5 at 18:18
    
@eldo That was a typo, sorry. And my writing is poor, so I apologize if it sounded arrogant. –  O.C. Jun 5 at 18:24
    
@Öskå I have provided the Mathematica version of the expressions, sorry. –  O.C. Jun 5 at 18:26

2 Answers 2

up vote 7 down vote accepted

To have w2 expressed in terms of w1, w1 cannot be assigned a value. If it is assigned a value then Mathematica will always substitute that value for w1. Consequently "define" w1 with an equation:

Clear[w1];

eq = w1 == (a + b)/c^2;

w2 = (a^3 + 3 a^2 b + 3 a b^2 + b^3)/c^6;

w2 /. Solve[eq, a][[1]] // Simplify

w1^3

However, in this case at least, you could Solve for any one of the variables in w2 and get the same result.

(w2 /. Solve[eq, #][[1]] // Simplify) & /@ Variables[w2]

{w1^3, w1^3, w1^3}

share|improve this answer
    
Very very good ! –  eldo Jun 5 at 20:35

Following @BobHanlon's suggestion to use Equal instead of Set, you can also use Eliminate:

 Eliminate[{w1 == (a + b)/c^2, w2 == (a^3 + 3 a^2 b + 3 a b^2 + b^3)/c^6}, {a, b, c}]
 (*  w2 == w1^3  *)
share|improve this answer

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