Lesson 1 of 15
Euler's Method
Euler's Method
Differential equations describe how quantities change over time. A first-order ODE has the form:
We cannot always solve this analytically. Euler's method is the simplest numerical approach: approximate the solution by taking small steps along the tangent line.
The Formula
Given the current state , take a small step of size :
The idea: is the slope (derivative) at the current point. Moving forward in time, we step in the y-direction.
Example
For (exponential growth) with and :
The exact answer at is . Euler's method gives — a reasonable approximation for a single step.
Your Task
Implement euler_step(f, t, y, h) that returns the next y value using one Euler step.
Pyodide loading...
Loading...
Click "Run" to execute your code.