MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

Selecting subscripted variables from an expression

Hi guys.  I have an expression containing terms with subscripted "a" and "b" variables.  Can someone help me devise an algorithm to select from this sum, all the terms that have a particular subscripted variable as the first term, such as all the terms that begin with an a_1 in them.  For example, if I have the expression:

myNumerator=2a_1a_2b_2  +  a_2  +  a_1b_2b_3  +  a_3b_2_b_3

then the routine would pick out the 2a_1a_2b_2 term and the a_1b_2b_3 terms.

The expression below is a particular example.  So I suppose the routine might look like some version of:

Select[myNumerator, (all terms that begin with a_1 for example)]

myNumerator = Subscript[a, 1]*Subscript[b, 0]^5 -
Subscript[a, 2]*Subscript[b, 0]^4*Subscript[b, 1] +
Subscript[a, 3]*Subscript[b, 0]^3*Subscript[b, 1]^2 -
Subscript[a, 4]*Subscript[b, 0]^2*Subscript[b, 1]^3 +
Subscript[a, 5]*Subscript[b, 0]*Subscript[b, 1]^4 -
Subscript[a, 6]*Subscript[b, 1]^5 - Subscript[a, 3]*Subscript[b, 0]^4*
Subscript[b, 2] + 2*Subscript[a, 4]*Subscript[b, 0]^3*Subscript[b, 1]*
Subscript[b, 2] - 3*Subscript[a, 5]*Subscript[b, 0]^2*Subscript[b, 1]^2*
Subscript[b, 2] + 4*Subscript[a, 6]*Subscript[b, 0]*Subscript[b, 1]^3*
Subscript[b, 2] + Subscript[a, 5]*Subscript[b, 0]^3*Subscript[b, 2]^2 -
3*Subscript[a, 6]*Subscript[b, 0]^2*Subscript[b, 1]*Subscript[b, 2]^2 -
Subscript[a, 4]*Subscript[b, 0]^4*Subscript[b, 3] +
2*Subscript[a, 5]*Subscript[b, 0]^3*Subscript[b, 1]*Subscript[b, 3] -
3*Subscript[a, 6]*Subscript[b, 0]^2*Subscript[b, 1]^2*Subscript[b, 3] +
2*Subscript[a, 6]*Subscript[b, 0]^3*Subscript[b, 2]*Subscript[b, 3] -
Subscript[a, 5]*Subscript[b, 0]^4*Subscript[b, 4] +
2*Subscript[a, 6]*Subscript[b, 0]^3*Subscript[b, 1]*Subscript[b, 4] -
Subscript[a, 6]*Subscript[b, 0]^4*Subscript[b, 5];

Thanks guys,

  • Prev by Date: Re: beginner question about syntax
  • Next by Date: Re: for loop outside a do cicle
  • Previous by thread: Re: Using package functions in Manipulate/DynamicModule
  • Next by thread: Re: Selecting subscripted variables from an expression