By clicking at a point on the slope field for an ode, a solution is plotted through that point. Additional clicks produce more plots; the plots are saved in graph and the points in pt. The following code is a slimmed down version.
Manipulate[
ClickPane[
Show[
Plot[graph, {t, -2, 2}, PlotRange -> {{-2, 2}, {-2, 2}}],
sf@dx[ode],
Graphics[{PointSize[Large], Point[pt]}]],
(AppendTo[graph, sol[dx[ode], #]];
AppendTo[pt, #]) &],
Style["Enter f(t,x)"], {{ode, x^2 - t, "dx/dt = "}},
(*
TrackingFunction\[Rule](pt=#;{t0,x0}=pt;&);
{{t0,0},InputField,TrackingFunction\[Rule](t0=#;pt[[1]]=t0;&)},
{{x0,0},InputField,TrackingFunction\[Rule](x0=#;pt[[2]]=x0;&)},
*)
Button["Delete all solutions", graph = {}; pt = {},
ImageSize -> {Automatic, 20}],
Initialization :> (
graph = {}; pt = {};
dx[de_] := ode;
sf[ode_] :=
VectorPlot[{1, ode}, {t, -2, 2}, {x, -2, 2}, VectorPoints -> 17,
VectorScale -> {0.03, Automatic, None},
VectorStyle -> {{Red, Arrowheads[0]}}, ImagePadding -> 1,
PerformanceGoal -> "Speed"];
sol[dx_, {t0_, x0_}] :=
y[t] /. First@
NDSolve[{y'[t] == dx /. {x -> y[t]}, y[t0] == x0,
WhenEvent[Abs[y[t]] > 2.5 , "StopIntegration"]}, y, {t, -2, 2},
"ExtrapolationHandler" -> {Indeterminate &,
"WarningMessage" -> False}];)
]
I want to accomplish the same by InputField of the initial point as well. All these plots are to be appended in graph and the the inputted initial point {t0,x0} appended to pt. In particular, graph and pt may contain plots and initial points from either ClickPane entries or InputField entries. I thought that TrackingFunction (see Karsten 7) might make this possible; if it does, I haven't coded it properly. (See the commented lines in the code.) Is this possible or is there another way? I realize that my implementation of the commented code is incorrect.
TrackingFunctionworks like the second argument ofDynamic. – Karsten7 Nov 26 '15 at 13:36