# Find parameters to fit data with a function

I have a question regarding to find parameters (k1 & k2) to fit functions. At the beginning, I guessed k1 & k2 equal to some values, and solve the system of ordinary equations using NDSolve.

k1 = 0.000392;
k2 = 0.007593554990113638;
eqn2 = {x'[t] == -k1*x[t]*y[t]/h[t] + k2*z[t],
y'[t] == 3*(-k1*x[t]*y[t]/h[t] + k2*z[t]),
z'[t] == k1*x[t]*y[t]/h[t] - k2*z[t],
h'[t] == -3*(-k1*x[t]*y[t]/h[t] + k2*z[t]),
x2'[t] == -k1*x2[t]*y[t]/h2[t] + k2*z[t],
h2'[t] == -3*(-k1*x2[t]*y[t]/h2[t] + k2*z[t]),
x[0] == .001, z[0] == 0, y[0] == 0.2, h[0] == .001, x2[0] == 0,
h2[0] == 1};

sol2 = NDSolve[eqn2, {x, y, z, h, x2, h2}, {t, 0, 1000}][[1]]


And I have 2 sets of data that I need to use to find actual k1 & k2:

fexp0909 = {0.000971950433, 0.0008233302179999999,
0.0007924154169999999, 0.000680523414, 0.000596964088,
0.000578306009, 0.000527957653, 0.000473419808, 0.000476272416,
0.00027648173100000003, 0.000307637797, 0.00029821450300000004,
0.00021866922100000001};
tfexp0909 = {0, 20, 35, 50, 65, 80, 95, 110, 125, 155, 185, 205, 235};
sexp0909 = {0., 0.000101203024, 0.00019527611, 0.000251654424,
0.000340771748, 0.00040908839600000004, 0.000576945417,
0.0005440241409999999, 0.000548239361, 0.000706775103,
0.0006841588389999999, 0.000800299649, 0.0008658322470000001,
0.0007847296200000001};
stexp0909 = {0, 15, 30, 45, 60, 75, 90, 105, 120, 150, 180, 200, 230, 250};
expplot0909s =
ListPlot[Transpose[{stexp0909, sexp0909}], PlotStyle -> {AbsolutePointSize[6], Red}];
expplot0909f =
ListPlot[Transpose[{tfexp0909, fexp0909}],
PlotStyle -> AbsolutePointSize[6]];


From the previous post, I know how to use 1 data and 1 function (x) to obtain k1 & k2,

Clear[k1, k2];
Equation[k1_?NumberQ,
k2__?NumberQ] = {x'[t] == -k1*x[t]*y[t]/h[t] + k2*z[t],
z'[t] == k1*x[t]*y[t]/h[t] - k2*z[t],
y'[t] == 3*(-k1*x[t]*y[t]/h[t] + k2*z[t]),
h'[t] == -3*(-k1*x[t]*y[t]/h[t] + k2*z[t]),
x[0] == .001, z[0] == 0, y[0] == 0.2, h[0] == 0.001};

Clear[chi2];
chi2[k1_?NumberQ,
k2_?NumberQ] := (sol =
x /. NDSolve[Equation[k1, k2], {x, y, z, h}, {t, 0, 1000}] // First;
(sol /@ tfexp0909) - fexp0909 // #.# &)

NMinimize[{chi2[k1, k2], 10^-4 > k1 > 0, 10^-4 > k2 > 10^-5}, {k1, k2}]


But anow I have problem using these two sets of data (tfexp0909 versus fexp0909 & stexp0909 & sexp0909) and two functions (x & x2) to find k1 & k2...

Thanks

-
 It looks like your surface chi2 has no minimum; have you tried plotting it ? – b.gatessucks Nov 8 '12 at 15:35