28.12.2012 Views

Figure Properties - SERC

Figure Properties - SERC

Figure Properties - SERC

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

2gcd<br />

Purpose Greatest common divisor<br />

Syntax G = gcd(A,B)<br />

[G,C,D] = gcd(A,B)<br />

Description G = gcd(A,B) returns an array containing the greatest common divisors of the<br />

corresponding elements of integer arrays A and B. By convention, gcd(0,0)<br />

returns a value of 0; all other inputs return positive integers for G.<br />

[G,C,D] = gcd(A,B) returns both the greatest common divisor array G, and<br />

the arrays C and D, which satisfy the equation: A(i).*C(i) + B(i).*D(i) =<br />

G(i). These are useful for solving Diophantine equations and computing<br />

elementary Hermite transformations.<br />

Examples The first example involves elementary Hermite transformations.<br />

For any two integers a and b there is a 2-by-2 matrix E with integer entries and<br />

determinant = 1 (a unimodular matrix) such that:<br />

E * [a;b] = [g,0],<br />

where g is the greatest common divisor of a and b as returned by the command<br />

[g,c,d] = gcd(a,b).<br />

The matrix E equals:<br />

c d<br />

-b/g a/g<br />

In the case where a = 2 and b = 4:<br />

[g,c,d] = gcd(2,4)<br />

g =<br />

2<br />

c =<br />

1<br />

d =<br />

0<br />

gcd<br />

2-955

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!