# How to write a variable in terms of the other [duplicate]

This question already has an answer here:

I have an equation that defines a variable like y=4x+a. I had another equation, z=x+2+4, I would like to know if there is a way in Mathematica to get an expression in which z= a*y+C, in which a and C are combinations of constants. These equations are examples, the equations I working are more complicated... (thanks for the patience I am newbie here)

-

## marked as duplicate by Mr.Wizard♦Jan 11 at 4:01

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.

If my approach doesn't work, it would help for you to provide the full equation that you're working with, so that the community can think of specific tricks that we can implement. –  Vincent Tjeng Jan 11 at 3:51
I am marking this question as a duplicate, because I believe it has been asked multiple times before in slightly different forms. Please see my answer in the duplicate for extensive links. If after reviewing these you feel your question is not a duplicate let me know in these comments. –  Mr.Wizard Jan 11 at 4:01

## 1 Answer

Depending on the complexity of the equations you are working with, the following method might work.

(z == x + 2 + 4) /. Solve[y == 4 x + a, x]

(* output is {z == 6 + 1/4 (-a + y)} *)


What this does is to solve the first equation for x, and substitute this value in the original equation.

-