Skip to main content
Added TraditionalForm
Source Link
Somos
  • 5.1k
  • 1
  • 10
  • 16

Perhaps the following code is close to what you want:

With[{n = 4}, Sum[Binomial[n, r] b^r ** a^(n - r), {r, 0, n}]]
  /. {NonCommutativeMultiply -> Dot} // InputForm

with resulting output

1 . a^4 + 4*b . a^3 + 6*b^2 . a^2 + 4*b^3 . a + b^4 . 1

You could use TradtionalForm instead which results in a more compact outuput.

Perhaps the following code is close to what you want:

With[{n = 4}, Sum[Binomial[n, r] b^r ** a^(n - r), {r, 0, n}]]
  /. {NonCommutativeMultiply -> Dot} // InputForm

with resulting output

1 . a^4 + 4*b . a^3 + 6*b^2 . a^2 + 4*b^3 . a + b^4 . 1

Perhaps the following code is close to what you want:

With[{n = 4}, Sum[Binomial[n, r] b^r ** a^(n - r), {r, 0, n}]]
  /. {NonCommutativeMultiply -> Dot} // InputForm

with resulting output

1 . a^4 + 4*b . a^3 + 6*b^2 . a^2 + 4*b^3 . a + b^4 . 1

You could use TradtionalForm instead which results in a more compact outuput.

Source Link
Somos
  • 5.1k
  • 1
  • 10
  • 16

Perhaps the following code is close to what you want:

With[{n = 4}, Sum[Binomial[n, r] b^r ** a^(n - r), {r, 0, n}]]
  /. {NonCommutativeMultiply -> Dot} // InputForm

with resulting output

1 . a^4 + 4*b . a^3 + 6*b^2 . a^2 + 4*b^3 . a + b^4 . 1