# Substitution

**URL:** <https://community.wolfram.com/t/substitution/2418>\
**Category:** Questions\
**Tags:** mathematica\
**Created:** [June 21, 2014, 12:55am UTC](https://community.wolfram.com/t/substitution/2418 "2014-06-21T00:55:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rmotome](https://avatars.discourse-cdn.com/v4/letter/r/e56c9b/32.png) [@rmotome](https://community.wolfram.com/u/rmotome)\
**Post date:** [June 21, 2014, 12:55am UTC](https://community.wolfram.com/t/substitution/2418/1 "2014-06-21T00:55:22Z")

</div>

For 2ab/(a+b). I would like to do a substitution, say I set z=a+b. I want the computer to know that a=z-b resulting in 2(z-b)b/z, then 2(bz-b^2)/z and so on.

Thanks

---

<div class="post-metadata">

**Author:** ![dlkeith](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/dlkeith/32/31494_2.png) [@dlkeith](https://community.wolfram.com/u/dlkeith)\
**Post date:** [June 21, 2014, 1:44am UTC](https://community.wolfram.com/t/substitution/2418/2 "2014-06-21T01:44:47Z")

</div>

In[1]:= Solve[{f == 2 a b/(a + b), z == a + b}, f, a]

```
During evaluation of In[1]:= Solve::bdomv: Warning: a is not a valid domain specification. Mathematica is assuming it is a variable to eliminate. >>

Out[1]= {{f -> (2 (-b^2 + b z))/z}}

```

---

<div class="post-metadata">

**Author:** ![nma](https://avatars.discourse-cdn.com/v4/letter/n/b5e925/32.png) [@nma](https://community.wolfram.com/u/nma)\
**Post date:** [June 21, 2014, 3:14am UTC](https://community.wolfram.com/t/substitution/2418/3 "2014-06-21T03:14:02Z")

</div>

another way

```
Clear[a, b]
expr = 2 a b/(a + b);
replace = z == a + b;
expr /. a -> (a /. First@Solve[replace, a])
(* (2*b*(-b + z))/z *)

```
