# Need help in nonlinear fitting

Posted 10 years ago
2355 Views
|
4 Replies
|
6 Total Likes
|
 Hello, I have experimental data with (y) and (x)I need to fit them into the following model Log (y/b) = Log (ax /b/1+ax/b) + (-0.22/1+(log ax/b)^2)The result should be a plot with Log y on the y-axis, Log x in the x axis. and the two constants a and b will be the result of the fitting. I tried that in Mathematica, but my problem is that I don't know how to define the function so I can keep (Logy/b) in the left side. Mathematica allows me only to defin a model in the form (y=f(x)) Any help please?
4 Replies
Sort By:
Posted 10 years ago
 10^{Log10[0.6]/(1 + {Log10[a x/b]}^2)}the above line causes trouble. It produce a listIn:= 10^{1}Out= {10}You may want to change the "{ }" to "( )" in the equation.
Posted 10 years ago
 Shenghui nailed the issue on the head. In case you are not familiar with how to work this out, the first thing to do is to break up the equation so that you can get it entirely in terms of Log and Log. Here is your original equation in Mathematica format:myEquality = Log[y/b] == Log[a x/b/1 + a x/b] + (-22/100 + (Log[a x/b])^2)Now we want to apply these rules, which will break up the products and divisions:{Log[a_/b_] -> Log[a] - Log[b], Log[a_* b_] -> Log[a] + Log[b]}Apply the rules:myNewEquality = myEquality//.{Log[a_/b_] -> Log[a] - Log[b], Log[a_* b_] -> Log[a] + Log[b]}And now we can Solve for Log:Solve[myNewEquality, Log[y]](*Output*){{Log[y] -> -(11/50) + Log + Log[a] +   Log[x] + (Log[a] - Log[b] + Log[x])^2[/b]}}This is the form you want to use for your model. To keep things simple, we will remove the logrithms while we solve the model, so Log will become newA and Log will become newX. You will need to run Log on your input data before runnning the model. NonlinearModelFit[data, -(11/50) + Log + newA +   newX + (newA - newB + newX)^2, {newA, newB}, newX]Once you get the values for newA and newB, keep in mind that (newA = Log) which will allow you to solve for the original values.
Posted 10 years ago
 Log10[y/b] ==  Log10[a x/b/{1 + a x/b}] + 10^{Log10[0.6]/(1 + {Log10[a x/b]}^2)}Sorry, I think Log should be Log10, and also this is the coorected form of the equation. Could you please re-write the code, I tried to do it and it failed!Ismail
Posted 10 years ago
 The key here is that you do the preprocess for the y's to make the Log(y) as your new "Y". Also Log(a/b) -> Log(a) - Log(b), thus the left hand side of your equation contains Log(y) only, which the new Y.Now,you can use the Nonlinear model fit in Mathematica for Y (= Log(y)) = f(x;a,b).