# Optimization problem-find the rectangular box dimensions

A rectangular box with no top is to be made having volume 12 cubic feet.Cost per sq ft of the material to be used is Tk 4 for the bottom,Tk 3 for two opposite sides and Tk 2 for remaining opposite sides. Find dimensions of the box for minimum cost.

• Can you write the formula for the total cost depending on given box dimensions? Jun 7, 2020 at 16:05

Starting from @brenderson's answer, you need to minimize $$f= 4x_1x_2 + 6x_1x_3 + 4x_2x_3 \quad \text{subject to}\quad x_1x_2x_3 = 12$$ When you face equality constraints, it is often good to eliminate some wriables from the constaints.
In this case, $$x_3=\frac {12}{x_1\,x_2}$$ makes $$f=4 x_1 x_2+\frac{48}{x_1}+\frac{72}{x_2}$$ Compute the partial derivatives and set them equal to $$0$$ $$\frac{\partial f}{\partial x_1}=4 x_2-\frac{48}{x_1^2}=0\implies x_2=\frac{12}{x_1^2}$$ $$\frac{\partial f}{\partial x_2}=4 x_1-\frac{72}{x_2^2}=\frac{1}{2} x_1 \left(8-x_1^3\right)=0\implies x_1=2$$ So $$x_1=2$$ , $$x_2=3$$ and $$x_3=2$$
Let the length of the box edges be $$x_1,x_2,x_3\in\mathbb{R}$$, where $$x_3$$ is the height. Define $$x=(x_1,x_2,x_3)$$. Then the cost of the box is $$$$f(x) = 4x_1x_2 + 6x_1x_3 + 4x_2x_3.$$$$ To minimize the cost of the box, subject to your volumetric constraint, it suffices to solve the following problem: \begin{aligned} & \text{minimize} && f(x) = 4x_1x_2 + 6x_1x_3 + 4x_2x_3 \\ & \text{subject to} && g(x) = x_1x_2x_3 - 12 = 0. \end{aligned} Define the Lagrange multiplier $$\lambda\in\mathbb{R}$$ and the Lagrangian $$$$L(x,\lambda) = f(x) + \lambda g(x) = 4x_1x_2 + 6x_1x_3 + 4x_2x_3 + \lambda(x_1x_2x_3-12).$$$$ Then the Lagrangian stationarity KKT condition requires that $$$$\nabla_x L(x^*,\lambda^*) = \begin{bmatrix} 4x_2^* + 6x_3^* + \lambda^* x_2^*x_3^* \\ 4x_1^* + 4x_3^* + \lambda^* x_1^*x_3^* \\ 6x_1^* + 4x_2^* + \lambda^* x_1^*x_2^* \end{bmatrix} = 0.$$$$ Therefore, by multiplying these three equations by $$x_1^*$$, $$x_2^*$$, and $$x_3^*$$, respectively, we may substitute the primal feasibility KKT condition (namely, $$x_1^*x_2^*x_3^*=12$$) to obtain $$$$\begin{bmatrix} 4x_1^*x_2^* + 6x_1^*x_3^*+12\lambda^* \\ 4x_1^*x_2^* + 4x_2^*x_3^*+12\lambda^* \\ 6x_1^*x_3^* + 4x_2^*x_3^* + 12\lambda^* \end{bmatrix} = 0.$$$$ Subtracting the second equation from the first, we find that $$6x_1^*x_3^*-4x_2^*x_3^*=0$$, which has the nontrivial solution $$x_1^*=\frac{2}{3}x_2^*$$. Subtracting the third equation from the second, we find that $$4x_1^*x_2^*-6x_1^*x_3^*=0$$, which has the nontrivial solution $$x_3^*=\frac{2}{3}x_2^*$$. Therefore, substituting these results back into the primal feasibility condition, we find that $$$$x_1^*x_2^*x_3^*=\frac{4}{9}x_2^{*3}=12,$$$$ which implies that $$$$x^*=(x_1^*,x_2^*,x_3^*)=(2,3,2).$$$$ Note that plugging this primal solution back into the Lagrangian stationarity condition yields $$\lambda^*=-4$$ from all three equations.