Fitting polynomial equations with gnuplot

I wanted an equation to summarise the following data so that it could conveniently be used for some calculations, after many attempts I found that I could fit the data using 2, 6 order polynomials. One was fitted on the data between x = 0-200 and another in the range x = 200-900.

Final polynomial equations fit.

1 polynomial equation after fitting.

Final polynomial equations fit.

Second polynomial equation after fitting.

Final ploynomial equations fit.

Final polynomial equations after fitting.

Source files


set terminal png
set output "HH.png"

#set cntrparam cubicspline
#set cntrparam order 2

#plot "HH.DAT" using 1:2:(1.0) smooth acsplines title "acsplines"
#sw(x,S)=1/(x*x*S)
#plot "HH.DAT" using 1:2 smooth csplines title "csplines"
#plot "HH.DAT" using 1:2 smooth bezier title "bezier"
#plot "HH.DAT" using 1:2 smooth sbezier title "sbezier"
#plot "HH.DAT" using 1:2 smooth unique title "unique"
#plot "HH.DAT" using 1:2 smooth frequency title "frequency"

# Linear Regression
#f(x) = m*x+c
#fit f(x) "HH.DAT" via m,c
#plot "HH.DAT", f(x)
#f(x) = a + b*x + c*x**2 + d*x**3 + e*x**4 + f*x**5
#fit f(x) "HH.DAT" via a,b,c,d,e,f
#plot "HH.DAT" ps 0.1, f(x)

a = 100
f(x) = a + b*x + c*x**2 + d*x**3 + e*x**4 + f*x**5 + g*x**6
fit [200:900] f(x) "HH.DAT" via a,b,c,d,e,f,g
plot "HH.DAT" ps 0.1 , f(x)

#g(x) = h * exp (((x-j)*(x-j))/(2*i*i))
#g(x) = h + j*x + i*x**2
g(x) = h + i*x + j*x**2 + k*x**3 + l*x**4 + m*x**5 + n*x**6

fit [0:200] g(x) "HH.DAT" via h,i,j,k,l,m,n
set yrange [-2000:10000]
set output "HH2.png"
plot "HH.DAT" ps 0.1, g(x)

set output "HH3.png"
h(x) = (x<200 ? g(x) : f(x))
plot "HH.DAT" ps 0.1, h(x)

show variables

Advertisements

The Universe in a Glass of Wine

An glass of red wine, picture from wikipedia.

A poet I think it is once said, “The whole universe is in a glass of wine.” I don’t know, I don’t think we’ll ever know in what sense he said that… for the poets do not write to be understood. But it is true that if you look at a glass of wine closely enough you see the entire universe.
There are the things of physics: the twisting liquid, the reflections in the glass, and our imagination adds the atoms. It evaporates, depending on the wind and weather. The glass is a distillation of the earth’s rocks, and in its composition as we’ve seen, the secret of the universe’s age, and the evolution of the stars. What strange array of chemicals are in the wine? How did they come to be? There are the ferments, the enzymes, the substrates, and the products; and there in wine is found the great generalization: all life is fermentation. Nor can you discover the chemistry of wine without discovering, as did Pasteur, the cause of much disease. How vivid is the claret, pressing its existence into the consciousness that watches it!
If in our small minds, for some convenience, divide this glass of wine, this universe, into parts – physics, biology, geology, astronomy, psychology, and all – remember that nature does not know it! So let us put it all back together, not forgetting ultimately what it is for. Let us give one more final pleasure: drink it up and forget about it all!

— Richard Feynman
Listen to above at this URL

One question has been praying on my mind, does it matter if it is red or white wine?

Top Gear Show Nano

Top gear mentioned the Tata Nano in their news segment, seemingly just to make fun of this tiny car.

Tata Nano on Top gear news segment

Pikachu on left and Tata Nano on right
Pikachu on left and Tata Nano on right

After pointing out the similarity of the luxury version of the car to Pokemon Pikachu, saying they had kept the cost down by copying the design from the cartoon character, they said that the economy version is pulled by a mule.