1 / 25

ADVANCED ALGORITHMS

ADVANCED ALGORITHMS. Polynomials and the FFT (UNIT-3 ). Polynomials : A polynomial in the variable x over an algebraic field F represents a function A(x) as a formal sum : A(x) =  a j x j j = 0 to n-1. Here, we call the values a 0, a 1, a 2, a 3,…., a n-1 as the

gratia
Download Presentation

ADVANCED ALGORITHMS

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ADVANCED ALGORITHMS Polynomials and the FFT(UNIT-3)

  2. Polynomials : A polynomial in the variable x over an algebraic field F represents a function A(x) as a formal sum : A(x) = ajxj j = 0 to n-1 Here, we call the values a0, a1, a2, a3,….,an-1 as the coefficients of the polynomial. A polynomial has degree k, if its highest non-zero coefficient is ak. Any integer strictly greater than the degree of a polynomial ‘k’, is degree-bound ‘n’. i.e., n > k.

  3. The representation of a Polynomial : Ex-1 : A(x) = 𝑥3 − 2𝑥 − 1 Here, A(x) has degree 3. A(x) has degree bounds 4,5,6,.. A(x) has coefficients (-1,-2,0,1) Ex-2 : 𝑥4 + 𝑥2 − 1 Here, A(x) has degree 4. A(x) has degree bounds 5,6,7,.. A(x) has coefficients (-1,0,1,0,1)

  4. Coefficient Representation :(CR) A CR of a polynomial of degree bound ‘n’ is a vector of coefficients a = Adding Polynomials : Let a = (a0,a1,a2,… , an-1) b = (b0,b1,b2,… , bn-1) Sum is the coefficient vector C, where c = (c0,c1,c2,… , cn-1) Here, cj= aj+ bj  j = 0,1,2,..,n-1.

  5. Multiplying Polynomials : Multiplying of two degree-bound ‘n’ polynomials A(x) and B(x) : C(x) = Ex-3 : Add & Multiply the following two polynomials : A(x) = x2 - 10 x + 9 B(x) = x2 + 4 x - 5 A(x) + B(x) = 2x2 - 6 x + 4 A(x) X B(x) = x4 – 6 x3 – 36 x2 + 86 x - 45

  6. Horner’s Rule : Given the Polynomial : p(x) = ai xi = a0 + a1 x + a2 x2+ … + anxn i = 0 to n Here,  i = 0,1,2,..,n-1,n aiis a real number. The above polynomial can be written in the form : p(x) = a0 + x (a1 + x (a2 + x (a3 + …. + x (an-1 + an x )……)) Let x = x0 Now, assume bn := an bn-1 := an-1 + bn xo ………….. b0 := a0 + b1 xo

  7. Here let us substitute b values into expression of p(x0). So, p(x0) = a0 + x0 (a1 + x0 (a2 + x0 (a3 + …. + x0 (an-1 + bn x0 )……)) = a0 + x0 (a1 + x0 (a2 + x0 (a3 + …. + x0 bn-1 )……)) = ………… = a0 + x0 (a1 + x0 (a2 + x0 b3 )) = a0 + x0 (a1 + x0 b2) = a0 + x0 b1 = b0 Hence p(x0) = b0

  8. Ex-4 : Evaluate 2x3 - 6x2 + 2x - 1 for x = 3 Synthetic Division : (Horner’s Method) x0 | x3 x2 x1 x0 ---------------------------------------- 3 | 2 - 6 2 - 1 | 6 0 6 ----------------------------------------- 2 0 2 5 i.e., The Value of p(x0) is 5.

  9. Ex-5 : Evaluate x3 - 6x2 + 11 x - 6 for x = 2 Synthetic Division : (Horner’s Method) x0 | x3 x2 x1 x0 ---------------------------------------- 2 | 1 - 6 11 - 6 | 2 - 8 6 ----------------------------------------- 1 - 4 3 0 i.e., The Value of p(x0) is 0.

  10. 3. Point-Value Representation : A Point-Value Representation of a polynomial A(x) of degree-bound n is a set of n point-value pairs : {(x0 ,y0), (x1 ,y1), (x2 ,y2),…, (xn-1 ,yn-1),} such that all of the xk are distinct and yk = A(xk) for k = 0,1,2,…,n-1. Ex-6 : A(x) = x3 - 2 x + 1 Here, xk : 0, 1, 2, 3 A(xk ) : 1, 0, 5, 22  { (0,1), (1,0), (2,5), (3,22) }

  11. Interpolation of PVR : The inverse of evaluation is Interpolation. - determines coefficient form of polynomial from point value representation. Theorem : (Uniqueness of an interpolating polynomial) “For any set {(x0 ,y0), (x1 ,y1), (x2 ,y2),…, (xn-1 ,yn-1),} of n point-value pairs  all the xk values are distinct, there is a unique polynomial A(x) of degree-bound n such that yk = A(xk) for k = 0, 1, 2, …, n-1.”

  12. The above theorem can be written as : The matrix on the left is denoted V(x0 , x1 , x2 , …, xn-1). It is known as : Vander-monde Matrix. i.e., a = V -1 y.

  13. Lagrange’s Formula : A(x) =  yk Z, where k = 0 to n-1 Z =  j  k (x – xj) /  j  k (xk – xj) Ex-7 : Consider the PVR : [ (0,1), (1,0), (2,5), (3,22) ] Here, 1.[(x-1)(x-2)(x-3)] / [(0-1) (0-2) (0-3)] = (x3 - 6x2 + 11 x - 6) / - 6 = (-x3 + 6x2 - 11 x + 6) / 6 ….(1) And 0.[(x-0)(x-2)(x-3)] / [(1-0) (1-2) (1-3)] = 0 ….(2)

  14. And5.[(x-0)(x-1)(x-3)] / [(2-0) (2-1) (2-3)] = 5. (x3 - 4x2 + 3 x ) / (-2) = (-15 x3 + 60 x2 - 45 x ) / 6 …..(3) And22.[(x-0)(x-1)(x-2)] / [(3-0) (3-1) (3-2)] = 22 (x3 - 3 x2 + 2 x ) / 6 = (22 x3 - 66 x2 + 44 x ) / 6 ……(4) + (2) + (3) + (4) : (6 x3 + 0 x2 - 12 x + 6) / 6 = x3 - 2 x + 1 …Answer The above is the polynomial for the given PVR.

  15. Adding Polynomials using PVR : Let C(x) = A(x) + B(x) A : [(x0 ,y0), (x1 ,y1), (x2 ,y2),…, (xn-1 ,yn-1)] B : [(x0 ,z0), (x1 ,z1), (x2 ,z2),…, (xn-1 ,zn-1)] C : [ (x0 , y0+ z0), (x1 , y1+ z1), …., (xn-1 , yn-1+ zn-1) ] Ex-8 : Find the value of C(x) in PVR, where A(x) = x3 - 2 x + 1 B(x) = x3 + x2 + 1 Let x = (0,1,2,3) Then A : [(0,1), (1,0), (2, 5), (3,22) ] B : [ (0,1), (1,3), (2, 13), (3, 37) ] Hence C : [(0,2), (1, 3), (2, 18), (3, 59) ]

  16. Multiplying Polynomials using PVR : Let C(x) = A(x) . B(x) A : [(x0 ,y0), (x1 ,y1), (x2 ,y2),…, (x2n-1 ,y2n-1)] B : [(x0 ,z0), (x1 ,z1), (x2 ,z2),…, (x2n-1 ,z2n-1)] C : [ (x0 , y0 z0), (x1 , y1 z1),….,(x2n-1 , y2n-1+ z2n-1) ] Ex-9 : Find the value of C(x) in PVR, where A(x) = x3 - 2 x + 1 ; B(x) = x3 + x2 + 1 Let x = (-3,-2,-1,0,1,2,3) A : [(-3,20), (-2,-3), (-1,2),(0,1), (1,0), (2, 5), (3,22) ] B : [ (-3,-17),(-2,-3), (-1, 1),(0,1), (1,3), (2, 13), (3,17)] C : [(-3,340),(-2,9),(-1,2),(0,1), (1, 0), (2, 65), (3,814) ]

  17. Ex-8 Contd… There are FOUR cordinates : C : [(0,2), (1, 3), (2, 18), (3, 59) ] Basing on First & Second Coordinates : - 2 x3 + 12 x2 - 22 x + 12 …..(1) 9 x3 - 45 x2 + 54 x …..(2) Basing on Third & Fourth Coordinates : - 54 x3 + 216 x2 - 162 x …..(1) 59 x3 - 177 x2 + 118 x …..(2) The denominator is 6. Finally 2 x3 + x2 - 2 x + 2

  18. 4. Complex Roots of Unity : A complex nth root of unity (1) is a complex number  such that n = 1. There are exactly n complex nth roots of unity : e2 i k / nfor k = 0, 1, 2, …., n-1 where eiu = cos (u) + i sin (u) Using e2  i k / n =cos(2 k / n) + i sin(2 k / n) we can check that it is a root. (e2  i k / n)n = e2  i k = cos(2 k) + i sin (2k) = 1 + 0 = 1

  19. Degrees : 00 450 900 1800 SIN 0 1/ 21 0 COS 1 1/ 2 0 -1 Principal nth Root of Unity : The Valuen = e 2∏i /n is called the ‘principal nth root of unity’. All of the other complex nth roots of unity are powers of n . The n complex nth roots of unity are : n0, n1, n2,….., nn-1 Note :Here, nn = n0 = 1

  20. Ex-10 : Find the 8th complex roots of unity. The two roots of unity are : +1, - 1 The complex 4th roots of unity are : 1, - 1, i, - iwhere (-1) = i In general, the n complex roots of unity are equally spaced around the circle of unit radius centered at the origin of the complex plane. Note :nj . nk = nj+k = n(j + k) mod n

  21. Visualizing 8 Complex 8th Roots of Unity :

  22. First Root :80 = 88 = 1 Here, k = 0, n = 8 So, 80 = e 2∏i k / n = e 0 = 1 Second Root : Here, k = 1, n = 8 81 = e 2 ∏i k / n =e 2 ∏i / 8 = e ∏i / 4 by using the formula eiu = cos (u) + i sin (u) So, 81 = cos (/4) + i sin (/4) = 1 / 2 + i / 2

  23. Third Root : Here, k = 2, n = 8 82 = e 2 ∏i k / n =e 2 ∏i 2 / 8 = e ∏i / 2 So, 82 = cos (/2) + i sin (/2) = i Fourth Root : Here, k = 3, n = 8 83 = e 2 ∏ i k / n =e 2 ∏ i 3 / 8 = e ∏ i 3 / 4 So, 83 = cos (3/4) + i sin (3/4) = cos ( - /4) + i sin ( - /4) = - cos /4 + i sin /4) [since cos ( - x) = - cos x, sin ( - x) = sin x] = - 1 / 2 + i /2

  24. Fifth Root : Here, k = 4, n = 8 84 = e 2 ∏ i k / n =e 2 ∏ i 4 / 8 = e ∏ i So, 84 = cos () + i sin () = - 1 Sixth Root : Here, k = 5, n = 8 85 = e 2 ∏ i k / n =e 2 ∏ i 5 / 8 = e ∏ i 5 / 4 So, 85 = cos (5/4) + i sin (5/4) = cos ( + /4) + i sin ( + /4) = - cos /4 + i (- sin /4) [since cos ( + x) = - cos x, sin ( + x) = - sin x] = - 1 / 2 - i /2

  25. Seventh Root : Here, k = 6, n = 8 86 = e 2 ∏ i k / n =e 2 ∏ i 6 / 8 = e 3∏ i / 2 So, 86 = cos ( + /2 ) + i sin ( + /2) = - cos (/2) + i (- sin (/2) ) = - 0 + i ( - 1) = - i Eighth Root : Here, k = 7, n = 8 87= e 2 ∏ i k / n =e 2 ∏ i7 / 8 = e ∏ i7 / 4 So, 87 = cos(7/4) + i sin (7/4) = cos ( + 3/4) + i sin ( + 3/4) = - cos3/4 + i (- sin 3/4) [since cos ( + x) = - cos x, sin ( + x) = - sin x] = cos/4 + i (- sin /4) = 1 / 2 - i /2

More Related