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

I have a quite simple question. I have an expression that looks similar to $T=\frac{1}{a_1}-\frac{1}{a_2}+1$ and I'd like Mathematica to use $A=\frac{a_1}{a_2}$ to reformat the expression (if possible) such that only $A$ appears in it.

Any idea?

Cheers, Pascal

share|improve this question
Does this help: ? – Yves Klett Feb 6 '13 at 12:13
Sorry, but no. The example used in the mentioned thread is way to elaborate for me to understand. – Pascal Feb 6 '13 at 13:13
If you could transform your expression in something depending on A only that would mean that the original expression would not change if I'd multiply both a1 and a2 with the same constant (A = a1/a2 = (c a1)/(c a2) ). Clearly, making that change to the original variables does change T. So, the transformation you want isn't possible. – Sjoerd C. de Vries Feb 6 '13 at 13:31

Here is your expression and a rule for replacement:

T = 1/a1 - 1/a2;
rule = a1 -> A*a2;

Let us replace:

T /. rule

You get this:

-(1/a2) + 1/(A a2)

You may further transform it. For example:

% // Factor

The result is:

-((-1 + A)/(A a2))

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.