Mathematica Fitting Curve to Data Points using Mathematica

AI Thread Summary
The discussion focuses on using Mathematica for curve fitting with a specific set of data points. The user attempts to utilize the Fit function but encounters difficulties. They compare this approach with their established method in Excel, which involves organizing data into columns, defining adjustable parameters for the fitting function, calculating the squared differences between actual and theoretical values, and using the Solver tool to minimize these differences. This Excel method allows for flexible least-squares fitting with various functions. The conversation highlights the challenges of implementing curve fitting in Mathematica compared to the more familiar Excel process.
Dustinsfl
Messages
2,217
Reaction score
5
I am trying to use Mathematica to fit a curve to these data points
Code:
ListPlot[{{2*Pi/(1 - 0^2/16), 5 (3 - Log[2])}, {2*Pi/(1 - .05^2/16), 
   10 (3 - Log[2])}, {2*Pi/(1 - .1^2/16), 
   15 (3 - Log[2])}, {2*Pi/(1 - .15^2/16), 
   20 (3 - Log[2])}, {2*Pi/(1 - .2^2/16), 
   25 (3 - Log[2])}, {2*Pi/(1 - .25^2/16), 
   30 (3 - Log[2])}, {2*Pi/(1 - .3^2/16), 
   35 (3 - Log[2])}, {2*Pi/(1 - .35^2/16), 
   40 (3 - Log[2])}, {2*Pi/(1 - .4^2/16), 
   45 (3 - Log[2])}, {2*Pi/(1 - .45^2/16), 50 (3 - Log[2])},}, 
 PlotRange -> {{6.28, 6.39}, {10, 116}}]
However, I tried the Fit option and some other put it doesn't seem to work.
 
Physics news on Phys.org
I typically go with Excel as follows:

1. Put actual data in one column.

2. Use a few cells to write in the changeable arbitrary parameters of the function you want to fit.

3. Write the column next to the first one as having your theoretical curve, making sure to use $F$5 (for example), for the cells in step 2.

4. In the next column over, set cells equal to =(B2-A2)*(B2-A2).

5. Sum this last column.

6. Use the Solver routine to minimize the sum cell in step 5 subject to changing the parameters in step 2.

This is least-squares fit using any function you can write in Excel, which is quite a few.
 

Similar threads

Replies
10
Views
2K
Replies
1
Views
1K
Replies
4
Views
3K
Replies
4
Views
1K
Replies
10
Views
3K
Replies
6
Views
4K
Replies
1
Views
2K
Replies
6
Views
3K
Back
Top