2
$\begingroup$

I have two functions as follows:

$$a=\frac{5}{16}(x+2y)$$ $$b=-\frac{5}{16}(x-2y)$$

The user may enter any arbitrary number for (x, y). However only values which produce whole integers of a and b are considered valid. Given these conditions, is it possible to find the nearest valid (x, y) to the user's inputted x and y which would produce whole numbers for a and b.

I thought representing both equations as planes and finding the closest point on them to a specified point using Lagrange multiplication. But wasn't sure exactly how to do so, to produce the results I was looking for.

Edit: Follow-up question found here

  • 0
    What do you mean by "nearest"? Do you mean to find the valid $(x,y)$ whose Euclidean distance to the inputted $(x,y)$ is minimal?2017-01-16
  • 0
    @EricWofsey precisely that, yes.2017-01-16

1 Answers 1

1

See, that $5$ and $16$ are relatively prime. So we need to $$\begin{cases}x+2y \equiv 0 \mod 16\\ x-2y \equiv 0 \mod 16\end{cases}$$

We have then: $$x+2y - (x-2y) \equiv 0 \mod 16$$ $$4y \equiv 0 \mod 16$$ So: $$y\in \{16k, 16k+4, 16k+8, 16k+12 | k\in \mathbb{Z}\}$$ Because $x+2y \equiv 0 \mod 16$, we have:

  • for $y=16k$: $x\equiv 0 \mod 16$
  • for $y=16k+4$: $x\equiv 8 \mod 16$
  • for $y=16k+8$: $x\equiv 0 \mod 16$
  • for $y=16k+12$: $x\equiv 8 \mod 16$

The valid pairs $(x,y)$ are then: $$(x,y) \in \{(16l, 16k),(16l+8, 16k+4),(16l, 16k+8),(16l+8,16k+12)|l,k \in \mathbb{Z}\}$$

  • 0
    Given the above functions for *a* and *b* in my question are simplified equations of the more generic equations: $a=(py+qx)/(2pq)$ and $b=(py-qx)/(2pq)$ Where *p* and *q* represent some real number (in the above equations they're equal to 1.6 and 0.8, respectively). Can your approach be used for these equations? And if so how?2017-01-16
  • 0
    @Manmax75 That would be good to ask as a new question and provide a link back to this one.2017-01-16