[Date Index]
[Thread Index]
[Author Index]
# 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: Possible bug in FindRoot[] in Mathematica 3.0**
Next by Date:
**Re: Computing my own function efficiently**
Prev by thread:
**elliptic cylinder scattering**
| |