Slack variables are used in

Linear Optimization to turn

constraints stated as

inequalities into

equalities and a constraint that the slack variable be non-negative.

Linear programming problems should be set up so that all variables must be non-negative anyway, so this last constraint isn't so important. The variable can grow to take up the 'slack' in the inequality, but never shrinks small enough (i.e. goes negative) to break the inequality.

You'll normally be using slack variables to set up a problem in matrix form so that you can run it through the Simplex method or some similar algorithm, almost all of which will require constraints to be stated as equalities (but where slack variables can easily be added.)

Starting with an inequality:

x + y >= 10

We either add or subtract a slack variable so that if the statement is an equality, the slack variable is zero, and the slack would have to be negative if the inequality weren't satisfied:

x + y - s = 10, s >= 0

Here, if x+y < 10, s will have to be negative to satisfy the inequality. Thus the second pair of constraints is equivalent to the first.

Some other sample slack variable additions:

3x + 5y <=100

3x + 5y + c_{1} = 100, c_{1} >= 0

100 x_{1} - 150 x_{2} + 5 x_{5} >= 100

100 x_{1} - 150 x_{2} + 5 x_{5} - x_{7} = 100, x_{7} >= 0