Project 4: Numerical ODE

Evaluating using numerical methods to solve ordinary differential equations. We made use of the Euler method, the 4th Order Runge-Kutta and the adaptive 4th Order Runge-Kutta.

Homework problems.

Euler

Euler is good to get an understanding of the numerical method

Euler Code

Runge-Kutta

Interesting, he Runge-Kutta reduces error with larger steps than the Euler, but if the Euler is given very small steps it find and error equivalent to the RK4 with very small steps.

Runge-Kutta 4th Order Code

Adaptive Runge-Kutta

Adaptively changing the step size gets interesting. We evaluate the step in two half steps and compare the error to a full step. This way if we are smooth parts of the integral we can take large steps and conversely we can take small steps to evaluate interesting portions of the function. Also interesting is that taking large jumps in step size still actually ends up taking longer to step because it is essentially an underdamped controller trying to evaluate to a step function. Playing with the step sizes I found incrementing them a fraction of a step size was more effective at reducing total number of steps than taking large leaps.

Adaptive Runge-Kutta 4th Order Code