0

I am starting with a formula like $w = ix \bmod{n}$

Originally, I knew $i$, $x$, and $n$, so solving for $w$ was trivial.

But now I'm in the situation where $w$, $i$, $n$ are known, but $x$ is unknown.

$i$ and $n$ are relatively prime to each other.

I don't know if it's possible to algebraically manipulate this statement to get $x$ isolated by itself, and the rest to the other side of the equation.

I had myself convinced that multiplying both sides by the modulo inverse of ($ix \pmod{n}$) would be the breakthrough. But then I realized, "to calculate that, I need to know the value of $ix$ in the first place. So I'm still stuck, because I don't know $x$ and that's what I want to find.

Maybe I'm off on a totally incorrect tangent here. Not sure how I can solve for $x$ in this equation.


(For those who didn't get me)

What I'm trying to ask is, I have this equation $ix \bmod n$ that generates a remainder that I assign to $w$. But my situation now is, I know the remainder $w$ value, but I don't know the value of $x$ any more. If this was a simple algebra statement $w=ix$, I'd just divide both sides by $i$ to isolate the $x$ on one side. But I've got this '$\bmod n$' operation on the equation too. I don't know how to 'get rid of it' so that I can then divide both sides by $i$, leaving me with $x$ by itself on one side. (I want to calculate value of $x$, knowing the other things)

Spectre
  • 1,573
  • 3
    Multiply both sides by the inverse modulo $N$ of $I$ (not $I \cdot X$), then you get $X = W \cdot I^{-1} \pmod N,$. – dxiv Jun 27 '21 at 06:11
  • 2
    @dxiv You are right but I think the OP wants an explicit formula for this inverse, a formula which doesn't exist. – Jean Marie Jun 27 '21 at 06:14
  • 2
    This thread is high on the list I got when I searched with the relevant buzzwords. I think that this is a duplicate, but if people feel differently, there is scope for disagreement. Anyway, you should not necessarily think of this in terms of a formula but rather an algorithm. From a programmer's point of view a formula here would be more or less the same thing as an algorithm that your hardware manufacturer built in for you. Well, it is inefficient to bloat the complexity of the hardware by having every possible algorithm implemented there. – Jyrki Lahtonen Jun 27 '21 at 06:25
  • 1
  • @JeanMarie Hope was that the comment would prompt the OP to clarify the question, since it's hard to guess which step they are missing. There is no formula, indeed, but the $a$ in $aI+bN=1$ which can be determined via euclidean division would seem to suffice for OP's purposes. – dxiv Jun 27 '21 at 07:05
  • 1
    @Spectre I don't wholeheartedly approve of your edit. Using %, while unheard of in mathematics, is standard notation for the remainder in programming, in C-language in particular. Also, those who want to make a distinction use \bmod (as in binary mod) as the TeX-command here. Your choice of \pmod is used, when we write a congruence. I am not a TeXpert, but I think there are differences in spacing at least, and, of course, the parens. So $ix\bmod n$ is the result of a remainder operation, which is what the OP meant. – Jyrki Lahtonen Jun 27 '21 at 07:11
  • Mind you, it would do programmers a lot of good to learn about congruences, but it is hardly their fault that their educators don't feel that way. – Jyrki Lahtonen Jun 27 '21 at 07:12
  • @JyrkiLahtonen I understood that the OP meant that he/she wanted the remainder, but when I saw an equals sign between $w$ and the RHS, I felt confused and from my best guess, I conjectured that it could be that the OP wanted to assign the remainder to $w$. – Spectre Jun 27 '21 at 07:20
  • @JyrkiLahtonen I did know that \pmod may not always be right in the place, but looking at the statement as if it were a program, it mostly seemed to me as assigning the remainder of division of the product $ix$ by $n$. – Spectre Jun 27 '21 at 08:02
  • @JyrkiLahtonen oh ok... now I seem to understand why.... I'll edit it right away – Spectre Jun 27 '21 at 08:06
  • See the linked dupe for theory and algorithms for solving linear congruences. – Bill Dubuque Jun 27 '21 at 08:24
  • @JeanMarie $a^{-1}\bmod b\equiv \frac{-b\cdot b^{-1}+1}{a}$ where $b^{-1}$ is calculated modulo $a$ – Roddy MacPhee Jun 27 '21 at 23:07

0 Answers0