Lagrange Multipliers for Olympiad Question The question is as follows: 
Given $a,b,c,d > 0$ and integers, and that $a+b+c+d=40$ -- find the maximum value of $ab+bc+cd$ 
There is a way to answer this question without using calculus (I am aware of this) but I was wondering how I could apply the method of legrange multipliers? (I have only just learnt the concept) 
My attempt gave me a maximum that was 1 off! 
 A: Lagrange multipliers are not very adequate here. Note that $a,b,c,d$ are integers.
First, we have
$$(a+c)(b+d)=ab+ad+bc+cd$$
Then
$$ab+bc+cd=(a+c)(b+d)-ad$$
So we should try maximize $(a+c)(b+d)$ and minimize $ad$.
To maximize $(a+c)(b+d)$, note that $(a+c)+(b+d)=40$, so we have to maximize the product of two numbers, given their sum. It is well known that this happens when the numbers (namely, $a+c$ and $b+d$) are equal, so we can say that $a+c=b+d=20$.
Now, to minimize $ad$, simply take the least possible values for $a$ and $d$. Since they are positive integers, we have $a=d=1$. Then the solution comes with the values
$$a=1,b=19,c=19,d=1$$
A: You take the partial derivatives of $f-\lambda g$ with respect to all variables, including $\lambda$, and set them equal to zero, where $f$ is the function to be maximized and $g$ is the constraint. The intuition is that this guarantees that $\nabla f$ and $\nabla g$ are parallel, so the function and the constraint are tangent, which must occur at any constrained extremum. 
In this case we have $(ab + bc+ cd)-\lambda(a+b+c+d-40)$. Set the partial derivatives equal to zero and we have the equations $b-\lambda=0$, $a+c-\lambda=0$, $b+d-\lambda=0$, $c-\lambda=0$, and the constraint $a+b+c+d=40$.
The solution is $a=d=0$, and $b=c=20.$  the value of the function is 400.
I guess since you require the numbers to be positive, this solution is outside your domain. However this is the only solution you can get by Lagrange multipliers. 
