Algorithm Desig d Alsis Victor Admchi CS 5-45 Sprig 4 Lecture 3 J 7, 4 Cregie Mello Uiversit Outlie Fst Fourier Trsform ) Legedre s Iterpoltio ) Vdermode Mtri 3) Roots of Uit 4) Polomil Evlutio Guss (777 855) Lgrge (736 83) Fourier (768 83) High Level Ide The orst-cse compleit To compute the polomil (order ) product A()B(), ) evlute A() d B() t some (+) poits, ) multipl A( )B( ), 3) the fid the polomil hich psses through these poits. To compute the polomil product A()B(), ) evlute A() d B() t some poits, - ht s the compleit of A( )-? - ht s the compleit of A( ) t poits? ) multipl A( )B( ), 3) the fid the polomil hich psses through these poits. - ho c e do it? Wht is it compleit? Iterpoltio Give set of poits Iterpoltio Give pirs (, ), (, ),, (, ) (, ) ( 3, 3 ) ( 5, 5 ) Theorem: There is ectl oe polomil P() of degree t most such tht P( ) = for ll =,,. ( 4,b 4 ) Fid (lo-degree) polomil hich fits the dt
Theorem Proof There re to thigs to prove.. There is t lest oe polomil of degree pssig through ll + dt poits.. There is t most oe polomil of degree pssig through ll + dt poits. Let s prove # first. Proof #: There is t most oe polomil Suppose P() d Q() both do the tric. Let R() = P() Q(). Sice deg(p), deg(q) e must hve deg(r). But R( ) = b b = for ll =,,. Thus R() hs more roots (+) th its degree. Thus, R() must be the polomil, i.e., P()=Q(). Proof # Lgrge Iterpoltio The method for costructig the polomil is clled Lgrge s Iterpoltio. Discovered i 795 b J.-L. Lgrge. - b b b b - b Wt P() ith degree such tht P( ) = b. Specil Cse - Oce e solve this specil cse, the geerl cse is ver es. Specil Cse - Let Q() = ( )( )( ) Degree is. Q( ) = Q ( ) = = Q ( ) =. Q( ) =??
Numertor is deg. polomil Lgrge Iterpoltio - Deomitor is ozero field elemet Q() ( )( ) S () Q( ) ( )( ) Cll this the selector polomil for. Aother specil cse - ( - )( )( ) S () ( )( )( ) Lgrge Iterpoltio Gret! But ht bout this dt? b b b - - b - b ( )( - ) S () ( )( ) - P() = b S () + + b S () This formul is clled Lrge s Iterpoltio Lgrge Iterpoltio Give pirs (, ), (, ),, (, ) There is uique polomil to fit these poits: () Emple Give to polomils A() = + + B() = + + 3 Compute their vlues t = -, -,,, {A(-), A(-), A(), A(), A()} = {3,,, 3, 7} {B(-), B(-), B(), B(), B()} = {9,,, 6, 7} Poitise multiplictio: {C(-), C(-), C(), C(), C()} = {7,,, 8, 9} 3
4 Emple Poits to fit (-,7), (-,), (, ), (, 8), (, 9) This ields 4 3 3 5 6 3 () () Wht is the rutime compleit of Lgrge s iterpoltio? O( 3 ), if e epd () Mtri Form Cosider cse of to poits This could be ritte i mtri form tht defies d. The Vdermode Mtri The Lgrge formul defies polomil here coefficiets c be foud b solvig this or i short V. = A() Thus, = V -. The Vdermode Mtri V I order to iverse the mtri V, e hve to prove tht it s osigulr. Determit of the Vdermode Mtri - ) ( det Sice the + poits re distict, the determit c't be zero. The proof (b iductio o ) is left s eercise to studet
Compleit of Iterpoltio It follos tht the compleit of iterpoltio depeds o ho fst c e iverse the Vdermode mtri. Lgrge s Iterpoltio formul c be represeted vi the Vdermode Mtri. The success depeds o the vlues of, =,, Computig Polomils Give polomil of degree. Wht is the compleit of computig its vlue t sigle poit, A( )? Horer s Rule: A() O() Computig Polomils So e compute the sigle vlue i lier time. Therefore, it tes O( ) to compute polomil of degree t poits. I the et slides e ill develop e method tht hs O( log ) rutime compleit. A() ( ( ( )) Computig Polomils The e ide is to use the divide-d-coquer lgorithm. We split polomil ito to prts: ith eve d odd degree terms. For emple, A() = A ( ) + A ( ) ++3 +4 3 +5 4 +6 5 =(+3 +5 4 )+(+4 +6 4 ) Worst-time Compleit Let T() be the compleit of computig degree- polomil t + poits. Thus T() T(/) O() This solves to O( log ). Gret! The ol problem is tht the lgorithm requires of hvig hlf positive d hlf egtive poits o ech itertio. 5
Ver specil poits A() = A ( ) + A ( ) So, e eed to fid such set of poits tht ) hlf of poits re egtive d the secod hlf is positive Roots of Uit The re defied s solutios to z =. Here is = 8 - i i +i i π/4 i e + ) this propert holds fter squrig i -i i i Comple umbers o uit circle re represeted b z = e i =cos() + i si() Roots of Uit: = 8 Let = i, the roots of z 8 = c be ritte s,,, 3, 4, 5, 6, 7 Sice i = -, d thus 4 = -, the c lso be ritte s,,, 3, -, -, -, - 3 Let us te hlf d squre them (,,, 3 ) = (,, 4, 6 ) = (,, -, - ) Do it gi (, ) = (, 4 ) = (, -) Computig Polomils Give polomil of degree. A() Our ts to compute A(), A(), A( ), here + =. We c rite these computtios i mtri form!!! Computig Polomils A() A() A( ) A() Lgrge s Iterpoltio formul c be represeted vi the Vdermode Mtri. Polomil evlutio is lso computed vi the Vdermode Mtri. This is the Vdermode mtri. We ill prove tht this mtri multiplictio c be doe i O( log ) 6
High Level Ide To compute the product A()B() of polomils (of order ) O( log ) ) evlute A() d B() t (+) roots of uit, usig the Vdermode mtri ) multipl A( )B( ), O() 3) the fid the polomil usig Lgrge s iterpoltio vi the Vdermode mtri O( log ) 7