MathGroup Archive 1998

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

Search the Archive

Altering terms of an Expression

	There are 3 things I want to do with an expression.
        The expression may have 1 or more terms added together, each
term is composed of a product of elements.

1).  I want to multiply each term in the expression by a product of
     functions.  For example,  the expression labelled by integers k,l
     might look like

	gm[[k,l]]= a*b*c
     I want it to become

	gm[[k,l]]= a*b*c*f[k]*f[l]

     I have written a Do loop that doesn't work because I wish that
     Length would output the number of terms added in the expression
     (1 term in above expression), but Length gives 3 for the expression

            },{k,1,n},{l,k+1,n},{i,1,Length[gm[[k,l]]]} ];

     This works fine when the expression contains 2 or more terms.
     How do I make it work (automatically) even in the case of 1
     term in the expression?

2).  I want to order each term in the expression by the index.
     For example, say the expression is in alphabetical order,


     I want it ordered numerically 


3). Then in each term of the expression, I want to combine
    the strings that refer to the same index and multiply in
    a new string if the index is missing.  

    For example, the expression in numerical order from the
    last step might be,


    I want it to become


    To summarize:
    In Step 1 Length[expression] gives the number of terms
    summed together in expression except when there is only 1 term.
    I need to know how to get around that.

    The result of Step 3, merging strings with the same index, is the
    other thing I want.  Numerical ordering of the indices is not
    required in the result, I just thought it might make Step 3 
    easier to accomplish.


    Susan Rempe

  • Prev by Date: Re: Installation of Mathematica 3.0.2 on NextStep
  • Next by Date: RE: fractional simplification
  • Prev by thread: Re: Installation of Mathematica 3.0.2 on NextStep
  • Next by thread: Re: Altering terms of an Expression