0
$\begingroup$

I want to simplify an algebraic expression in Mathematica.

In[1] 1/a(2ba+ca+ba)
Out[1] 3b+c

but i want to multiply 1/a only. Not doing addition in same step. like

Out [2] (2b+c+b)

how can i calculate Out[2].

$\endgroup$
1
$\begingroup$

What you want to do cannot be done in a straightforward way. Mathematica will automatically evaluate your wanted result 2b+c+b to 3b+c. So we have to prevent the addition to be executed. That can be done by inactivating Plus:

Inactivate[1/a(2 b a + c a + b a), Plus] 


(* (2 a b + a c + a b) / a *)

The multiplication is not distributed over Inactive[Plus]. So we have to do that ourselves:

%  /. x_ Inactive[Plus][y__] :> Inactive[Plus]  @@ (x {y})

(* 2 b + c + b *)

This looks like the result you want to have, but observe that the plus sign is grayed. It is Inactive[Plus] instead of Plus. Activating it again gives the normal Mathematica result:

Activate[%]

(* 3 b + c *) 
| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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