Finding polynomials from a set of coordinates

03102017, 07:39 PM
Post: #1




Finding polynomials from a set of coordinates
Hi.
I need to find polynomial functions from a given set of coordinates, does anyone know how to do this with the 50g? Example: Temperatures are measured 6 times during 24 hours: time  temp (celsius) 0000 8 0400 5 0800 11 1200 16 1600 18 2000 14 How can i find the function and plot for this? 

03102017, 07:42 PM
(This post was last modified: 03102017 09:06 PM by Han.)
Post: #2




RE: Finding polynomials from a set of coordinates
http://support.hp.com/usen/document/c01939749
EDIT: I don't have my HP50G in front of me and the screenshots in the link above do not list polynomial fit as a choice, so the link above my not apply directly to you if you are looking for a polynomial fit. So if there is no polynomial fit option, you would need to do it by hand using the Vandermonde matrix. https://en.wikipedia.org/wiki/Polynomial_regression EDIT #2: [[ 8 ] [ 5 ] [ 11 ] [ 16 ] [ 18 ] [ 14]] [ 0 4 8 12 16 20 ] VANDERMONDE / returns [[ 8 ] [ '439/120' ] [ '203/192' ] [ '151/1536' ] [ '13/3072' ] [ '3/40960' ]] This is a list of the cefficients \( a_0, a_1, \dotsm, a_5 \) of the polynomial \[ a_0 + a_1 \cdot x + a_2 \cdot x^2 + a_3 \cdot x^3 + a_4 \cdot x^4 + a_5 \cdot x^5 \] That is, \( a_0 = 8 \), \( a_1 = \frac{439}{120} \), \( a_2 = \frac{203}{192} \), \( a_3 = \frac{151}{1536} \), \(a_4 = \frac{13}{3072} \), and \(a_5 = \frac{3}{40960} \). Graph 3D  QPI  SolveSys 

03102017, 08:44 PM
Post: #3




RE: Finding polynomials from a set of coordinates
Hello, you have to use the Lagrange polynomial. First enter a matrix with the values of x in the first row and then the values of y in the second row, and then the LAGRANGE command, for example:
[[0 4 8 12 16 20] [8 5 11 16 18 14]] ENTER ALPHA ALPHA LAGRANGE ENTER 

03102017, 09:09 PM
Post: #4




RE: Finding polynomials from a set of coordinates
Come to think of it, there are so many polynomial fits that you may want to clarify which types of polynomials to use: Taylor Polynomials, Lagrange Polynomial, Cubic Spline Interpolation, or Least Squares Polynomials.
Graph 3D  QPI  SolveSys 

03102017, 09:13 PM
Post: #5




RE: Finding polynomials from a set of coordinates
(03102017 09:09 PM)Han Wrote: Come to think of it, there are so many polynomial fits that you may want to clarify which types of polynomials to use: Taylor Polynomials, Lagrange Polynomial, Cubic Spline Interpolation, or Least Squares Polynomials.Honestly I don't know, i guess I'll just try the methods in your link and the LAGRANGE command and see if i get results that look like the ones in my math book 

03102017, 09:18 PM
(This post was last modified: 03102017 09:19 PM by Han.)
Post: #6




RE: Finding polynomials from a set of coordinates
(03102017 09:13 PM)tdh79 Wrote:(03102017 09:09 PM)Han Wrote: Come to think of it, there are so many polynomial fits that you may want to clarify which types of polynomials to use: Taylor Polynomials, Lagrange Polynomial, Cubic Spline Interpolation, or Least Squares Polynomials.Honestly I don't know, i guess I'll just try the methods in your link and the LAGRANGE command and see if i get results that look like the ones in my math book Out of curiosity, what is the topic (in your book) from which you obtained the original problem? And what type of math book is it? (Stats, Linear Algebra, ... ) Graph 3D  QPI  SolveSys 

03102017, 09:57 PM
Post: #7




RE: Finding polynomials from a set of coordinates
(03102017 09:18 PM)Han Wrote:I don't know right now where excactly the problem is presented but it's somewhere in chapters covering polynomial functions, derivations and integrals. I'm studying electrical engineering, powerplants, communications etc..(03102017 09:13 PM)tdh79 Wrote: Honestly I don't know, i guess I'll just try the methods in your link and the LAGRANGE command and see if i get results that look like the ones in my math book I've been a sertified telco lineman for 18 years and I'm trying to get some more education, please excuse my poor english I'm Norwegian so my accent is almost as bad as Thor Heyerdahl's 

03112017, 12:53 AM
(This post was last modified: 03112017 12:54 AM by SlideRule.)
Post: #8




