Calculate acceleration,velocity?

Dear Friends,
I have received an assignment to calculate the velocity and position from acceleration formula (dx^2/dt^2=-g which is acceleration equation) by using the integral formula below (Euler method) and save the output in .txt file. would you please help me? the formula below is from another code but the principle is the same.
I mean I want to have a table that from t=0-100, every 1sec, calculate the acceleration, velocity and position of a rocket

// function to integrate equation du/dt=a using euler method
void solve_x(double *x, double *u, double dt, int time_step){

u[time_step+1]=(dt/2)*(a[time_step+1] + a[time_step]) + u[time_step];
-----------------------------------------------------------------------------------------// function to integrate equation dx/dt=u using euler method
void solve_x(double *x, double *u, double dt, int time_step){

x[time_step+1]=(dt/2)*(u[time_step+1] + u[time_step]) + x[time_step];



Last edited on
Topic archived. No new replies allowed.