I wrote an orbit propagator (calculates position and velocity of a satellite for each time step) in matlab and it's pretty accurate (4.5 km in a 24-hour propagation). I had to rewrite it in C, I did it and it's working properly but my results are much less accurate (450 km for a 24-hour propagation), so I was wondering what could cause this loss of accuracy in C for the exact same calculations (I compared the scripts to be sure I didn't forget anything.) ?
All my variables are double or long double depending on the needs. There are no divisions by ints. The error grows linearly over time.
My main function contains a while loop that updates the values of my position and velocity arrays by calling the calculating function that takes pointers to the arrays as arguments.