Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Mod Function Inverse

  1. Dec 14, 2008 #1
    Hi Guys,
    I was wondering, since (a)mod(n) can be written in terms of the floor function, thus [tex] a - n Floor[\frac{n}{a}],[/tex] and therefore, can't we describe the floor function as an invertible function? I know that [tex]Floor[x] = -1/2 + x + \frac{ArcTan(Cot(\pi x))}{\pi} [/tex]. Thus, can't we inverse this formula? Furthermore, there is another idea that works on any function, but deals with sets. In general, given a function f: A → B and a subset S of B, then f-1(S) = {x ∈ A | f(x) ∈ S}. In the case of the floor function, if n is an integer, then floor-1({n}) = [n, n + 1). Note that these are sets, not numbers.

    Please let me know as I am saying these things right off of the top of my head.
  2. jcsd
  3. Dec 14, 2008 #2
  4. Dec 14, 2008 #3
    Ok, so if I have (2x)mod(x+1) = 9, then can't I find x?
    Can't I find x by saying that, [tex]2x-(x+1)(Floor[\frac{2x}{x+1}])=9[/tex]
    Equivalently, [tex]2x-(x+1)(-1/2 + \frac{2x}{x+1} + \frac{ArcTan(Cot(\pi (\frac{2x}{x+1})))}{\pi} )=9[/tex].

    Thus, can't I solve for x from there?
    Last edited: Dec 14, 2008
  5. Dec 14, 2008 #4
    I invite you to try to find an inverse of
    [tex]\operatorname{floor}(x) = -1/2 + x + \frac{\arctan(\cot \pi x)}{\pi}.[/tex]
    Hint: you can't, because multiple values of x correspond to the same floor value.

    If you're trying to solve 2x mod x + 1 = 9, you're approaching the problem in completely the wrong way. Instead of just writing out expressions for the mod function, why not use your brain?

    For example: In general, 0 ≤ x mod y < y. Thus, in that equation, 2x mod x + 1 = 9 < x + 1, so x > 8. Then, x + 1 < 2x < 2(x + 1), which means that 2x mod x + 1 = 2x - (x + 1) = 9. Solving that gives x = 10. Notice that there is a unique solution to the equation.

    Your formula isn't even right; the correct one is this: a mod n = a - n floor(a / n).
  6. Dec 14, 2008 #5
    I don't mean to be rude, adriank, but when you said, "Your formula isn't even right; the correct one is this: a mod n = a - n floor(a / n).", using the word "this" without a noun following it is grammatically incorrect. Thus, if you really want to help someone out, try to utilize a more eloquent tone, but most importantly, know your grammatical dogma well.
  7. Dec 14, 2008 #6
    I'm sorry if my tone isn't very nice, and I don't mean to be rude either, but it does get a little frustrating when, after attempting to explain numerous times, you just don't understand that what can't be done can't be done, no matter how cleverly you try and go about doing it. If you have a function that gives the same value for multiple inputs, there is no way of defining its inverse function, no matter how you write the function.

    If you're trying to get Mathematica or similar to solve something for you, you have to know how to interpret the result. Just because it can give you something using just trigonometric functions doesn't mean you can use those blindly; you have to be aware that what it gives you depends crucially on the fact that arctan is really a multi-valued function, and the particular function ArcTan in Mathematica uses its principal value, so in that sense ArcTan is not a true inverse of Tan. If you really do try to manipulate expressions such as ArcTan[Cot[x]], you have to be extremely careful. (ArcTan[Cot[x]] is the same as ArcTan[Tan[Pi/2 - x]], which is in general not Pi/2 - x, because Tan is not one-to-one.)

    I'm really just trying to deter you from trying to express, say, the floor function as some other thing involving trigonometric or exponential functions and whatnot, since they are typically much less useful (and harder to work with). In your question (solve 2x mod x + 1 = 9), you might be able to get somewhere by rewriting it as 2x - (x + 1)floor(2x / (x + 1)) = 9, but making a bigger mess out of it by rewriting floor using arctan and cot isn't going to help you solve it.

    As for my grammar, there is a noun following "this", and that is the equation. Regardless, even if you find that grammatically strange, there is no chance of misunderstanding and it's still very clear. I could have picked apart your grammar in many places, but I didn't because it would be quite irrelevant to the discussion.

    I'm sorry if I was rude in my last post. I was just trying to get you see that there are better ways of approaching problems like that.

    I'm kind of curious: what's your goal with writing out the floor function, etc. in terms of other functions?
  8. Dec 14, 2008 #7
    An equation is not a noun, it is an expression that equates two or more ideas with one another. Besides, a noun is a linguistic concept not a mathematical one.

    Regardless, I am sorry for getting somewhat frustrated with you. I am not stupid; I do realize that expressing the mod function in terms of the floor function and then expressing the floor function in terms of the trigonometric function is difficult (not to mention impractical).

    Thus, do not take it the wrong way, I am not mad at you. In fact, I am thankful that you have been willing to help me. It's just that I want to be able to solve for problems such as, (2x)mod(x+1) = 9, and it has become so frustrating for me. I sincerely apologize for my behavior.

    Now, back to the math. The main reason why I want to solve such problems is for fun. I enjoy mathematics. Also, I may have incorrectly worded my last post. I don't mean to find the inverse of the floor or mod functions (because they do not pass the vertical line test and therefore aren't one-to-one), but I just thought that by representing the mod function in terms of the floor function and then representing the floor function as trigonometric function, I can solve for x (without having to find the inverse function).

    I guess that's my logic behind this whole problem, and again, I am sorry if I came off angry at you. I am frustrated with the problem, not you.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook