Work out a function formula from existing points

I have the following numbers: (BTW, I am a software developer and this is a tariff)

x <= 3000, y = 1259.00
3000 < x <= 5000, y = 1364.00
5000 < x <= 7000, y = 1720.00
7000 < x <= 9000, y = 2055.00
9000 < x <= 11000,  y = 2349.00
11000 < x <= 13000, y = 2705.00
13000 < x <= 15000, y = 3040.00
15000 < x <= 17000, y = 3481.00
17000 < x <= 20000, y = 3817.00
20000 < x <= 25000, y = 4005.00
25000 < x <= 30000, y = 4298.00
30000 < x <= 35000, y = 4571.00
35000 < x <= 40000, y = 4969.00
40000 < x <= 45000, y = 5305.00
45000 < x <= 50000, y = 5703.00
50000 < x <= 55000, y = 5787.00
55000 < x <= 60000, y = 5912.00
60000 < x <= 65000, y = 6039.00
65000 < x <= 70000, y = 6164.00
70000 < x <= 75000, y = 6290.00
75000 < x <= 80000, y = 6374.00
80000 < x <= 85000, y = 6416.00
85000 < x <= 90000, y = 6458.00
90000 < x <= 95000, y = 6499.00
95000 < x <= 100000, y = 6542.00 
x > 100000  y = 6585.00

I would like to find the formula that, given x, it will return the correct y for the exact number, and the interpolated value of y for the other ones. It doesn't need to be 100% correct.

Please note that I am not interested in the solution to this particular problem. I am more interested in... how do you actually do it?

I did calculus, studied functions, etc. As a teenager, I was really interested in functions and remember having cracked in a more-or-less intuitive way how to work out functions based on shapes. However, it's been more than 30 years, and... I have no idea how (or why :D ) I did it.

Apologies if tags are not 100% pertinent.


Solution 1:

Choose $x$ values at the mid-point of each interval. Then copy the 25 $(x,y)$ pairs into Excel, make a chart from them, and ask Excel to fit a “trend-line” to the data. It gives you a choice of several fitting functions, and you can pick the one you like best. If you check the “show equation” button, Excel will tell you the formula of the curve in the form $y=f(x)$. Further instructions here.

If you just want a linear relationship defined by some constant multiplier $k$, so that $y = kx$, then choose the “linear” trend-line in Excel.

Or, if you want to write code yourself, you can start by looking up terms like “curve fitting” or “least squares fitting”, or maybe even “linear regression”.