# Find the set of points where two functions are equal

Given the function: $$f(M, \vec{p}, d) = \sum_{i=1}^m log(\frac{\mathbb{I}(|\vec{M}_i - \vec{p}|_2<d)}{|\vec{M}_i - \vec{p}|_2})$$ Where $M \in \mathbb{R}^{m \times n}$ is a matrix, $\vec{p} \in \mathbb{R}^{n}$ is a vector describing a point, $d \in \mathbb{R}$ is a minimum distance scalar, and $|\vec{M}_i - \vec{p}|_2$ is the euclidean distance between two points. Also when $\mathbb{I}(|\vec{M}_i - \vec{p}|_2<d)$ is true 1 is returned, otherwise its zero. If I had two different matrices and plugged them into this function, how would I find the $n$ dimensional points where the two functions are equal to each other?

As simple example let us look at the matrices $A$ and $B$: $$A = \begin{bmatrix} 0.3 & 0.3 \\ 0.3 & 0.4 \\ 0.4 & 0.3 \\ \end{bmatrix} B = \begin{bmatrix} 0.6 & 0.6 \\ 0.6 & 0.7 \\ 0.7 & 0.6 \\ \end{bmatrix}$$ And the minimum distance is: $$d=0.3$$

How would one go about finding the set of points where $f(A, p) = f(B, p)$? I know you would make them equal to one another like: $$\sum_{i=1}^3 log(\frac{\mathbb{I}(|\vec{A}_i - \vec{p}|_2<0.3)}{|\vec{A}_i - \vec{p}|_2}) = \sum_{i=1}^3 log(\frac{\mathbb{I}(|\vec{B}_i - \vec{p}|_2<0.3)}{|\vec{B}_i - \vec{p}|_2})$$ But I don't know how to solve this. Also bare in mind that I need this to work for examples with points of higher dimensionality ($n > 0$), and when the size of the $m$ dimension of the two matrices are not equal.

To help you understand the problem more clearly I have created a visual aid: A graph describing the intersection of the two functions, where the red line indicates where the two functions would be equal.

If you require any further details feel free to ask.

Using properties of $\log$, we can rewrite the equation as $$|A_1-p|^2\cdot |A_2-p|^2\cdot |A_3 -p|^2=|B_1-p|^2\cdot |B_2-p|^2\cdot |B_3 -p|^2.$$ If we write all the points in their coordinates and let $p=(x,y)$, this equation turns into an equation of the form $F(x,y)=0$, where $F(x,y)$ is a two-variable function of degree 5. For general $A,B$, the set of solutions of $F(x,y)=0$ could be complicated.
In this case, the points in $A$ are the vertices of a right triangle and the points in $B$ are obtained by translating the points in $A$ by the vector $(0.3, 0.3)$. The symmetry across the line $y=x$ suggests that a solution $p$ might exist on the line $y=x$. By letting $x=y$ in the equation we get a degree-5 polynomial. It turns out that it has a unique root around $x_0 \approx 0.48$. All other solutions form a curve passing through $(x_0,x_0)$ and the curve is symmetric with respect to $y=x$.
• The simplification I mentioned still works but finding $p$ in general is difficult and only possible numerically. – Marco Aug 29 '18 at 14:12
• Perfect, thank you. Just to check, where you put ${|A1−p|}^2$ is that the L2 norm of the vector resulting from $A1−p$? or did you mean the squared absolute value of the vector? – Michael Murray Aug 29 '18 at 14:22
• It's the square of the distance from $A_1$ to $p$. – Marco Aug 29 '18 at 14:45
• Where does the squared come from? My ${|B_i−p|}_2$ was meant to indicate the L2 norm not the square. – Michael Murray Aug 29 '18 at 14:52