%
\documentclass[11pt]{article}
\setlength{\textheight}{9.5in}
\setlength{\textwidth}{6.5in}
\setlength{\topmargin}{0pt}
\setlength{\headheight}{0in}
\setlength{\topsep}{0in}
\setlength{\oddsidemargin}{0pt}
\setlength{\evensidemargin}{0pt}
\setlength{\marginparwidth}{0in}
\setlength{\marginparsep}{0in}
\setlength{\footskip}{0in}
\parindent=0in
\pagestyle{empty}
\begin{document}
\centerline{\bf Maple Lab 1}
\medskip
Your {\bf Maple} typing lesson to be done in the computer lab classroom LCB 115.
If you missed it, then do it on your own in the Math Center computer lab,
lowest floor between buildings JWB and LCB. Report by email how it worked out.
\begin{verbatim}
 restart():
 # First Computer Lab
 # Math 2270-2 Spring 2016
 # What follows # on that line is a comment.
 # Use comments to put your name and the title of
 # the assignment at the top of the worksheet.
 # Use comments to introduce each problem or major step.
 # End each non-comment line with a semicolon (;) or a colon (:)
 # A semicolon causes BLUE echo and a colon causes no echo.
 #
 # Hand calculator functions.
 # Use ctrl-Z, backspace, Delete, Arrow keys.
 2+2; 3*5; 3^6*5/2; 7*(9+11); 10^(1.5);
 sin(Pi/2),cos(Pi),tan(Pi/4);
 #
 # Plotting. Right mouse click on the curve to improve the plot.
 plot(sin(x),x=0..Pi);
 #
 # Printing
  # Use the FILE menu and choose PRINT.
 #
 # The assignment operator ":=" (colon equals) assigns a value to a symbol.
 u:=2; u+3, u*exp(-u^2), sin(Pi*u);
 #
 # Define column vectors with angle brackets.
 v:=<1,2,3>; w:=<1,0,0>;
 #
 #Use a period "." for dot products.
 v.w; v.v;
 #
 # Define a matrix using column vectors separated by a bar "|".
 M:=<v|w|<1,1,0>>;
 #
 # Syntax for Matrix multiply and Matrix times Vector.
 M.M;  M.v;
 N:=<<1,2,3,4>|<5,6,7,8>|<9,10,11,12>>;  N.M;
 #
 # Error message for incompatible matrix multiply.
 M.N;
 #
 # Matrices can be entered by rows (preferred).
 P:=Matrix([[1,2,3],[4,5,6],[7,8,9]]);
 #
 # Linear combinations of matrices by math-style operations.
 2*P; P-M; 5*P-3*M;
 #
 # Help Commands for 2270-2 support functions in package laylinalg
 with(laylinalg);
 ?laylinalg
 ?replace
 ?scale
 ?swap
 # Use Gaussian Elimination to reduce matrix Q to upper triangular form.
 # The percent sign "%" recalls the result of the previous computation.
 Q:=<<1,2,1>|<2,3,4>|<1,1,1>>; # Matrix entry by columns
 E1:=<<1,-2,0>|<0,1,0>|<0,0,1>>; # E1:=Matrix([[1,0,0],[-2,1,0],[0,0,1]]);
 Q1:=%.Q; # Left multiply by Elimination matrix E1
 E2:=<<1,0,-1>|<0,1,0>|<0,0,1>>; # E2:=Matrix([[1,0,0],[0,1,0],[-1,0,1]]);
 Q2:=%.Q1; # Left multiply by Elimination matrix E2
 #
 # The matrix Q has three non-zero pivots, so it is invertible.
 # Find the inverse using two different notations.
 # An answer check is inverse(Q) times Q = identity matrix.
 Q^(-1); 1/Q; %.Q;
 #
 # Symbolic computations.
 A:=Matrix([[a[1,1], a[1,2]],[a[2,1],a[2,2]]]); # mouse copy it
 B:=Matrix([[b[1,1], b[1,2]],[b[2,1],b[2,2]]]); # ctrl-K opens a line
 C:=Matrix([[c[1,1], c[1,2]],[c[2,1],c[2,2]]]); # ctrl-F is find/replace
 #
 # Verify associativity of matrix multiplication.
 (A.B).C-A.(B.C);
 # The zero matrix is expected. To encourage the maple engine
 # to simplify algebraic expressions, use:
 simplify(%);
 #
 # Elimination can be done step by step in maple.
 # Load the maple library for linear algebra, as follows.
 # Once per session. The colon removes BLUE printout.
 with(LinearAlgebra):
 # Perform Elimination, showing only the answer, no steps.
 # We choose the system Qx=b, where b:=<1,2,3>:
 b:=<1,2,3>: Q; A1:=<Q|b>;
 GaussianElimination(A1); # ESC key = word completion
 ReducedRowEchelonForm(A1);
 #
 # Elimination steps with LinearAlgebra functions. Definitions:
 combo:=(a,s,t,c)->RowOperation(a,[t,s],c);
 swap:=(a,s,t)->RowOperation(a,[t,s]);
 mult:=(a,t,c)->RowOperation(a,t,c);
 A1:=<Q|b>;           # Do 9-10 steps with combo, swap, mult.
 A2:=combo(%,1,2,-2); # Invent the other steps.
 # This is a good way to do homework problems. Answer check:
 ReducedRowEchelonForm (A1);
 # Lay Linalg Package
 # Functions: swap, replace, scale have different syntax than swap, combo, mult
 # but give the same elementary row operation results.
 A1:=<Q|b>;             # Do 9-10 steps with combo, swap, mult.
 A2:=replace(%,1,-2,2); # Means replace row 1 by (-2) times row 2
 #
 #
 # There is an interactive Gauss-Jordan Elimination Tutorial
 # in the Student[LinearAlgebra] package. Try it out by
 # un-commenting the next line, then execute the line.
 #Student[LinearAlgebra][GaussJordanEliminationTutor](A1);
 # End of lab1
 \end{verbatim}
\end{document} 