I want to solve the following problem with Mathematica
: I have a physical model relating the $y$ variable with the $x$ variable given by the next expression:
$$y=C_1\left[ \exp\left( \dfrac{x-C_3y}{0.0259C_2} \right)-1 \right]$$
where $C_i$ are the parameters that should be fitted given a set of experimental data $(x_i,y_i)$.
The problem that confuse me here is the nature of the model, the $y$ variable appears in both side of the equation and I cannot express that in the form $y=f(x,\vec{C_i})$, so I think that I can't use FindFit
or NonlinearModelFit
functions. I tried to use the following objective function instead:
$$\sum_{i=1}^{\text{data}}\left(y_i-C_1\left[ \exp\left( \dfrac{x_i-C_3y^{\text{model}}}{0.0259C_2} \right)-1 \right] \right)^{2}$$
and find its minimum using FindMinimum
, but still having the problem that I can't calculate the $y$ values predicted by model if I don't have the values of the parameters. I wrote this attempt of the solution in Mathematica
, but is obviously wrong:
fun1[x_, y_, c1_, c2_, c3_] :=c1*(Exp[(x - c3*y)/(0.0259*c2)] - 1);
data = Import[NotebookDirectory[] <> "ivdata.txt", "Table"];
s = Sum[(i[[2]] - fun1[i[[1]], i[[2]], c1, c2, c3])^2, {i, data}];
c = {1.0*10^-9, 2.0, 1.0} (*initials values*);
NMinimize[s, {c1, c2, c3}]
(*or*)
FindMinimum[s, {c1, c[[1]]}, {c2, c[[2]]}, {c3, c[[3]]}]
I would appreciate some advice to solve this problem