Maximum value of $x+y+z$

152 Views Asked by At

If $2(x^3+y^3+z^3) = 3(x+y+z)^2$then find the maximum value of $x+y+z$. given that $x,y,z$ are all non negative integers.

2

There are 2 best solutions below

0
On

The Z3 solver does not find an objective value larger than $2$:

from z3 import *

X, Y, Z = Ints('X Y Z')

s = Optimize()

s.add(X >= 0, X <= Y, X < 10)
s.add(Y >= 0, Y <= Z, Y < 10)
s.add(Z >= 0, Z < 10)
s.add(2*(X**3+Y**3+Z**3) == (X+Y+Z)**2)

obj = Sum(X+Y+Z)
s.maximize(obj)

print(s.check())
try:
  print(s.model())
except Z3Exception as ex:
  print(ex)

I limited the value ranges and imposed an $ X \le Y \le Z$ ordering to get a fast answer.

Result:

sat
[Y = 1, Z = 1, X = 0]
1
On

WLOG we may assume $x\geq y\geq z\geq0$. It is easy to see that $(x,y,z)=(1,1,0)$ is a solution. Let's treat $x,y$ as constant and consider both the LHS and RHS as functions of $z$ only. Clearly, the LHS is a cubic polynomial which is monotonously increasing on $[0,\infty)$, and the RHS is a quadratic polynomial which also increases monotonously on $[0,\infty)$. If we plug in $z=1$, we have $\mathrm{LHS}=6$ and $\mathrm{RHS}=9$. If we plug in $z=2$, then $\mathrm{LHS}=20$ and $\mathrm{RHS}=16$, and the LHS has already "outgrowed" the RHS. Indeed this will always happen regardless of the values of $x,y$ you choose, and a similar argument (by treating $y,z$ as constant and $x$ as the variable, for example) shows that increasing $x,y$ from $(1,1,0)$ will only make the LHS "outgrow" the RHS quicker. Hence, $(1,1,0)$ and $(1,1,1)$ are the only two possible solutions to satisfy $\mathrm{LHS}\leq\mathrm{RHS}$, and since $(1,1,1)$ doesn't work, the unique solution to the equation is $(1,1,0)$.