Re: Sum of powers of multiplied terms

• To: mathgroup at smc.vnet.net
• Subject: [mg117784] Re: Sum of powers of multiplied terms
• From: Daniel Lichtblau <danl at wolfram.com>
• Date: Thu, 31 Mar 2011 04:02:51 -0500 (EST)

```Chelly wrote:
> I am new to Mathematica and need some help on the following:
>
> I have a variable which has a sum of many sine terms as shown below:
>
> x = k1^2 k2^2 e^2 Sin(phi) + k3^2 e k4^2 Sin(theta) +....
>
> I'd like to create a table where the first element is the index of the list and the second element is the sum of the powers of the amplitude terms. In this case, I'd like it to be
>
> {1,6},{2,5}
>
> where the sum of powers of the first amplitude term is 2+2+2=6, and similarly for the second term it is 2+1+2=5
>
> Thanks
> Chelly

Here is one way to do it. The idea is to change from a sum to a List,
replace each algebraic variable k by t*k, the get exponents in t for
each resulting term. We also remember the index via MapIndexed (instead
of just using Map).

In[25]:= x = k1^2 k2^2 e^2 Sin[phi] + k3^2 e k4^2 Sin[theta];
vars = {k1, k2, e, k3, k4};

In[31]:= MapIndexed[{#2[[1]], Exponent[#1, t]} &,
List @@ (x /. Thread[vars -> t*vars])]

Out[31]= {{1, 6}, {2, 5}}

Daniel Lichtblau
Wolfram Research

```

• Prev by Date: Re: Capture values that Min(imize)
• Next by Date: Re: Why Mathematica does not issue a warning when the calculations
• Previous by thread: Re: Sum of powers of multiplied terms
• Next by thread: New lines in InputField