Your problem is that you should be using lerpf
instead of lerp
for example, your code should look like:
func apply_horizontal_deceleration(delta : float) -> void:
velocity.x = lerpf(0, velocity.x, pow(2, -40 * delta))
I struggled a lot with this problem aswell and I found this works