Following code

Maybe some trig will help you find something more to your liking.

Also take a look at Hooke’s law, which is an elasticity formula.