Find a values of the equation that will be satisfy the constraints on that values

80 Views Asked by At

I want to find coefficients in the equation that will be satisfy the constraints lying on them or find that this is impossible:

$$14.31818 = \frac{48}{Div_1} \times \Big( Div_2 + \frac{FRACN}{2^{13}} \Big) $$ where: $$Div_1 \in [1:63] \\ Div_2 \in [4:512] \\ FRACN \in [0:2^{13}-1]$$

So I need to find the exact coefficients within this allowable range or to know that this is not possible. What kind of math can I apply to problem like this one?

For those who interested where it come from it's coefficients for sigma-delta modulator that will produce frequency on his output, there is may be the case when $$\frac{FRACN}{2^{13}}$$ granularity wont enough for this particular frequency, so I want to know if it's the case too.

I think i can just optimize this coefficients with gradient descend algorithm or similar, but I wonder may be there is a more straightforward way to do it.

1

There are 1 best solutions below

4
On BEST ANSWER

$1431818=2\cdot715909,$ where $715909$ is prime, according to Wolfram Alpha. We have $$ 2\cdot715909Div_1=10^5\cdot48\left(Div_2+\frac{FRACN}{2^{13}}\right),$$ so that$$ \frac{48\cdot10^5FRACN}{2^{13}}=\frac{3\cdot5^5FRACN}{2^4}$$ is an integer, so that FRACN = $2^4k$ for some integer $0\le k<2^9=512$. Therefore, we have $$ 2\cdot715909m = 10^5n+3\cdot5^5k,\tag{1}$$ where $m=Div_1,\ n=Div_2,$ and we note that $k$ must be even, so that there are $256$ possible values of $k$.

For some admissible value of $k,$ write $a=3\cdot5^5 k$. Then we see that $10^5n+a$ is divisible by $715909$ so that $10^5n\equiv-a\pmod{715909}.$ By the extended Euclidean algorithm, we find that $179056\cdot 10^5\equiv1\pmod{715909},$ and $$n\equiv -179056a\equiv536853a\pmod{715909}$$

At this point, the problem is small enough for brute force. For each possible value of $k$ compute $536853a\pmod{715909}$ and see if it gives an admissible value of $n=Div_2.$ If so, use $(1)$ to compute $m=Div_1$ and check if it is admissible. This procedure will find all solutions, if any exist.

EDIT

I wrote a little python script to test this, and it returned no solutions:

for k in range(0,512,2):
    a = 3*5**5*k
    n = (536853*a)%715909
    if not 4<=n<=512: continue
    m = (10**5*n+a)//143818
    if 1<=m<=63:
        print('FRACN  = ', 16*k, 'Div1 = ', m, 'Div2 = ', n)
print('Done')