For one of my homework assignments in a mathematical modeling class, we were supposed to take a 2d system of second order differential equations, and convert it to a 4d first order system of differential equations. This system of differential equations is supposed to model the flight path of a space shuttle around the equator until it touches down. Here is the following code I used.

(*declare constants*)
M = 5.972*10^24;
G = 6.674*10^-11;
R = 6.378*10^6;
m = 1200;
k = 8.33*10^-8;
B = 4.8*10^-5;

(*define values for matrix*)
a = -((G*M)/(x[t]^2 + y[t]^2)^(3/2));
b = -k/m*Exp[-B ((x[t]^2 + y[t]^2)^(1/2) - R)] (u[t]^2 + v[t]^2)^(1/2);

(*define matrix*)
A = {{0, 0, 1, 0},
   {0, 0, 0, 1},
   {a, 0, b, 0},
   {0, a, 0, b}};

(*Set up linear system and solve it*)
w[t_] = {x[t], y[t], u[t], v[t]};
eqn = w'[t] == A.w[t];
sol = NDSolve[{eqn, y[0] == 100000 + R, u[0] == 7850, x[0] == 0, 
   v[0] == 0}, {x[t], y[t], u[t], v[t]}, {t, 0, 2000}]

One of the questions on the homework was to find the time it took for the shuttle to reach the surface of the earth starting from 100000m of altitude with an initial velocity of 7850m/s tangent to the earths surface.

I used the following to extract the interpolating functions from the solution set given by NDSolve

yint = y[t] /. First[sol]
xint = x[t] /. First[sol]

I run into issues when it comes to getting values from the interpolating functions at time t. For example I'd need to find the time when the magnitude of the (x,y) vector is equal to the radius of the earth(R). I've had very limited success with FindRoot, and Solve.

  • $\begingroup$ Define yint[t_] = y[t] /. First[sol]; xint[t_] = x[t] /. First[sol]; . $\endgroup$ – Akku14 Feb 28 '20 at 19:53
  • 5
    $\begingroup$ As an alternative approach, consider using WhenEvent within NDSolve to find the time you need. $\endgroup$ – Chris K Feb 28 '20 at 20:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.