2
$\begingroup$

Although I have received a lot of help, there is a rather difficult question.
Let we have a system with parameter:
$$x_{n+1}=x_n^p$$
As long p changes, we have to write sequential results in an array.
But if you change seed, trace list should be cleared, and process should start with new value:

Manipulate[SeedRandom[seed];
newvar = var^p;
 AppendTo[trace, newvar];
 var = newvar, 
{{p, 0.5}, 0.1, 1., 0.1}, 
{seed, 1, 100, 1},
 Initialization :> {var = RandomReal[], trace = {}}, 
TrackedSymbols :> {p,seed}]

To put it simply, when seed is changed, Initialization should start. But if p is changed, all should be going on continuously. And I have no idea how to do it using TrackedSymbols.

$\endgroup$

1 Answer 1

3
$\begingroup$

Use TrackingFunction on seed.

Manipulate[SeedRandom[seed];
 newvar = var^p;
 AppendTo[trace, newvar];
 var = newvar,
 {{p, 0.5}, 0.1, 1., 0.1},
 {seed, 1, 100, 1, 
  TrackingFunction -> (seed = #; var = RandomReal[]; trace = {}; &)},
 Initialization :> {var = RandomReal[], trace = {}}, 
 TrackedSymbols :> {p, seed}]
$\endgroup$
1
  • $\begingroup$ And another thanks! )) Why there is no link to TrackingFunction in TrackedSymbols page? ( $\endgroup$
    – lesobrod
    Mar 28 at 10:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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