0
$\begingroup$

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

$\endgroup$
0
$\begingroup$

Perhaps this approach?

Transform the equation by manipulating and taking the log of both sides:

eq = Log[y + c1] == Log[c1] + (x - c3 y)/(0.0259 c2)

Solve for x to get x as a function of y:

x /. Solve[eq, x][[1]]

(* -0.0259 c2 (-((38.61 c3 y)/c2)+ Log[c1]-Log[c1+y]) *)

Now we have x as a function of y and 3 parameters, so we can ft the data to this model.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.