Skip to content

Implementing change of basis outcome in MX #785

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions source/linear-algebra/exercises/bank.xml
Original file line number Diff line number Diff line change
Expand Up @@ -196,16 +196,17 @@
<path>outcomes/MX/MX2</path>
<slug>MX2</slug>
<description>
Determine if a matrix is invertible, and if so, compute its inverse.
Determine if a matrix is invertible, and if so, compute its inverse
and use it to solve an appropriate system of equations.
</description>
</outcome>
<outcome>
<title>Solving systems with inverse matrices</title>
<title>Change of basis</title>
<path>outcomes/MX/MX3</path>
<slug>MX3</slug>
<description>
Find the unique solution for a system of equations using an
inverse matrix.
Calculate the change-of-basis matrix for the standard basis to a
non-standard basis of <m>\mathbb R^n</m>.
</description>
</outcome>
<outcome>
Expand Down
13 changes: 13 additions & 0 deletions source/linear-algebra/exercises/outcomes/MX/MX2/generator.sage
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,33 @@ class Generator(BaseGenerator):
shuffle(labels)
# invertible matrix
A=CheckIt.simple_random_matrix_of_rank(4,rows=4,columns=4)
solution = column_matrix(
vector(QQ, [randrange(1,5)*choice([-1,1]) for _ in range(4)])
)
vars = column_matrix(var("x_1 x_2 x_3 x_4"))
constants = A*solution
m = A.augment(constants, subdivide=True)
matrices = [{
"matrix": A,
"rref": A.rref(),
"invertible": True,
"inverse": A^(-1),
"label": labels[0],
"vars": vars,
"solution": solution,
"constant_vector": constants,
"vector_eq": TBIL.VectorEquation(m),
}]
# non-invertible matrix
A=CheckIt.simple_random_matrix_of_rank(choice([2,3]),rows=4,columns=4)
constants = A*solution
m = A.augment(constants, subdivide=True)
matrices += [{
"matrix": A,
"rref": A.rref(),
"invertible": False,
"label": labels[1],
"vector_eq": TBIL.VectorEquation(m),
}]

