summaryrefslogtreecommitdiff
path: root/tutorials/module_3/5_ode.md
diff options
context:
space:
mode:
Diffstat (limited to 'tutorials/module_3/5_ode.md')
-rw-r--r--tutorials/module_3/5_ode.md42
1 files changed, 27 insertions, 15 deletions
diff --git a/tutorials/module_3/5_ode.md b/tutorials/module_3/5_ode.md
index 81f6c6b..acb0cff 100644
--- a/tutorials/module_3/5_ode.md
+++ b/tutorials/module_3/5_ode.md
@@ -14,9 +14,9 @@ $$
\frac{dy}{dt}=f(t,y), \quad y(t_0)=y_0
$$
where $f(t,y)$ describes the rate of change of $y$ with respect to time $t$.
-## Explicit Methods
+# Explicit Methods
-### Euler's Method
+## Euler's Method
![forward_eulers_method|350](fw_eulers.png)
Eulers method or more specifically Forwards Eulers method is one of the simplest methods for solving ODE's. The idea of the Forward Euler method is to approximate the solution curve by taking small time steps, each step moving forward along the tangent given by the slope $f(t,y)$. At each step, the method updates the solution using the formula
$$
@@ -68,27 +68,39 @@ The idea is to improve accuracy by not relying solely on the slope at the beginn
$$
y_{n+1} = y_n + \frac{h}{2}\big[f(t_n, y_n) + f(t_{n+1}, y_n + h f(t_n, y_n))\big]
$$
-This averaging of slopes makes the method **second-order accurate**, which means its global error decreases proportionally to $h^2$ rather than just hhh, as in Forward Euler.
+This averaging of slopes makes the method **second-order accurate**, which means its global error decreases proportionally to $h^2$ rather than just $h$, as in Forward Euler.
-In practice, Heun’s method provides a significant improvement in accuracy without adding much computational cost. It still only requires evaluating the function $f(t,y)$ twice per step, making it more efficient than higher-order methods like Runge–Kutta while being more stable and reliable than Forward Euler. Because of this balance, Heun’s method is often used as an introduction to the idea of correcting predictions in numerical ODE solvers and as a stepping stone toward understanding more advanced predictor–corrector schemes.
-## Runge-Kutta
-The Runge-Kutta method,
-The Runge–Kutta family of methods can be thought of as systematic improvements on Euler’s idea of “stepping forward” using slope information. In fact, Euler’s method itself is the simplest **Runge–Kutta method of order 1 (RK1)**: it uses just the slope at the beginning of the step to predict the next value. Heun’s method can then be seen as a **Runge–Kutta method of order 2 (RK2)**: instead of relying only on the initial slope, it takes two slope evaluations (one at the start and one at the predicted end), then averages them for better accuracy. This use of multiple slope samples within each step is the hallmark of the Runge–Kutta framework—higher-order accuracy comes from cleverly combining several slope evaluations.
+![Heuns Method|350](heuns_method.png)
+In practice, Heun’s method provides a significant improvement in accuracy without adding much computational cost. It still only requires evaluating the function $f(t,y)$ twice per step, making it more efficient than higher-order methods like Runge–Kutta while being more stable and reliable than Forward Euler.
+## Classical Runge-Kutta
+Also known as the **classical fourth-order Runge–Kutta (RK4)** method. It takes four slope evaluations per step: one at the beginning, two at intermediate points, and one at the end of the step. These slopes are then combined in a weighted average to update the solution. RK4 is accurate to **fourth order**, meaning the global error scales as $h^4$, which is far more accurate than Euler or Heun for the same step size. In practice, this makes RK4 the “workhorse” of many ODE solvers where stability and accuracy are needed but the system is not excessively stiff.
-The most widely used member of this family is the **classical fourth-order Runge–Kutta (RK4)** method. It takes four slope evaluations per step: one at the beginning, two at intermediate points, and one at the end of the step. These slopes are then combined in a weighted average to update the solution. RK4 is accurate to **fourth order**, meaning the global error scales as h4h^4h4, which is far more accurate than Euler or Heun for the same step size. In practice, this makes RK4 the “workhorse” of many ODE solvers where stability and accuracy are needed but the system is not excessively stiff.
-
-Modern libraries, such as **SciPy’s `solve_ivp`**, build on this idea with adaptive Runge–Kutta methods. For example, `RK45` is an adaptive solver that pairs a 4th-order method with a 5th-order method, comparing the two at each step to estimate the error. Based on this estimate, the solver adjusts the step size automatically: smaller steps in regions where the solution changes quickly, and larger steps where the solution is smooth. This makes `RK45` both efficient and robust, giving you the accuracy benefits of Runge–Kutta methods while also taking away the burden of manually choosing an appropriate step size.
-
-Would you like me to also show the Butcher tableaux for RK1, RK2, and RK4 so you see the structure that unifies them?
+**SciPy’s `solve_ivp`**, build on this idea with adaptive Runge–Kutta methods. For example, `RK45` is an adaptive solver that pairs a 4th-order method with a 5th-order method, comparing the two at each step to estimate the error. Based on this estimate, the solver adjusts the step size automatically: smaller steps in regions where the solution changes quickly, and larger steps where the solution is smooth. This makes `RK45` both efficient and robust, giving you the accuracy benefits of Runge–Kutta methods while also taking away the burden of manually choosing an appropriate step size.
## Problem 1: Exponential decay
## Problem 2: The Predator-Pray Model
+## Problem 3: Swinging Pendulum
+
+
+# Implicit Method
+Implicit methods for solving ODEs are another numerical schemes in which the new solution value at the next time step appears on both sides of the update equation. This makes them fundamentally different from explicit methods, where the next value is computed directly from already-known quantities. While explicit methods are simple and computationally cheap per step, implicit methods generally require solving algebraic equations at every step. In exchange, implicit methods provide much greater numerical stability, especially for stiff problems. The general idea of an implicit method for a first-order ODE is to write the time-stepping update in a form such that
+$$
+y_{n+1} = y_n + h f(t_{n+1}, y_{n+1})\tag{2}
+$$
+where $h$ is the step size. Unlike explicit schemes (where $f$ is evaluated at known values $t_n$, $y_n$​), here the function is evaluated at the unknown point $t_{n+1}, y_{n+1}$​. This results in an equation that must be solved for $y_{n+1}$​ before advancing to the next step.
+
+Implicit methods are especially useful when dealing with stiff ODEs, where some components of the system change much faster than others. In such cases, explicit methods require extremely small time steps to remain stable, making them inefficient. Implicit schemes allow much larger time steps without losing stability, which makes them the preferred choice in fields like chemical kinetics, heat conduction, and structural dynamics with damping. Although they require more computational effort per step, they are often far more efficient overall for stiff problems.
+## Backwards Eulers
+The implicit counter part of Forward Euler is the Backward Euler method. Like Forward Euler, it advances the solution using a single slope estimate, but instead of using the slope at the current point, it uses the slope at the unknown future point. This creates an implicit update equation that must be solved at each step, making Backward Euler both the easiest implicit method to derive and an excellent starting point for studying implicit schemes.
+
+## Problem 1: Chemical Kinetics
+## Problem 2:
-# Implicit ODE
-### Backwards Eulers
+# Systems of ODE's
+All methods for single ODE equations can be extended to using for system of ODEs
-# System of ODE's \ No newline at end of file
+## Problem 1: \ No newline at end of file