RE: Finding polynomials from a set of coordinates
(03102017 07:39 PM)tdh79 Wrote: I need to find polynomial functions from a given set of coordinates ... How can i find the function and plot for this? Try this URL Online Curve Fitting for a free numerical / graphical (albeit PC based rather than HP50g based) solution(s). BEST! SlideRule ps: the answer is in decimal fraction versus integer fraction form. 

03112017, 10:25 AM
Post: #9




RE: Finding polynomials from a set of coordinates
(03102017 07:39 PM)tdh79 Wrote: I need to find polynomial functions from a given set of coordinates, does anyone know how to do this with the 50g? Fitting a polynomial to a set of coordinates can be done by changing your system into a set of linear equations that you then resolve using the GaussJourdain pivot method. One thing you need to know is that you need n+1 points to fit a polynomial of degree n. Eg. you need 2 points to fit a line (a.x + b = 0), 3 points to fit a quadratic (a.x^{2} + b.x + c = 0) etc. Eg. You have the points (3,1), (1,0) and (2,1). For the quadratic to fit, all of these points must satisfy the equation, so substituting the coordinates' values of x and y in the equation you end up with something like this: a.(3)^{2} + b.(3) + c = 1 a.1^{2} + b.1 + c = 0 a.2^{2} + b.2 +c = 1  or  9a 3b +c = 1 a + b + c = 0 4a + 2b + c = 1 That looks suspiciously like a system of 3 linear equations that you can solve directly on the HP 50g. You will then get your values of a, b and c that you can replace in your quadratic equation and hey presto, there's your polynomial that passes through your three points. The solution to this system is a=1/4, b=1/4 and c=1/2 If you plot f(x)=(x^2)/4 + x/4  1/2 you'll see that the curve passes through all three points. 

03122017, 01:49 PM
Post: #10




RE: Finding polynomials from a set of coordinates
(03112017 10:25 AM)grsbanks Wrote: ... One thing you need to know is that you need n+1 points to fit a polynomial of degree n. Eg. you need 2 points to fit a line (a.x + b = 0), 3 points to fit a quadratic (a.x^{2} + b.x + c = 0) etc... Clarification  I always use three or more cartesian coordinates for a curve fit because a) two coordinates, by DEFINITION, are the endpoints of a line segment {either rectilinear or curvilinear} and b) a single coordinate fails the basic definition of a line segment. Alibis? BEST! SlideRule 

03122017, 05:58 PM
Post: #11




RE: Finding polynomials from a set of coordinates  
03122017, 06:38 PM
(This post was last modified: 03122017 06:52 PM by Dieter.)
Post: #12




RE: Finding polynomials from a set of coordinates
(03102017 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? (03102017 07:39 PM)tdh79 Wrote: Temperatures are measured 6 times during 24 hours: 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 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 ...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 

03122017, 07:56 PM
Post: #13




RE: Finding polynomials from a set of coordinates
(03102017 08:44 PM)Juan14 Wrote: Hello, you have to use the Lagrange polynomial. First enter a matrix with the values of x in the first row and then the values of y in the second row, and then the LAGRANGE command, for example: This seems to do what i need, thanks Is there any way to go directly to a spesific X value when this has been plotted? I can find it in TABLE but i was hoping there was a "GOTO" function in the plot view so i could easily read values at certain points without solving the function. 

03122017, 08:27 PM
Post: #14




RE: Finding polynomials from a set of coordinates
(03122017 06:38 PM)Dieter Wrote: A periodic function is not required (...) a 6th order polynomial would result in a perfect fit. The real problem is that you teach this guy something which is MATHEMATICALLY right but not right if he want to understand the model behind his data. Do not teach him anything without you do not clarify that his model is not right for this case. You can see later he will use this method for all of data what he must to analyse. If he will work as CSI, he will use the polynomial fit for the body temperature cooling down  because he learned polynomial fit without any clarification. Maybe he will design your medical stuffz when you will an old man  I hope, he will learn other models during thats years... And two additional thing: 1.) Why do not teach him how he can decide which polynomial degree is sufficient to fit? 2.) What about your 6th degree model first derivative in t=0 and t=24? As I guess these values aren't same  so that is not a good solution. Csaba 

03122017, 11:31 PM
Post: #15




