# Separating product terms and keep a custom order in addition

**URL:** <https://community.wolfram.com/t/separating-product-terms-and-keep-a-custom-order-in-addition/16446>\
**Category:** Questions\
**Tags:** algebra, calculus\
**Created:** [July 16, 2020, 9:24am UTC](https://community.wolfram.com/t/separating-product-terms-and-keep-a-custom-order-in-addition/16446 "2020-07-16T09:24:07Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![artin](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/artin/32/23581_2.png) [@artin](https://community.wolfram.com/u/artin)\
**Post date:** [July 16, 2020, 9:24am UTC](https://community.wolfram.com/t/separating-product-terms-and-keep-a-custom-order-in-addition/16446/1 "2020-07-16T09:24:07Z")

</div>

I would like to write equations in the form as following:  
1/2y + 3/8 x == 2/5 z + w

When this is evaluated it returns

![Clipboard01.jpg](https://global.discourse-cdn.com/wolfram/original/3X/2/7/27564384b2b6bc20b7753071da910978bd68b38a.jpeg)

however I would like keep the product terms separated from the symbols and the order of addition as placed in the original equation i.e. I would like to keep the following format:

![Clipboard02.jpg](https://global.discourse-cdn.com/wolfram/original/2X/7/7b9269a131839edf54f4b74d670153a0dfd2e423.jpeg)

My solution so far is to use this syntax:

```
HoldForm[HoldForm[1/2]*y + HoldForm[3/8]*x] == 
 HoldForm[HoldForm[2/5] *z + w]

```

but I am not aware how I can generalize this in a programatic way or if there is any other more simple way to achive the same result.

Any suggestion is welcome.

---

<div class="post-metadata">

**Author:** ![gianlucagorni](https://avatars.discourse-cdn.com/v4/letter/g/ec9cab/32.png) [@gianlucagorni](https://community.wolfram.com/u/gianlucagorni)\
**Post date:** [July 16, 2020, 10:21am UTC](https://community.wolfram.com/t/separating-product-terms-and-keep-a-custom-order-in-addition/16446/2 "2020-07-16T10:21:24Z")

</div>

You can try with a pattern replacement. For example

```
(1/2 y + 3/8 x == 2/5 z + w) /.
 coeff_?NumberQ*v__Symbol :>
  Inactive[Times][coeff, v]

```

---

<div class="post-metadata">

**Author:** ![artin](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/artin/32/23581_2.png) [@artin](https://community.wolfram.com/u/artin)\
**Post date:** [July 16, 2020, 10:29am UTC](https://community.wolfram.com/t/separating-product-terms-and-keep-a-custom-order-in-addition/16446/3 "2020-07-16T10:29:10Z")

</div>

Thank you for your reply.  
This really works with the multiplication term, but how can I keep also the order of addition.

---

<div class="post-metadata">

**Author:** ![artin](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/artin/32/23581_2.png) [@artin](https://community.wolfram.com/u/artin)\
**Post date:** [July 16, 2020, 10:56am UTC](https://community.wolfram.com/t/separating-product-terms-and-keep-a-custom-order-in-addition/16446/4 "2020-07-16T10:56:39Z")

</div>

I think for the addition order I cannot avoid the hard way:

```
ClearAttributes[Plus, Orderless] 

```

while for the product terms:

```
Replace[expression, Times[x_, y_] -> HoldForm[HoldForm[x]*y], Infinity]

```

---

<div class="post-metadata">

**Author:** ![gianlucagorni](https://avatars.discourse-cdn.com/v4/letter/g/ec9cab/32.png) [@gianlucagorni](https://community.wolfram.com/u/gianlucagorni)\
**Post date:** [July 16, 2020, 3:18pm UTC](https://community.wolfram.com/t/separating-product-terms-and-keep-a-custom-order-in-addition/16446/5 "2020-07-16T15:18:30Z")

</div>

Modifying the function `Plus` sounds dangerous. I would rather make it `Inactive`:

```
(Inactive[Plus][1/2 y, 3/8 x] == Inactive[Plus][2/5 z, w]) /. 
 coeff_?NumberQ*v__Symbol :> Inactive[Times][coeff, v]

```

---

<div class="post-metadata">

**Author:** ![artin](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/artin/32/23581_2.png) [@artin](https://community.wolfram.com/u/artin)\
**Post date:** [July 16, 2020, 4:20pm UTC](https://community.wolfram.com/t/separating-product-terms-and-keep-a-custom-order-in-addition/16446/6 "2020-07-16T16:20:47Z")

</div>

Thank you for your comments and help.
