MathGroup Archive 1998

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

Search the Archive

RE: Efficient use of coefficient--Efficient simplification


  • To: mathgroup@smc.vnet.net
  • Subject: [mg11191] RE: [mg11183] Efficient use of coefficient--Efficient simplification
  • From: jmt <jmthomas@cybercable.tm.fr>
  • Date: Mon, 2 Mar 1998 23:10:48 -0500
  • Organization: TeA
  • Return-Receipt-To: jmt <jmthomas@cybercable.tm.fr>

Try this: f defines your expression: f[n_]:=-(Sqrt[n] (Sqrt[-1 + n]
ket[-2 + n] - Sqrt[n] ket[n])) +
    Sqrt[1 + n] (Sqrt[1 + n] ket[n] - Sqrt[2 + n] ket[2 + n])

Once your expression is evaluated at u v=Variables@f[u]

DeleteCases[v,x_/;Head[x]=!=ket] will give you the set of your ket
variables.

Hope this helps,


----------------------------------------------- Jean-Marie THOMAS
Conseil et Audit en Ingenierie de Calcul www.cybercable.tm.fr/~jmthomas
------------------------------------------------


-----Message d'origine-----
De:	Joel Cannon [SMTP:cannon@alpha.centenary.edu] Date:	mercredi 25
fevrier 1998 09:32 A:	mathgroup@smc.vnet.net
Objet:	[mg11183] Efficient use of coefficient--Efficient simplification

I wish to simplify expressions such as the following which possess terms
involving ket[n+i]. They involve a variable range of indices i.

Out[164]=
-(Sqrt[n] (Sqrt[-1 + n] ket[-2 + n] - Sqrt[n] ket[n])) + 
 
  Sqrt[1 + n] (Sqrt[1 + n] ket[n] - Sqrt[2 + n] ket[2 + n])

I can collect the various terms in ket[n+i] with the following
operation:

In[176]:=
Out[164]//Expand// Table[ket[n+i] Coefficient[#,ket[n+i]  ],{i,-2,2}]&
//Plus @@ #&

Out[176]=
-(Sqrt[-1 + n] Sqrt[n] ket[-2 + n]) + (1 + 2 n) ket[n] - 
 
  Sqrt[1 + n] Sqrt[2 + n] ket[2 + n]

My problem is this, Since I do no know what the range of ket[n+i] will
be, I would like to write a general expression that will find what
ket[n+i] are present and collect the coefficients of each of these. The
inelegant wat is to run over a range of i's that will surely bracket
any ket[n+i] that I will possibly encounter, but that is distasteful. 
I am using version 2.2  but will probably switch to 3.0 soon.

Any other suggestions to that way I have done things are welcomed.  If
possible, please copy me on email since I might otherwise miss posts to
the newsgroup.

cannon@alpha.centenary.edu

Thanks very much,

------------------------------------------------------------------------------
Joel W. Cannon                 |   (318)869-5160          Dept. of
Physics               |   (318)869-5026  FAX    Centenary College of
Louisiana |       P. O. Box 41188		       |	      Shreveport, LA
71134-1188      |




  • Prev by Date: Re: random number generation
  • Next by Date: init.m on IBM
  • Prev by thread: Re: Efficient use of coefficient--Efficient simplification
  • Next by thread: Re: Efficient use of coefficient--Efficient simplification