RE: Finding polynomials from a set of coordinates
(03122017 08:27 PM)Csaba Tizedes Wrote: 1.) Why do not teach him how he can decide which polynomial degree is sufficient to fit? Sure – why not? Go ahead! ;) (03122017 08:27 PM)Csaba Tizedes Wrote: 2.) What about your 6th degree model first derivative in t=0 and t=24? As I guess these values aren't same  so that is not a good solution. Yes, f'(0) and f'(24) being equal would be nicer. Of course calculating a periodoc function is possible as well. Here is a possible result with a period of 24 hours: temperature ~ 12 – 13/3 cos(r*t) + 1/3 cos(3r*t) – 8/sqrt(3) sin(r*t) – 1/sqrt(3) sin(2r*t) where r = 2pi/24 = pi/12 This may be a better solution, although it's not what the OP asked for. Dieter 

03132017, 02:11 AM
Post: #16




RE: Finding polynomials from a set of coordinates
(03102017 07:39 PM)tdh79 Wrote: ... I need to find polynomial functions from a given set of coordinates, ...find the function and plot ...A starting point is polynomial interpolation. Do you have a background in Technical Mathematics sufficient to identify the following; a) Local Minima / Maxima b) Inflection Points on a data plot of cartesian coordinates? Comprehension of these topics is not essential but will greatly facilitate the formulation of a solution for your proposition, such as the shape of the plot or the degree of the polynomial constituting the same plot. "If you need the curve to pass through all the points in the data set, the only foolproof way is to use a polynomial of degree (n1) where n is the number of data points. If not, regression can be used." This process can be overwhelming while an inexact or approximate function may suffice within the required / implied accuracy /precision of the data set. As in every problem, an initial estimate or approximation of the desired answer is welcome prior to a more rigorous and exacting analysis. With a better understanding of your background, the application of the methods and procedures the many members have proffered may facilitate a most positive and productive learning experience for us all. BEST! SlideRule 

03132017, 03:00 PM
Post: #17




RE: Finding polynomials from a set of coordinates
(03122017 11:31 PM)Dieter Wrote:(03122017 08:27 PM)Csaba Tizedes Wrote: 1.) Why do not teach him how he can decide which polynomial degree is sufficient to fit? OK, let's see: 0.) I'm an engineer, my solution shows clearly how an engineer is thinking about this kind of problems 1.) This data has a minimal and a maximal value 2.) If I want to select a polynom, at least 3rd order must to use  because the 3rd order has a min. and max. extremum 3.) We have 6 data points, therefore we can use max. 5th order of polynom 4.) Fit 1st, 2nd, 3rd, 4th and 5th order polynom and check where the correlation coefficient is changes dramatically  see the picture below 5.) It's looks the 1st and 2nd is worst and 3rd order and above is better solution, the question is that what magnitude of error in each points is acceptable 6.) If no any special requirement, the 3rd is the simplest to use Csaba 

03132017, 03:05 PM
Post: #18




RE: Finding polynomials from a set of coordinates
(03132017 03:00 PM)Csaba Tizedes Wrote: 4.) Fit 1st, 2nd, 3rd, 4th and 5th order polynom and check where the correlation coefficient is changes dramatically  see the picture below The question is, is the OP asking for a polynomial that fits the provided data set or one that is close? That much is unclear. 

03132017, 03:37 PM
Post: #19




RE: Finding polynomials from a set of coordinates
(03122017 11:31 PM)Dieter Wrote: Of course calculating a periodoc function is possible as well. Here is a possible result with a period of 24 hours: And the second part of my answer about the periodic function: If I'm sitting in the middle of nowhere and I want to fit a periodic function, I will use the simplest solution: 1.) This is about a data of one day: the period is 24 hours 2.) The min and max values are exactly at t=4h and at t=16h 3.) Therefore the inflection is between them at t=10h 4.) The range of data between the max and min values of temperature, therefore we can calculate the amplitude of periodic function and the mean value for the shift of the function 5.) If I want to more exact value for the shift on the temperature axis, I can calculate the average of the measured temperatures  this requires little more keypress, no problem, I like it 6.) Just for fun, draw a little diagram and calculate the temperature differences and calculate RMS Everything fits in this half letter paper: And I used only one piece of paper, one of my favourite durable pencil and my most durable HP15C. This IS the engineering problem solving, not the sooo looong equuuuaaatioooons with looots of coefficients. Csaba PS.: I have no problem with you, I hope you're feel it, I'm just this kind of men. 

03142017, 02:20 AM
Post: #20




RE: Finding polynomials from a set of coordinates
tdh79
I will assume we sufficiently answered your question and in future queries a common reference might be an edition of the Lineman and Cableman's Field Manual ISBN: 9780071621229 (2nd edition) or related occupational manual? BEST! SlideRule 

« Next Oldest  Next Newest »

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