# How to deal with rapid acceleration/deceleration from physics forces?

I'm working on a game in LOVE2D using Lua, where you pilot a drilling vehicle. The idea is that as you drill into different surfaces, you speed up/slow down depending on how dense that surface is. I'm simulating it using drag forces, something like this:

engineForce = engineForce + userInput * dt -- increase the engine speed based on user input
dragForce = .25 * dragCoefficient * speed^2 -- a simple implementation of the drag equation
acceleration = engineForce - dragForce
speed = speed + acceleration*dt


What's supposed to happen is velocity will increase until dragForce = engineForce and it maintains speed. This mostly works except occasionally it gets into a weird feedback loop where speed overshoots slightly (not sure if it's due to a rounding error or what) so drag becomes stronger than the engine causing it to decelerate. But because it decelerated, drag decreases and now the engine is stronger than drag, causing it to accelerate again. And again it will overshoot the target, causing the process to repeat again.

Does anyone know best practices for programming physics like this?