Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1998
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1998

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

Search the Archive

Altering terms of an Expression



Hi,
	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
     above.

	Do[{
	     answer=gm[[k,l]][[i]]*f[k]*f[l];
            },{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,

           astring[3]*bstring[1]

     I want it ordered numerically 

          bstring[1]*astring[3]


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,

        bstring[1]*cstring[1]*astring[3]

    I want it to become

	bstringcstring[1]*newstring[2]*astring[3]	   


    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.

    Thanks.

    Susan Rempe
    rempe@u.washington.edu



  • 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