Click to See Complete Forum and Search --> : Calculus in programs
enfekted
October 8th, 2004, 03:12 PM
I have a table of data (x,y) and I need to find a way to determine what the data would be at a certain location that could be beyond the bounds of the data.
For example,
- I have this data in a table:
X Y
1 3
4 2
7 5
9 6
- I want to know what Y will be when X=0
I assume that I will need to use calculus to find the derivative until it is a constant value and then find the anti-derivatives until all data is satisfied, but I'm not sure how to go about doing this programmatically.
Any ideas?
indiocolifa
October 26th, 2004, 05:53 AM
you may look into curve interpolation math. Search for some numerical library to do that. such as GSL (GNU Scentific Library).
DeepButi
October 27th, 2004, 03:53 AM
Any numerical serie of any number of items can be continued by ... any number you like :cool: ... there will always be a n-grade curve that fits your needs.
This is what I always wanted to answer to those boring tests "wich number follows 1-6-11-16? ... well 2378 will fit perfectly, just let me some time to find the curve." Unfortunately test-passing people never understands it :rolleyes:.
Anyway ... what about a finite differences method?
3 2 5 6
-1 3 1
4 -2
-6
And now expand it ...
3 2 5 6 ... -1 -22
-1 3 1 ... -7 -21
4 -2 ... -8 -14
-6 ... -6 -6
Got the idea? Easy to implement.
Hope it helps
enfekted
October 29th, 2004, 10:07 AM
Thank you for your replies. I think what I'm trying to ask for is a programmatic Curve Fitting function that will satisfy all data in a table. I probably should have used f(x) instead of y in my previously mentioned table.
If I knew that there were a set number of points, I could probably find a polynomial function (Ax^2 + Bx + C) and then just save A, B, and C to find any point on the line. However the table could consist of any number of points.
DeepButi, that is a good idea, however I think that only works if the change in X values are constant.
indiocolifa, GSL looks good. I'll have to look into it to find out if it has exactly the right function I'm looking for. Otherwise it should prove to be a good place to start.
Thanks all for your reply.
kepler777
June 26th, 2005, 02:39 PM
you may look into curve interpolation math. Search for some numerical library to do that. such as GSL (GNU Scentific Library).
I agree, but there's a problem I'm trying to solve. How do I put the GSL working with Visual Basic 6.0? There's, apparently, a problem:
"As to my knowledge the GSL DLLs on Windows unfortunately do not
use the 'Pascal calling convention' (or __stdcall using MSVC).
One either has to re-compile the whole library for that. Or just
use a wrapper which does nothing but cares for that convention and
if you only need it for simple functions (no arrays, structs ...)
that is not too complicated"
How do I do this?
Kind regards,
kepler777
codeguru.com
Copyright WebMediaBrands Inc., All Rights Reserved.