{VERSION 6 0 "SUN SPARC SOLARIS" "6.0" } {USTYLETAB {CSTYLE "Maple Input" -1 0 "Courier" 0 1 255 0 0 1 0 1 0 0 1 0 0 0 0 1 }{CSTYLE "2D Math" -1 2 "Times" 0 1 0 0 0 0 0 0 2 0 0 0 0 0 0 1 }{CSTYLE "2D Output" 2 20 "" 0 1 0 0 255 1 0 0 0 0 0 0 0 0 0 1 } {CSTYLE "" -1 256 "" 1 24 0 0 0 0 0 0 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 257 "" 1 24 0 0 0 0 0 0 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 258 "" 1 24 0 0 0 0 0 0 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 259 "" 1 24 0 0 0 0 0 0 0 0 0 0 0 0 0 1 }{PSTYLE "Normal" -1 0 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "Text Ou tput" -1 2 1 {CSTYLE "" -1 -1 "Courier" 1 10 0 0 255 1 0 0 0 0 0 1 3 0 3 1 }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 1 }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 1 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "M aple Output" 0 11 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 }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 41 "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(\"\"&!\"$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 power = 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..d egree(f,x) )];" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%5list_of_coefficie ntsG7&!\"$\"\"&\"\"!#\"\"$\"\"#" }}}{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 = [a 0, a1, a2, ..., an] will correspond to the polynomial" }}{PARA 0 "" 0 "" {TEXT -1 101 " f = an * x^n + ... + a1*x^1 + a0*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 procedure 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 that corre sponds 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 length s 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 lengths 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 happens 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 degree 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] and then y ou 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 "be cause 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 th e 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 "Note 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 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 139 "So if a poly nomial f is represented by a list L, and if k is some number, then thi s will let you determine the list of coefficients of k*f." }}{PARA 0 " " 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 68 "The next step is t he 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 on e 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 calculate 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 list by using the add_poly command fro m 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 "Assignment 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 number*number that Maple must do eq uals: nops(L), there is one multiplication for each element of L." }} {PARA 0 "" 0 "" {TEXT -1 134 "If L1 and L2 both have n entries, then h ow many number*number multiplications will be done during the computat ion: mult_poly(L1, L2) ?" }}}}{MARK "0 6 0" 31 }{VIEWOPTS 1 1 0 1 1 1803 1 1 1 1 }{PAGENUMBERS 0 1 2 33 1 1 }