Write a program using fourth order runge kutta...
This is a classic example of a system for which an adaptive step size method is useful because for the large periods of time when the comet is moving slowly we can use long time steps, so that the program runs quickly, but short time-steps are crucial in the brief but fast-moving period close to the sun. The differential equation obeyed by a comet is straightforward to derive. The form between the sun, with mass M at the origin, and a cornet of mass m with positions vector r is GMm/r^2 in direction -r/r (i.e., the direction towards the Sun), and here Newton's second law tells us that m d^2r/dt^2 = -(GMm/r^2) r/r, Canceling the m and taking the x component we have d^2x/dt^2 = -GM x/r^3, and similarly for the other two coordinates. We can, however, throw out one of the coordinates because the comet stays in a single plane as it orbits. If we orient our axes so that this plane is perpendicular to the z-axis, we can forget about the z coordinate and we are left with just two second-order equations to solve: d^2x/dt^2 = -GM x/r^3, d^2y/dt^2 = -GM y/r^3 where r = squareroot x^2 + y^2 a) Turn these two second-order equations into four first-order equations, using the methods you have learned b) Write a program to solve your equations using the fourth-order Runge-Kutta method with a fixed step size. You will need to look up the mass of the Sun and Newton's gravitational constant G. As an initial condition, take a comet at coordinates x = 4 billion kilometers and y = 0 (which is somewhere out around the orbit of Neptune) with initial velocity v_x = 0 and v_y = 500ms^-1. Make a graph showing the trajectory of the comet (i.e., a plot of y against x) Choose a fixed step size h that allows you to accurately calculate at least two full orbits of the comet. Since orbits are periodic, a good indicator of an accurate calculation is that successive orbits of the comet lie on top of one another on your plot. If they do not then you need a smaller value of h. Give a short description d) This is a classic example of a system for which an adaptive step size method is useful because for the large periods of time when the comet is moving slowly we can use long time steps, so that the program runs quickly, but short time-steps are crucial in the brief but fast-moving period close to the sun. The differential equation obeyed by a comet is straightforward to derive. The form between the sun, with mass M at the origin, and a cornet of mass m with positions vector r is GMm/r^2 in direction -r/r (i.e., the direction towards the Sun), and here Newton's second law tells us that m d^2r/dt^2 = -(GMm/r^2) r/r, Canceling the m and taking the x component we have d^2x/dt^2 = -GM x/r^3, and similarly for the other two coordinates. We can, however, throw out one of the coordinates because the comet stays in a single plane as it orbits. If we orient our axes so that this plane is perpendicular to the z-axis, we can forget about the z coordinate and we are left with just two second-order equations to solve: d^2x/dt^2 = -GM x/r^3, d^2y/dt^2 = -GM y/r^3 where r = squareroot x^2 + y^2 a) Turn these two second-order equations into four first-order equations, using the methods you have learned b) Write a program to solve your equations using the fourth-order Runge-Kutta method with a fixed step size. You will need to look up the mass of the Sun and Newton's gravitational constant G. As an initial condition, take a comet at coordinates x = 4 billion kilometers and y = 0 (which is somewhere out around the orbit of Neptune) with initial velocity v_x = 0 and v_y = 500ms^-1. Make a graph showing the trajectory of the comet (i.e., a plot of y against x) Choose a fixed step size h that allows you to accurately calculate at least two full orbits of the comet. Since orbits are periodic, a good indicator of an accurate calculation is that successive orbits of the comet lie on top of one another on your plot. If they do not then you need a smaller value of h. Give a short description d)