Algebra with Matrices, Vectors, and Arrays - Maple Programming Help

Algebra with Matrices, Vectors, and Arrays

 Expressions involving sums, products, and powers with rtable objects are evaluated directly. An rtable object is either an Array, Matrix, or Vector.

Description

 • The result that is returned for a particular expression is described below. In each of the following sections:
 - A is an Array
 - M is a Matrix
 - V is a Vector
 - c is a numeric constant
 - s is a non-numeric scalar

Sums

 The result that is returned when an expression of type '+' includes at least one rtable depends on the operands.

 Expression Result ${A}_{1}+{A}_{2}$ The component-wise sum of ${A}_{1}$ and ${A}_{2}$, if the dimensions match; otherwise, returns an error $A+c$ Adds $c$ to every element of $A$ $A+s$ Returns unevaluated ${M}_{1}+{M}_{2}$ The component-wise sum of ${M}_{1}$ and ${M}_{2}$, if the dimensions match; otherwise, returns an error $M+c$ Adds $c$ to the main diagonal of $M$ $M+s$ Returns unevaluated ${V}_{1}+{V}_{2}$ The component-wise sum of ${V}_{1}$ and ${V}_{2}$, if dimensions and orientations match; otherwise, returns an error $V+c$ An error $V+s$ Returns unevaluated other All other combinations raise errors

 Direct evaluation of these expressions is implemented by calls to the rtable/Sum library routine.

Products

 The result that is returned when an expression of type '*' includes at least one rtable depends on the operands. If the operands are either Matrices, Vectors or a combination of each (with appropriate dimensions), the '.' operator must be used. For more information, see dot.

 Expression Result ${A}_{1}{A}_{2}$ The component-wise product of ${A}_{1}$ and ${A}_{2}$, if the dimensions match; otherwise, returns an error $cA$ Multiplies every element of $A$ by $c$ $sA$ Returns unevaluated ${M}_{1}{M}_{2}$ An error (must use the '.' (dot) operator) $cM$ Multiplies every element of $M$ by $c$ $sM$ Returns unevaluated ${V}_{1}{V}_{2}$ An error (must use the '.' (dot) operator) $cV$ Multiplies every element of $V$ by $c$ $sV$ Returns unevaluated other All other combinations raise errors

 Direct evaluation of these expressions is implemented by calls to the rtable/Product library routine.

Powers

 The result that is returned when an expression of type '^' includes an rtable object base depends on the exponent type.
 There are two cases in which the exponent is interpreted specially: ${R}^{+}=\mathrm{LinearAlgebra}:-\mathrm{Transpose}\left(R\right)$ and ${R}^{*}=\mathrm{LinearAlgebra}:-\mathrm{HermitianTranspose}\left(R\right)$.  (The deprecated notations, ${R}^{\mathrm{%T}}$ and ${R}^{\mathrm{%H}}$, respectively, are similarly interpreted.)
 Otherwise, the following interpretations of a power of an rtable apply.

 Expression Result ${A}^{c}$ The component-wise exponentiation of $A$. Constant c can be any (complex) numeric value. ${A}^{s}$ Returns unevaluated ${M}^{c}$ If M is square and c is a positive integer, then the result is the matrix product $M\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}.\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}M\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}.\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}M$ ... $M$ (c factors using the dot operator) If c is a negative integer, the result is $\mathrm{MatrixInverse}$( $M\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}.\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}M\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}.\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}M$ ... $M$) ($c$ factors using the dot operator) If $c=0$, the result is $1$ If $c$ is not an integer, it returns unevaluated ${M}^{s}$ Returns unevaluated

 Direct evaluation of these expressions is implemented by calls to the rtable/Power library routine.

