From caed688b5341b41e01b76de3b860f5914faf2c5c Mon Sep 17 00:00:00 2001 From: Virachai Wongsena Date: Wed, 8 Jan 2025 19:10:32 +0700 Subject: [PATCH] Add explanation for odeint usage and output image Added a brief explanation of the code and the usage of odeint, emphasizing its role in solving differential equations numerically. Included an output visualization as an image stored under the media folder in the docs directory for better understanding. --- .../concepts/scipy-integrate/terms/odeint/odeint.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/content/scipy/concepts/scipy-integrate/terms/odeint/odeint.md b/content/scipy/concepts/scipy-integrate/terms/odeint/odeint.md index a38d3a447bc..8f4630de7bc 100644 --- a/content/scipy/concepts/scipy-integrate/terms/odeint/odeint.md +++ b/content/scipy/concepts/scipy-integrate/terms/odeint/odeint.md @@ -70,15 +70,17 @@ plt.grid() plt.show() ``` +### Explanation + +In the code, `odeint` is used to numerically solve the ODE \( \frac{dy}{dt} = -2y + 3 \) with an initial condition \( y(0) = 5 \). The `model` function defines the derivative, and `odeint` integrates this function over the specified time points, returning the solution as an array. + ### Output The plot shows the solution \( y(t) \) over time, illustrating the system's dynamics as it approaches a steady state. +![Output from above code](https://raw.githubusercontent.com/Codecademy/docs/main/media/odeint_solution_plot.png) + ## Notes - **`odeint()`** is ideal for many scientific and engineering applications due to its robustness and flexibility. - For more advanced control or alternative solvers, consider using **`scipy.integrate.solve_ivp()`**, which offers a more modern API. - -## References - -- [SciPy Documentation on `odeint`](https://docs.scipy.org/doc/scipy/reference/generated/scipy.integrate.odeint.html)