Skip to content

Commit

Permalink
Add explanation for odeint usage and output image
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
virachai authored Jan 8, 2025
1 parent 6ae4c7e commit caed688
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions content/scipy/concepts/scipy-integrate/terms/odeint/odeint.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit caed688

Please sign in to comment.