-3
$\begingroup$

i have an expression:

n*Subscript[e,3] Subscript[e,4] Subscript[e,7]...*Subscript[e,k]*Subscript[e,k]

I would evaluate it such as return n*Subscript[e,3*4*k*k+1] n is generic Number Any idea?

$\endgroup$
7
  • 1
    $\begingroup$ Can you provide some more context? $\endgroup$ Commented Mar 17, 2016 at 9:34
  • $\begingroup$ thedude interval Analysis, but my question is generic $\endgroup$
    – plus91
    Commented Mar 17, 2016 at 14:39
  • $\begingroup$ Are you aware that upper-case N is the name of a built-in Mathematica function? $\endgroup$
    – murray
    Commented Mar 17, 2016 at 15:05
  • $\begingroup$ @murray Yes, i edited question;) $\endgroup$
    – plus91
    Commented Mar 17, 2016 at 15:07
  • $\begingroup$ It is still not clear what you want. $\endgroup$ Commented Mar 17, 2016 at 15:11

1 Answer 1

4
$\begingroup$
expr = n * Subscript[e, 3] * Subscript[e, 4] * Subscript[e, 7] * 
           Subscript[e, k] * Subscript[e, k + 1];

expr /. HoldPattern[
           Times[s : Repeated[Subscript[e, _]]]
        ] :> Subscript[e, Times @@ Last /@ {s}]

(* n Subscript[e, 84 k (1 + k)] *)
$\endgroup$
0

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