# Euclidean division of a linear combination of real numbers

I have this following problem:

$$T=nP_1 + mP_2$$

With $$T$$, $$P_1$$ and $$P_2$$ real numbers. I have access to those three values, but is it possible to determine $$m$$ and $$n$$ ? This looks like the Bézout identity but with real values instead of integers. So would it be a generalization? I also know that $$m$$ and $$n$$ are integers between $$0$$ and $$8$$.

For context, I am looking at the neighbors of a cell in an array, so 8 surrounding cells with 3 values possible and I want to retrive from the total sum of the values the linear combination of $$P_1$$ and $$P_2$$. So I don't have to use several loops and if statements slowing down my program.

If T, P1 and P2 are totally random, there is generally no solution with n and m integers. Even without the limintation between 0 and 8.

If they are not random, and combinations of 2 well-known values, you have a system with 2 equations and 2 values.

Ex :

$$T = 5 \times \sqrt{2}+\sqrt{3}$$
$$P1 = 6 \times \sqrt{2}+4 \times \sqrt{3}$$
$$P2 = 7 \times \sqrt{2}-\sqrt{3}$$

• Could you please specify the set of equations to solve because I can't put my finger on them ? Commented Oct 24, 2022 at 13:29
• Also, $P_1$ and $P_2$ are set to $0.2$ and $0.3$ in my case. And T is necessarly a combination of them because I'm looking at the sum of neighbors of a cell in an array. Cell having a value of $0$, $P_1$ or $P_2$ Commented Oct 24, 2022 at 13:32
• With numbers like this (decimal numbers), in many cases, you have many options. example : (n=3,m=0) and (n=0,m=2) give same result. So there is no direct method. Just try all values for n (9 values only) , and for each of them, check if m is a valid number. Commented Oct 26, 2022 at 11:47