{VERSION 3 0 "SGI MIPS UNIX" "3.0" } {USTYLETAB {CSTYLE "Maple Input" -1 0 "Courier" 0 1 255 0 0 1 0 1 0 0 1 0 0 0 0 }{CSTYLE "2D Math" -1 2 "Times" 0 1 0 0 0 0 0 0 2 0 0 0 0 0 0 }{CSTYLE "2D Output" 2 20 "" 0 1 0 0 255 1 0 0 0 0 0 0 0 0 0 } {CSTYLE "" -1 256 "" 1 24 0 0 0 0 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 257 "" 1 24 0 0 0 0 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 258 "" 1 24 0 0 0 0 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 259 "" 1 24 0 0 0 0 0 0 0 0 0 0 0 0 0 }{PSTYLE "Normal" -1 0 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "Text Output" -1 2 1 {CSTYLE "" -1 -1 "Courier" 1 10 0 0 255 1 0 0 0 0 0 1 3 0 3 }1 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "Warning" 2 7 1 {CSTYLE "" -1 -1 "" 0 1 0 0 255 1 0 0 0 0 0 0 1 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "Error" 7 8 1 {CSTYLE "" -1 -1 "" 0 1 255 0 255 1 0 0 0 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "Maple Output" 0 11 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 }3 3 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }} {SECT 0 {EXCHG {PARA 0 "" 0 "" {TEXT 256 24 "Multiplying polynomials. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 40 "A pol ynomial f in Q[x] is an expression:" }}{PARA 0 "" 0 "" {TEXT -1 0 "" } }{PARA 0 "" 0 "" {TEXT -1 21 " f = sum a.i * x^i" }}{PARA 0 "" 0 " " {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 45 "where a.i are rational \+ numbers. For example: " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 25 "f := 3/2 * x^3 + 5*x - 3;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"fG,(*$ )%\"xG\"\"$\"\"\"#F)\"\"#F(\"\"&!\"$\"\"\"" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 35 "degree(f,x); # = highest power of x" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"\"$" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 72 "ldegree(f,x); # = lowest power of x. Note: 3 = 3*x^0 so lowest pow er = 0" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"\"!" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 64 "list_of_coefficients := [seq( coeff(f,x,i), i= 0..degree(f,x) )];" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%5list_of_coeff icientsG7&!\"$\"\"&\"\"!#\"\"$\"\"#" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 55 "Now we will represent polynomials in the following way:" }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 68 "The list \+ L = [a0, a1, a2, ..., an] will correspond to the polynomial" }}{PARA 0 "" 0 "" {TEXT -1 101 " f = an * x^n + ... + a1*x^1 + a 0*x^0 (note: x^1 is just x and a0*x^0 is just a0)." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }{TEXT 257 14 "Assignment 1: " }{TEXT -1 25 "Write a pro cedure called:" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 24 "add_poly := proc(L1, L2)" }}{PARA 0 "" 0 "" {TEXT -1 12 " local ..." }}{PARA 0 "" 0 "" {TEXT -1 5 " ..." }}{PARA 0 "" 0 "" {TEXT -1 4 "end:" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 118 "whose input is two lists, and whose output is one list t hat corresponds to the sum. Note: Maple can already add lists:" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 25 "[3,6,-1,3/4] + [0,0,3,1];" } }{PARA 11 "" 1 "" {XPPMATH 20 "6#7&\"\"$\"\"'\"\"##\"\"(\"\"%" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 20 "[1,2,3,4] + [1,2,3];" }} {PARA 8 "" 1 "" {TEXT -1 39 "Error, adding lists of different length" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 56 "but the addition only works if \+ the lengths are the same." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 " " 0 "" {TEXT -1 42 "So your procedure should do the following:" }} {PARA 0 "" 0 "" {TEXT -1 67 " if the lengths are the same (nops(L1) \+ =nops(L2)) then just use +" }}{PARA 0 "" 0 "" {TEXT -1 119 " if the l engths are not the same, then make the shorter list longer by adding \+ 0's at the end, and then add the lists." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 72 "At the end, if the last entry happen s to be 0, for example when you add:" }}{PARA 0 "" 0 "" {TEXT -1 18 " \+ f1 := 3*x^2 - 1;" }}{PARA 0 "" 0 "" {TEXT -1 24 " f2 := -3*x^2 + 5*x \+ + 1;" }}{PARA 0 "" 0 "" {TEXT -1 295 "then you have L1 = [-1,0,3] and \+ L2 = [1,5,-3] and the sum is [0,5,0] but f1+f2 = 5*x which has only de gree 1, so you want to simplify the list L1+L2=[0,5,0] by removing the last 0. So if the input is L1, L2, you compute first L1+L2=[0,5,0] an d then you remove the last 0. You can not do that by:" }}{PARA 0 "" 0 "" {TEXT -1 22 " subs(0 = NULL, ....)" }}{PARA 0 "" 0 "" {TEXT -1 69 "because that would also remove the first 0 which is not what we want. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 86 "So at the end, if L = L1+L2 and f = f1+f2 then you want: nops(L) = degree (f1,x) + 1." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }{TEXT 258 13 "Assignment 2:" }}{PARA 0 "" 0 "" {TEXT -1 55 "N ote that in Maple you can multiply a list by a number:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 17 "-2 * [3,45,0,-2];" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#7&!\"'!#!*\"\"!\"\"%" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 139 "So if a polynomial f is represented by a list L, and if \+ k is some number, then this will let you determine the list of coeffic ients of k*f." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 68 "The next step is the determine the list of: f, x*f, x^2* f, ... etc." }}{PARA 0 "" 0 "" {TEXT -1 108 "Note that to compute the \+ list of x*f, you need to add one entry (with value 0) at the beginning of the list." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 67 "Now, if g = b0*x^0 + ... + bn*x^n then you can calcula te g*f as:" }}{PARA 0 "" 0 "" {TEXT -1 36 " b0*f + b1 * x*f + b2 * x^ 2*f + ..." }}{PARA 0 "" 0 "" {TEXT -1 78 "and you can compute this lis t by using the add_poly command from assignment 1." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 35 "This way you can write a \+ procedure:" }}{PARA 0 "" 0 "" {TEXT -1 25 "mult_poly := proc(L1, L2)" }}{PARA 0 "" 0 "" {TEXT -1 10 " ...\nend:" }}{PARA 0 "" 0 "" {TEXT -1 45 "that computes the product of two polynomials." }}{PARA 0 "" 0 " " {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }{TEXT 259 13 "Assignm ent 3:" }}{PARA 0 "" 0 "" {TEXT -1 198 "If L is a list of numbers, and k is a number, and you do: k*L then the number of multiplications num ber*number that Maple must do equals: nops(L), there is one multiplic ation for each element of L." }}{PARA 0 "" 0 "" {TEXT -1 134 "If L1 an d L2 both have n entries, then how many number*number multiplications \+ will be done during the computation: mult_poly(L1, L2) ?" }}}}{MARK "1 0 16 0" 134 }{VIEWOPTS 1 1 0 1 1 1803 }