Surgo - surely f is not a function of x, and is instead +1 if the stat is being boosted and -1 if the stat is being reduced, with x being the number of boosts/reductions?
That way you don't get problems trying to put x = -2 or something..
So if I use Swords Dance, my attack is doubled? ooh...broken..