polyFit[] for Mathematica 5.2
Author
Alessandro Torre
Title
polyFit[] for Mathematica 5.2
Description
polyFit[n, {xdata, errX}, {ydata, errY}, #, opts] finds the polynomial expression of the form y = a + b x + c x^2 + ... that fit best with 'xdata' and 'ydata' (it's a least-squares fit) 'n' is the degree of the polynomial, 'errX' and 'errY' are the errors of 'xdata' and 'ydata' (they're optional) '#' is the output format (graphical or numerical) The chief advantages in confront of Fit[] are : - the graphical output - error of the parameters - chi-square test and linear-correlation coefficient - error propagation The function includes a complete and well tested management of input error and own messages. All the details displayed by ?polyFit (after evaluating the function)
Category
Working Material
Keywords
URL
http://www.notebookarchive.org/2018-10-10qt33b/
DOI
https://notebookarchive.org/2018-10-10qt33b
Date Added
2018-10-02
Date Last Modified
2018-10-02
File Size
6.3 kilobytes
Supplements
Rights
Redistribution rights reserved




<<\polyFit`
◇
MAX & MIN
MAX & MIN
The error on the periods (errT) and on the distances (errS)
errS=0.001;errT=0.01;
The period T for each data array :
T={220,240,260,280,300,320,340};
The values to be fitted :
max1={24.6,26.4,27.6,28.1,28.0,27.2,25.9};min1={9.1,8.0,7.4,7.3,7.8,8.7,10.0};max2={21.9,22.8,23.4,23.6,23.4,22.8,21.9};min2={11.8,11.2,11.0,11.0,11.4,12.0,12.8};max3={20.0,20.6,20.9,21.0,20.7,20.3,19.8};min3={14.2,13.7,13.4,13.3,13.4,13.7,14.1};max4={19.0,19.2,19.4,19.4,19.2,18.8,18.5};min4={15.1,14.8,14.7,14.7,14.8,15.0,15.3};max5={18.0,18.2,18.3,18.4,18.3,18.2,18.0};min5={15.9,15.7,15.6,15.6,15.7,15.7,15.8};max6={17.5,17.7,17.8,17.8,17.8,17.7,17.6};min6={16.1,16.0,16.0,16.0,16.0,16.1,16.2};max7={17.3,17.4,17.5,17.5,17.4,17.4,17.3};min7={16.4,16.3,16.3,16.3,16.3,16.4,16.5};max8={17.1,17.1,17.2,17.2,17.2,17.1,17.1};
"values" contains the previous data converted in metres.
We create this array to easily perform all the 15 regression.
We create this array to easily perform all the 15 regression.
values={max1,min1,max2,min2,max3,min3,max4,min4,max5,min5,max6,min6,max7,min7,max8}/100;
We are looking for parabolic relations :
Do[Block[{},Print["\n",StyleForm[StringJoin[ToString[i],"° FIT"],FontSize24,FontWeight"Bold",FontColorRGBColor[1,0,0]]];Off[Inverse::luc];parabolicFit[{T,errT},{values[[i]],errS},0,AxesLabel{"T (s)","S (cm)"}];On[Inverse::luc];],{i,Length[values]}]
We save all the results in a mathematical format :
fits=Table[parabolicFit[{T,errT},{values[[i]],errS},1],{i,Length[values]}];
The best-fitting curves follow :
Table[fits[[i,1]],{i,Length[fits]}]


Cite this as: Alessandro Torre, "polyFit[] for Mathematica 5.2" from the Notebook Archive (2007), https://notebookarchive.org/2018-10-10qt33b

Download

