linalg.tex 57 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411
  1. \documentstyle[11pt,reduce,fancyheadings]{article}
  2. \title{A Linear Algebra package for \REDUCE{}}
  3. \author{Matt Rebbeck \\
  4. Konrad-Zuse-Zentrum f\"ur Informationstechnik Berlin}
  5. \date{July 1994}
  6. \def\foottitle{The Linear Algebra Package}
  7. \pagestyle{fancy}
  8. \lhead[]{{\footnotesize\leftmark}{}}
  9. \rhead[]{\thepage}
  10. \setlength{\headrulewidth}{0.6pt}
  11. \setlength{\footrulewidth}{0.6pt}
  12. \cfoot{}
  13. \rfoot{\small\foottitle}
  14. %decided against using these.
  15. %\def\ltri{$\triangleleft$}
  16. %\def\rtri{$\triangleright$}
  17. %\newcommand{\tribound}[1]{\rtri#1\ltri}
  18. \def\exprlist {expr$_{1}$,expr$_{2}$, \ldots ,expr$_{{\tt n}}$}
  19. \def\lineqlist {lin\_eqn$_{1}$,lin\_eqn$_{2}$, \ldots ,lin\_eqn$_{n}$}
  20. \def\matlist {mat$_{1}$,mat$_{2}$, \ldots ,mat$_{n}$}
  21. \def\veclist {vec$_{1}$,vec$_{2}$, \ldots ,vec$_{n}$}
  22. \def\lazyfootnote{\footnote{If you're feeling lazy then the \{\}'s can
  23. be omitted.}}
  24. \renewcommand{\thefootnote}{\fnsymbol{footnote}}
  25. \begin{document}
  26. \maketitle
  27. \index{Linear Algebra package}
  28. \section{Introduction}
  29. This package provides a selection of functions that are useful
  30. in the world of linear algebra. These functions are described
  31. alphabetically in section 3 of this document and are labelled 3.1 to
  32. 3.51. They can be classified into four sections(n.b: the numbers after
  33. the dots signify the function label in section 3).
  34. Contributions to this package have been made by Walter Tietze (ZIB).
  35. \subsection{Basic matrix handling}
  36. \begin{center}
  37. \begin{tabular}{l l l l l l}
  38. add\_columns & \ldots & 3.1 &
  39. add\_rows & \ldots & 3.2 \\
  40. add\_to\_columns & \ldots & 3.3 &
  41. add\_to\_rows & \ldots & 3.4 \\
  42. augment\_columns & \ldots & 3.5 &
  43. char\_poly & \ldots & 3.9 \\
  44. column\_dim & \ldots & 3.12 &
  45. copy\_into & \ldots & 3.14 \\
  46. diagonal & \ldots & 3.15 &
  47. extend & \ldots & 3.16 \\
  48. find\_companion & \ldots & 3.17 &
  49. get\_columns & \ldots & 3.18 \\
  50. get\_rows & \ldots & 3.19 &
  51. hermitian\_tp & \ldots & 3.21 \\
  52. matrix\_augment & \ldots & 3.28 &
  53. matrix\_stack & \ldots & 3.30 \\
  54. minor & \ldots & 3.31 &
  55. mult\_columns & \ldots & 3.32 \\
  56. mult\_rows & \ldots & 3.33 &
  57. pivot & \ldots & 3.34 \\
  58. remove\_columns & \ldots & 3.37 &
  59. remove\_rows & \ldots & 3.38 \\
  60. row\_dim & \ldots & 3.39 &
  61. rows\_pivot & \ldots & 3.40 \\
  62. stack\_rows & \ldots & 3.43 &
  63. sub\_matrix & \ldots & 3.44 \\
  64. swap\_columns & \ldots & 3.46 &
  65. swap\_entries & \ldots & 3.47 \\
  66. swap\_rows & \ldots & 3.48 &
  67. \end{tabular}
  68. \end{center}
  69. \subsection{Constructors}
  70. Functions that create matrices.
  71. \begin{center}
  72. \begin{tabular}{l l l l l l}
  73. band\_matrix & \ldots & 3. 6 &
  74. block\_matrix & \ldots & 3. 7 \\
  75. char\_matrix & \ldots & 3. 8 &
  76. coeff\_matrix & \ldots & 3. 11 \\
  77. companion & \ldots & 3. 13 &
  78. hessian & \ldots & 3. 22 \\
  79. hilbert & \ldots & 3. 23 &
  80. jacobian & \ldots & 3. 24 \\
  81. jordan\_block & \ldots & 3. 25 &
  82. make\_identity & \ldots & 3. 27 \\
  83. random\_matrix & \ldots & 3. 36 &
  84. toeplitz & \ldots & 3. 50 \\
  85. Vandermonde & \ldots & 3. 51 &
  86. Kronecker\_Product & \ldots & 3. 52
  87. \end{tabular}
  88. \end{center}
  89. \subsection{High level algorithms}
  90. \begin{center}
  91. \begin{tabular}{l l l l l l}
  92. char\_poly & \ldots & 3.9 &
  93. cholesky & \ldots & 3.10 \\
  94. gram\_schmidt & \ldots & 3.20 &
  95. lu\_decom & \ldots & 3.26 \\
  96. pseudo\_inverse & \ldots & 3.35 &
  97. simplex & \ldots & 3.41 \\
  98. svd & \ldots & 3.45 &
  99. triang\_adjoint & \ldots & 3.51
  100. \end{tabular}
  101. \end{center}
  102. \vspace*{5mm}
  103. There is a separate {\small NORMFORM}[1] package for computing
  104. the following matrix normal forms in \REDUCE.
  105. \begin{center}
  106. smithex, smithex\_int, frobenius, ratjordan, jordansymbolic, jordan.
  107. \end{center}
  108. \subsection{Predicates}
  109. \begin{center}
  110. \begin{tabular}{l l l l l l}
  111. matrixp & \ldots & 3.29 &
  112. squarep & \ldots & 3.42 \\
  113. symmetricp & \ldots & 3.49 &
  114. \end{tabular}
  115. \end{center}
  116. \subsection*{Note on examples:}
  117. In the examples the matrix ${\cal A}$ will be
  118. \begin{flushleft}
  119. \begin{math}
  120. {\cal A} = \left( \begin{array}{ccc} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9
  121. \end{array} \right)
  122. \end{math}
  123. \end{flushleft}
  124. \subsection*{Notation}
  125. Throughout ${\cal I}$ is used to indicate the identity matrix and
  126. ${\cal A}^T$ to indicate the transpose of the matrix ${\cal A}$.
  127. \section{Getting started}
  128. If you have not used matrices within {\REDUCE} before then the
  129. following may be helpful.
  130. \subsection*{Creating matrices}
  131. Initialisation of matrices takes the following syntax:
  132. {\tt mat1 := mat((a,b,c),(d,e,f),(g,h,i));}
  133. will produce
  134. \begin{flushleft}
  135. \begin{math}
  136. mat1 := \left( \begin{array}{ccc} a & b & c \\ d & e & f \\ g & h & i
  137. \end{array} \right)
  138. \end{math}
  139. \end{flushleft}
  140. \subsection*{Getting at the entries}
  141. The (i,$\,$j)'th entry can be accessed by:
  142. {\tt mat1(i,j);}
  143. \subsection*{Loading the linear\_algebra package}
  144. The package is loaded by:
  145. {\tt load\_package linalg;}
  146. \section{What's available}
  147. \subsection{add\_columns, add\_rows}
  148. %{\bf How to use it:}
  149. \hspace*{0.175in} {\tt add\_columns(${\cal A}$,c1,c2,expr);}
  150. \hspace*{0.1in}
  151. \begin{tabular}{l l l}
  152. ${\cal A}$ & :- & a matrix. \\
  153. c1,c2 & :- & positive integers. \\
  154. expr & :- & a scalar expression.
  155. \end{tabular}
  156. {\bf Synopsis:} %{\bf What it does:}
  157. \begin{addtolength}{\leftskip}{0.22in}
  158. \parbox[t]{0.95\linewidth}{{\tt add\_columns} replaces column c2 of
  159. ${\cal A}$ by expr $*$ column(${\cal A}$,c1) $+$ column(${\cal A}$,c2).}
  160. {\tt add\_rows} performs the equivalent task on the rows of ${\cal A}$.
  161. \end{addtolength}
  162. {\bf Examples:}
  163. \begin{flushleft}
  164. \begin{math}
  165. \hspace*{0.16in}
  166. \begin{array}{ccc}
  167. {\tt add\_columns}({\cal A},1,2,x) & = &
  168. \left( \begin{array}{ccc} 1 & x+2 & 3 \\ 4 & 4*x+5 & 6 \\ 7 & 7*x+8 & 9
  169. \end{array} \right)
  170. \end{array}
  171. \end{math}
  172. \end{flushleft}
  173. \vspace*{0.1in}
  174. \begin{flushleft}
  175. \hspace*{0.1in}
  176. \begin{math}
  177. \begin{array}{ccc}
  178. {\tt add\_rows}({\cal A},2,3,5) & = &
  179. \left( \begin{array}{ccc} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 27 & 33 & 39
  180. \end{array} \right)
  181. \end{array}
  182. \end{math}
  183. \end{flushleft}
  184. {\bf Related functions:}
  185. \hspace*{0.175in} {\tt add\_to\_columns}, {\tt add\_to\_rows},
  186. {\tt mult\_columns}, {\tt mult\_rows}.
  187. \subsection{add\_rows}
  188. \hspace*{0.175in} see: {\tt add\_columns}.
  189. \subsection{add\_to\_columns, add\_to\_rows}
  190. %{\bf How to use it:}
  191. \hspace*{0.175in} {\tt add\_to\_columns(${\cal A}$,column\_list,expr);}
  192. \hspace*{0.1in}
  193. \begin{tabular}{l l l}
  194. ${\cal A}$ &:-& a matrix. \\
  195. column\_list &:-& a positive integer or a list of positive integers. \\
  196. expr &:-& a scalar expression.
  197. \end{tabular}
  198. {\bf Synopsis:} %{\bf What it does:}
  199. \begin{addtolength}{\leftskip}{0.22in}
  200. {\tt add\_to\_columns} adds expr to each column specified in
  201. column\_list of ${\cal A}$.
  202. {\tt add\_to\_rows} performs the equivalent task on the rows of
  203. ${\cal A}$.
  204. \end{addtolength}
  205. {\bf Examples:}
  206. \begin{flushleft}
  207. \hspace*{0.175in}
  208. \begin{math}
  209. \begin{array}{ccc}
  210. {\tt add\_to\_columns}({\cal A},\{1,2\},10) & = &
  211. \left( \begin{array}{ccc} 11 & 12 & 3 \\ 14 & 15 & 6 \\ 17 & 18 & 9
  212. \end{array} \right)
  213. \end{array}
  214. \end{math}
  215. \end{flushleft}
  216. \vspace*{0.1in}
  217. \begin{flushleft}
  218. \hspace*{0.175in}
  219. \begin{math}
  220. \begin{array}{ccc}
  221. {\tt add\_to\_rows}({\cal A},2,-x) & = &
  222. \left( \begin{array}{ccc} 1 & 2 & 3 \\ -x+4 & -x+5 & -x+6 \\ 7 & 8 & 9
  223. \end{array} \right)
  224. \end{array}
  225. \end{math}
  226. \end{flushleft}
  227. {\bf Related functions:}
  228. \hspace*{0.175in}
  229. {\tt add\_columns}, {\tt add\_rows}, {\tt mult\_rows},
  230. {\tt mult\_columns}.
  231. \subsection{add\_to\_rows}
  232. \hspace*{0.175in} see: {\tt add\_to\_columns}.
  233. \subsection{augment\_columns, stack\_rows}
  234. %{\bf How to use it:}
  235. \hspace*{0.175in} {\tt augment\_columns(${\cal A}$,column\_list);}
  236. \hspace*{0.1in}
  237. \begin{tabular}{l l l}
  238. ${\cal A}$ &:-& a matrix. \\
  239. column\_list &:-& either a positive integer or a list of positive
  240. integers.
  241. \end{tabular}
  242. {\bf Synopsis:} %{\bf What it does:}
  243. \begin{addtolength}{\leftskip}{0.22in}
  244. {\tt augment\_columns} gets hold of the columns of ${\cal A}$ specified
  245. in column\_list and sticks them together.
  246. {\tt stack\_rows} performs the same task on rows of
  247. ${\cal A}$.
  248. \end{addtolength}
  249. {\bf Examples:}
  250. \begin{flushleft}
  251. \hspace*{0.1in}
  252. \begin{math}
  253. \begin{array}{ccc}
  254. {\tt augment\_columns}({\cal A},\{1,2\}) & = &
  255. \left( \begin{array}{cc} 1 & 2 \\ 4 & 5 \\ 7 & 8
  256. \end{array} \right)
  257. \end{array}
  258. \end{math}
  259. \end{flushleft}
  260. \vspace*{0.1in}
  261. \begin{flushleft}
  262. \hspace*{0.1in}
  263. \begin{math}
  264. \begin{array}{ccc}
  265. {\tt stack\_rows}({\cal A},\{1,3\}) & = &
  266. \left( \begin{array}{ccc} 1 & 2 & 3 \\ 7 & 8 & 9
  267. \end{array} \right)
  268. \end{array}
  269. \end{math}
  270. \end{flushleft}
  271. {\bf Related functions:}
  272. \hspace*{0.175in} {\tt get\_columns}, {\tt get\_rows},
  273. {\tt sub\_matrix}.
  274. \subsection{band\_matrix}
  275. %{\bf How to use it:}
  276. \hspace*{0.175in} {\tt band\_matrix(expr\_list,square\_size);}
  277. \hspace*{0.1in}
  278. \begin{tabular}{l l l}
  279. expr\_list \hspace*{0.088in} &:-& \parbox[t]{.72\linewidth}
  280. {either a single scalar expression or a list of an odd number of scalar
  281. expressions.}
  282. \end{tabular}
  283. \vspace*{0.04in}
  284. \hspace*{0.1in}
  285. \begin{tabular}{l l l}
  286. square\_size &:-& a positive integer.
  287. \end{tabular}
  288. {\bf Synopsis:} %{\bf What it does:}
  289. \begin{addtolength}{\leftskip}{0.22in}
  290. {\tt band\_matrix} creates a square matrix of dimension
  291. square\_size. The diagonal consists of the middle expr
  292. of the expr\_list. The exprs to the left of this fill
  293. the required number of sub\_diagonals and the exprs
  294. to the right the super\_diagonals.
  295. \end{addtolength}
  296. {\bf Examples:}
  297. \begin{flushleft}
  298. \hspace*{0.1in}
  299. \begin{math}
  300. \begin{array}{ccc}
  301. {\tt band\_matrix}(\{x,y,z\},6) & = &
  302. \left( \begin{array}{cccccc} y & z & 0 & 0 & 0 & 0 \\ x & y & z & 0 & 0
  303. & 0 \\ 0 & x & y & z & 0 & 0 \\ 0 & 0 & x & y & z & 0 \\ 0 & 0 & 0 & x &
  304. y & z \\ 0 & 0 & 0 & 0 & x & y
  305. \end{array} \right)
  306. \end{array}
  307. \end{math}
  308. \end{flushleft}
  309. {\bf Related functions:}
  310. \hspace*{0.175in} {\tt diagonal}.
  311. \subsection{block\_matrix}
  312. %{\bf How to use it:}
  313. \hspace*{0.175in} {\tt block\_matrix(r,c,matrix\_list);}
  314. \hspace*{0.1in}
  315. \begin{tabular}{l l l}
  316. r,c &:-& positive integers. \\
  317. matrix\_list &:-& a list of matrices.
  318. \end{tabular}
  319. {\bf Synopsis:} %{\bf What it does:}
  320. \begin{addtolength}{\leftskip}{0.22in}
  321. {\tt block\_matrix} creates a matrix that consists of r by c matrices
  322. filled from the matrix\_list row wise.
  323. \end{addtolength}
  324. {\bf Examples:}
  325. \begin{flushleft}
  326. \hspace*{0.1in}
  327. \begin{math}
  328. \begin{array}{ccc}
  329. {\cal B} = \left( \begin{array}{cc} 1 & 0 \\ 0 & 1
  330. \end{array} \right), &
  331. {\cal C} = \left( \begin{array}{c} 5 \\ 5
  332. \end{array} \right), &
  333. {\cal D} = \left( \begin{array}{cc} 22 & 33 \\ 44 & 55
  334. \end{array} \right)
  335. \end{array}
  336. \end{math}
  337. \end{flushleft}
  338. \vspace*{0.175in}
  339. \begin{flushleft}
  340. \hspace*{0.1in}
  341. \begin{math}
  342. \begin{array}{ccc}
  343. {\tt block\_matrix}(2,3,\{{\cal B,C,D,D,C,B}\}) & = &
  344. \left( \begin{array}{ccccc} 1 & 0 & 5 & 22 & 33 \\ 0 & 1 & 5 & 44 & 55
  345. \\
  346. 22 & 33 & 5 & 1 & 0 \\ 44 & 55 & 5 & 0 & 1
  347. \end{array} \right)
  348. \end{array}
  349. \end{math}
  350. \end{flushleft}
  351. \subsection{char\_matrix}
  352. %{\bf How to use it:}
  353. \hspace*{0.175in} {\tt char\_matrix(${\cal A},\lambda$);}
  354. \hspace*{0.1in}
  355. \begin{tabular}{l l l}
  356. ${\cal A}$ &:-& a square matrix. \\
  357. $\lambda$ &:-& a symbol or algebraic expression.
  358. \end{tabular}
  359. {\bf Synopsis:} %{\bf What it does:}
  360. \begin{addtolength}{\leftskip}{0.22in}
  361. {\tt char\_matrix} creates the characteristic matrix ${\cal C}$ of
  362. ${\cal A}$.
  363. This is ${\cal C} = \lambda * {\cal I} - {\cal A}$.
  364. \end{addtolength}
  365. {\bf Examples:}
  366. \begin{flushleft}
  367. \hspace*{0.1in}
  368. \begin{math}
  369. \begin{array}{ccc}
  370. {\tt char\_matrix}({\cal A},x) & = &
  371. \left( \begin{array}{ccc} x-1 & -2 & -3 \\ -4 & x-5 & -6 \\ -7 & -8 &
  372. x-9
  373. \end{array} \right)
  374. \end{array}
  375. \end{math}
  376. \end{flushleft}
  377. {\bf Related functions:}
  378. \hspace*{0.175in} {\tt char\_poly}.
  379. \subsection{char\_poly}
  380. %{\bf How to use it:}
  381. \hspace*{0.175in} {\tt char\_poly(${\cal A},\lambda$);}
  382. \hspace*{0.1in}
  383. \begin{tabular}{l l l}
  384. ${\cal A}$ &:-& a square matrix. \\
  385. $\lambda$ &:-& a symbol or algebraic expression.
  386. \end{tabular}
  387. {\bf Synopsis:} %{\bf What it does:}
  388. \begin{addtolength}{\leftskip}{0.22in}
  389. {\tt char\_poly} finds the characteristic polynomial of
  390. ${\cal A}$.
  391. This is the determinant of $\lambda * {\cal I} - {\cal A}$.
  392. \end{addtolength}
  393. {\bf Examples:}
  394. \hspace*{0.175in}
  395. {\tt char\_poly({\cal A},$x$) $= x^3-15*x^2-18*x$}
  396. {\bf Related functions:}
  397. \hspace*{0.175in} {\tt char\_matrix}.
  398. \subsection{cholesky}
  399. %{\bf How to use it:}
  400. \hspace*{0.175in} {\tt cholesky(${\cal A}$);}
  401. \hspace*{0.1in}
  402. \begin{tabular}{l l l}
  403. ${\cal A}$ &:-& a positive definite matrix containing numeric entries.
  404. \end{tabular}
  405. {\bf Synopsis:} %{\bf What it does:}
  406. \begin{addtolength}{\leftskip}{0.22in}
  407. {\tt cholesky} computes the cholesky decomposition of ${\cal A}$.
  408. It returns \{${\cal L,U}$\} where ${\cal L}$
  409. is a lower matrix, ${\cal U}$ is an upper matrix, \\ ${\cal A} =
  410. {\cal LU}$, and ${\cal U} = {\cal L}^T$.
  411. \end{addtolength}
  412. {\bf Examples:}
  413. \begin{flushleft}
  414. \hspace*{0.175in}
  415. \begin{math}
  416. {\cal F} = \left( \begin{array}{ccc} 1 & 1 & 0 \\ 1 & 3 & 1 \\ 0 & 1 &
  417. 1
  418. \end{array} \right)
  419. \end{math}
  420. \end{flushleft}
  421. \begin{flushleft}
  422. \hspace*{0.1in}
  423. \begin{math}
  424. \begin{array}{ccc}
  425. ${\tt cholesky}$({\cal F}) & = &
  426. \left\{ \left( \begin{array}{ccc} 1 & 0 & 0 \\ 1 & \sqrt{2} & 0 \\
  427. 0 & \frac{1}{\sqrt{2}} & \frac{1}{\sqrt{2}} \end{array} \right), \left(
  428. \begin{array}{ccc} 1 & 1 & 0 \\ 0 & \sqrt{2} & \frac{1}{\sqrt{2}} \\ 0
  429. & 0 & \frac{1}{\sqrt{2}} \end{array} \right)
  430. \right\} \end{array}
  431. \end{math}
  432. \end{flushleft}
  433. {\bf Related functions:}
  434. \hspace*{0.175in} {\tt lu\_decom}.
  435. \subsection{coeff\_matrix}
  436. %{\bf How to use it:}
  437. \hspace*{0.175in} {\tt coeff\_matrix(\{\lineqlist{}\});}
  438. \lazyfootnote{}
  439. \hspace*{0.1in}
  440. \begin{tabular}{l l l}
  441. \lineqlist &:-& \parbox[t]{.435\linewidth}{linear equations. Can be
  442. of the form {\it equation $=$ number} or just {\it equation}.}
  443. \end{tabular}
  444. {\bf Synopsis:} %{\bf What it does:}
  445. \begin{addtolength}{\leftskip}{0.22in}
  446. {\tt coeff\_matrix} creates the coefficient matrix
  447. ${\cal C}$ of the linear equations.
  448. It returns \{${\cal C,X,B}$\} such that ${\cal CX} = {\cal B}$.
  449. \end{addtolength}
  450. {\bf Examples:}
  451. \begin{math}
  452. \hspace*{0.175in}
  453. {\tt coeff\_matrix}(\{x+y+4*z=10,y+x-z=20,x+y+4\}) =
  454. \end{math}
  455. \vspace*{0.1in}
  456. \begin{flushleft}
  457. \hspace*{0.175in}
  458. \begin{math}
  459. \left\{ \left( \begin{array}{ccc} 4 & 1 & 1 \\ -1 & 1 & 1 \\ 0 & 1 & 1
  460. \end{array} \right), \left( \begin{array}{c} z \\ y \\ x \end{array}
  461. \right), \left( \begin{array}{c} 10 \\ 20 \\ -4
  462. \end{array} \right) \right\}
  463. \end{math}
  464. \end{flushleft}
  465. \subsection{column\_dim, row\_dim}
  466. %{\bf How to use it:}
  467. \hspace*{0.175in} {\tt column\_dim(${\cal A}$);}
  468. \hspace*{0.1in}
  469. \begin{tabular}{l l l}
  470. ${\cal A}$ &:-& a matrix.
  471. \end{tabular}
  472. {\bf Synopsis:} %{\bf What it does:}
  473. \hspace*{0.175in} {\tt column\_dim} finds the column dimension of
  474. ${\cal A}$.
  475. \hspace*{0.175in} {\tt row\_dim} finds the row dimension of ${\cal A}$.
  476. {\bf Examples:}
  477. \hspace*{0.175in}
  478. {\tt column\_dim}(${\cal A}$) = 3
  479. \subsection{companion}
  480. %{\bf How to use it:}
  481. \hspace*{0.175in} {\tt companion(poly,x);}
  482. \hspace*{0.1in}
  483. \begin{tabular}{l l l}
  484. poly &:-& a monic univariate polynomial in x. \\
  485. x &:-& the variable.
  486. \end{tabular}
  487. {\bf Synopsis:} %{\bf What it does:}
  488. \begin{addtolength}{\leftskip}{0.22in}
  489. {\tt companion} creates the companion matrix ${\cal C}$
  490. of poly.
  491. This is the square matrix of dimension n, where n is the degree of poly
  492. w.r.t. x.
  493. The entries of ${\cal C}$ are:
  494. ${\cal C}$(i,n) = -coeffn(poly,x,i-1) for i = 1
  495. \ldots n, ${\cal C}$(i,i-1) = 1 for i = 2 \ldots n and
  496. the rest are 0.
  497. \end{addtolength}
  498. {\bf Examples:}
  499. \begin{flushleft}
  500. \hspace*{0.1in}
  501. \begin{math}
  502. \begin{array}{ccc}
  503. {\tt companion}(x^4+17*x^3-9*x^2+11,x) & = &
  504. \left( \begin{array}{cccc} 0 & 0 & 0 & -11 \\ 1 & 0 & 0 & 0 \\
  505. 0 & 1 & 0 & 9 \\ 0 & 0 & 1 & -17
  506. \end{array} \right)
  507. \end{array}
  508. \end{math}
  509. \end{flushleft}
  510. {\bf Related functions:}
  511. \hspace*{0.175in} {\tt find\_companion}.
  512. \subsection{copy\_into}
  513. %{\bf How to use it:}
  514. \hspace*{0.175in} {\tt copy\_into(${\cal A,B}$,r,c);}
  515. \hspace*{0.1in}
  516. \begin{tabular}{l l l}
  517. ${\cal A,B}$ &:-& matrices. \\
  518. r,c &:-& positive integers.
  519. \end{tabular}
  520. {\bf Synopsis:} %{\bf What it does:}
  521. \hspace*{0.175in} {\tt copy\_into} copies matrix ${\cal A}$ into
  522. ${\cal B}$ with ${\cal A}$(1,1) at ${\cal B}$(r,c).
  523. {\bf Examples:}
  524. \begin{flushleft}
  525. \hspace*{0.175in}
  526. \begin{math}
  527. {\cal G} = \left( \begin{array}{cccc} 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 \\
  528. 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0
  529. \end{array} \right)
  530. \end{math}
  531. \end{flushleft}
  532. \begin{flushleft}
  533. \hspace*{0.1in}
  534. \begin{math}
  535. \begin{array}{ccc}
  536. {\tt copy\_into}({\cal A,G},1,2) & = &
  537. \left( \begin{array}{cccc} 0 & 1 & 2 & 3 \\ 0 & 4 & 5 & 6 \\ 0 & 7 & 8
  538. & 9 \\ 0 & 0 & 0 & 0
  539. \end{array} \right)
  540. \end{array}
  541. \end{math}
  542. \end{flushleft}
  543. {\bf Related functions:}
  544. \begin{addtolength}{\leftskip}{0.22in}
  545. {\tt augment\_columns}, {\tt extend}, {\tt matrix\_augment},
  546. {\tt matrix\_stack}, {\tt stack\_rows}, {\tt sub\_matrix}.
  547. \end{addtolength}
  548. \subsection{diagonal}
  549. %{\bf How to use it:}
  550. \hspace*{0.175in} {\tt diagonal(\{\matlist{}\});}\lazyfootnote{}
  551. \hspace*{0.1in}
  552. \begin{tabular}{l l l}
  553. \matlist &:-& \parbox[t]{.58\linewidth}{each can be either a scalar
  554. expr or a square matrix. }
  555. \end{tabular}
  556. {\bf Synopsis:} %{\bf What it does:}
  557. \hspace*{0.175in} {\tt diagonal} creates a matrix that contains the
  558. input on the diagonal.
  559. {\bf Examples:}
  560. \begin{flushleft}
  561. \hspace*{0.175in}
  562. \begin{math}
  563. {\cal H} = \left( \begin{array}{cc} 66 & 77 \\ 88 & 99
  564. \end{array} \right)
  565. \end{math}
  566. \end{flushleft}
  567. \begin{flushleft}
  568. \hspace*{0.1in}
  569. \begin{math}
  570. \begin{array}{ccc}
  571. {\tt diagonal}(\{{\cal A},x,{\cal H}\}) & = &
  572. \left( \begin{array}{cccccc} 1 & 2 & 3 & 0 & 0 & 0 \\ 4 & 5 & 6 & 0 & 0
  573. & 0 \\ 7 & 8 & 9 & 0 & 0 & 0 \\ 0 & 0 & 0 & x & 0 & 0 \\ 0 & 0 & 0 & 0
  574. & 66 & 77 \\ 0 & 0 & 0 & 0 & 88 & 99
  575. \end{array} \right)
  576. \end{array}
  577. \end{math}
  578. \end{flushleft}
  579. {\bf Related functions:}
  580. \hspace*{0.175in} {\tt jordan\_block}.
  581. \subsection{extend}
  582. %{\bf How to use it:}
  583. \hspace*{0.175in} {\tt extend(${\cal A}$,r,c,expr);}
  584. \hspace*{0.1in}
  585. \begin{tabular}{l l l}
  586. ${\cal A}$ &:-& a matrix. \\
  587. r,c &:-& positive integers. \\
  588. expr &:-& algebraic expression or symbol.
  589. \end{tabular}
  590. {\bf Synopsis:} %{\bf What it does:}
  591. \begin{addtolength}{\leftskip}{0.22in}
  592. {\tt extend} returns a copy of ${\cal A}$ that has been
  593. extended by r rows and c columns. The new entries are
  594. made equal to expr.
  595. \end{addtolength}
  596. {\bf Examples:}
  597. \begin{flushleft}
  598. \hspace*{0.1in}
  599. \begin{math}
  600. \begin{array}{ccc}
  601. {\tt extend}({\cal A},1,2,x) & = &
  602. \left( \begin{array}{ccccc} 1 & 2 & 3 & x & x \\ 4 & 5 & 6 & x & x
  603. \\ 7 & 8 & 9 & x & x \\ x & x & x & x & x
  604. \end{array} \right)
  605. \end{array}
  606. \end{math}
  607. \end{flushleft}
  608. {\bf Related functions:}
  609. \begin{addtolength}{\leftskip}{0.22in}
  610. \parbox[t]{0.95\linewidth}{{\tt copy\_into}, {\tt matrix\_augment},
  611. {\tt matrix\_stack}, {\tt remove\_columns}, {\tt remove\_rows}.}
  612. \end{addtolength}
  613. \subsection{find\_companion}
  614. \hspace*{0.175in} {\tt find\_companion(${\cal A}$,x);}
  615. \hspace*{0.1in}
  616. \begin{tabular}{l l l}
  617. ${\cal A}$ &:-& a matrix. \\
  618. x &:-& the variable.
  619. \end{tabular}
  620. {\bf Synopsis:}
  621. \begin{addtolength}{\leftskip}{0.22in}
  622. Given a companion matrix, {\tt find\_companion} finds the polynomial
  623. from which it was made.
  624. \end{addtolength}
  625. {\bf Examples:}
  626. \begin{flushleft}
  627. \hspace*{0.175in}
  628. \begin{math}
  629. {\cal C} = \left( \begin{array}{cccc} 0 & 0 & 0 & -11 \\ 1 & 0 & 0 & 0
  630. \\ 0 & 1 & 0 & 9 \\ 0 & 0 & 1 & -17
  631. \end{array} \right)
  632. \end{math}
  633. \end{flushleft}
  634. \vspace*{3mm}
  635. \begin{flushleft}
  636. \hspace*{0.175in}
  637. \begin{math}
  638. {\tt find\_companion}({\cal C},x) = x^4+17*x^3-9*x^2+11
  639. \end{math}
  640. \end{flushleft}
  641. \vspace*{3mm}
  642. {\bf Related functions:}
  643. \hspace*{0.175in} {\tt companion}.
  644. \subsection{get\_columns, get\_rows}
  645. %{\bf How to use it:}
  646. \hspace*{0.175in} {\tt get\_columns(${\cal A}$,column\_list);}
  647. \hspace*{0.1in}
  648. \begin{tabular}{l l l}
  649. ${\cal A}$ &:-& a matrix. \\
  650. c &:-& either a positive integer or a list of positive
  651. integers.
  652. \end{tabular}
  653. {\bf Synopsis:} %{\bf What it does:}
  654. \begin{addtolength}{\leftskip}{0.22in}
  655. {\tt get\_columns} removes the columns of ${\cal A}$ specified in
  656. column\_list and returns them as a list of column
  657. matrices.
  658. \end{addtolength}
  659. \hspace*{0.175in} {\tt get\_rows} performs the same task on the rows of
  660. ${\cal A}$.
  661. {\bf Examples:}
  662. \begin{flushleft}
  663. \hspace*{0.1in}
  664. \begin{math}
  665. \begin{array}{ccc}
  666. {\tt get\_columns}({\cal A},\{1,3\}) & = &
  667. \left\{
  668. \left( \begin{array}{c} 1 \\ 4 \\ 7 \end{array} \right),
  669. \left( \begin{array}{c} 3 \\ 6 \\ 9 \end{array} \right)
  670. \right\}
  671. \end{array}
  672. \end{math}
  673. \end{flushleft}
  674. \vspace*{0.1in}
  675. \begin{flushleft}
  676. \hspace*{0.1in}
  677. \begin{math}
  678. \begin{array}{ccc}
  679. {\tt get\_rows}({\cal A},2) & = &
  680. \left\{
  681. \left( \begin{array}{ccc} 4 & 5 & 6 \end{array} \right)
  682. \right\}
  683. \end{array}
  684. \end{math}
  685. \end{flushleft}
  686. {\bf Related functions:}
  687. \hspace*{0.175in} {\tt augment\_columns}, {\tt stack\_rows},
  688. {\tt sub\_matrix}.
  689. \subsection{get\_rows}
  690. \hspace*{0.175in} see: {\tt get\_columns}.
  691. \subsection{gram\_schmidt}
  692. %{\bf How to use it:}
  693. \hspace*{0.175in} {\tt gram\_schmidt(\{\veclist{}\});} \lazyfootnote{}
  694. \hspace*{0.1in}
  695. \begin{tabular}{l l l}
  696. \veclist &:-& \parbox[t]{.62\linewidth}{linearly independent vectors.
  697. Each vector must be written as a list,
  698. eg:\{1,0,0\}. }
  699. \end{tabular}
  700. {\bf Synopsis:} %{\bf What it does:}
  701. \begin{addtolength}{\leftskip}{0.22in}
  702. {\tt gram\_schmidt} performs the gram\_schmidt
  703. orthonormalisation on the input vectors.
  704. It returns a list of orthogonal normalised vectors.
  705. \end{addtolength}
  706. {\bf Examples:}
  707. \hspace*{0.175in}
  708. {\tt gram\_schmidt(\{\{1,0,0\},\{1,1,0\},\{1,1,1\}\})} =
  709. \{\{1,0,0\},\{0,1,0\},\{0,0,1\}\}
  710. \hspace*{0.175in}
  711. {\tt gram\_schmidt(\{\{1,2\},\{3,4\}\})} $=
  712. \{\{ \frac{1}{{\sqrt{5}}} , \frac{2}{\sqrt{5}} \},
  713. \{ \frac{2*\sqrt{5}}{5} , \frac{-\sqrt{5}}{5} \}\}$
  714. \subsection{hermitian\_tp}
  715. %{\bf How to use it:}
  716. \hspace*{0.175in} {\tt hermitian\_tp(${\cal A}$);}
  717. \hspace*{0.1in}
  718. \begin{tabular}{l l l}
  719. ${\cal A}$ &:-& a matrix.
  720. \end{tabular}
  721. {\bf Synopsis:} %{\bf What it does:}
  722. \begin{addtolength}{\leftskip}{0.22in}
  723. {\tt hermitian\_tp} computes the hermitian transpose of
  724. ${\cal A}$.
  725. This is a matrix in which the (i,$\,$j)'th entry is the conjugate of
  726. the (j,$\,$i)'th entry of ${\cal A}$.
  727. \end{addtolength}
  728. {\bf Examples:}
  729. \begin{flushleft}
  730. \hspace*{0.175in}
  731. \begin{math}
  732. {\cal J} = \left( \begin{array}{ccc} i+1 & i+2 & i+3 \\ 4 & 5 & 2 \\ 1 &
  733. i & 0
  734. \end{array} \right)
  735. \end{math}
  736. \end{flushleft}
  737. \vspace*{0.1in}
  738. \begin{flushleft}
  739. \hspace*{0.1in}
  740. \begin{math}
  741. \begin{array}{ccc}
  742. {\tt hermitian\_tp}({\cal J}) & = &
  743. \left( \begin{array}{ccc} -i+1 & 4 & 1 \\ -i+2 & 5 & -i \\-i+3 & 2 & 0
  744. \end{array} \right)
  745. \end{array}
  746. \end{math}
  747. \end{flushleft}
  748. {\bf Related functions:}
  749. \hspace*{0.175in} {\tt tp}\footnote{standard reduce call for the
  750. transpose of a matrix - see {\REDUCE} User's Manual[2].}.
  751. \subsection{hessian}
  752. %{\bf How to use it:}
  753. \hspace*{0.175in} {\tt hessian(expr,variable\_list);}
  754. \hspace*{0.1in}
  755. \begin{tabular}{l l l}
  756. expr &:-& a scalar expression. \\
  757. variable\_list &:-& either a single variable or a list of variables.
  758. \end{tabular}
  759. {\bf Synopsis:} %{\bf What it does:}
  760. \begin{addtolength}{\leftskip}{0.22in}
  761. {\tt hessian} computes the hessian matrix of expr w.r.t.
  762. the varibles in variable\_list.
  763. This is an n by n matrix
  764. where n is the number of variables and the (i,$\,$j)'th
  765. entry is df(expr,variable\_list(i),variable\_list(j)).
  766. \end{addtolength}
  767. {\bf Examples:}
  768. \begin{flushleft}
  769. \hspace*{0.1in}
  770. \begin{math}
  771. \begin{array}{ccc}
  772. {\tt hessian}(x*y*z+x^2,\{w,x,y,z\}) & = &
  773. \left( \begin{array}{cccc} 0 & 0 & 0 & 0 \\ 0 & 2 & z & y \\ 0 & z & 0
  774. & x \\ 0 & y & x & 0
  775. \end{array} \right)
  776. \end{array}
  777. \end{math}
  778. \end{flushleft}
  779. {\bf Related functions:}
  780. \hspace*{0.175in} {\tt df}\footnote{standard reduce call for
  781. differentiation - see {\REDUCE} User's Manual[2]}.
  782. \subsection{hilbert}
  783. %{\bf How to use it:}
  784. \hspace*{0.175in} {\tt hilbert(square\_size,expr);}
  785. \hspace*{0.1in}
  786. \begin{tabular}{l l l}
  787. square\_size &:-& a positive integer. \\
  788. expr &:-& an algebraic expression.
  789. \end{tabular}
  790. {\bf Synopsis:} %{\bf What it does:}
  791. \begin{addtolength}{\leftskip}{0.22in}
  792. {\tt hilbert} computes the square hilbert matrix of
  793. dimension square\_size.
  794. This is the symmetric matrix in
  795. which the (i,$\,$j)'th entry is 1/(i+j-expr).
  796. \end{addtolength}
  797. {\bf Examples:}
  798. \begin{flushleft}
  799. \hspace*{0.1in}
  800. \begin{math}
  801. \begin{array}{ccc}
  802. {\tt hilbert}(3,y+x) & = &
  803. \left( \begin{array}{ccc} \frac{-1}{x+y-2} & \frac{-1}{x+y-3}
  804. & \frac{-1}{x+y-4} \\ \frac{-1}{x+y-3} & \frac{-1}{x+y-4} &
  805. \frac{-1}{x+y-5} \\ \frac{-1}{x+y-4} & \frac{-1}{x+y-5} &
  806. \frac{-1}{x+y-6}
  807. \end{array} \right)
  808. \end{array}
  809. \end{math}
  810. \end{flushleft}
  811. \subsection{jacobian}
  812. %{\bf How to use it:}
  813. \hspace*{0.175in} {\tt jacobian(expr\_list,variable\_list);}
  814. \hspace*{0.1in}
  815. \begin{tabular}{l l l}
  816. expr\_list \hspace*{0.175in} &:-& \parbox[t]{.72\linewidth}{either a
  817. single algebraic expression or a list of algebraic expressions.}
  818. \end{tabular}
  819. \vspace*{0.04in}
  820. \hspace*{0.1in}
  821. \begin{tabular}{l l l}
  822. variable\_list &:-& either a single variable or a list of variables.
  823. \end{tabular}
  824. {\bf Synopsis:} %{\bf What it does:}
  825. \begin{addtolength}{\leftskip}{0.22in}
  826. {\tt jacobian} computes the jacobian matrix of expr\_list w.r.t.
  827. variable\_list.
  828. This is a matrix whose (i,$\,$j)'th entry is df(expr\_list(i),
  829. variable\_list(j)).
  830. The matrix is n by m where n is the
  831. number of variables and m the number of expressions.
  832. \end{addtolength}
  833. {\bf Examples:}
  834. \hspace*{0.175in}
  835. {\tt jacobian(\{$x^4,x*y^2,x*y*z^3$\},\{$w,x,y,z$\})} =
  836. \vspace*{0.1in}
  837. \begin{flushleft}
  838. \hspace*{0.175in}
  839. \begin{math}
  840. \left( \begin{array}{cccc} 0 & 4*x^3 & 0 & 0 \\ 0 & y^2 & 2*x*y & 0 \\
  841. 0 & y*z^3 & x*z^3 & 3*x*y*z^2
  842. \end{array} \right)
  843. \end{math}
  844. \end{flushleft}
  845. {\bf Related functions:}
  846. \hspace*{0.175in} {\tt hessian}, {\tt df}\footnote{standard reduce call
  847. for differentiation - see {\REDUCE} User's Manual[2].}.
  848. \subsection{jordan\_block}
  849. %{\bf How to use it:}
  850. \hspace*{0.175in} {\tt jordan\_block(expr,square\_size);}
  851. \hspace*{0.1in}
  852. \begin{tabular}{l l l}
  853. expr &:-& an algebraic expression or symbol. \\
  854. square\_size &:-& a positive integer.
  855. \end{tabular}
  856. {\bf Synopsis:} %{\bf What it does:}
  857. \begin{addtolength}{\leftskip}{0.22in}
  858. {\tt jordan\_block} computes the square jordan block matrix ${\cal J}$
  859. of dimension square\_size.
  860. The entries of ${\cal J}$ are:
  861. ${\cal J}$(i,i) = expr for i=1
  862. \ldots n, ${\cal J}$(i,i+1) = 1 for i=1
  863. \ldots n-1, and all other entries are 0.
  864. \end{addtolength}
  865. {\bf Examples:}
  866. \begin{flushleft}
  867. \hspace*{0.1in}
  868. \begin{math}
  869. \begin{array}{ccc}
  870. {\tt jordan\_block(x,5)} & = &
  871. \left( \begin{array}{ccccc} x & 1 & 0 & 0 & 0 \\ 0 & x & 1 & 0 & 0 \\ 0
  872. & 0 & x & 1 & 0 \\ 0 & 0 & 0 & x & 1 \\ 0 & 0 & 0 & 0 & x
  873. \end{array} \right)
  874. \end{array}
  875. \end{math}
  876. \end{flushleft}
  877. {\bf Related functions:}
  878. \hspace*{0.175in} {\tt diagonal}, {\tt companion}.
  879. \subsection{lu\_decom}
  880. %{\bf How to use it:}
  881. \hspace*{0.175in} {\tt lu\_decom(${\cal A}$);}
  882. \hspace*{0.1in}
  883. \begin{tabular}{l l l}
  884. ${\cal A}$ &:-& \parbox[t]{.848\linewidth}{a matrix containing either
  885. numeric entries or imaginary entries with numeric coefficients.}
  886. \end{tabular}
  887. {\bf Synopsis:} %{\bf What it does:}
  888. \begin{addtolength}{\leftskip}{0.22in}
  889. {\tt lu\_decom} performs LU decomposition on ${\cal A}$,
  890. ie: it returns \{${\cal L,U}$\} where ${\cal L}$
  891. is a lower diagonal matrix, ${\cal U}$ an upper diagonal
  892. matrix and ${\cal A} = {\cal LU}$.
  893. \end{addtolength}
  894. {\bf caution:}
  895. \begin{addtolength}{\leftskip}{0.22in}
  896. The algorithm used can swap the rows of ${\cal A}$
  897. during the calculation. This means that ${\cal LU}$ does
  898. not equal ${\cal A}$ but a row equivalent of it. Due to
  899. this, {\tt lu\_decom} returns \{${\cal L,U}$,vec\}. The
  900. call {\tt convert(${\cal A}$,vec)} will return the
  901. matrix that has been decomposed, ie: ${\cal LU} = $
  902. {\tt convert(${\cal A}$,vec)}.
  903. \end{addtolength}
  904. {\bf Examples:}
  905. \begin{flushleft}
  906. \hspace*{0.175in}
  907. \begin{math}
  908. {\cal K} = \left( \begin{array}{ccc} 1 & 3 & 5 \\ -4 & 3 & 7 \\ 8 & 6 &
  909. 4
  910. \end{array} \right)
  911. \end{math}
  912. \end{flushleft}
  913. \begin{flushleft}
  914. \hspace*{0.1in}
  915. \begin{math}
  916. \begin{array}{cccc}
  917. ${\tt lu} := {\tt lu\_decom}$({\cal K}) & = &
  918. \left\{
  919. \left( \begin{array}{ccc} 8 & 0 & 0 \\ -4 & 6 & 0 \\ 1 & 2.25 &
  920. 1.125 1 \end{array} \right),
  921. \left( \begin{array}{ccc} 1 & 0.75 & 0.5 \\ 0 & 1 & 1.5 \\ 0 &
  922. 0 & 1 \end{array} \right),
  923. [\; 3 \; 2 \; 3 \; ]
  924. \right\}
  925. \end{array}
  926. \end{math}
  927. \end{flushleft}
  928. \vspace*{0.1in}
  929. \begin{flushleft}
  930. \hspace*{0.1in}
  931. \begin{math}
  932. \begin{array}{ccc}
  933. ${\tt first lu * second lu}$ & = &
  934. \left( \begin{array}{ccc} 8 & 6 & 4 \\ -4 & 3 & 7 \\ 1 & 3 & 5
  935. \end{array} \right)
  936. \end{array}
  937. \end{math}
  938. \end{flushleft}
  939. \begin{flushleft}
  940. \hspace*{0.1in}
  941. \begin{math}
  942. \begin{array}{ccc}
  943. ${\tt convert(${\cal K}$,third lu}$) \hspace*{0.055in} & = &
  944. \left( \begin{array}{ccc} 8 & 6 & 4 \\ -4 & 3 & 7 \\ 1 & 3 & 5
  945. \end{array} \right)
  946. \end{array}
  947. \end{math}
  948. \end{flushleft}
  949. \vspace*{0.5in}
  950. \begin{flushleft}
  951. \hspace*{0.175in}
  952. \begin{math}
  953. {\cal P} = \left( \begin{array}{ccc} i+1 & i+2 & i+3 \\ 4 & 5 & 2 \\ 1
  954. & i & 0
  955. \end{array} \right)
  956. \end{math}
  957. \end{flushleft}
  958. \begin{eqnarray}
  959. \hspace*{0.22in}
  960. {\tt lu} := {\tt lu\_decom}({\cal P}) & = &
  961. \left\{
  962. \left( \begin{array}{ccc} 1 & 0 & 0 \\ 4 & -4*i+5 & 0 \\ i+1 &
  963. 3 & 0.41463*i+2.26829 \end{array} \right), \right. \nonumber \\ & &
  964. \left. \: \; \, \left( \begin{array}{ccc} 1 & i & 0 \\ 0 & 1 &
  965. 0.19512*i+0.24390 \\ 0 & 0 & 1 \end{array} \right), \hspace*{0.05in}
  966. [\; 3 \; 2 \; 3 \;] \hspace*{0.05in}
  967. \right\} \nonumber
  968. \end{eqnarray}
  969. \vspace*{0.1in}
  970. \begin{flushleft}
  971. \hspace*{0.1in}
  972. \begin{math}
  973. \begin{array}{ccc}
  974. ${\tt first lu * second lu}$ & = &
  975. \left( \begin{array}{ccc} 1 & i & 0 \\ 4 & 5 & 2 \\ i+1 & i+2 &
  976. i+3
  977. \end{array} \right)
  978. \end{array}
  979. \end{math}
  980. \end{flushleft}
  981. \begin{flushleft}
  982. \hspace*{0.1in}
  983. \begin{math}
  984. \begin{array}{ccc}
  985. ${\tt convert({\cal P},third lu}$) \hspace*{0.1in} & = & \left(
  986. \begin{array}{c c c} 1 & i & 0 \\ 4 & 5 & 2 \\ i+1 & i+2 & i+3
  987. \end{array} \right)
  988. \end{array}
  989. \end{math}
  990. \end{flushleft}
  991. {\bf Related functions:}
  992. \hspace*{0.175in} {\tt cholesky}.
  993. \subsection{make\_identity}
  994. %{\bf How to use it:}
  995. \hspace*{0.175in} {\tt make\_identity(square\_size);}
  996. \hspace*{0.1in}
  997. \begin{tabular}{l l l}
  998. square\_size &:-& a positive integer.
  999. \end{tabular}
  1000. {\bf Synopsis:} %{\bf What it does:}
  1001. \hspace*{0.175in} {\tt make\_identity} creates the identity matrix of
  1002. dimension square\_size.
  1003. {\bf Examples:}
  1004. \begin{flushleft}
  1005. \hspace*{0.1in}
  1006. \begin{math}
  1007. \begin{array}{ccc}
  1008. {\tt make\_identity}(4) & = &
  1009. \left( \begin{array}{cccc} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0
  1010. & 0 & 1 & 0 \\ 0 & 0 & 0 & 1
  1011. \end{array} \right)
  1012. \end{array}
  1013. \end{math}
  1014. \end{flushleft}
  1015. {\bf Related functions:}
  1016. \hspace*{0.175in} {\tt diagonal}.
  1017. \subsection{matrix\_augment, matrix\_stack}
  1018. %{\bf How to use it:}
  1019. \hspace*{0.175in} {\tt matrix\_augment(\{\matlist\});}\lazyfootnote{}
  1020. \hspace*{0.1in}
  1021. \begin{tabular}{l l l}
  1022. \matlist &:-& matrices.
  1023. \end{tabular}
  1024. {\bf Synopsis:} %{\bf What it does:}
  1025. \hspace*{0.175in} {\tt matrix\_augment} sticks the matrices in
  1026. matrix\_list together horizontally.
  1027. \hspace*{0.175in}
  1028. {\tt matrix\_stack} sticks the matrices in matrix\_list
  1029. together vertically.
  1030. {\bf Examples:}
  1031. \begin{flushleft}
  1032. \hspace*{0.1in}
  1033. \begin{math}
  1034. \begin{array}{ccc}
  1035. {\tt matrix\_augment}(\{{\cal A,A}\}) & = &
  1036. \left( \begin{array}{cccccc} 1 & 2 & 3 & 1 & 2 & 3 \\ 4 & 4 & 6
  1037. & 4 & 5 & 6 \\ 7 & 8 & 9 & 7 & 8 & 9
  1038. \end{array} \right)
  1039. \end{array}
  1040. \end{math}
  1041. \end{flushleft}
  1042. \vspace*{0.1in}
  1043. \begin{flushleft}
  1044. \hspace*{0.1in}
  1045. \begin{math}
  1046. \begin{array}{ccc}
  1047. {\tt matrix\_stack}(\{{\cal A,A}\}) & = &
  1048. \left( \begin{array}{ccc} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9
  1049. \\ 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9
  1050. \end{array} \right)
  1051. \end{array}
  1052. \end{math}
  1053. \end{flushleft}
  1054. {\bf Related functions:}
  1055. \hspace*{0.175in} {\tt augment\_columns}, {\tt stack\_rows},
  1056. {\tt sub\_matrix}.
  1057. \subsection{matrixp}
  1058. %{\bf How to use it:}
  1059. \hspace*{0.175in} {\tt matrixp(test\_input);}
  1060. \hspace*{0.1in}
  1061. \begin{tabular}{l l l}
  1062. test\_input &:-& anything you like.
  1063. \end{tabular}
  1064. {\bf Synopsis:} %{\bf What it does:}
  1065. \begin{addtolength}{\leftskip}{0.22in}
  1066. {\tt matrixp} is a boolean function that returns t if
  1067. the input is a matrix and nil otherwise.
  1068. \end{addtolength}
  1069. {\bf Examples:}
  1070. \hspace*{0.175in} {\tt matrixp}(${\cal A}$) = t
  1071. \hspace*{0.175in} {\tt matrixp}(doodlesackbanana) = nil
  1072. {\bf Related functions:}
  1073. \hspace*{0.175in} {\tt squarep}, {\tt symmetricp}.
  1074. \subsection{matrix\_stack}
  1075. \hspace*{0.175in} see: {\tt matrix\_augment}.
  1076. \subsection{minor}
  1077. %{\bf How to use it:}
  1078. \hspace*{0.175in} {\tt minor(${\cal A}$,r,c);}
  1079. \hspace*{0.1in}
  1080. \begin{tabular}{l l l}
  1081. ${\cal A}$ &:-& a matrix. \\
  1082. r,c &:-& positive integers.
  1083. \end{tabular}
  1084. {\bf Synopsis:} %{\bf What it does:}
  1085. \begin{addtolength}{\leftskip}{0.22in}
  1086. {\tt minor} computes the (r,c)'th minor of ${\cal A}$.
  1087. This is created by removing the r'th row and the c'th
  1088. column from ${\cal A}$.
  1089. \end{addtolength}
  1090. {\bf Examples:}
  1091. \begin{flushleft}
  1092. \hspace*{0.1in}
  1093. \begin{math}
  1094. \begin{array}{ccc}
  1095. {\tt minor}({\cal A},1,3) & = &
  1096. \left( \begin{array}{cc} 4 & 5 \\ 7 & 8
  1097. \end{array} \right)
  1098. \end{array}
  1099. \end{math}
  1100. \end{flushleft}
  1101. {\bf Related functions:}
  1102. \hspace*{0.175in} {\tt remove\_columns}, {\tt remove\_rows}.
  1103. \subsection{mult\_columns, mult\_rows}
  1104. %{\bf How to use it:}
  1105. \hspace*{0.175in} {\tt mult\_columns(${\cal A}$,column\_list,expr);}
  1106. \hspace*{0.1in}
  1107. \begin{tabular}{l l l}
  1108. ${\cal A}$ &:-& a matrix. \\
  1109. column\_list &:-& a positive integer or a list of positive integers. \\
  1110. expr &:-& an algebraic expression.
  1111. \end{tabular}
  1112. {\bf Synopsis:} %{\bf What it does:}
  1113. \begin{addtolength}{\leftskip}{0.22in}
  1114. {\tt mult\_columns} returns a copy of ${\cal A}$ in which
  1115. the columns specified in column\_list have been
  1116. multiplied by expr.
  1117. {\tt mult\_rows} performs the same task on the rows of ${\cal A}$.
  1118. \end{addtolength}
  1119. {\bf Examples:}
  1120. \begin{flushleft}
  1121. \hspace*{0.1in}
  1122. \begin{math}
  1123. \begin{array}{ccc}
  1124. {\tt mult\_columns}({\cal A},\{1,3\},x) & = &
  1125. \left( \begin{array}{ccc} x & 2 & 3*x \\ 4*x & 5 & 6*x \\ 7*x &
  1126. 8 & 9*x
  1127. \end{array} \right)
  1128. \end{array}
  1129. \end{math}
  1130. \end{flushleft}
  1131. \vspace*{0.1in}
  1132. \begin{flushleft}
  1133. \hspace*{0.1in}
  1134. \begin{math}
  1135. \begin{array}{ccc}
  1136. {\tt mult\_rows}({\cal A},2,10) & = &
  1137. \left( \begin{array}{ccc} 1 & 2 & 3 \\ 40 & 50 & 60 \\ 7 & 8 &
  1138. 9 \end{array} \right)
  1139. \end{array}
  1140. \end{math}
  1141. \end{flushleft}
  1142. {\bf Related functions:}
  1143. \hspace*{0.175in} {\tt add\_to\_columns}, {\tt add\_to\_rows}.
  1144. \subsection{\tt mult\_rows}
  1145. \hspace*{0.175in} see: {\tt mult\_columns}.
  1146. \subsection{pivot}
  1147. %{\bf How to use it:}
  1148. \hspace*{0.175in} {\tt pivot(${\cal A}$,r,c);}
  1149. \hspace*{0.1in}
  1150. \begin{tabular}{l l l}
  1151. ${\cal A}$ &:-& a matrix. \\
  1152. r,c &:-& positive integers such that ${\cal A}$(r,c) neq 0.
  1153. \end{tabular}
  1154. {\bf Synopsis:} %{\bf What it does:}
  1155. \begin{addtolength}{\leftskip}{0.22in}
  1156. {\tt pivot} pivots ${\cal A}$ about its (r,c)'th entry.
  1157. To do this, multiples of the r'th row are added to every
  1158. other row in the matrix.
  1159. This means that the c'th column
  1160. will be 0 except for the (r,c)'th entry.
  1161. \end{addtolength}
  1162. {\bf Examples:}
  1163. \begin{flushleft}
  1164. \hspace*{0.1in}
  1165. \begin{math}
  1166. \begin{array}{ccc}
  1167. {\tt pivot}({\cal A},2,3) & = &
  1168. \left( \begin{array}{ccc} -1 & -0.5 & 0 \\ 4 & 5 & 6 \\ 1 & 0.5
  1169. & 0
  1170. \end{array} \right)
  1171. \end{array}
  1172. \end{math}
  1173. \end{flushleft}
  1174. {\bf Related functions:}
  1175. \hspace*{0.175in} {\tt rows\_pivot}.
  1176. \subsection{pseudo\_inverse}
  1177. %{\bf How to use it:}
  1178. \hspace*{0.175in} {\tt pseudo\_inverse(${\cal A}$);}
  1179. \hspace*{0.1in}
  1180. \begin{tabular}{l l l}
  1181. ${\cal A}$ &:-& a matrix.
  1182. \end{tabular}
  1183. {\bf Synopsis:} %{\bf What it does:}
  1184. \begin{addtolength}{\leftskip}{0.22in}
  1185. {\tt pseudo\_inverse}, also known as the Moore-Penrose inverse, computes
  1186. the pseudo inverse of ${\cal A}$.
  1187. Given the singular value decomposition of ${\cal A}$, i.e: ${\cal A} =
  1188. {\cal U}
  1189. \sum {\cal V}^T$, then the pseudo inverse ${\cal A}^{-1}$ is defined
  1190. by ${\cal A}^{-1} = {\cal V}^T \sum^{-1} {\cal U}$.
  1191. Thus ${\cal A}$ $ * $ {\tt pseudo\_inverse}$({\cal A}) = {\cal I}$.
  1192. \end{addtolength}
  1193. {\bf Examples:}
  1194. % \begin{flushleft}
  1195. % \hspace*{0.175in}
  1196. % \begin{math}
  1197. % {\cal R} = \left( \begin{array}{cccc} 1 & 2 & 3 & 4 \\ 9 & 8 & 7 & 6
  1198. % \end{array} \right)
  1199. % \end{math}
  1200. % \end{flushleft}
  1201. \begin{flushleft}
  1202. \hspace*{0.1in}
  1203. \begin{math}
  1204. \begin{array}{ccc}
  1205. {\tt pseudo\_inverse}({\cal A}) & = &
  1206. \left( \begin{array}{cc} -0.2 & 0.1 \\ -0.05 & 0.05 \\ 0.1 & 0
  1207. \\ 0.25 & -0.05
  1208. \end{array} \right)
  1209. \end{array}
  1210. \end{math}
  1211. \end{flushleft}
  1212. {\bf Related functions:}
  1213. \hspace*{0.175in} {\tt svd}.
  1214. \subsection{random\_matrix}
  1215. %{\bf How to use it:}
  1216. \hspace*{0.175in} {\tt random\_matrix(r,c,limit);}
  1217. \hspace*{0.1in}
  1218. \begin{tabular}{l l l}
  1219. r,c,$\,$limit &:-& positive integers. \\
  1220. \end{tabular}
  1221. {\bf Synopsis:} %{\bf What it does:}
  1222. \begin{addtolength}{\leftskip}{0.22in}
  1223. {\tt random\_matrix} creates an r by c matrix with random
  1224. entries in the range $-$limit $<$ entry $<$ limit.
  1225. \end{addtolength}
  1226. {\bf switches:}
  1227. \hspace*{0.1in}
  1228. \begin{tabular}{l l l}
  1229. {\tt imaginary} \hspace*{0.175in} &:-& \parbox[t]{0.685\linewidth}{if
  1230. on then matrix entries are x+i$*$y where $-$limit $<$ x,y $<$ limit.}
  1231. \end{tabular}
  1232. \vspace*{0.04in}
  1233. \hspace*{0.1in}
  1234. \begin{tabular}{l l l}
  1235. {\tt not\_negative} &:-& \parbox[t]{0.685\linewidth}{if on then 0 $<$
  1236. entry $<$ limit. In the imaginary case we have 0 $<$ x,y $<$ limit.}
  1237. \end{tabular}
  1238. \vspace*{0.04in}
  1239. \hspace*{0.1in}
  1240. \begin{tabular}{l l l}
  1241. {\tt only\_integer} &:-& \parbox[t]{0.685\linewidth}{if on then each
  1242. entry is an integer. In the imaginary case x and y are integers.}
  1243. \end{tabular}
  1244. \vspace*{0.04in}
  1245. \hspace*{0.1in}
  1246. \begin{tabular}{l l l}
  1247. {\tt symmetric} &:-& if on then the matrix is symmetric. \\
  1248. {\tt upper\_matrix} &:-& \parbox[t]{0.685\linewidth}{if on then the
  1249. matrix is upper triangular.} \\
  1250. {\tt lower\_matrix} &:-& if on then the matrix is lower triangular.
  1251. \end{tabular}
  1252. {\bf Examples:}
  1253. \begin{flushleft}
  1254. \hspace*{0.1in}
  1255. \begin{math}
  1256. \begin{array}{ccc}
  1257. {\tt random\_matrix}(3,3,10) & = &
  1258. \left( \begin{array}{ccc} -4.729721 & 6.987047 & 7.521383 \\
  1259. - 5.224177 & 5.797709 & - 4.321952 \\
  1260. - 9.418455 & - 9.94318 & - 0.730980
  1261. \end{array} \right)
  1262. \end{array}
  1263. \end{math}
  1264. \end{flushleft}
  1265. \vspace*{0.2in}
  1266. \hspace*{0.165in}
  1267. {\tt on only\_integer, not\_negative, upper\_matrix, imaginary;}
  1268. \begin{flushleft}
  1269. \hspace*{0.12in}
  1270. \begin{math}
  1271. \begin{array}{ccc}
  1272. {\tt random\_matrix}(4,4,10) & = &
  1273. \left( \begin{array}{cccc} 2*i+5 & 3*i+7 & 7*i+3 & 6 \\ 0 & 2*i+5 &
  1274. 5*i+1 & 2*i+1 \\ 0 & 0 & 8 & i \\ 0 & 0 & 0& 5*i+9
  1275. \end{array} \right)
  1276. \end{array}
  1277. \end{math}
  1278. \end{flushleft}
  1279. \subsection{remove\_columns, remove\_rows}
  1280. %{\bf How to use it:}
  1281. \hspace*{0.175in} {\tt remove\_columns(${\cal A}$,column\_list);}
  1282. \hspace*{0.1in}
  1283. \begin{tabular}{l l l}
  1284. ${\cal A}$ &:-& a matrix. \\
  1285. column\_list &:-& either a positive integer or a list of
  1286. positive integers.
  1287. \end{tabular}
  1288. {\bf Synopsis:} %{\bf What it does:}
  1289. \hspace*{0.175in} {\tt remove\_columns} removes the columns specified in
  1290. column\_list from ${\cal A}$.
  1291. \hspace*{0.175in} {\tt remove\_rows} performs the same task on the rows
  1292. of ${\cal A}$.
  1293. {\bf Examples:}
  1294. \begin{flushleft}
  1295. \hspace*{0.1in}
  1296. \begin{math}
  1297. \begin{array}{ccc}
  1298. {\tt remove\_columns}({\cal A},2) & = &
  1299. \left( \begin{array}{cc} 1 & 3 \\ 4 & 6 \\ 7 & 9
  1300. \end{array} \right)
  1301. \end{array}
  1302. \end{math}
  1303. \end{flushleft}
  1304. \vspace*{0.1in}
  1305. \begin{flushleft}
  1306. \hspace*{0.1in}
  1307. \begin{math}
  1308. \begin{array}{ccc}
  1309. {\tt remove\_rows}({\cal A},\{1,3\}) & = &
  1310. \left( \begin{array}{ccc} 4 & 5 & 6
  1311. \end{array} \right)
  1312. \end{array}
  1313. \end{math}
  1314. \end{flushleft}
  1315. {\bf Related functions:}
  1316. \hspace*{0.175in} {\tt minor}.
  1317. \subsection{remove\_rows}
  1318. \hspace*{0.175in} see: {\tt remove\_columns}.
  1319. \subsection{row\_dim}
  1320. \hspace{0.175in} see: {\tt column\_dim}.
  1321. \subsection{rows\_pivot}
  1322. %{\bf How to use it:}
  1323. \hspace*{0.175in} {\tt rows\_pivot(${\cal A}$,r,c,\{row\_list\});}
  1324. \hspace*{0.1in}
  1325. \begin{tabular}{l l l}
  1326. ${\cal A}$ &:-& a matrix. \\
  1327. r,c &:-& positive integers such that ${\cal A}$(r,c) neq 0.\\
  1328. row\_list &:-& positive integer or a list of positive integers.
  1329. \end{tabular}
  1330. {\bf Synopsis:} %{\bf What it does:}
  1331. \begin{addtolength}{\leftskip}{0.22in}
  1332. {\tt rows\_pivot} performs the same task as {\tt pivot} but applies
  1333. the pivot only to the rows specified in row\_list.
  1334. \end{addtolength}
  1335. {\bf Examples:}
  1336. \begin{flushleft}
  1337. \hspace*{0.175in}
  1338. \begin{math}
  1339. {\cal N} = \left( \begin{array}{ccc} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 &
  1340. 9 \\1 & 2 & 3 \\ 4 & 5 & 6
  1341. \end{array} \right)
  1342. \end{math}
  1343. \end{flushleft}
  1344. \begin{flushleft}
  1345. \hspace*{0.1in}
  1346. \begin{math}
  1347. \begin{array}{ccc}
  1348. {\tt rows\_pivot}({\cal N},2,3,\{4,5\}) & = & \left( \begin{array}
  1349. {c c c}1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \\ -0.75 & 0 & 0.75 \\
  1350. -0.375 & 0 & 0.375
  1351. \end{array} \right)
  1352. \end{array}
  1353. \end{math}
  1354. \end{flushleft}
  1355. {\bf Related functions:}
  1356. \hspace*{0.175in} {\tt pivot}.
  1357. \subsection{simplex}
  1358. %{\bf How to use it:}
  1359. \hspace*{0.175in} {\tt simplex(max/min,objective function,\{linear
  1360. inequalities\});}
  1361. \hspace*{0.1in}
  1362. \begin{tabular}{l l l}
  1363. max/min & :- & \parbox[t]{.63\linewidth}{either max or min
  1364. (signifying maximise and minimise).} \\
  1365. objective function & :- & the function you are maximising or
  1366. minimising. \\
  1367. linear inequalities & :- & \parbox[t]{.63\linewidth}{the constraint
  1368. inequalities. Each one must be of the form
  1369. {\it sum of variables ($<=,=,>=$) number}.}
  1370. \end{tabular}
  1371. {\bf Synopsis:} %{\bf What it does:}
  1372. \begin{addtolength}{\leftskip}{0.22in}
  1373. {\tt simplex} applies the revised simplex algorithm to find the
  1374. optimal(either maximum or minimum) value of the objective function
  1375. under the linear inequality constraints.
  1376. It returns \{optimal value,\{ values of variables at this optimal\}\}.
  1377. The algorithm implies that all the variables are non-negative.
  1378. \end{addtolength}
  1379. {\bf Examples:}
  1380. \begin{addtolength}{\leftskip}{0.22in}
  1381. %\begin{math}
  1382. {\tt simplex($max,x+y,\{x>=10,y>=20,x+y<=25\}$);}
  1383. %\end{math}
  1384. {\tt ***** Error in simplex: Problem has no feasible solution.}
  1385. \vspace*{0.2in}
  1386. \parbox[t]{0.96\linewidth}{\tt simplex($max,10x+5y+5.5z,\{5x+3z<=200,
  1387. x+0.1y+0.5z<=12$,\\
  1388. \hspace*{0.55in} $0.1x+0.2y+0.3z<=9, 30x+10y+50z<=1500\}$);}
  1389. \vspace*{0.1in}
  1390. {\tt $\{525.0,\{x=40.0,y=25.0,z=0\}$\}}
  1391. \end{addtolength}
  1392. \subsection{squarep}
  1393. %{\bf How to use it:}
  1394. \hspace*{0.175in} {\tt squarep(${\cal A}$);}
  1395. \hspace*{0.1in}
  1396. \begin{tabular}{l l l}
  1397. ${\cal A}$ &:-& a matrix.
  1398. \end{tabular}
  1399. {\bf Synopsis:} %{\bf What it does:}
  1400. \begin{addtolength}{\leftskip}{0.22in}
  1401. {\tt squarep} is a boolean function that returns t if
  1402. the matrix is square and nil otherwise.
  1403. \end{addtolength}
  1404. {\bf Examples:}
  1405. \begin{flushleft}
  1406. \hspace*{0.175in}
  1407. \begin{math}
  1408. {\cal L} = \left( \begin{array}{ccc} 1 & 3 & 5
  1409. \end{array} \right)
  1410. \end{math}
  1411. \end{flushleft}
  1412. \vspace*{0.1in}
  1413. \hspace*{0.175in} {\tt squarep}(${\cal A}$) = t
  1414. \hspace*{0.175in} {\tt squarep}(${\cal L}$) = nil
  1415. {\bf Related functions:}
  1416. \hspace*{0.175in} {\tt matrixp}, {\tt symmetricp}.
  1417. \subsection{stack\_rows}
  1418. \hspace*{0.175in} see: {\tt augment\_columns}.
  1419. \subsection{sub\_matrix}
  1420. %{\bf How to use it:}
  1421. \hspace*{0.175in} {\tt sub\_matrix(${\cal A}$,row\_list,column\_list);}
  1422. \hspace*{0.1in}
  1423. \begin{tabular}{l l l}
  1424. ${\cal A}$ &:-& a matrix. \\
  1425. row\_list, column\_list &:-& \parbox[t]{.605\linewidth}{either a
  1426. positive integer or a list of positive integers.}
  1427. \end{tabular}
  1428. {\bf Synopsis:} %{\bf What it does:}
  1429. \begin{addtolength}{\leftskip}{0.22in}
  1430. {\tt sub\_matrix} produces the matrix consisting of the
  1431. intersection of the rows specified in row\_list and the
  1432. columns specified in column\_list.
  1433. \end{addtolength}
  1434. {\bf Examples:}
  1435. \begin{flushleft}
  1436. \hspace*{0.1in}
  1437. \begin{math}
  1438. \begin{array}{ccc}
  1439. {\tt sub\_matrix}({\cal A},\{1,3\},\{2,3\}) & = &
  1440. \left( \begin{array}{cc} 2 & 3 \\ 8 & 9
  1441. \end{array} \right)
  1442. \end{array}
  1443. \end{math}
  1444. \end{flushleft}
  1445. {\bf Related functions:}
  1446. \hspace*{0.175in} {\tt augment\_columns}, {\tt stack\_rows}.
  1447. \subsection{svd (singular value decomposition)}
  1448. %{\bf How to use it:}
  1449. \hspace*{0.175in} {\tt svd(${\cal A}$);}
  1450. \hspace*{0.1in}
  1451. \begin{tabular}{l l l}
  1452. ${\cal A}$ &:-& a matrix containing only numeric entries.
  1453. \end{tabular}
  1454. {\bf Synopsis:} %{\bf What it does:}
  1455. \begin{addtolength}{\leftskip}{0.22in}
  1456. {\tt svd} computes the singular value decomposition of ${\cal A}$.
  1457. It returns \{${\cal U},\sum,{\cal V}$\} where ${\cal A} = {\cal U}
  1458. \sum {\cal V}^T$ and $\sum = diag(\sigma_{1}, \ldots ,\sigma_{n}). \;
  1459. \sigma_{i}$ for $i= (1 \ldots n)$ are the singular values of ${\cal A}$.
  1460. n is the column dimension of ${\cal A}$.
  1461. The singular values of ${\cal A}$ are the non-negative square roots of
  1462. the eigenvalues of ${\cal A}^T {\cal A}$.
  1463. ${\cal U}$ and ${\cal V}$ are such that ${\cal UU}^T = {\cal VV}^T =
  1464. {\cal V}^T {\cal V} = {\cal I}_n$.
  1465. \end{addtolength}
  1466. {\bf Examples:}
  1467. \begin{flushleft}
  1468. \hspace*{0.175in}
  1469. \begin{math}
  1470. {\cal Q} = \left( \begin{array}{cc} 1 & 3 \\ -4 & 3
  1471. \end{array} \right)
  1472. \end{math}
  1473. \end{flushleft}
  1474. \begin{eqnarray}
  1475. \hspace*{0.1in}
  1476. {\tt svd({\cal Q})} & = &
  1477. \left\{
  1478. \left( \begin{array}{cc} 0.289784 & 0.957092 \\ -0.957092 &
  1479. 0.289784 \end{array} \right), \left( \begin{array}{cc} 5.149162 & 0 \\
  1480. 0 & 2.913094 \end{array} \right), \right. \nonumber \\ & & \left. \: \;
  1481. \, \left( \begin{array}{cc} -0.687215 & 0.726453 \\ -0.726453 &
  1482. -0.687215 \end{array} \right)
  1483. \right\} \nonumber
  1484. \end{eqnarray}
  1485. \subsection{swap\_columns, swap\_rows}
  1486. %{\bf How to use it:}
  1487. \hspace*{0.175in} {\tt swap\_columns(${\cal A}$,c1,c2);}
  1488. \hspace*{0.1in}
  1489. \begin{tabular}{l l l}
  1490. ${\cal A}$ &:-& a matrix. \\
  1491. c1,c1 &:-& positive integers.
  1492. \end{tabular}
  1493. {\bf Synopsis:} %{\bf What it does:}
  1494. \hspace*{0.175in}
  1495. {\tt swap\_columns} swaps column c1 of ${\cal A}$ with column c2.
  1496. \hspace*{0.175in} {\tt swap\_rows} performs the same task on 2 rows of
  1497. ${\cal A}$.
  1498. {\bf Examples:}
  1499. \begin{flushleft}
  1500. \hspace*{0.1in}
  1501. \begin{math}
  1502. \begin{array}{ccc}
  1503. {\tt swap\_columns}({\cal A},2,3) & = &
  1504. \left( \begin{array}{ccc} 1 & 3 & 2 \\ 4 & 6 & 5 \\ 7 & 9 & 8
  1505. \end{array} \right)
  1506. \end{array}
  1507. \end{math}
  1508. \end{flushleft}
  1509. {\bf Related functions:}
  1510. \hspace*{0.175in} {\tt swap\_entries}.
  1511. \subsection{swap\_entries}
  1512. %{\bf How to use it:}
  1513. \hspace*{0.175in} {\tt swap\_entries(${\cal A}$,\{r1,c1\},\{r2,c2\});}
  1514. \hspace*{0.1in}
  1515. \begin{tabular}{l l l}
  1516. ${\cal A}$ &:-& a matrix. \\
  1517. r1,c1,r2,c2 &:-& positive integers.
  1518. \end{tabular}
  1519. {\bf Synopsis:} %{\bf What it does:}
  1520. \hspace*{0.175in} {\tt swap\_entries} swaps ${\cal A}$(r1,c1) with
  1521. ${\cal A}$(r2,c2).
  1522. {\bf Examples:}
  1523. \begin{flushleft}
  1524. \hspace*{0.1in}
  1525. \begin{math}
  1526. \begin{array}{ccc}
  1527. {\tt swap\_entries}({\cal A},\{1,1\},\{3,3\}) & = &
  1528. \left( \begin{array}{ccc} 9 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 1
  1529. \end{array} \right)
  1530. \end{array}
  1531. \end{math}
  1532. \end{flushleft}
  1533. {\bf Related functions:}
  1534. \hspace*{0.175in} {\tt swap\_columns}, {\tt swap\_rows}.
  1535. \subsection{swap\_rows}
  1536. \hspace*{0.175in} see: {\tt swap\_columns}.
  1537. \subsection{symmetricp}
  1538. %{\bf How to use it:}
  1539. \hspace*{0.175in} {\tt symmetricp(${\cal A}$);}
  1540. \hspace*{0.1in}
  1541. \begin{tabular}{l l l}
  1542. ${\cal A}$ &:-& a matrix.
  1543. \end{tabular}
  1544. {\bf Synopsis:} %{\bf What it does:}
  1545. \begin{addtolength}{\leftskip}{0.22in}
  1546. {\tt symmetricp} is a boolean function that returns t if the
  1547. matrix is symmetric and nil otherwise.
  1548. \end{addtolength}
  1549. {\bf Examples:}
  1550. \begin{flushleft}
  1551. \hspace*{0.175in}
  1552. \begin{math}
  1553. {\cal M} = \left( \begin{array}{cc} 1 & 2 \\ 2 & 1
  1554. \end{array} \right)
  1555. \end{math}
  1556. \end{flushleft}
  1557. \vspace*{0.1in}
  1558. \hspace*{0.175in} {\tt symmetricp}(${\cal A}$) = nil
  1559. \hspace*{0.175in} {\tt symmetricp}(${\cal M}$) = t
  1560. {\bf Related functions:}
  1561. \hspace*{0.175in} {\tt matrixp}, {\tt squarep}.
  1562. \subsection{toeplitz}
  1563. %{\bf How to use it:}
  1564. \hspace*{0.175in} {\tt toeplitz(\{\exprlist{}\});} \lazyfootnote{}
  1565. \hspace*{0.1in}
  1566. \begin{tabular}{l l l}
  1567. \exprlist{} &:-& algebraic expressions.
  1568. \end{tabular}
  1569. {\bf Synopsis:} %{\bf What it does:}
  1570. \begin{addtolength}{\leftskip}{0.22in}
  1571. {\tt toeplitz} creates the toeplitz matrix from the
  1572. expression list.
  1573. This is a square symmetric matrix in
  1574. which the first expression is placed on the diagonal
  1575. and the i'th expression is placed on the (i-1)'th sub
  1576. and super diagonals.
  1577. It has dimension n where n is the
  1578. number of expressions.
  1579. \end{addtolength}
  1580. {\bf Examples:}
  1581. \begin{flushleft}
  1582. \hspace*{0.1in}
  1583. \begin{math}
  1584. \begin{array}{ccc}
  1585. {\tt toeplitz}(\{w,x,y,z\}) & = &
  1586. \left( \begin{array}{cccc} w & x & y & z \\ x & w & x & y \\
  1587. y & x & w & x \\ z & y & x & w
  1588. \end{array} \right)
  1589. \end{array}
  1590. \end{math}
  1591. \end{flushleft}
  1592. \subsection{triang\_adjoint}
  1593. %{\bf How to use it:}
  1594. \hspace*{0.175in} {\tt triang\_adjoint(${\cal A}$);}
  1595. \hspace*{0.1in}
  1596. \begin{tabular}{l l l}
  1597. ${\cal A}$ &:-& a matrix.
  1598. \end{tabular}
  1599. {\bf Synopsis:} %{\bf What it does:}
  1600. \begin{addtolength}{\leftskip}{0.22in}
  1601. {\tt triang\_adjoint} computes the triangularizing adjoint ${\cal F}$ of
  1602. matrix ${\cal A}$ due to the algorithm of Arne Storjohann. ${\cal F}$ is
  1603. lower triangular matrix and the resulting matrix ${\cal T}$ of
  1604. ${\cal F * A = T}$ is upper triangular with the property that the $i$-th
  1605. entry in the diagonal of ${\cal T}$ is the determinant of the principal
  1606. $i$-th submatrix of the matrix ${\cal A}$.
  1607. \end{addtolength}
  1608. {\bf Examples:}
  1609. \begin{flushleft}
  1610. \hspace*{0.1in}
  1611. \begin{math}
  1612. \begin{array}{ccc}
  1613. {\tt triang\_adjoint}({\cal A}) & = &
  1614. \left( \begin{array}{ccc} 1 & 0 & 0 \\ -4 & 1 & 0 \\ -3 & 6 & -3
  1615. \end{array} \right)
  1616. \end{array}
  1617. \end{math}
  1618. \end{flushleft}
  1619. \vspace*{0.1in}
  1620. \begin{flushleft}
  1621. \hspace*{0.1in}
  1622. \begin{math}
  1623. \begin{array}{ccc}
  1624. {\cal F} * {\cal A} & = &
  1625. \left( \begin{array}{ccc} 1 & 2 & 3 \\ 0 & -3 & -6 \\ 0 & 0 & 0
  1626. \end{array} \right)
  1627. \end{array}
  1628. \end{math}
  1629. \end{flushleft}
  1630. \subsection{Vandermonde}
  1631. %{\bf How to use it:}
  1632. \hspace*{0.175in} {\tt vandermonde}(\{\exprlist{}\}); \addtocounter
  1633. {footnote}{-1}\footnotemark
  1634. %\lazyfootnote{}
  1635. \hspace*{0.1in}
  1636. \begin{tabular}{l l l}
  1637. \exprlist{} &:-& algebraic expressions.
  1638. \end{tabular}
  1639. {\bf Synopsis:} %{\bf What it does:}
  1640. \begin{addtolength}{\leftskip}{0.22in}
  1641. {\tt Vandermonde} creates the Vandermonde matrix from
  1642. the expression list.
  1643. This is the square matrix in which
  1644. the (i,$\,$j)'th entry is expr\_list(i) $^{(j-1)}$.
  1645. It has dimension n where n is the number of expressions.
  1646. \end{addtolength}
  1647. {\bf Examples:}
  1648. \begin{flushleft}
  1649. \hspace*{0.1in}
  1650. \begin{math}
  1651. \begin{array}{ccc}
  1652. {\tt vandermonde}(\{x,2*y,3*z\}) & = &
  1653. \left( \begin{array}{ccc} 1 & x & x^2 \\ 1 & 2*y & 4*y^2 \\ 1
  1654. & 3*z & 9*z^2
  1655. \end{array} \right)
  1656. \end{array}
  1657. \end{math}
  1658. \end{flushleft}
  1659. \subsection{kronecker\_product}
  1660. \hspace*{0.175in} {\tt kronecker\_product}($Mat_1,Mat_2$)
  1661. \hspace*{0.1in}
  1662. \begin{tabular}{l l l}
  1663. $Mat_1,Mat_2$ &:-& Matrices
  1664. \end{tabular}
  1665. {\bf Synopsis:}
  1666. \begin{addtolength}{\leftskip}{0.22in}
  1667. {\tt kronecker\_product} creates a matrix containing the Kronecker product
  1668. (also called {\tt direct product} or {\tt tensor product}) of its arguments.
  1669. \end{addtolength}
  1670. {\bf Examples:}
  1671. \begin{verbatim}
  1672. a1 := mat((1,2),(3,4),(5,6))$
  1673. a2 := mat((1,1,1),(2,z,2),(3,3,3))$
  1674. kronecker_product(a1,a2);
  1675. \end{verbatim}
  1676. \begin{flushleft}
  1677. \hspace*{0.1in}
  1678. \begin{math}
  1679. \begin{array}{ccc}
  1680. \left( \begin{array}{cccccc} 1 & 1 & 1 & 2 & 2 & 2 \\
  1681. 2 & z & 2 & 4 &2*z &4 \\
  1682. 3 & 3 & 3 & 6 & 6 &6 \\
  1683. 3 & 3 & 3 & 4 & 4 &4 \\
  1684. 6 & 3*z& 6 & 8 &4*z &8 \\
  1685. 9 & 9 & 9 & 12 &12 &12\\
  1686. 5 & 5 & 5 & 6 & 6 &6 \\
  1687. 10 &5*z& 10& 12 &6*z &12 \\
  1688. 15 &15 & 15& 18 &18 &18 \end{array} \right)
  1689. \end{array}
  1690. \end{math}
  1691. \end{flushleft}
  1692. \section{Fast Linear Algebra}
  1693. By turning the {\tt fast\_la} switch on, the speed of the following
  1694. functions will be increased:
  1695. \begin{tabular}{l l l l}
  1696. add\_columns & add\_rows & augment\_columns & column\_dim \\
  1697. copy\_into & make\_identity & matrix\_augment & matrix\_stack\\
  1698. minor & mult\_column & mult\_row & pivot \\
  1699. remove\_columns & remove\_rows & rows\_pivot & squarep \\
  1700. stack\_rows & sub\_matrix & swap\_columns & swap\_entries\\
  1701. swap\_rows & symmetricp
  1702. \end{tabular}
  1703. The increase in speed will be insignificant unless you are making a
  1704. significant number(i.e: thousands) of calls. When using this switch,
  1705. error checking is minimised. This means that illegal input may give
  1706. strange error messages. Beware.
  1707. \newpage
  1708. \section{Acknowledgments}
  1709. Many of the ideas for this package came from the Maple[3] Linalg package
  1710. [4].
  1711. The algorithms for {\tt cholesky}, {\tt lu\_decom}, and {\tt svd} are
  1712. taken from the book Linear Algebra - J.H. Wilkinson \& C. Reinsch[5].
  1713. The {\tt gram\_schmidt} code comes from Karin Gatermann's Symmetry
  1714. package[6] for {\REDUCE}.
  1715. \begin{thebibliography}{}
  1716. \bibitem{matt} Matt Rebbeck: NORMFORM: A {\REDUCE} package for the
  1717. computation of various matrix normal forms. ZIB, Berlin. (1993)
  1718. \bibitem{Reduce} Anthony C. Hearn: {\REDUCE} User's Manual 3.6.
  1719. RAND (1995)
  1720. \bibitem{Maple} Bruce W. Char\ldots [et al.]: Maple (Computer
  1721. Program). Springer-Verlag (1991)
  1722. \bibitem{linalg} Linalg - a linear algebra package for Maple[3].
  1723. \bibitem{WiRe} J. H. Wilkinson \& C. Reinsch: Linear Algebra
  1724. (volume II). Springer-Verlag (1971)
  1725. \bibitem{gat} Karin Gatermann: Symmetry: A {\REDUCE} package for the
  1726. computation of linear representations of groups. ZIB, Berlin. (1992)
  1727. \end{thebibliography}
  1728. \end{document}