Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #1317

Re: Sum of powers of multiplied terms

From Bob Hanlon <hanlonr@cox.net>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Sum of powers of multiplied terms
Date 2011-03-31 09:00 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <in1fqo$4f6$1@smc.vnet.net> (permalink)

Show all headers | View raw


x = k1^2 k2^2 e^2 Sin[phi] + k3^2 e k4^2 Sin[theta];

Thread[{
  Range[Length[x]],
  Replace[Plus @@@ List @@ x, _^n_. -> n, {2}] - 1}]

{{1, 6}, {2, 5}}

@@ is Apply
@@@ is Apply to level 1
_. is Default

Bob Hanlon

---- Chelly <chelly85086@gmail.com> 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

Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

Re: Sum of powers of multiplied terms Bob Hanlon <hanlonr@cox.net> - 2011-03-31 09:00 +0000

csiph-web