Examples

 > $c≔2$
 ${c}{:=}{2}$ (1)
 > $\mathrm{A1}≔\mathrm{Array}\left(\left[\left[1,2\right],\left[3,4\right]\right]\right)$
 ${\mathrm{A1}}{:=}\left[\begin{array}{rr}{1}& {2}\\ {3}& {4}\end{array}\right]$ (2)
 > $\mathrm{A2}≔\mathrm{Array}\left(\left[\left[u,v\right],\left[w,x\right]\right]\right)$
 ${\mathrm{A2}}{:=}\left[\begin{array}{cc}{u}& {v}\\ {w}& {x}\end{array}\right]$ (3)
 > $\mathrm{M1}≔⟨⟨1,2⟩|⟨-2,1⟩⟩$
 ${\mathrm{M1}}{:=}\left[\begin{array}{rr}{1}& {-}{2}\\ {2}& {1}\end{array}\right]$ (4)
 > $\mathrm{M2}≔⟨⟨2,3⟩|⟨4,4⟩⟩$
 ${\mathrm{M2}}{:=}\left[\begin{array}{rr}{2}& {4}\\ {3}& {4}\end{array}\right]$ (5)
 > $\mathrm{V1}≔⟨x|y⟩$
 ${\mathrm{V1}}{:=}\left[\begin{array}{cc}{x}& {y}\end{array}\right]$ (6)
 > $\mathrm{A1}+\mathrm{A2}$
 $\left[\begin{array}{cc}{1}{+}{u}& {2}{+}{v}\\ {3}{+}{w}& {4}{+}{x}\end{array}\right]$ (7)
 > $\mathrm{A1}+c$
 $\left[\begin{array}{rr}{3}& {4}\\ {5}& {6}\end{array}\right]$ (8)
 > $\mathrm{A1}+s$
 ${s}{+}\left[\begin{array}{rr}{1}& {2}\\ {3}& {4}\end{array}\right]$ (9)
 > $\mathrm{M1}+\mathrm{M2}$
 $\left[\begin{array}{rr}{3}& {2}\\ {5}& {5}\end{array}\right]$ (10)
 > $\mathrm{M1}+c$
 $\left[\begin{array}{rr}{3}& {-}{2}\\ {2}& {3}\end{array}\right]$ (11)
 > $\mathrm{M1}+s$
 ${s}{+}\left[\begin{array}{rr}{1}& {-}{2}\\ {2}& {1}\end{array}\right]$ (12)
 > $\mathrm{A1}\mathrm{A2}$
 $\left[\begin{array}{cc}{u}& {2}{}{v}\\ {3}{}{w}& {4}{}{x}\end{array}\right]$ (13)
 > $\mathrm{A1}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}.\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathrm{A2}$
 $\left[\begin{array}{cc}{u}& {2}{}{v}\\ {3}{}{w}& {4}{}{x}\end{array}\right]$ (14)

The * operator cannot be used to multiply Matrices or Vectors.

 > $\mathrm{M1}\mathrm{M2}$
 > $c\mathrm{M1}$
 $\left[\begin{array}{rr}{2}& {-}{4}\\ {4}& {2}\end{array}\right]$ (15)
 > $c\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}.\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathrm{M1}$
 $\left[\begin{array}{rr}{2}& {-}{4}\\ {4}& {2}\end{array}\right]$ (16)

Note the difference between * and . when one operand is a symbolic scalar.

 > $s\mathrm{M1}$
 $\left[\begin{array}{cc}{s}& {-}{2}{}{s}\\ {2}{}{s}& {s}\end{array}\right]$ (17)
 > $s\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}.\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathrm{M1}$
 ${s}{.}\left[\begin{array}{rr}{1}& {-}{2}\\ {2}& {1}\end{array}\right]$ (18)
 > $\mathrm{M1}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}.\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathrm{M2}$
 $\left[\begin{array}{rr}{-}{4}& {-}{4}\\ {7}& {12}\end{array}\right]$ (19)
 > $\mathrm{V1}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}.\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathrm{M2}$
 $\left[\begin{array}{cc}{2}{}{x}{+}{3}{}{y}& {4}{}{x}{+}{4}{}{y}\end{array}\right]$ (20)
 > ${\mathrm{A1}}^{c}$
 $\left[\begin{array}{rr}{1}& {4}\\ {9}& {16}\end{array}\right]$ (21)
 > ${\mathrm{A1}}^{s}$
 $\left[\begin{array}{cc}{1}& {{2}}^{{s}}\\ {{3}}^{{s}}& {{4}}^{{s}}\end{array}\right]$ (22)
 > ${\mathrm{M2}}^{c}$
 $\left[\begin{array}{rr}{16}& {24}\\ {18}& {28}\end{array}\right]$ (23)
 > ${\mathrm{M2}}^{s}$
 ${\left[\begin{array}{rr}{2}& {4}\\ {3}& {4}\end{array}\right]}^{{s}}$ (24)
 > ${\mathrm{M2}}^{\mathrm{%T}}$
 $\left[\begin{array}{rr}{2}& {3}\\ {4}& {4}\end{array}\right]$ (25)
 > ${\mathrm{V1}}^{\mathrm{%H}}$
 $\left[\begin{array}{c}\stackrel{{&conjugate0;}}{{x}}\\ \stackrel{{&conjugate0;}}{{y}}\end{array}\right]$ (26)