Solving linear indefinite equations

Source: Internet
Author: User

1,

definition : Linear indeterminate equation refers to ax + by = c.

2,

The integers a, B, C are given, first a set of solutions is obtained, and then
Then discuss how to represent the general solution (all solutions). First set gcd (A; b) = d. If c is not a multiple of D, then the equation
No solution, because the left is a multiple of D, and the right is not. In the case of a solution, set c = C0£d, you can first ask
Out of ax + by = d for a group (x0; y0), then ax0 + by0 = d, both sides multiplied by C0: A (c0x0) + b (c0y0) = C, because
This (c0x0; c0y0) is a set of solutions to the original equation. In other words, the core problem is: ask for the solution of ax + by = gcd (A; b).

3,

The following extended Euclid algorithm is used to find such a set of solutions.

void gcd (intint int int. int int & y)    {if  10;}     Else      {    gcd (b, a//  (*)    y-= x* (A/b);    }}

4, proof :

The mathematical induction method can prove its correctness. Inductive basis:

b = 0 o'clock, gcd (A; 0) = A, take x = 1; y = 0, with ax + by = a¢1 + 0¢0 = a = gcd (A; 0), established.

First, assuming I iterate, the line gets the correct result, that is, the return value y0 and x0 satisfy:
By0 + (a mod b) x0 = gcd (b; a mod b) = gcd (A; b) = d
After step y¡= x0¤ (a=b), the new number pair (x; y) satisfies:
Ax + by = ax0 + B (y0¡x0 (a=b)) = ax0 + by0¡bx0 (a=b) = s
The a=b here is the integer divide operation, which equals (a¡a mod b) =b,

so s = ax0 +by0¡bx0 (a¡a mod b) =b = ax0 +by0¡ax0 + (a mod b) x0 = By0 + (a mod b) x0 = d

Solving linear indefinite equations

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.