I would like to carry out a following iteration process:
Apply function f1[a_,b_,c_,d_]
to a starting list l1={a1,b1,c1,d1}
, which will result in l2={a2,b2,c2,d2}
. Then apply function f2[a_,b_,c_,d_]
to list l2
to get l3={a3,b3,c3,d3}
. Finally apply function f3[a_,b_,c_,d_]
to list l3
to get l4={a4,b4,c4,d4}
. As soon as this is over, I would like {a4,b4,c4,d4}
to be the starting values of the process, in other words to start the procedure with values of l4
obtained in the previous step. This should repeat until l1
and l4
in the same step are identical. It would be also good if I could get lists l1
,...,l4
from the last step returned at the end of the process. Any idea how can I do it in Mathematica?
I couldn't find a similar problem solved on the net. I read all about FixedPoint
, NestWhile
and Fold
in the documentation, but I still don't know how to apply it to this problem, so I'd be grateful for all tips and advices.
Functions f1
,...,f3
are a bit complicated and involve reading values from dll library. Let's say they look like this one:
f1[{a_,b_,c_,d_}]:={
afrombc[b-0.2,c],
b-0.2,
c,
dfromab[afrombc[b-0.2,c],b-0.2]
}
afrombc[]
and dfromab[]
are predefined functions connected with dll library.
FixedPoint
application. In what way doesFixedPoint[f3[f2[f1[#]]] &, {a1, a2, a3, a4}]
or similar does not work for you? $\endgroup$FixedPoint[f3[f2[f1[#]]] &, {a1, a2, a3, a4}]
would mean that the iteration goes until{a1, a2, a3, a4}
doesn't change in two subsequent steps? $\endgroup$FixedPoint
approach should work, right? Anything more specific will depend on you supplying working functions. $\endgroup$