📚 The CoCalc Library - books, templates and other resources
License: OTHER
<?xml version="1.0" encoding="UTF-8" ?>12<!-- Sage and Linear Algebra Worksheets -->3<!-- Robert A. Beezer -->4<!-- Copyright 2017-2019 License: CC BY-SA -->5<!-- See COPYING for more information -->67<pretext xmlns:xi="http://www.w3.org/2001/XInclude">89<xi:include href="../worksheetinfo.xml" />1011<article xml:id="RREF">12<title>Sage and Linear Algebra Worksheet</title>13<subtitle>FCLA Section RREF</subtitle>1415<!-- header inclusion needs -xinclude switch on xsltproc -->16<frontmatter>17<xi:include href="../header.xml" />18</frontmatter>1920<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>2122<sage>23<input>24A = matrix(QQ, 3, 4, [[-1, 1, 1, 1],25[ 2, -1, -2, -3],26[-2, 2, 1, -1]])27A28</input>29</sage>3031<p>Then use the <c>.rref()</c> method to compute the reduced row-echelon form.</p>3233<exercise>34<statement>35<p>Use a new cell, enter <c>A.rref()</c>, and execute the cell.</p>36</statement>37</exercise>3839<sage />4041<p>Here is a larger example.</p>4243<sage>44<input>45B = matrix(QQ, [[ 0, 0, -1, 3, 3, -1, 2, -1],46[ 1, -5, 0, -4, 5, -2, 4, 4],47[-1, 5, -1, 7, -2, 2, -5, -7],48[-1, 5, 1, 1, -8, 3, -6, -3]])49B50</input>51</sage>5253<exercise>54<statement>55<p>As above, use a new cell to compute the reduced row-echelon form of <c>B</c>.</p>56</statement>57</exercise>5859<sage />6061<xi:include href="../legal.xml" />6263</article>6465</pretext>666768