You show the code, which is your proposed solution. But you didn't state what the original problem was, so it's not possible to know whether this is correct or not.
On line 29 dt is not initialised, producing garbage values for f, and for all the values in the a array.
On lines 36, 42, 48 b[i] is always negative by assignment, but could be positive given the garbage value for f.
Btw, I think you should always use doubles, not floats - mixing the two can cause problems, and there is no need to use floats (presumably not processing billions of them).
The only other suggestion I have is to use the debugger to deduce where things go wrong. using the debugger can save one heaps of time tracking down run time errors.