I would like to add constraints on a model and its derivatives and then use FindFit
to fit some parameters. An example is below:
modelt[a_?NumberQ, k_?NumberQ] := (modelt[a, k] =
First[x /.NDSolve[{x'[t] == (1/2)*y[t]*(Sin[x[t] + a] + Cos[x[t] + a]),
y'[t] == k Sin[x[t]], x[0] == Pi/2, y[0] == 1/2}, {x, y}, {t, 0, 1000}]])
FindFit[{1000, Pi/6}, {modelt[a, k][t]}, {a, k}, t,
Method -> {NMinimize, Method -> "SimulatedAnnealing"}]
Is there a way to add constraints to FindFit
such as x'[1000] == 0, x''[1000] < 0,
. How do you go about doing this? Thanks!
FindFit
(see help). And becausex[t]
ismodelt[a, k][t]
you can write smth. likeFindFit[{1000, Pi/6}, {modelt[a, k][t], modelt[a, k]'[1000]==0,modelt[a, k]''[1000]<0}, {a, k}, t, Method -> {NMinimize, Method -> "SimulatedAnnealing"}]
. $\endgroup$