Skip to main content
added 898 characters in body
Source Link
Mr.Wizard
  • 273.1k
  • 34
  • 595
  • 1.4k

Here's an alternative for you to consider:

mySum[p_List, iMin_] :=
  Sum[CenterDot[i + iMin - 1, p[[i]]], {i, Length@p}] //
    Row[{#, Times @@@ #}, "\[LongEqual]"] &

mySum[1/7 {3, 2, 0, 2}, 0]

enter image description here


Thanks for the Accept. Since you found this helpful I'd like to make sure you understand it.

The function CenterDot formats objects as implied, and by default it has no meaning so it will not evaluate to anything. This is used in Sum which you are already familiar with. (If you watched the evolution of this answer you saw that originally I used MapIndexed, which is equally applicable, but I thought Sum would be more comfortable.)

The second important bit is the function Row[{#, Times @@@ #}, "\[LongEqual]"] &.
Row itself is a formatting function that puts objects in a row, optionally with a separating character.
Times @@@ # replaces the heads at level one (here CircleDot) with Times effecting the evaluation of the sum.

Here's an alternative for you to consider:

mySum[p_List, iMin_] :=
  Sum[CenterDot[i + iMin - 1, p[[i]]], {i, Length@p}] //
    Row[{#, Times @@@ #}, "\[LongEqual]"] &

mySum[1/7 {3, 2, 0, 2}, 0]

enter image description here

Here's an alternative for you to consider:

mySum[p_List, iMin_] :=
  Sum[CenterDot[i + iMin - 1, p[[i]]], {i, Length@p}] //
    Row[{#, Times @@@ #}, "\[LongEqual]"] &

mySum[1/7 {3, 2, 0, 2}, 0]

enter image description here


Thanks for the Accept. Since you found this helpful I'd like to make sure you understand it.

The function CenterDot formats objects as implied, and by default it has no meaning so it will not evaluate to anything. This is used in Sum which you are already familiar with. (If you watched the evolution of this answer you saw that originally I used MapIndexed, which is equally applicable, but I thought Sum would be more comfortable.)

The second important bit is the function Row[{#, Times @@@ #}, "\[LongEqual]"] &.
Row itself is a formatting function that puts objects in a row, optionally with a separating character.
Times @@@ # replaces the heads at level one (here CircleDot) with Times effecting the evaluation of the sum.

edited body
Source Link
Mr.Wizard
  • 273.1k
  • 34
  • 595
  • 1.4k

Here's an alternative for you to consider:

mySum[p_List, iMin_] :=
 Tr @Sum[CenterDot[i MapIndexed[CenterDot[iMin+ iMin - 1 + #2[[1]], #]p[[i]]], &{i, p]Length@p}] //
    Row[{#, Times @@@ #}, "\[LongEqual]"] &

mySum[1/7 {3, 2, 0, 2}, 0]

enter image description here

Here's an alternative for you to consider:

mySum[p_List, iMin_] :=
 Tr @ MapIndexed[CenterDot[iMin - 1 + #2[[1]], #] &, p] //
  Row[{#, Times @@@ #}, "\[LongEqual]"] &

mySum[1/7 {3, 2, 0, 2}, 0]

enter image description here

Here's an alternative for you to consider:

mySum[p_List, iMin_] :=
  Sum[CenterDot[i + iMin - 1, p[[i]]], {i, Length@p}] //
    Row[{#, Times @@@ #}, "\[LongEqual]"] &

mySum[1/7 {3, 2, 0, 2}, 0]

enter image description here

deleted 15 characters in body
Source Link
Mr.Wizard
  • 273.1k
  • 34
  • 595
  • 1.4k

Here's an alternative for you to consider:

mySum[p_List, iMin_] :=
 Row[{#, Times @@@ #}, "\[LongEqual]"] &[
   Tr @ MapIndexed[CenterDot[iMin - 1 + #2[[1]], #] &, 1p] /7/
  Row[{3#, 2,Times 0,@@@ 2#}]
, ]"\[LongEqual]"] &

mySum[1/7 {3, 2, 0, 2}, 0]

enter image description here

Here's an alternative for you to consider:

mySum[p_List, iMin_] :=
 Row[{#, Times @@@ #}, "\[LongEqual]"] &[
   Tr @ MapIndexed[CenterDot[iMin - 1 + #2[[1]], #] &, 1/7 {3, 2, 0, 2}]
 ]

mySum[1/7 {3, 2, 0, 2}, 0]

enter image description here

Here's an alternative for you to consider:

mySum[p_List, iMin_] :=
 Tr @ MapIndexed[CenterDot[iMin - 1 + #2[[1]], #] &, p] //
  Row[{#, Times @@@ #}, "\[LongEqual]"] &

mySum[1/7 {3, 2, 0, 2}, 0]

enter image description here

Source Link
Mr.Wizard
  • 273.1k
  • 34
  • 595
  • 1.4k
Loading