All problems
Euler Method One Step
Problem
Take one explicit Euler step for the ODE y' = a * y + b * t.
Given the current state (y, t) and step size dt, return y + dt * (a * y + b * t).
Hint
Evaluate the right-hand side at the current point and add dt times that slope.
Test cases
case 1
in: [1,0,0.1,1,0]
expected: 1.1
case 2
in: [2,1,0.5,0,1]
expected: 2.5
case 3
in: [0,1,1,5,3]
expected: 3
case 4
in: [-1,2,0.25,-2,1]
expected: 0
Starter codePython
def euler_step(y, t, dt, a, b):
# Your code here
pass4 test cases · run your code against them in the editor