First, making an assignment to a symbol with = or := usually triggers an update; this is because if the value or definition (down values) of a tracked symbol is changed, the system marks the code within a Dynamic that depends on the symbol for an update. The whole body of the Manipulate is put inside a Dynamic, so that the definition y1[t_] := y[t, 2] causes an update if y1 is a tracked symbol, which it will be by default. This leads to an infinite loop because each time the body is executed, the tracked symbol y1 is defined.
There are two (or three) basic ways to go: (1) Remove the dependency of the code on (or do not define y1 in the bode), or (2) do not track y1. Below shows (1), since @eldo has already shown (2). I've also done a few other things. I've isolated the code segment that depends on the symbol s by wrapping it in Dynamic. This means that when s changes, only the point is redrawn and the Plot is not recomputed. This can be a great trick for improving the responsiveness of a Manipulate. Next, I used Mod instead of If. I've localized the symbols y and y1, which would be my preference unless there is a need for them to be global. The declaration
{{y, y}, ControlType -> None}
initializes y to be y and makes it a local variable of the DynamicModule created by Manipulate; in contrast, the declaration
{y, ControlType -> None}
initializes y to be 0, the default. This causes an error when y[t_, x0_] :=... is executed. Finally, I put both function definitions, y and y1, in the Initialization option. This takes the definitions out of the body of Manipulate and prevents the infinite loop.
Manipulate[
Plot[y1[Pause[0.002]; t], {t, 0, 20},
PlotRange -> {0, 2},
Epilog -> {PointSize[0.02], Red,
Dynamic @ With[{s = Mod[s, 20]}, Point[{s, y1[s]}]]}],
{{s, 0, "GO"}, 0, 20, .01, ControlType -> Trigger, AnimationRate -> 4},
{{y, y}, ControlType -> None}, {{y1, y1}, ControlType -> None},
Initialization :> (
y1[t_] := y[t, 2];
y[t_, x0_] := 1/(1 + (1/x0 - 1) Exp[-0.2 t])
)]
y1[t_]=...insideInitialization, i.e.,Initialization :> {y[t_, x0_] := 1/(1 + (1/x0 - 1) Exp[-0.2 t]), y1[t_] = y[t, 2]}(after fixing the typo as eldo noted --If[s==20,...]instead ofIf[s=20,...]) – kglr Jun 06 '14 at 15:42Initialization. But even then you have to replace their "t" by "x" (or any other unused symbol). Also, the bracket afterSaveDefinitionsis in the wrong place. It has to close theTrigger-definition. – eldo Jun 06 '14 at 16:16PlotwithEvaluate. Strangely, this can become necessary when you useInitialization: [(http://mathematica.stackexchange.com/questions/41699/why-does-initialization-slow-down-manipulate-in-this-case)] – eldo Jun 06 '14 at 16:29SaveDefinitionas defined in your example. – eldo Jun 06 '14 at 16:34Initialization. – eldo Jun 06 '14 at 16:57