Here's how you can do it in Mathematica:
Define the problem and variables:
Let x be the number of 19" pieces to cut from each 2x4, and y be the number of 7" pieces to cut from each 2x4.
Define the objective function:
The objective is to minimize the waste, which can be represented as (96 - (19x + 7y)), as 96 is the length of each 2x4 and (19x + 7y) is the total length of pieces cut from it.
Set up the constraints:
You have the constraint that the total length of pieces cut from each 2x4 cannot exceed 96 inches, so the constraint is (19x + 7y <= 96).
Use Mathematica to solve the linear programming problem:
(* Load the LinearProgramming package *)
Needs["LinearProgramming`"]
(* Define the objective function coefficients and constraints *)
objectiveCoefficients = {19, 7};
constraintsMatrix = {{19, 7}};
constraintsVector = {96};
(* Set up the optimization problem *)
solution = LinearProgramming[objectiveCoefficients, constraintsMatrix, constraintsVector];
(* Extract the values of x and y from the solution *)
{x, y} = solution;
(* Calculate the waste *)
waste = 96 - (19x + 7y);
(* Print the results *)
Print["Number of 19\" pieces (x) per 2x4: ", x];
Print["Number of 7\" pieces (y) per 2x4: ", y];
Print["Waste: ", waste, " inches"];