# How to solve these type : If $a + b + c + d = 63$ then find the Maximum of $(a b+ b c+ c d)$

If a + b + c + d == 63 then find the Maximum of a b + b c + c d. I tried using If, With
but unable to get the solution/answer. Any help is appreciated. The answer is 991.

• {a,b,c,d}>=0? Aug 6 at 14:32
• Maximize[{a b + b c + c d, a + b + c + d == 63}, {a, b, c, d}] should work but does not, for some reason. Aug 6 at 14:51
• Aside from the problem being unbounded as @cvgmt pointed out, one can see from the Hessian that any critical point is a saddle point: D[z /. First@ Solve[{z == a b + b c + c d, a + b + c + d == 63}, {z, d}], {{a, b, c}, 2}] // Eigenvalues // N. On a bounded domain, the extrema will be on the boundary. Aug 6 at 17:45
• Need to add a condition {a, b, c, d} ∈ PositiveIntegers or {a, b, c, d} ∈ Integers,{a,b,c,d}>0. Aug 7 at 14:46

Updated

Maximize[{a*b + b*c + c*d,
a + b + c + d == 63, {a, b, c, d} ∈ PositiveIntegers}, {a,
b, c, d}]


{991, {a -> 1, b -> 30, c -> 31, d -> 1}}

Original

We must add some conditions since without it the question is unbounded. See the example as below.

a b + b c + c d /.
FindInstance[{a + b + c + d == 63}, {a, b, c, d}, Reals, 20] // N


{5502.96, 6579.89, -10891.8, 2442.18, -6627.59, -7054.56, 2829.6, 415.69, 305.09, 918.08, 410.02, -6148.25, -6412.11, -10460.1, 1677.84, -4958.71, 1965.59, -2993.25, 315.68, -1949.59}

Maximize[{a b + b c + c d,
a + b + c + d == 63, {a, b, c, d} >= 0}, {a, b, c, d}]


{3969/4, {a -> 0, b -> 16, c -> 63/2, d -> 31/2}}

• Thank you very much. Aug 9 at 2:07

QuadraticOptimization can optimize quadratic functions with linear constraints:

QuadraticOptimization[-(a b + b c + c d), a + b + c + d == 63, {a, b, c, d}]
(* {a -> 0., b -> 31.5, c -> 31.5, d -> 0.} *)


Alternatively use Solve on the KKT-conditions:

{D[a b + b c + c d + μ (a + b + c + d - 63), {{a, b, c, d}, 1}],
a + b + c + d - 63} == 0 // Solve
(* {{a -> 0, b -> 63/2, c -> 63/2, d -> 0, μ -> -(63/2)}} *)


You can solve it using the Lagrange multipliers technique as follows:

obj = a b + b c + c d;
L = obj + lambda (a + b + c + d - 63)
vars = Variables[L]