1# results
which are perfect results |
line 68 and 68 are the wrong way around: you are copying elem 2 over elem 1 and then copying the new elem 1 over elem 0. So elem 0 and 1 are always the same.
If you swap these two lines then you're results will be better.
#2 initial two and final two points
When is comes to the first two and last two points, you could special case them. That is, use one of the other formula discussed earlier in the thread.
- use the forward delta version of Alg #1 for the first point
- use the reverse delta version of Alg #1 for the last point
- use version of Alg #2 for the second and one before the last points
But to get improved accuracy, you will need to look for a way of interpolating which uses more than 2 or 3 points. (I've always just dropped the two first points.)
#3 Books
I am unsure about what you mean "maths for real applications". Some areas of computing, like games and fincancial applications, use quite a lot of maths. So books on these subjects should also be mathematical.
One book which might be relevant is "Numerical Recipes in C++: The Art of Scientific Computing".
Andy