2

How does one minimize the following function?

$$f(x,y) = |kx + ly + c|$$

where $x,y \in \mathbb N$.

  • 2
    obivously this function is minimal if $f(x,y) = 0$. So the question reduces to finding all $(x,y)$ such that $kx + ly + c = 0$. – user159517 Jun 04 '16 at 17:06
  • 2
    If x and y have to be integers, then f(x,y) will not always be minimized to 0. Example : k = 2, l= -2, c = -1. – Priyansh Goel Jun 04 '16 at 17:08
  • Why is the question downvoted? – Priyansh Goel Jun 04 '16 at 17:29
  • Have you considered adding constraints to make and equivalent constrained linear integer program? Otherwise, you have convex relaxations, so a simple branch and bound would work. Are you looking for/hoping for a closed form solution? – David Jun 04 '16 at 19:39

1 Answers1

1

What is going on?

Let us first look at the real case:

2D view 3D view

We see that $f(x,y) = \lvert (k, l) (x,y)^\top + c \rvert$ results in a $V$ shaped surface. The reason is the "case distinction" of the absolute value function.

The valley line (the red line at $z=0$) is $$ \frac{1}{\sqrt{k^2 + l^2}} (k, l) (x,y)^\top = \frac{-c}{\sqrt{k^2 + l^2}} = d $$ where $(1/\sqrt{k^2 + l^2}) (k,l)^\top$ is a unit normal vector to the valley line (see the vector on the unit circle in the left graph) and $\lvert d \rvert$ is the distance to the origin (see the radius of the green circle and green sphere).

Discrete case:

For the discrete case we need to determine the intersections of $f$ with the grid $\mathbb{Z}^3$.

It should run down into coming up with the two planes that the $V$ is part of, stating the linear Diophantine equation there, and going for the smallest positive solution each, finally picking the smallest $z$-value of both cases.

Determining the planes:

The two linear Diophantine equations in three variables are $$ k x + l y - z = -c \\ k x + l y + z = -c $$ where the part intersecting with $f$ is characterized by $z \ge 0$.

Examples on how to solve such equations are given here and here.

mvw
  • 34,562