shuffle(matrices)
Expand Down
18 changes: 18 additions & 0 deletions source/linear-algebra/exercises/outcomes/MX/MX2/template.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,24 @@ of an appropriate augmented matrix).
<!-- {{/invertible}} -->
<!-- {{^invertible}} -->
N/A
<!-- {{/invertible}} -->
</p>
</outtro>
</knowl>
<knowl>
<content>
<p>
If the matrix is invertible, explain how to use it with
technology to solve the vector equation <me>{{vector_eq}}.</me>
</p>
</content>
<outtro>
<p>
<!-- {{#invertible}} -->
<me>{{inverse}}{{constant_vector}}={{solution}}</me>
<!-- {{/invertible}} -->
<!-- {{^invertible}} -->
N/A
<!-- {{/invertible}} -->
</p>
</outtro>
Expand Down
35 changes: 19 additions & 16 deletions source/linear-algebra/exercises/outcomes/MX/MX3/generator.sage
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,25 @@ class Generator(BaseGenerator):
def data(self):
# create a 3x3 invertible matrix
A = CheckIt.simple_random_matrix_of_rank(3,rows=3,columns=3)
solution = column_matrix(
new_vector = column_matrix(
vector(QQ, [randrange(1,5)*choice([-1,1]) for _ in range(3)])
)
vars = column_matrix(var("x_1 x_2 x_3"))
constants = A*solution
result = {
"vars": vars,
"solution": solution,
"matrix": A,
"inverse": A^(-1),
"constant_vector": constants,
old_vector = A*new_vector
lin_combo_exp = TBIL.LinearCombination(
[
new_vector[i]
for i in range(3)
],
[
LatexExpr(f"\\vec b_{i+1}")
for i in range(3)
],
)
return {
"M_B": A^(-1),
"v": old_vector,
"lin_combo_exp": lin_combo_exp,
"b_1": column_matrix(A.columns()[0]),
"b_2": column_matrix(A.columns()[1]),
"b_3": column_matrix(A.columns()[2]),
}
m = A.augment(constants, subdivide=True)
if choice([True,False]):
result["system"] = CheckIt.latex_system_from_matrix(m)
else:
result["vector_eq"] = TBIL.VectorEquation(m)
return result

29 changes: 12 additions & 17 deletions source/linear-algebra/exercises/outcomes/MX/MX3/template.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,35 @@
<knowl mode="exercise" xmlns="https://spatext.clontz.org" version="0.2">
<intro>
<p>
Consider the
<!-- {{#system}} -->
system of equations <me>{{system}}</me>
<!-- {{/system}} -->
<!-- {{#vector_eq}} -->
vector equation <me>{{vector_eq}}</me>
<!-- {{/vector_eq}} -->
with a unique solution.
Let <m>\vec{v}= {{v}}</m> and <m>\mathcal B=\{\vec b_1,\vec b_2,\vec b_3\}</m>
where <m>\vec b_1 = {{b_1}}</m>, <m>\vec b_2= {{b_2}}</m>,
and <m>\vec b_3 = {{b_3}}</m>.
</p>
</intro>
<knowl>
<content>
<p>
Explain and demonstrate how this problem can be restated
using matrix multiplication.
Explain and demonstrate how to verify that <m>\mathcal{B}</m> is a basis of <m>\mathbb R^3</m>
and how to calculate <m>M_\mathcal{B}</m>, the change-of-basis matrix from the standard basis of
<m>\mathbb R^3</m> to <m>\mathcal{B}</m>.
</p>
</content>
<outtro>
<p>
<me>{{matrix}}{{vars}}={{constant_vector}}</me>
</p>
<p><m>M_{\mathcal B} = {{M_B}}</m></p>
</outtro>
</knowl>

<knowl>
<content>
<p>
Use the properties of matrix multiplication to find the
unique solution.
Explain and demonstrate how to use <m>M_\mathcal{B}</m> to express <m>\vec{v}</m> in terms of
<m>\mathcal{B}</m>-basis vectors.
</p>
</content>
<outtro>
<p>
<me>{{inverse}}{{constant_vector}}={{solution}}</me>
<m>\vec v = {{lin_combo_exp}}</m>
</p>
</outtro>
</knowl>
</knowl>
</knowl>
128 changes: 128 additions & 0 deletions source/linear-algebra/source/04-MX/02.ptx
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,36 @@ Is the matrix <m>\left[\begin{array}{ccc} 2 &amp; 3 &amp; 1 \\ -1 &amp; -4 &amp;
</statement>
</observation>

<observation>
<statement>
<p>
Let <m>T:\IR^n\to\IR^n</m> be a linear bijection with standard matrix <m>A</m> and suppose <m>\vec{b}\in\IR^n</m>.
By definition of the inverse map and inverse matrix, the vector <m>\vec{x}=A^{-1}\vec{b}</m> is the unique solution to the equation <m>A\vec{x}=\vec{b}</m>.
</p>
<p>
In other words, when the matrix <m>A</m> is invertible, we have a new method for solving the equation <m>A\vec{x}=\vec{b}</m>: we can first calculate <m>A^{-1}</m> and then calculate the product <m>\vec{x}=A^{-1}\vec{b}</m>.
</p>
</statement>
</observation>

<activity>
<introduction>
<p> Consider the vector equation <me>x_{1} \left[\begin{array}{c} 0 \\ 1 \\ 1\\1 \end{array}\right] + x_{2} \left[\begin{array}{c} 0 \\ 0 \\ 1\\-1 \end{array}\right] + x_{3} \left[\begin{array}{c} 0 \\ -1 \\ 0\\-1 \end{array}\right] +x_{4}\left[\begin{array}{c} -1 \\ -4 \\ -4\\2 \end{array}\right]= \left[\begin{array}{c} 1 \\ 1 \\ 1 \\ 1\end{array}\right]</me> with a unique solution. </p>
</introduction>
<task>
<statement>
<p> Use technology to both verify that the coefficient matrix is invertible and calculate its inverse.</p>
</statement>
</task>
<task>
<statement>
<p> Explain and demonstrate how to use the inverse to find the unique solution to the given vector equation. </p>
</statement>
</task>
</activity>
<sage language="octave">
</sage>

<activity estimated-time='10'>
<introduction>
<p>
Expand Down Expand Up @@ -308,6 +338,77 @@ Is the matrix <m>\left[\begin{array}{ccc} 2 &amp; 3 &amp; 1 \\ -1 &amp; -4 &amp;
</statement>
</task>
</activity>
<activity>
<introduction>
<p>
Solving linear systems using matrix multiplication is most useful when we are working with one common coefficient matrix, and varying the right-hand side.
That is, when we have <m>A\vec{x}=\vec{b}</m> for several different values of <m>\vec{b}</m>.
</p>
<p>
In the following, let <m>A=\left[\begin{matrix}2 &amp; -1 &amp; -6\\ 2 &amp; 1 &amp; 3\\ 1 &amp; 1 &amp; 4\end{matrix}\right]</m> and consider the following questions about various equations of the form <m>A\vec{x}=\vec{b}</m>?
</p>
</introduction>
<task>
<statement>
<p>
Suppose that <m>\vec{b}=\left[\begin{matrix} 1\\1\\1\end{matrix}\right]</m>.
If asked to solve the equation <m>A\vec{x}=\vec{b}</m>, which of the following approaches do you prefer?
<ol marker="A.">
<li>
<p>
Calculate <m>\RREF[A|\vec{b}]</m>.
</p>
</li>
<li>
<p>
Calculate <m>A^{-1}</m> and then compute <m>\vec{x}=A^{-1}\vec{b}</m>
</p>
</li>
</ol>
</p>
</statement>
</task>
<task>
<statement>
<p>
Suppose that <m>\vec{b}_1,\vec{b}_2,\vec{b}_3=\left[\begin{matrix} 1\\1\\1\end{matrix}\right],\left[\begin{matrix} 2\\1\\3\end{matrix}\right],\left[\begin{matrix} -1\\3\\5\end{matrix}\right]</m>.
If asked to solve each of the equations <m>A\vec{x}=\vec{b}_1, A\vec{x}=\vec{b}_2, A\vec{x}=\vec{b}_3</m>, which of the following approaches do you prefer?
<ol marker="A.">
<li>
<p>
Calculate <m>\RREF[A|\vec{b}_1]</m>, <m>\RREF[A|\vec{b}_2]</m>, and <m>\RREF[A|\vec{b}_3]</m>
</p>
</li>
<li>
<p>
Calculate <m>A^{-1}</m> and then compute <m>\vec{x}=A^{-1}\vec{b}_1</m>, <m>\vec{x}=A^{-1}\vec{b}_2</m>, and <m>\vec{x}=A^{-1}\vec{b}_3</m>
</p>
</li>
</ol>
</p>
</statement>
</task>
<task>
<statement>
<p>
Suppose that <m>\vec{b}_1,\dots, \vec{b}_{10}</m> are 10 distinct vectors.
If asked to solve each of the equations <m>A\vec{x}=\vec{b}_1, \dots, A\vec{x}=\vec{b}_{10}</m>, which of the following approaches do you prefer?
<ol marker="A.">
<li>
<p>
Calculate <m>\RREF[A|\vec{b}_1]</m>, ... <m>\RREF[A|\vec{b}_{10}]</m>.
</p>
</li>
<li>
<p>
Calculate <m>A^{-1}</m> and then compute <m>\vec{x}=A^{-1}\vec{b}_1</m>, ... <m>\vec{x}=A^{-1}\vec{b}_{10}</m>.
</p>
</li>
</ol>
</p>
</statement>
</task>
</activity>
</subsection>
<subsection>
<title>Videos</title>
Expand Down Expand Up @@ -355,6 +456,33 @@ Is the matrix <m>\left[\begin{array}{ccc} 2 &amp; 3 &amp; 1 \\ -1 &amp; -4 &amp;
</ul>
</statement>
</exploration>
<exploration>
<statement>
Use row reduction to find the inverse of the following general matrix. Give conditions on which this inverse exists.
<me>\left[\begin{array}{ccc}1 &amp; b &amp; c \\ d &amp; e &amp; f \\ g &amp; h &amp; i \end{array}\right]</me>
</statement>
</exploration>

<exploration>
<statement>Assume that <m>H</m> is invertible, and that <m>HG</m> is the zero matrix. Prove that <m>G</m> must be the zero matrix. Would this still be true if <m>H</m> were not invertible?
</statement>
</exploration>

<exploration>
<statement>If <m>H</m> is invertible and <m>r \in \mathbb{R}</m>, what is the inverse of <m>rH</m>?
</statement>
</exploration>

<exploration>
<statement>If <m>H</m> and <m>G</m> are invertible, is <m>H^{-1} + G^{-1} = (H+G)^{-1}</m>?
</statement>
</exploration>

<exploration>
<statement>Prove that if <m>A</m>, <m>P</m>, and <m>Q</m> are invertible with <m>PAQ = I</m>, then <m>A^{-1} = QP</m>.
</statement>
</exploration>

</subsection>
<subsection>
<title>Sample Problem and Solution</title>
Expand Down
Loading