0
$\begingroup$

i have some initial state $psi[x,t]$. I perform some operation on it and store the value in another state $pi1[x,t]$. Now on the next step i have to use $psi1[x,t]$ as initial state and perform the functions again and store in $psi2[x,t]$, Please anybody help me how to use loops for this.

$\endgroup$
1
  • 3
    $\begingroup$ If it is about Mathematica, the software, NestList is exactly what you need. $\endgroup$
    – Kuba
    Commented Apr 17, 2014 at 15:32

1 Answer 1

1
$\begingroup$

I think you might be looking for Nest or NestList as noted by Kuba.

NestList[someOperation, psi[x,t], 2]

gives

 {psi[x, t], someOperation[psi[x, t]], someOperation[someOperation[psi[x, t]]]}
$\endgroup$
2
  • $\begingroup$ i am looking for $operation[operation[operation[psi(x,t)]]]$, where $psi(x,t)$ is some initial function then i store the value of $operation[psi(x,t)]$ into $psi1(x,t)$. Later I have to use $psi1(x,t)$ as initial state and perform same operation as $operation[psi1(x,t)]$. I have to do it n times. $\endgroup$
    – sam
    Commented Apr 17, 2014 at 16:19
  • $\begingroup$ yes you are right. I am looking for something this. Thank you very much $\endgroup$
    – sam
    Commented Apr 21, 2014 at 16:50

Not the answer you're looking for? Browse other questions tagged or ask your own question.