Math formula

Soulkeeper

Diamond Member
Nov 23, 2001
6,713
142
106
I'm working on a software project where I have some numbers output.
I want to find a math formula to fit the numbers to better understand the data.

X Y
3 1
4 4
5 10
6 20
7 35
8 56
9 84
10 120
11 165
12 220
13 286

How would I go about getting a formula that would tell me a Y value given an X ?
I'm not even sure if this is calculus/algebra or what terms i'd google for here.
thanks
 

PottedMeat

Lifer
Apr 17, 2002
12,365
475
126
heh if you were a windows user i'd tell you to dump it into excel and do a scatter plot and then add a trendline

excel says:

i picked polynomial because it looked like it matched

y = 0.1667x^3 - 0.5x^2 + 0.3333x + 5E-11
R2 = 1


edit: look up 'curve fitting'



i think we did this by hand in physics lab a long long time ago
 
Last edited:

Soulkeeper

Diamond Member
Nov 23, 2001
6,713
142
106
heh if you were a windows user i'd tell you to dump it into excel and do a scatter plot and then add a trendline

excel says:

i picked polynomial because it looked like it matched

y = 0.1667x^3 - 0.5x^2 + 0.3333x + 5E-11
R2 = 1


edit: look up 'curve fitting'



i think we did this by hand in physics lab a long long time ago

thanks
I was trying to solve that using this website http://www.johansens.us/sane/education/formula.htm i'd get to 0.1667x^3 But I kept failing at the x^2 step.
 

Soulkeeper

Diamond Member
Nov 23, 2001
6,713
142
106
y = (x^3)/6 - (x^2)/2 + x/3 appears to be correct
your windows app just fudged the numbers a bit

Now I just gotta figure out how to 'curve fitting' or solve similar problems in the future
 

Subyman

Moderator <br> VC&G Forum
Mar 18, 2005
7,876
32
86
If you just need a rough fit then look up least-squares. Its one of the most basic fits other than linear. You'll end up solving using matrix operations, so that will be how you will code it.

If you need an exact fit then you need the full polynomial interpolation and again solve it using matrix operations. The number of polynomials you need depends on the number of data points. That should be enough to get you headed in the right direction.
 

Howard

Lifer
Oct 14, 1999
47,989
10
81
How do you know, in general, that there would be a function that will fit your data? If the curve is just an approximation, it may not be safe to use it for extrapolating any new data.
 

Soulkeeper

Diamond Member
Nov 23, 2001
6,713
142
106
polynomial interpolation seems to be what I need
my numbers are being generated by loops incrementing based on the loop outside each so an exact fit is certain.
 

Subyman

Moderator <br> VC&G Forum
Mar 18, 2005
7,876
32
86
How do you know, in general, that there would be a function that will fit your data? If the curve is just an approximation, it may not be safe to use it for extrapolating any new data.

Its really a matter of the initial question. All he needs to find is a function that goes through all those points. A polynomial interpolation will do exactly that.
 

C1

Platinum Member
Feb 21, 2008
2,337
87
91
y = (x^3)/6 - (x^2)/2 + x/3 appears to be correct
your windows app just fudged the numbers a bit

Now I just gotta figure out how to 'curve fitting' or solve similar problems in the future


An HP Scientific calculator is able to provide the equation to a set of points and its "Solve" routine is able to provide the Y value for the given X value/input.
 

Soulkeeper

Diamond Member
Nov 23, 2001
6,713
142
106
hmm I see a solve button on my ti-83
Guess i'll have to refigure that out, been over a decade since i've actually used the thing.

thanks everyone
 

Murloc

Diamond Member
Jun 24, 2008
5,382
65
91
How do you know, in general, that there would be a function that will fit your data? If the curve is just an approximation, it may not be safe to use it for extrapolating any new data.
well that depends on the data and which conclusions you want to get, the interpolating function generator doesn't think for you
But if you know that a physical phenomenon behaves approximately in a certain way within your range of operation and you just need the parameters, this should be good enough.

I'm pretty sure this is implemented in Octave (it's the linux Matlab) as well so you could copy their code or at least their algorithm.
 
Last edited:

KWiklund

Member
Oct 30, 2013
35
0
16
Its really a matter of the initial question. All he needs to find is a function that goes through all those points. A polynomial interpolation will do exactly that.

In general, that's something you don't want to do. In most cases, you will end up over-fitting the data, and the resulting curve will fail to correctly generalize when presented with new data. What you really want is to find the lowest order model that accurately captures the trends in what may be noisy data.
 

C1

Platinum Member
Feb 21, 2008
2,337
87
91
Try this wed based "Polynomial Regression Data Fit" :

http://www.arachnoid.com/polysolve/

Just paste your data pair (ie, X,Y data values) into the "Data Entry" window then press "Solve".

For the data set given, setting the "Degree" =3 results in an almost perfect fit (R^2= 0.9999999999999998).

You will get the graphical fit, polynomial coefficients and the provided application allows to conveniently solve the poly for various selectable values of X.

(Solve for a specific X simply by manually entering the specific value in the "Start" box. )


