Click here to load reader
Upload
swamy-j-s
View
498
Download
0
Embed Size (px)
Citation preview
MATLAB CODE FOR CALCULATING GCD OF INTEGERS AND POLYNOMIAL
Project Associates:ABHISHEK - 1PI14LVS01APARNA BHAT - 1PI14LVS02ASHWINI SHENOY- 1PI14LVS03CHAITRA ALASE G - 1PI14LVS04SWAMY J S- 1PI14LVS17EUCLIDEAN ALGORITHM FOR GCD OF INTEGERS AND POLYNOMIALS
CONTENTS2Introduction GCDEuclidean GCD Applications of Euclidean AlgorithmFlowchart MATlab code for integers GCD for Polynomials.MATlab FunctionsFuture work
GCD3Inmathematics, thegreatest common divisor(gcd) of two or moreintegers, when at least one of them is not zero, is the largest positive integer thatdividesthe numbers without aremainder.
The GCD is also known as thegreatest common factor(gcf),highest common factor(hcf),greatest common measure(gcm),orhighest common divisor.
Euclidean GCD4It is named after the ancient GreekmathematicianEuclid, who first described it inEuclidsElements(c. 300 BC)
Efficient algorithm to calculate GCD is Euclidean GCD.
Uses a division Algorithm.
The Euclidean algorithm is based on the principle that the greatest common divisor of two numbers does not change if the larger number is replaced by its difference with the smaller number.
CONTD5The original algorithm was described only for natural numbers and geometric lengths (real numbers), but the algorithm was generalized in the 19th century to other types of numbers, such asGaussian integersandpolynomialsof one variable. This led to modernabstract algebraicnotions such asEuclidean domains.
Applications of Euclidean Algorithm6The Euclidean algorithm has many theoretical and practical applications.
It is used for reducingfractionsto theirsimplest form and for performingdivisioninmodular arithmetic. cryptographic protocols that are used to secureinternetcommunications.
The Euclidean algorithm may be used to solveDiophantine equations.
It is a basic tool for proving theorems innumber theorysuch as Lagranges four-square theoremand theuniqueness of prime factorizations.
Euclidean Algorithm:7GCD(a,b) where a and b are integers.
For all a , b with a > b there is a q (quotient) and r (remainder) such that a = qb + r with r < b or r = 0
This is calculated repeatedly by making a=b and b=r until r=0.Finally, GCD=b.
Properties of GCD:8
Gcd(a,0)=aGcd(a,a)=aGcd(a,b)=gcd(b,a mod b)a mod b=a-b [floor(a/b)]
FLOWCHART9
Fig.1: Flowchart of Euclidean GCD calculation
9
MATLAB CODE10
clear; clc
a = input('First number: ');b = input('Second number: ');a = abs(a);b = abs(b);r = a - b*floor(a/b);whiler ~= 0a = b;b = r;r = a - b*floor(a/b);end
GCD = b
11
12
13GCD OF POLYNOMIALSDefinition: The greatest common divisor of two polynomials is a polynomial, of the highest possible degree, that is a factor of both the original polynomials.
In of univariate polynomials , the polynomial GCD can be computed, like that for the integer GCD, by Euclid's algorithm using long division.
The similarity between the integer GCD and the polynomial GCD allows us to extend some properties of integer GCD to polynomial GCD. Property: The roots of the GCD of two polynomials are the common roots of the two polynomials.This allows to get information on the roots without computing them.
14
FLOWCHART:
14
15
Example:
1) De-convolution(p1,p2)=polynomial division(p1/p2)16Polynomial Division:
QP2P1R
17
MATLAB deconv command execution:
18function b = polystab(a)
r = roots(a);v = find(abs(r)>1); //finds indices of the vector r whose absolute value is greater than 1r(v) = 1./conj(r(v)); b = a(1) * poly ( r );if isreal(a), b = real(b); endif
endfunction2) Polystab(p1): Stabilizing the polynomial transfer function
19
20
21FUTURE WORK:
Rectify errors in MATLAB code for GCD of polynomials.
Write Verilog code for GCD of two integers and dump the same into FPGA.
Write Verilog code for GCD of two Polynomials.
22Thank you!!