**Example Programs for Gnuplot**

###
Below is a list of programs plus data that can be run using gnuplot. The gnuplot programs
have a *.p extension. The data files have a *.txt extension. To run
a program in gnuplot in terminal mode, type "gnuplot program.p". The programs listed below
are used to find the best fit to data in the data file "*.txt" with a function f(x)
that contains a certain number of free parameters.
- The program fitdata.p finds a best fit to the data
sampledata.txt.
The fit function in fitdata.p is f(x) = k1 + k2*x*x. The free parameters in the fit are
k1 and k2. The best fit parameters are printed on the screen and the program also produces
a graph of the data and fit in *.pdf format.
- The program fitsteelcool.p finds a best fit to the data
steelcool.txt. The data are the difference in temperature of
steel and water as the steel cools down.
The fit function in fitsteelcool.p is f(x) = T0*exp(-g*x). The free parameters in the fit are
T0 and g. For gnuplot to find a good fit, you need to supply initial non-zero starting values for
the search. The program produces a graph of the data and fit in *.pdf format.
- The program fitfree_oscill.p finds a best fit to the data
dampdat.txt.
The program can be used to fit the data of an undriven damped oscillator subject to a linear restoring force
and a linear resistance force.
The fitting equation is f(x) = a*exp(-b*x)*cos(6.28319*x/T+p).
f(x) is the amplitude at a time x, and there are four parameters for the fit:
a, b, T, and p. You will need to supply non-zero initial starting values of these four parameters
for gnuplot to find a reasonable fit.
- For the case of the overdamped oscillator, one can use the gnuplot code
overdamped.p,
For the critically damped situation, the code
critdamped.p, can be used. In each case, be sure you have the
correct input data file and starting values for the parameters.

Siegel's Home Page