I have two variables $x$ and $y$. I can have them both in any combination of positive numbers that will add up to $1000$ and need to find the combination in which $z$ is at its minimum in the following formula:


So I could have $x=500$ and $y=500$ or $x=0$ and $y=1000$

I know this can be achieved by finding the derivative of the formula but I don't know how to derivate the formula if I have 3 variables and am trying to find the global minimum for $z$.

  • $\begingroup$ Use Lagrange's method: $$f(x,y) = \sqrt{(2.5x)^2 + (3.6y)^2}\\ \min_{\{(x,y)\in\mathbb R^2 | x+y = 1000\}} f(x,y)$$ $\endgroup$ – AlexR Jul 22 '14 at 10:54

Set $$f(x, y) = \sqrt{(2.5x)^2 + (3.6y)^2}$$ we have the constraint $x + y = 100, (0 \le x,y \le 100)$ or equivalently $y = 100-x \Rightarrow$ $$ f(x) = \sqrt{(2.5x)^2 + (360 - 3.6x)^2} $$

for simplicity let $u(x) = (2.5x)^2 + (360 - 3.6x)^2$. Differentiation with respect to $u(x)$ yields: $$ \frac{df}{du} = \frac{1}{2 \cdot \sqrt{u}} \cdot\frac{du}{dx} = 0 $$ where $$ \frac{du}{dx} = 2.5 \cdot 5x + 2(360 - 3.6x) \cdot (-3.6) $$ we now have $$ \frac{38.42x - 2592}{2 \cdot \sqrt{(2.5x)^2 + (360 - 3.6x)^2}} = 0 $$

this gives $$ x = \frac{129600}{1921} \\ y = \frac{62500}{1921} $$

ALTERNATIVE: Let $$ g(x) = (2.5x)^2 + (360 - 3.6x)^2 $$ which has the same minimum/maximum values as $f(x)$ Differentiation gives us $$ \frac{dg}{dx} = 38.42x - 2592 = 0 $$ and the x, y values is the same as before. The second derivative gives us $$ \frac{d^2u}{dx^2} = 38.42 $$ which proves that it is the minimum values we found

  • $\begingroup$ I realized i did a tiny mistake and thought that the constraint was x+y = 100 when is was x+y=1000. But see my answer as a hint with other numbers in order not to give you the answer directly ;) $\endgroup$ – Noxet Jul 22 '14 at 11:50
  • $\begingroup$ Thank you @Noxet, how do I know if the value is the minimum or the maximum? $\endgroup$ – ADGB Jul 22 '14 at 11:58
  • $\begingroup$ You can get rid of the square root and find minimum of $f(x)^2$ which will give you the same result. In order to prove that it is minimal, you can find the second derivative and show that it is positive for those values of x and y $\endgroup$ – Noxet Jul 22 '14 at 12:04
  • $\begingroup$ And just a final question, I am with you all the way to x=129600/1921 but are you then substituting the values for x in the first equation or are you doing the entire process again and finding y? $\endgroup$ – ADGB Jul 22 '14 at 12:10
  • $\begingroup$ No, no need, if we know x we find y by taking $100-x$ in my case, you will have to take $1000 - x$ since this was the constraint $\endgroup$ – Noxet Jul 22 '14 at 12:12

The general way of solving this is using Lagrange multipliers: We first let $$z = f(x, y) = \sqrt{(2.5x)^2 + (3.6y)^2}$$ And $$g(x, y) = x+y$$ Then we calculate the gradient of each function. $$\nabla f(x, y) = <\frac{5x}{2\sqrt{(2.5x)^2 + (3.6y)^2}}, \frac{7.2y}{2\sqrt{(2.5x)^2 + (3.6y)^2}}>$$ $$\nabla g(x, y) = <1 , 1>$$ Then we solve the equations: $$\nabla f(x, y) = \lambda\nabla g(x, y)$$ $$x + y = 100$$ For $x$ and $y$, and then you plug the solutions back into $f(x, y)$ and classify the value as a maximum or minimum value.

You can look at this site for more help.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.