Difference between revisions of "Matrices"
From GeoGebra Manual
m (template) |
(added new short syntax, missing descriptions and fixed format) |
||
(14 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
− | <noinclude>{{Manual Page | + | <noinclude>{{Manual Page|version=5.0}}</noinclude>{{objects|general}} |
− | {{objects|general}} | + | GeoGebra supports real matrices, which are represented as a list of [[lists]] that contain the rows of the matrix. |
− | GeoGebra | + | |
+ | {{Example|1=In GeoGebra, <nowiki>{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}</nowiki> represents the 3x3 matrix <math>\begin{pmatrix}1&2&3\\ 4&5&6\\ 7&8&9 \end{pmatrix}</math>}} | ||
+ | |||
+ | To display a matrix using LaTeX formatting in the [[File:Menu view graphics.svg|link=|16px]] [[Graphics View]], use the [[FormulaText]] command or drag and drop the matrix definition from ''Algebra View'' to ''Graphics View''. | ||
+ | {{Example|1=In the [[Input Bar]] type <code>FormulaText[<nowiki>{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}</nowiki>]</code> to display the matrix using LaTeX formatting.}} | ||
+ | |||
+ | ==Accessing Elements of Matrices== | ||
+ | To access particular elements of a matrix you can use the [[Element Command]] or the simplified syntax shown in the example below: | ||
+ | {{Example|1=Let <code>matrix={{1, 2}, {3, 4}}</code>, then: <div> | ||
+ | *<code>matrix(1, 1) </code> returns the first element in the first line: ''1'' | ||
+ | *<code>matrix(2, 2)</code>, <code>matrix(-1,2)</code>, <code>matrix(2,-1) </code> and <code>matrix(-1,-1) </code> all return the second element of the second line: ''4''. | ||
+ | *In general, <code>matrix(''i'', ''j'') </code>, where ''i'' and ''j'' are integers, returns the element of the matrix that occupies the ''i-th'' row and the ''j-th'' column.</div>}} | ||
− | |||
==Matrix Operations== | ==Matrix Operations== | ||
+ | Matrix operations are ''operations with lists'', so the following syntaxes produce the described results. | ||
+ | {{Note|1=Some syntaxes can represent operations which are not defined in the same way in the matrices set.}} | ||
− | ===Addition and subtraction | + | ===Addition and subtraction === |
− | * Matrix1 + Matrix2: | + | * <code>Matrix1 + Matrix2</code>: adds the corresponding elements of two compatible matrices. |
− | * Matrix1 – Matrix2: | + | * <code>Matrix1 – Matrix2</code>: subtracts the corresponding elements of two compatible matrices. |
− | ===Multiplication | + | ===Multiplication and division === |
− | * Matrix * Number: | + | * <code>Matrix * Number</code>: multiplies each element of ''Matrix'' by the given ''Number''. |
− | * Matrix1 * Matrix2: | + | * <code>Matrix1 * Matrix2</code>: uses matrix multiplication to calculate the resulting matrix. |
− | {{note|The rows of the first and columns of the second matrix need to have the same number of elements.}} | + | : {{note|The rows of the first and columns of the second matrix need to have the same number of elements.}} |
− | {{example| | + | : {{example|1={{1, 2}, {3, 4}, {5, 6}} * {{1, 2, 3}, {4, 5, 6}} yields the matrix {{9, 12, 15}, {19, 26, 33}, {29, 40, 51}}.}} |
− | * 2x2 Matrix * Point (or Vector): | + | * <code>2x2 Matrix * Point (or Vector)</code>: multiplies the ''Matrix'' by the given ''Point / Vector'' and yields a point. |
− | {{example| | + | : {{example|1={{1, 2}, {3, 4}} * (3, 4) yields the point ''A'' = (11, 25).}} |
− | * 3x3 Matrix * Point (or Vector): | + | * <code>3x3 Matrix * Point (or Vector)</code>: multiplies the ''Matrix'' by the given ''Point / Vector'' and yields a point. |
− | {{example| | + | : {{example|1={{1, 2, 3}, {4, 5, 6}, {0, 0, 1}} * (1, 2) gives you the point A = (8, 20).}} |
− | {{note|This is a special case for affine transformations where | + | : {{note|1=This is a special case for affine transformations where homogeneous coordinates are used: (x, y, 1) for a point and (x, y, 0) for a vector. This example is therefore equivalent to: <code><nowiki>{{1, 2, 3}, {4, 5, 6}, {0, 0, 1}} * {1, 2, 1}</nowiki></code>.}} |
+ | * <code>Matrix1 / Matrix2</code>: Divides each element of ''Matrix1'' by the corresponding element in ''Matrix2''. | ||
+ | :{{note|1=However, GeoGebra supports the syntax <code><nowiki>Matrix1 * Matrix2 ^(-1)</nowiki></code> .}} | ||
− | + | ==Other operations== | |
+ | The section [[Matrix Commands]] contains the list of all available commands related to matrices, such as: | ||
+ | * [[Determinant Command|Determinant]][Matrix]: calculates the determinant for the given matrix. | ||
+ | * [[Invert Command|Invert]][Matrix]: inverts the given matrix | ||
+ | * [[Transpose Command|Transpose]][Matrix]: transposes the given matrix | ||
+ | * [[ApplyMatrix Command|ApplyMatrix]][Matrix,Object]: apply affine transform given by matrix on object. | ||
+ | * [[ReducedRowEchelonForm Command|ReducedRowEchelonForm]][Matrix]: converts the matrix to a reduced row-echelon form | ||
− | |||
− | |||
− | + | __NOTOC__ | |
− | |||
− | |||
− |
Latest revision as of 11:13, 27 October 2015
GeoGebra supports real matrices, which are represented as a list of lists that contain the rows of the matrix.
Example: In GeoGebra, {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}} represents the 3x3 matrix \begin{pmatrix}1&2&3\\ 4&5&6\\ 7&8&9 \end{pmatrix}
To display a matrix using LaTeX formatting in the Graphics View, use the FormulaText command or drag and drop the matrix definition from Algebra View to Graphics View.
Example: In the Input Bar type
FormulaText[{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}]
to display the matrix using LaTeX formatting.
Accessing Elements of Matrices
To access particular elements of a matrix you can use the Element Command or the simplified syntax shown in the example below:
Example: Let
matrix={{1, 2}, {3, 4}}
, then: matrix(1, 1)
returns the first element in the first line: 1matrix(2, 2)
,matrix(-1,2)
,matrix(2,-1)
andmatrix(-1,-1)
all return the second element of the second line: 4.- In general,
matrix(i, j)
, where i and j are integers, returns the element of the matrix that occupies the i-th row and the j-th column.
Matrix Operations
Matrix operations are operations with lists, so the following syntaxes produce the described results.
Note: Some syntaxes can represent operations which are not defined in the same way in the matrices set.
Addition and subtraction
Matrix1 + Matrix2
: adds the corresponding elements of two compatible matrices.Matrix1 – Matrix2
: subtracts the corresponding elements of two compatible matrices.
Multiplication and division
Matrix * Number
: multiplies each element of Matrix by the given Number.Matrix1 * Matrix2
: uses matrix multiplication to calculate the resulting matrix.
- Note: The rows of the first and columns of the second matrix need to have the same number of elements.
- Example: {{1, 2}, {3, 4}, {5, 6}} * {{1, 2, 3}, {4, 5, 6}} yields the matrix {{9, 12, 15}, {19, 26, 33}, {29, 40, 51}}.
2x2 Matrix * Point (or Vector)
: multiplies the Matrix by the given Point / Vector and yields a point.
- Example: {{1, 2}, {3, 4}} * (3, 4) yields the point A = (11, 25).
3x3 Matrix * Point (or Vector)
: multiplies the Matrix by the given Point / Vector and yields a point.
- Example: {{1, 2, 3}, {4, 5, 6}, {0, 0, 1}} * (1, 2) gives you the point A = (8, 20).
- Note: This is a special case for affine transformations where homogeneous coordinates are used: (x, y, 1) for a point and (x, y, 0) for a vector. This example is therefore equivalent to:
{{1, 2, 3}, {4, 5, 6}, {0, 0, 1}} * {1, 2, 1}
.
Matrix1 / Matrix2
: Divides each element of Matrix1 by the corresponding element in Matrix2.
- Note: However, GeoGebra supports the syntax
Matrix1 * Matrix2 ^(-1)
.
Other operations
The section Matrix Commands contains the list of all available commands related to matrices, such as:
- Determinant[Matrix]: calculates the determinant for the given matrix.
- Invert[Matrix]: inverts the given matrix
- Transpose[Matrix]: transposes the given matrix
- ApplyMatrix[Matrix,Object]: apply affine transform given by matrix on object.
- ReducedRowEchelonForm[Matrix]: converts the matrix to a reduced row-echelon form
Comments
Note: See the official forum for a more detailed discussion about the multiplication of matrices.