5
$\begingroup$

That is real numbers modulo an integer. I'm just interested in shuffling around +-*/ operations.

If a concrete example helps here's my current problem. (I'm from a programming background so there's probably a notation disconnect, sorry about that.)

LI(x) = (LI0 + x / PI) % 1

LF(x) = (LF0 + x / PF) % 1

LI(s) + 0.5 = LF(f)

f = s + PT / 2

I need to find a solution for s, given LI0, LF0, PI, PF and PT.

Also I think I might have a solution by dropping the %1's, solving for s and then modding that by:

1 / abs(1 / PI - 1 / PF)

But I can't tell if that actually works because it introduces an enormous rounding error.

Also while this is the problem at hand and solving it is my immediate goal, I really want to understand how to generate that solution, for next time.

  • 0
    You can't do modular arithmetic with real numbers. (Actually, you can't even do modular arithmetic with rational numbers.) All you're doing is taking the remainder after some division operation.2011-08-03
  • 5
    well, the reals is an abelian group and contains the integers, so we can certainly mod out by any multiple of the integers.2011-08-03
  • 7
    @Tobias: But that only works if you restrict yourself to addition. As soon as you start multiplying, you run into problems because the integers don't form an *ideal* of the real numbers.2011-08-03
  • 2
    Working "modulo 1" is equivalent to working with the [fractional part function](http://en.wikipedia.org/wiki/Fractional_part_function), which is defined as $\{x\}=x-\lfloor x\rfloor$. Perhaps those magic words will give you the push you need.2011-08-03

2 Answers 2

6

Addition and subtraction are well-behaved, since the "circle group" is an abelian group.

Multiplication doesn't work: $2/3$ is the same as $-1/3$ and $3/5$ is the same as $-2/5$, but $(2/3)\cdot(3/5)$ doesn't end up being the same as $(-1/3)\cdot(-2/5)$.

2

So, what you need first of all is $LIo + \frac{s}{PI} + \frac{1}{2} = LFo + \frac{s + PT/2}{PF} + n$ for some integer $n$. That can be solved in the usual way (in terms of $n$):

$$ s = \frac{(2 LFo PF+PT-PF+2 n PF-2 LIo PF) PI}{2 (PF - PI)} $$

The only other requirement is that you need $\{ LIo + \frac{s}{PI} \} < \frac{1}{2}$. You'll have to see which $n$ will make that work. Given particular values of the parameters, that should be either easy or impossible.

For example, I tried $LFo=1,LIo=2,PF=3,PI=4,PT=5$, obtaining $s = 8 - 12 n$. Then $\{LIo + \frac{s}{PI}\} = \{4 - 3 n\} = 0$, so this works for any $n$.

On the other hand, with $LFo=1,LIo=2,PF=3,PI=5,PT=6$ I get $s = \frac{15 - 30 n}{4}$ and $\{LIo + \frac{s}{PI}\} = \{ \frac{11 - 6 n}{4} \}$. Now you need $11 - 6 n \equiv 0 \text{ or } 1 \mod 4$: 0 is impossible, but any odd $n$ will give you 1.