It does work if you replace: elasticity *= ratio; with elasticity = elasticity * ratio; Clearly we're analyzing wrong when there's only an assignment.