6

Here is the default answer.

enter image description here

However, I want to get the result which looks like this

enter image description here

Here is the Mathematica code:

Factor[Subscript[x, 1] Subscript[x, 2] + Subscript[x, 1] Subscript[x, 3] Subscript[x, 4] + Subscript[x, 1] Subscript[x, 3] Subscript[x, 5]]

Is it possible on Mathematica?

march
  • 23,399
  • 2
  • 44
  • 100
bios
  • 401
  • 2
  • 9
  • 1
    Next time you ask a question, please provide code that we can copy instead of images ;) – Marius Ladegård Meyer Jun 09 '16 at 14:05
  • OK. The code is quite cumbersome in my case.Factor[Subscript[x, 1] Subscript[x, 2] + Subscript[x, 1] Subscript[x, 3] Subscript[x, 4] + Subscript[x, 1] Subscript[x, 3] Subscript[x, 5]] – bios Jun 09 '16 at 14:31
  • 1
    bios: That is far from cumbersome code! I have edited your post to include it. As implicitly stated in @JohnDoty's answer, it is best to avoid subscripts when using Mathematica until you are well-versed in its idiosyncrasies. They act weird. In your case, it's fine, though. – march Jun 09 '16 at 16:30
  • Another possibility is Collect[expr, Subscript[x, _]]. I'm not sure how generalizable this is, though. Are there are other expressions for which you want to do this? Without more examples, it is difficult to give you a general solution (though perhaps the HornerForm answer below does it; I don't know). – march Jun 09 '16 at 16:32

1 Answers1

11
HornerForm[x1 x2 + x1 x3 x4 + x1 x3 x5]
(* x1 (x2 + x3 (x4 + x5)) *)
John Doty
  • 13,712
  • 1
  • 22
  • 42