PS: Recommend you just read your scientific calculator manual as it does all of this in the palm of your hand. In addition, the user typically has the application code used by the calculator and with that, you can just program it on a PC using free DOS "BASIC" (which you can run in a command window in a Windows OS such as XP - I do it all the time).
 

DrPizza

Administrator Elite Member Goat Whisperer
Mar 5, 2001
49,606
166
111
www.slatebrookfarm.com
Actually, it is a perfect fit if you did that. Calculators make slight rounding errors. His y-values are the number of balls in a triangular pyramid with x being the number of balls on each edge.
1 is obviously 1
2 along each edge gives a triangular base of 3, plus one on top.
3 along each edge gives a triangular base of 6, then 3 in the middle layer, then 1 = 10
4... base of 10, then 6, then 3, then 1 =20

5... let's see... The base triangle will have 5+4+3+2+1 (arranged like billiard balls), then the 4 sided pyramid of 20 balls resting on top.

6... 6+5+4+3+2+1 plus 5+4+3+2+1 plus 4+3+2+1 plus 3+2+1 plus 2+1 plus 1 = 56 balls.

You can derive a formula for this sum: = x(x+1)(x+2)÷6

Sorry I didn't answer the thread sooner.
 

shiekh

Junior Member
Sep 27, 2015
3
0
0
(x-2)(x-1)x/6

seems to work fine; maybe there is a slight typo in the previous posting.
 
Last edited:

DrPizza

Administrator Elite Member Goat Whisperer
Mar 5, 2001
49,606
166
111
www.slatebrookfarm.com
(x-2)(x-1)x/6

seems to work fine; maybe there is a slight typo in the previous posting.
Yes, thanks! I hadn't even looked back at the OPs post - I had focused more on the sequence of y-values: 1,4, 10, 20,... I neglected to notice that the OP started with a value of 3 for x.
x(x+1)(x+2) when x=1 is the same as
(x-2)(x-1)(x) when x=3.

My bad.
 

Soulkeeper

Diamond Member
Nov 23, 2001
6,713
142
106
Thanks for the input guys
I've moved on from this project since, but i'll pull this thread up if I decide to revisit it.
 

Anteaus

Platinum Member
Oct 28, 2010
2,448
4
81
How do you know, in general, that there would be a function that will fit your data? If the curve is just an approximation, it may not be safe to use it for extrapolating any new data.

I'm only repeating what some others have said, but in this case it was a perfect fit, verifiable by the fit value. If it were close but not exact, it would have returned something less than 1, such as the 0.9999... that C1 described. I'm guessing it fit so clean because it is academic and the original data were likely generated from a predictable polynomial.

To your second question, this is why if you are writing a technical/research paper where you extrapolate data you need to detail your error budget for the data being described. I work in geophysics and there is virtually never a case where the curve fits the data exactly.
 
sale-70-410-exam    | Exam-200-125-pdf    | we-sale-70-410-exam    | hot-sale-70-410-exam    | Latest-exam-700-603-Dumps    | Dumps-98-363-exams-date    | Certs-200-125-date    | Dumps-300-075-exams-date    | hot-sale-book-C8010-726-book    | Hot-Sale-200-310-Exam    | Exam-Description-200-310-dumps?    | hot-sale-book-200-125-book    | Latest-Updated-300-209-Exam    | Dumps-210-260-exams-date    | Download-200-125-Exam-PDF    | Exam-Description-300-101-dumps    | Certs-300-101-date    | Hot-Sale-300-075-Exam    | Latest-exam-200-125-Dumps    | Exam-Description-200-125-dumps    | Latest-Updated-300-075-Exam    | hot-sale-book-210-260-book    | Dumps-200-901-exams-date    | Certs-200-901-date    | Latest-exam-1Z0-062-Dumps    | Hot-Sale-1Z0-062-Exam    | Certs-CSSLP-date    | 100%-Pass-70-383-Exams    | Latest-JN0-360-real-exam-questions    | 100%-Pass-4A0-100-Real-Exam-Questions    | Dumps-300-135-exams-date    | Passed-200-105-Tech-Exams    | Latest-Updated-200-310-Exam    | Download-300-070-Exam-PDF    | Hot-Sale-JN0-360-Exam    | 100%-Pass-JN0-360-Exams    | 100%-Pass-JN0-360-Real-Exam-Questions    | Dumps-JN0-360-exams-date    | Exam-Description-1Z0-876-dumps    | Latest-exam-1Z0-876-Dumps    | Dumps-HPE0-Y53-exams-date    | 2017-Latest-HPE0-Y53-Exam    | 100%-Pass-HPE0-Y53-Real-Exam-Questions    | Pass-4A0-100-Exam    | Latest-4A0-100-Questions    | Dumps-98-365-exams-date    | 2017-Latest-98-365-Exam    | 100%-Pass-VCS-254-Exams    | 2017-Latest-VCS-273-Exam    | Dumps-200-355-exams-date    | 2017-Latest-300-320-Exam    | Pass-300-101-Exam    | 100%-Pass-300-115-Exams    |
http://www.portvapes.co.uk/    | http://www.portvapes.co.uk/    |