|
-
Nov 22nd, 2003, 01:37 PM
#1
Pattern recognition
Does anyone have an algorithm (in code or pseudocode) that enables a program to identify a polynomial function from an array (1 or 2 dimensional array) giving (x, y) data?
I need at least to be able to identify quadratic and 3 term polynomials (y=ax^3 + bx^2 + cx + d).
Any programming language is fine by me.
I don't live here any more.
-
Nov 23rd, 2003, 11:35 AM
#2
transcendental analytic
not sure what you mean, do you want to parse the polynominal from a string? why 1 or 2 dimensions?
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Nov 23rd, 2003, 12:02 PM
#3
Frenzied Member
I have something on my TI83 to find sequences if thats what you mean. but it's very long so unless you definately want it, I won't write it.
it can find
An^3 +Bn^2 Cn + D
or
A^n +B
If you want, I'll write out the psuedo code if you don't have a TI83
Have I helped you? Please Rate my posts. 
-
Nov 23rd, 2003, 12:04 PM
#4
Frenzied Member
the other thing crappy with it is that it needs the first 6 items in the sequence to find the rest, though this can probably be improved if I really tried.
Have I helped you? Please Rate my posts. 
-
Nov 23rd, 2003, 02:38 PM
#5
Do you mean that given n (x,y) pairs, you want to find a n-1th order polynomial equation y=axn+bxn-1+...+d?
If you have four (x,y) values, it means that you have these equations:
y1=ax13 + bx12 + cx1 + d
y2=ax23 + bx22 + cx2 + d
y3=ax33 + bx32 + cx3 + d
y4=ax43 + bx42 + cx4 + d
You can solve this system of equations using a matrix inverse:
Code:
[x13 , x12 , x1 , 1]
A = [x23 , x22 , x2 , 1]
[x33 , x32 , x3 , 1]
[x43 , x42 , x5 , 1]
[y1]
B = [y2]
[y3]
[y4]
You need to find a matrix X, such that AX = B. This matrix can be found using X=A-1B.
This algorithm needs a function for a matrix inverse, i don't have code handy that does that, but I'm sure you can find something on google.
Another method involves rewriting the equations, and substituting them. Rewrite the first equation as:
a = (bx12 + cx1 + d - y1) / x13
You can now substitute all a's in the other three equations with this this one:
y2=((bx12 + cx1 + d - y1) / x13)x23 + bx22 + cx2 + d
repeat this process untill only an equation of the form:
d = f(x1, y1, x2, y2, x3, y3, x4, y4)
remains, now you have the value of d. substitute d in the equations to find the value of c, etc.
You may be able to find more info on mathworld
Last edited by twanvl; Nov 23rd, 2003 at 02:42 PM.
-
Nov 24th, 2003, 03:41 AM
#6
-
Nov 27th, 2003, 08:19 AM
#7

Am I right in thinking that this...

is the pertinent equation that I should implement?
Blimey.
I don't live here any more.
-
Nov 28th, 2003, 05:42 AM
#8
Fanatic Member
-
Nov 29th, 2003, 02:03 PM
#9
I wonder, would it be utterly rude of me at this stage to ask if anyone has actually coded such a function? I don't think even my considerable skills of logic (riiiight! ) can figure out a way to code that.
Could I have a sneaky gander if so?
If not then not to worry, I have just been bombarded with several new projects to be getting on with in the meantime such as learning ASM .
I don't live here any more.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|