{VERSION 6 0 "IBM INTEL NT" "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 } {PSTYLE "Normal" -1 0 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 2 2 2 2 2 2 1 1 1 1 }1 1 0 0 0 0 1 0 1 0 2 2 0 1 }{PSTYLE "Maple Output" -1 11 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 2 2 2 2 2 2 1 1 1 1 }3 3 0 0 0 0 1 0 1 0 2 2 0 1 }} {SECT 0 {EXCHG {PARA 0 "" 0 "" {TEXT -1 62 "-------------------------- ------------------------------------" }}{PARA 0 "" 0 "" {TEXT -1 51 "n orm1.mws Norm functions for vectors and matrices" }}{PARA 0 "" 0 "" {TEXT -1 62 "--------------------------------------------------------- -----" }}{PARA 0 "" 0 "" {TEXT -1 59 "The idea here is that, if we wri te the functions ourselves," }}{PARA 0 "" 0 "" {TEXT -1 42 "we might p ossibly understand what they do." }}{PARA 0 "" 0 "" {TEXT -1 54 "Of co urse, the norms are part of Maple::LinearAlgebra." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 20 "with(LinearAlgebra) :" }}{PARA 0 "" 0 "" {TEXT -1 17 "The vector 2-norm" }}{PARA 0 "" 0 " " {TEXT -1 32 "norm2vt(u) = sqrt(sum (u[i])^2) " }}{PARA 0 "" 0 "" {TEXT -1 17 "t means temporary" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 125 "norm2vt:=proc(u) local d,i,s;\nd := Dimension(u);\ns := 0;\nf or i from 1 by 1 to d do s := s + u[i]^2 end do;\nsqrt(s)\nend proc: \+ " }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 14 "Test vector V1" }{MPLTEXT 1 0 0 "" }{TEXT -1 1 "\n" }{MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 29 "V1 := Vector([1,-2,3,-2,-7]);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%#V1G-%'RTABLEG6%\"(Gp5\"-%'MATRIXG6#7'7#\"\"\"7#!\"#7 #\"\"$F/7#!\"(&%'VectorG6#%'columnG" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "norm2vt(V1);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#*$\"# n#\"\"\"\"\"#" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 28 "A simpler versio n of norm2v " }}{PARA 0 "" 0 "" {TEXT -1 45 "norm2v(u) = sqrt() \+ One-line definition" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 32 "norm2v:=u-> sqrt(Transpose(u).u):" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "no rm2v(V1);\n" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#*$\"#n#\"\"\"\"\"#" }}} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" } }{PARA 0 "" 0 "" {TEXT -1 59 "We now look at the 1-norm and the infini ty-norm for vectors" }{MPLTEXT 1 0 1 "\n" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 26 "We first define the 1-norm" }}{PARA 0 "" 0 "" {TEXT -1 22 "norm1v(u) = sum |u[i]|" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 121 "norm1v:=proc(u) local d,i,s;\nd := Dimension(u);\ns := 0;\nfor i \+ from 1 by 1 to d do s := s + abs(u[i]) end do;\ns\nend proc: " }} {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 31 "norm1v(Vector([1,-2,3,-2,-7]));" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"#:" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 31 "Now we def ine the infinity-norm" }}{PARA 0 "" 0 "" {TEXT -1 22 "normiv(u\} = max |u[i]|" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 164 "normiv:=proc(u) local d ,i,s,si;\nd := Dimension(u);\ns := abs(u[1]);\nfor i from 2 by 1 to d \+ do\nsi := abs(u[i]); \nif (si > s) then s := si end if\nend do:\ns\nen d proc:\n " }{TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 31 "normiv(Vector([1,-2,3,-2,-7]));" }}{PARA 11 "" 1 "" {XPPMATH 20 "6 #\"\"(" }}}{EXCHG {PARA 11 "" 1 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 14 "Test matrix M1" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 36 "M1 := Matrix([[1,2],[-3,1],[1,-4]]);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%#M1G-%'RTABLEG6%\")[`u?-%'MATRIXG6#7%7$\"\"\"\" \"#7$!\"$F.7$F.!\"%%'MatrixG" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 21 "M atrix Frobenius norm" }}{PARA 0 "" 0 "" {TEXT -1 39 "normfm(M) = sum m [i,j]^2 = Trace M^t M" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 34 "normfm:= \+ m->Trace(Transpose(m).m):" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "normfm(Matrix(M1));" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"#K" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 13 "Matrix 1-norm" }}{PARA 0 "" 0 "" {TEXT -1 43 "norm1m(M) = max norm1v(column vectors of M)" }}{PARA 0 " " 0 "" {TEXT -1 13 "(uses norm1v)" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 197 "norm1m:=proc(m) local i,dc,si,s;\ndc := ColumnDimension(m);\ns := norm1v(Column(m,1));\nfor i from 1 by 1 to dc do\n si := norm1v(Colu mn(m,i));\n if (si > s) then s := si end if;\nend do;\n s\nend proc: " }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 17 "We try an example" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 3 "M1;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#-%'RTABLEG6%\")[`u?-%'MATRIXG6#7%7$\"\"\"\"\"#7$!\"$F,7$F,!\"%%'Mat rixG" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "norm1m(M1);" }} {PARA 11 "" 1 "" {XPPMATH 20 "6#\"\"(" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 51 "Maple has its own function MatrixNorm for this task" }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 17 "MatrixNorm(M1,1);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"\"(" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 20 "Matrix infinity-norm" }}{PARA 0 " " 0 "" {TEXT -1 40 "normim(M) = max normiv(row vectors of M)" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 32 "normim:=m->norm1m(Transpose(m)):" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 11 "Th e example" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 11 "normim(M1);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"\" &" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 29 "The Maple version of this is " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 24 "MatrixNorm(M1,infinity );" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"\"&" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 14 "Transpose(M1);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6# -%'RTABLEG6%\"'%o/'-%'MATRIXG6#7$7%\"\"\"!\"$F,7%\"\"#F,!\"%%'MatrixG " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 22 "norm1m(Transpose(M1)); " }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"\"&" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 28 "MatrixNorm(Transpose(M1),1);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"\"&" }}}{PARA 11 "" 1 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 22 "normim(Transpose(M1));" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"\"(" }}}{PARA 0 "" 0 "" {TEXT -1 26 "[ And, \+ again, a la Maple:" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 " > " 0 "" {MPLTEXT 1 0 35 "MatrixNorm(Transpose(M1),infinity);" }} {PARA 11 "" 1 "" {XPPMATH 20 "6#\"\"(" }}}}{MARK "36 0" 15 }{VIEWOPTS 1 1 0 1 1 1803 1 1 1 1 }{PAGENUMBERS 0 1 2 33 1 1 }{RTABLE_HANDLES 1106928 20745348 604684 }{RTABLE M7R0 I4RTABLE_SAVE/1106928X*%)anythingG6"6"[gl!#%!!!"&"&"""!"#""$F(!"(F& } {RTABLE M7R0 I5RTABLE_SAVE/20745348X,%)anythingG6"6"[gl!"%!!!#'"$"#"""!"$F'""#F'!"%F& } {RTABLE M7R0 I3RTABLE_SAVE/604684X,%)anythingG6"6"[gl!"%!!!#'"#"$"""""#!"$F'F'!"%6" }