Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

📚 The CoCalc Library - books, templates and other resources

132939 views
License: OTHER
1
<?xml version="1.0" encoding="UTF-8" ?>
2
3
<!-- Sage and Linear Algebra Worksheets -->
4
<!-- Robert A. Beezer -->
5
<!-- Copyright 2017-2019 License: CC BY-SA -->
6
<!-- See COPYING for more information -->
7
8
<pretext xmlns:xi="http://www.w3.org/2001/XInclude">
9
10
<xi:include href="../worksheetinfo.xml" />
11
12
<article xml:id="RREF">
13
<title>Sage and Linear Algebra Worksheet</title>
14
<subtitle>FCLA Section RREF</subtitle>
15
16
<!-- header inclusion needs -xinclude switch on xsltproc -->
17
<frontmatter>
18
<xi:include href="../header.xml" />
19
</frontmatter>
20
21
<p>To specify a matrix, first specify that your entries are rational numbers, <c>QQ</c> in Sage parlance. This is extremely important, though an explanation is best saved for later. Then the number of rows and columns. Follow this with a list of rows for the matrix, where each row is another list. We use square brackets, <c>[, ]</c> to organize lists. To actually see <c>A</c> we just write it as the last line.</p>
22
23
<sage>
24
<input>
25
A = matrix(QQ, 3, 4, [[-1, 1, 1, 1],
26
[ 2, -1, -2, -3],
27
[-2, 2, 1, -1]])
28
A
29
</input>
30
</sage>
31
32
<p>Then use the <c>.rref()</c> method to compute the reduced row-echelon form.</p>
33
34
<exercise>
35
<statement>
36
<p>Use a new cell, enter <c>A.rref()</c>, and execute the cell.</p>
37
</statement>
38
</exercise>
39
40
<sage />
41
42
<p>Here is a larger example.</p>
43
44
<sage>
45
<input>
46
B = matrix(QQ, [[ 0, 0, -1, 3, 3, -1, 2, -1],
47
[ 1, -5, 0, -4, 5, -2, 4, 4],
48
[-1, 5, -1, 7, -2, 2, -5, -7],
49
[-1, 5, 1, 1, -8, 3, -6, -3]])
50
B
51
</input>
52
</sage>
53
54
<exercise>
55
<statement>
56
<p>As above, use a new cell to compute the reduced row-echelon form of <c>B</c>.</p>
57
</statement>
58
</exercise>
59
60
<sage />
61
62
<xi:include href="../legal.xml" />
63
64
</article>
65
66
</pretext>
67
68