Semi-Implicit Euler for a Damped Spring
~12 mincode completion
Implement spring_steps(x, v, m, k, c, dt, n_steps) returning the array [x, v] after n_steps steps.
Where this shows up
~12 min
••••••••••••
6 employers weight this skill
4 autonomy companies, 2 defense companies. Top match scores 93.
Python
import numpy as np
def spring_steps(x, v, m, k, c, dt, n_steps):
"""
Simulate a damped mass-spring with semi-implicit Euler.
Args:
x, v: initial position and velocity
m: mass
k: spring stiffness
c: damping coefficient
dt: time step
n_steps: number of steps
Returns:
array [x, v] after n_steps
"""
# YOUR CODE HERE
pass