Finding polynomials from a set of coordinates
03-12-2017, 06:38 PM (This post was last modified: 03-12-2017 06:52 PM by Dieter.)
Post: #12
 Dieter Senior Member Posts: 2,397 Joined: Dec 2013
RE: Finding polynomials from a set of coordinates
(03-10-2017 07:39 PM)tdh79 Wrote:  I need to find polynomial functions from a given set of coordinates

You said it: there are infinitely many polynomial functions that may approximate the given data here. Question is: what do you want?

(03-10-2017 07:39 PM)tdh79 Wrote:  Temperatures are measured 6 times during 24 hours:
time - temp (celsius)
0000 8
0400 5
0800 11
1200 16
1600 18
2000 14

There are essentially two different approaches:

1. From n=6 data points you can determine an (n–1) = 5th order polynomial that passes exactly through these six points. That's quite trivial since this is nothing more than solving a 6th order linear equation system. A piece of cake for the 50g. The required equations are simple:

1*a + t*b + t^2*c + t^3 * d + t^4 * e +t^5* f = temperature

Do this six times for every time (t) and temperature combination, solve for a...f.
This is the method proposed by Han in the second post.

2. You can approximate (!) a set of n datapoints by a polynomial regression function of order m < n–1. In your case you can approximate the six points by a polynomial of order 4, 3 or 2. The higher m, the better the match. This is also done by solving a linear equation system, the required equations are found in the respective Wikipedia article already mentioned here.

Example: fit a cubic function (m=3) through these six points. The result is:
temperature ~ 7,7143 – 1,5714 t + 0,3281 t² – 0,0117 t³

Note: t is not given as 800 or 1200 (does not make sense) but as 8 or 12.

Compare this approximation with the original data:

Code:
time  temperature   estimate  0         8          7,71  4         5          5,93  8        11         10,14 12        16         15,86 16        18         18,57 20        14         13,79

Using a 4th order polynomial, the results move closer to the original data. Here the result is:
temperature ~ 7,9643 – 2,4163 t + 0,6081 t² – 0,0345 t³ + 0,00057 t^4

Again compare this approximation with the original data...

Code:
time  temperature   estimate  0         8          7,96  4         5          5,18  8        11         10,64 12        16         16,36 16        18         17,82 20        14         14,04

...and the estimate already matches the original data when rounded to whole degrees. Finally a 5th order polynomial would exacly match the data (cf. Han's post).

Regarding Csaba Tizedes' remark: I would simply add a 7th data point for t=24 and temperature = 8 (same as for t=0). A periodic function is not required, simply apply the polynomial on (time mod 24). In this case a 6th order polynomial would result in a perfect fit, and 5th, 4th, 3rd... order approximations would come more or less close.

Dieter
 « Next Oldest | Next Newest »

 Messages In This Thread Finding polynomials from a set of coordinates - tdh79 - 03-10-2017, 07:39 PM RE: Finding polynomials from a set of coordinates - Han - 03-10-2017, 07:42 PM RE: Finding polynomials from a set of coordinates - Juan14 - 03-10-2017, 08:44 PM RE: Finding polynomials from a set of coordinates - tdh79 - 03-12-2017, 07:56 PM RE: Finding polynomials from a set of coordinates - Han - 03-10-2017, 09:09 PM RE: Finding polynomials from a set of coordinates - tdh79 - 03-10-2017, 09:13 PM RE: Finding polynomials from a set of coordinates - Han - 03-10-2017, 09:18 PM RE: Finding polynomials from a set of coordinates - tdh79 - 03-10-2017, 09:57 PM RE: Finding polynomials from a set of coordinates - SlideRule - 03-11-2017, 12:53 AM RE: Finding polynomials from a set of coordinates - grsbanks - 03-11-2017, 10:25 AM RE: Finding polynomials from a set of coordinates - SlideRule - 03-12-2017, 01:49 PM RE: Finding polynomials from a set of coordinates - Csaba Tizedes - 03-12-2017, 05:58 PM RE: Finding polynomials from a set of coordinates - Dieter - 03-12-2017 06:38 PM RE: Finding polynomials from a set of coordinates - Csaba Tizedes - 03-12-2017, 08:27 PM RE: Finding polynomials from a set of coordinates - Dieter - 03-12-2017, 11:31 PM RE: Finding polynomials from a set of coordinates - Csaba Tizedes - 03-13-2017, 03:00 PM RE: Finding polynomials from a set of coordinates - grsbanks - 03-13-2017, 03:05 PM RE: Finding polynomials from a set of coordinates - Csaba Tizedes - 03-13-2017, 03:37 PM RE: Finding polynomials from a set of coordinates - SlideRule - 03-13-2017, 02:11 AM RE: Finding polynomials from a set of coordinates - SlideRule - 03-14-2017, 02:20 AM RE: Finding polynomials from a set of coordinates - tdh79 - 03-19-2017, 10:35 AM RE: Finding polynomials from a set of coordinates - SlideRule - 03-19-2017, 11:49 PM

User(s) browsing this thread: 1 Guest(s)