Message Boards Message Boards

0
|
23359 Views
|
8 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Using Findfit

Posted 9 years ago

I am trying to find a,b,c from this equation using an array of x and y,

enter image description here

This is my input in mathematica,

FindFit[{{171.29, 6}, {171.63, 12.1}, {171.86, 24.2}, {172.06, 
       48.3}}, {x == (((sqrt (a^2 + 8 a y) - a) (b - c))/(4 y)) + c}, {a, 
      b, c}, {x, y}]

But I get this message, FindFit::fitc: Number of coordinates (1) is not equal to the number of variables (2). >>

Please advice how to solve for a,b,c

POSTED BY: Damodaran Achary
8 Replies
Posted 5 years ago

Look carefully at the syntax coloring, a, b, and c are blue, y is black. This means that y has an existing definition. With your cursor in that cell, select the menu item Help / Why the Coloring?. Clear the definition of y by evaluating ClearAll[y].

POSTED BY: Rohit Namjoshi

Hello Bill, I am using Mathematica 11.0 Student Edition and when I copied your suggested solution, it is giving error for the variables given.

What could be causing this problem? This is the exact same input code as given. enter image description here

POSTED BY: Yash Khemka

@Damodaran

Could you give a hint where your equation to be fitted comes from?

HD

POSTED BY: Hans Dolhaine

Hans, This equation is used for determining self-association of molecules in solution. Basically I get Kd (Dissociation constant). Let me know if you need more info. Damodaran

POSTED BY: Damodaran Achary
Posted 9 years ago

If you read the documentation for FindFit and you click on the triangle next to Scope and you then click on the triangle next to Constraints and Starting Values then you will see an example showing how to place limits on the parameters you are finding.

POSTED BY: Bill Simpson

Thanks so much Bill. Is there a way to include limits to a, b or c ? Thanks.

POSTED BY: Damodaran Achary
Posted 9 years ago

Look very carefully for each of the very tiny changes made to what you wrote.

In[1]:= sol = FindFit[{{171.29, 6}, {171.63, 12.1}, {171.86, 24.2}, {172.06, 48.3}},
   (((Sqrt [a^2 + 8 a y] - a) (b - c))/(4 y)) + c, {a, b, c}, y, MaxIterations -> 10^4]

Out[1]= {a -> 324223., b -> -8925.88, c -> 8.45726*10^6}

In[2]:= Show[Plot[(((Sqrt [a^2 + 8 a y] - a) (b - c))/(4 y))+c/.sol, {y, 171.29, 172.06}, PlotRange->{0,50}],
   ListPlot[{{171.29, 6}, {171.63, 12.1}, {171.86, 24.2}, {172.06, 48.3}}]]

enter image description here

In[3]:= sol = FindFit[{{171.29, 6}, {171.63, 12.1}, {171.86, 24.2}, {172.06, 48.3}},
   a y^2 + b y + c, {a, b, c}, y, MaxIterations -> 10^4]

Out[3]= {a -> 94.8838, b -> -32524.8, c -> 2.78726*10^6}

In[4]:= Show[Plot[a y^2 + b y + c /. sol, {y, 171.29, 172.06}, PlotRange -> {0, 50}],
   ListPlot[{{171.29, 6}, {171.63, 12.1}, {171.86, 24.2}, {172.06, 48.3}}]]

enter image description here

POSTED BY: Bill Simpson
Attachments:
POSTED BY: Hans Dolhaine
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract