Turn on thread page Beta
    • Thread Starter
    Offline

    1
    ReputationRep:
    If I have an equation of the form An + B ≡ X mod 2X,
    where A, B and X are all coprime to each other. X is a power of 2 if that makes any difference.

    Is there a simple formula I can use to calculate the first solution? First solution meaning in the range [0, 2X]


    I've been googling modular arithmetic, linear congruence, even tried Chinese Remainder Theorem for the last hour and keep going nowhere.

    Am I missing something obvious or is there no neat solution?
    Offline

    3
    ReputationRep:
    (Original post by bencrossley1)
    If I have an equation of the form An + B ≡ X mod 2X,
    where A, B and X are all coprime to each other. X is a power of 2 if that makes any difference.

    Is there a simple formula I can use to calculate the first solution? First solution meaning in the range [0, 2X]


    I've been googling modular arithmetic, linear congruence, even tried Chinese Remainder Theorem for the last hour and keep going nowhere.

    Am I missing something obvious or is there no neat solution?
    It's quite simple. Let's do an example, 3n + 5 = 4 (mod 8).
    Notice that any number that is congruent to 4 (mod 8) can be written as 8m + 4 for some m.
    Hence 3n + 5 = 8m + 4 -> 8m - 3n = 1. We can solve this Diophantine equation either using the Euclidean algorithm or just trial and error, to get m = 2 and n = 5 as an initial solution. Thus the "first solution" for n is 5.

    The procedure is, of course, the same regardless of the values of A, B, and X.
    • Thread Starter
    Offline

    1
    ReputationRep:
    (Original post by HapaxOromenon3)
    It's quite simple. Let's do an example, 3n + 5 = 4 (mod 8).
    Notice that any number that is congruent to 4 (mod 8) can be written as 8m + 4 for some m.
    Hence 3n + 5 = 8m + 4 -> 8m - 3n = 1. We can solve this Diophantine equation either using the Euclidean algorithm or just trial and error, to get m = 2 and n = 5 as an initial solution. Thus the "first solution" for n is 5.

    The procedure is, of course, the same regardless of the values of A, B, and X.
    I don't wish to use the Euclidean algorithm or trial and error. I am after a deterministic formula. Thanks for putting in the time though!

    I'm doing some work which would be much faster given a formula, For example:
    n=7 solves 2187n + 17459 ≡ 32768 mod 65536
    therefore
    n=7 solves 6561n + 85145 ≡ 131072 mod 262144

    The numbers I intend to work with are only increasing. So T&E is a complete no go, and I dislike algorithms. Or at least, for what I am doing they will not be of use.
    Offline

    3
    ReputationRep:
    (Original post by bencrossley1)
    I don't wish to use the Euclidean algorithm or trial and error. I am after a deterministic formula. Thanks for putting in the time though!

    I'm doing some work which would be much faster given a formula, For example:
    n=7 solves 2187n + 17459 ≡ 32768 mod 65536
    therefore
    n=7 solves 6561n + 85145 ≡ 131072 mod 262144

    The numbers I intend to work with are only increasing. So T&E is a complete no go, and I dislike algorithms. Or at least, for what I am doing they will not be of use.
    If you don't want to use the Euclidean Algorithm, which is the only thing that can help you, simply for ideological reasons, then you are simply an idiot. There is no explicit formula for solving the type of equation that you have described.
    • Thread Starter
    Offline

    1
    ReputationRep:
    (Original post by HapaxOromenon3)
    If you don't want to use the Euclidean Algorithm, which is the only thing that can help you, simply for ideological reasons, then you are simply an idiot. There is no explicit formula for solving the type of equation that you have described.
    Calling me an idiot is unwarranted.

    Given the general expression An + B ≡ C mod D

    yes I would agree, no deterministic solution.

    Given the added criteria that A = 3^a, B is not divisible by 2 or 3, C = 2^c and D = 2^c+1 it is possible that under these conditions that a formula may exist.

    I already have a formula for a=0 and a=1. By inspection I expect to be able to generate further formulas and eventually a general one for any a.
    Offline

    18
    ReputationRep:
    (Original post by bencrossley1)
    Calling me an idiot is unwarranted.

    Given the general expression An + B ≡ C mod D

    yes I would agree, no deterministic solution.

    Given the added criteria that A = 3^a, B is not divisible by 2 or 3, C = 2^c and D = 2^c+1 it is possible that under these conditions that a formula may exist.

    I already have a formula for a=0 and a=1. By inspection I expect to be able to generate further formulas and eventually a general one for any a.
    Lol.


    Posted from TSR Mobile
 
 
 
Reply
Submit reply
Turn on thread page Beta
Updated: July 10, 2016
Poll
“Yanny” or “Laurel”
Useful resources

Make your revision easier

Maths

Maths Forum posting guidelines

Not sure where to post? Read the updated guidelines here

Equations

How to use LaTex

Writing equations the easy way

Student revising

Study habits of A* students

Top tips from students who have already aced their exams

Study Planner

Create your own Study Planner

Never miss a deadline again

Polling station sign

Thinking about a maths degree?

Chat with other maths applicants

Can you help? Study help unanswered threads

Groups associated with this forum:

View associated groups

The Student Room, Get Revising and Marked by Teachers are trading names of The Student Room Group Ltd.

Register Number: 04666380 (England and Wales), VAT No. 806 8067 22 Registered Office: International House, Queens Road, Brighton, BN1 3XE

Write a reply...
Reply
Hide
Reputation gems: You get these gems as you gain rep from other members for making good contributions and giving helpful advice.