Fitting a data set to an equation to get constants

Hi,

I have a data set with y and x. I have an equation that I want to fit this data to y=a/b(1-e^bx).
Can someone tell me how do I plot the data to this equation to get the constants a and b.

For a better explanation:
Generally when we are given x and y, we can plot this data and use either excel or mathematica etc to get either a linear, polynomial or exponential fit. From those fitted equations we can extrapolate data.
In this case, I have a small data set, and I know the function that I want the data to be fit in. From the fit data I want to get the constants in the equation so that I can extrapolate the data.

Thanks,

Is FindFit what you’re looking for?

I tried Findfit, but in vain.

When I take the ratio of 2 x and 2 y’s, I get the following equation to solve
-36 - 23.1 e^(-39.36 b) + 59.1 e^(-19.38 b) == 0, b
but
Solve was unable to solve the system with inexact coefficients or the
system obtained by direct rationalization of inexact numbers present
in the system. Since many of the methods used by Solve require exact
input, providing Solve with an exact version of the system may help.

In Mathematica, the base of the natural log is E, not e.

In[1]:= eq = -36 - 23.1 E^(-39.36 b) + 59.1 E^(-19.38 b) == 0;

In[2]:= sol = Solve[eq, b, Reals]

During evaluation of In[2]:= Solve::ratnz: Solve was unable to solve the system with inexact coefficients. The answer was obtained by solving a corresponding exact system and numericizing the result. >>

Out[2]= {{b -> -0.0209738}, {b -> 0.}}

In[3]:= eq /. sol

Out[3]= {True, True}

However, it would help you get a good response if you would post your code and data. Attaching a notebook and a spreadsheet or CSV file would be good.

Best regards, David

Hi David,
Thanks for the help.

y=a/b(1-exp(-bx))

x={19.38, 39.36, 58.62, 78.6, 99, 119.4, 138.6, 158.4, 199.2, 219,
239.4, 259.8, 278.4, 299.4};
y={23.1667, 59.1667, 147, 176.667, 228.333, 266.667, 300, 330, 401.667,
413.333, 425, 415, 408.333, 446.667}

Need to find a and b.

I used this for Mathematica

FindFit[{{19.38`, 39.36`, 58.62`, 78.6`, 99, 119.4`, 138.6`, 158.4`, 
   199.2`, 219, 239.4`, 259.8`, 278.4`, 299.4`}, {23.16666667`, 
   59.16666667`, 147, 176.6666667`, 228.3333333`, 266.6666667`, 300, 
   330, 401.6666667`, 413.3333333`, 425, 415, 408.3333333`, 
   446.6666667`}}, (y - ((a/b)*(1 - e^(-bx)))), (a, b), (x, y)]

Thanks,

Hi math,

There are a number of syntax errors you will find corrected below. (Look up FindFit in the help system!)

Best, David

In[1]:= xData = {19.38, 39.36, 58.62, 78.6, 99, 119.4, 138.6, 158.4, 
  199.2, 219, 239.4, 259.8, 278.4, 299.4}; yData = {23.1667, 59.1667, 
  147, 176.667, 228.333, 266.667, 300, 330, 401.667, 413.333, 425, 
  415, 408.333, 446.667};

In[2]:= (* FindFit wants pairs *)
data = Transpose@{xData, yData};

In[3]:= (* the model is an expression for the dependent variable in \
terms of the independent and parameters. Note the space in b x, and \
also the curly braces for lists *)
solution = FindFit[data, (a/b)*(1 - E^(-b x)), {a, b}, x]

Out[3]= {a -> 2.91944, b -> 0.00494724}

In[4]:= Show[ListPlot[data, PlotStyle -> Red], 
 Plot[(a/b)*(1 - E^(-b x)) /. solution, {x, 19, 450}]]

Hi, David

Thank you very much for the help. Appreciate it.

Best wishes,