Its this side thing I was working one, when I got the chance. Its not very good right
now, as its still in its developing stage. But its still ok, where I can show it of, lol.
Attached is an exe, that given a set of data points, it tries its best to return a POLYNOMIAL function that maps to those data points, and emphasis on polynomial!

For example here are some test runs :

<enter data points( '.' to end) >  1 2 3 .

<function : f(n) = n >
<f(n) evaluated from n = 1 to 20 : { 1,2,3,4,....19,20 }

Another example run :

<enter data points( '.' to end) > 2 4 6 8 10 .

<function : f(n) = 2n >
<f(n) evaluated from n = 1 to 20 : {2,4,6,8,10 ... 40 }

You get the idea. Again, its not very good. It can only do the simple things. And be nice .

Should this be posted under code snippets or something? There's not really a question is there?

Dave

You forgot to ask "Would you like source with that?" Let's hope it's legit :D

I'd be interested to know which approximation you were using and stuff.

>> Should this be posted under code snippets or something

I was thinking about it, but then there is no code.

You forgot to ask "Would you like source with that?" Let's hope it's legit :D

I'd be interested to know which approximation you were using and stuff.

Wow, you really think it wasn't legit, lol. Actually, I'm flattered. Not sure I'f I
want to release it yet. So what do you guys think?

but then there is no code

That's very metaphysical. It must have some code somewhere. It's not critical to see, it was just curious that you're having us critique an exe.

I'm having a problem trying to run this program. Is there anything special I need to do to run it. the error I'm getting is attached. Also this flagged my sonar protection with Norton but not sure if that matters.

Yes that worked. Not sure what happened with the other one. BTW it worked really well for your question. I had to break down and use my TI85.

Yes that worked. Not sure what happened with the other one. BTW it worked really well for your question. I had to break down and use my TI85.

Lol, nice.

If you ever decide to release the source code I would love to take a look at it.

If you ever decide to release the source code I would love to take a look at it.

Actually, its not hard at all. The method I used is actually an old one, called finite
difference. Here is an example.

Consider the following sequence,

[TEX]S = {1,2,3 ... }.[/TEX]


To find a approximated polynomial function that maps into those data points, we need to
do three things.

1) Find the polynomial degree needed.
2) Create a linear system of equation.
3) Solve the linear system of equation.


To do 1), we do compute the difference between i, and i+1, if possible, until we get
a constant row of numbers. So for the above example,



ROW 0 = 1 2 3
ROW 1 = 1 1


From above, we computed the difference between the adjacent numbers. And we see that
there is a row of constant number, namely Row 1. This tells us that there is a polynomial
of degree 1, that maps into ROW 0.

A polynomial of degree 1, has the following form :

[TEX]p(n) = an^1 + b;[/TEX] [a and b are scalers]


Now for 2), we need to come up with an linear equation for p(n). We can do the
following,

[TEX]p(1) = a(1) + b[/TEX]
[TEX]p(2) = a(2) + b[/TEX]

and by setting p(1) to say the first data point in Row 0, namely 1, and by setting
p(2) to the second data point, namely 2. We generate the following linear equation :

[TEX]1 = a + b
2 = 2a + b[/TEX]

Now solving this linear equation, we see that a = 1 and c = 0.

Now going back to our polynomial, p(n) = an + b, we can now substitute a = 1, and c = 0,
to get :

[TEX]p(n) = 1*n + 0[/TEX]
[TEX]p(n) = n[/TEX]

This the approximated function, [TEX]p(n) = n[/TEX] is our approximated function that
maps onto the given data point.

The only part that might be troublesome is to solve a NbyN linear system of equation.
One can create his own matrix class that does this, or use others. I created my own.
And the other part, that might be hard, is to find a efficient algorithm to generate
the system of linear equation into an array or whatever data structure on wishes to use.

So as you see its not hard at all. Just a little bit of work.

commented: Nice job with it +4

I guess I forgot more math then I thought. A couple of years ago this would have been second nature. Oh well I guess I'll just have to buy some math books and relearn what I forgot. Thanks for the explanation.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.