In order to successfully complete this assignment you must do the required reading, watch the provided videos and complete all instructions. The embedded survey form must be entirely filled out and submitted on or before 11:59pm on on the day before class. Students must come to class the next day prepared to discuss the material covered in this assignment.
# Load Useful Python Libraries
%matplotlib inline
import matplotlib.pylab as plt
import numpy as np
import sympy as sym
sym.init_printing(use_unicode=True)
In class we talked about the Python sympy
library which has a "reduced row echelon form" (rref) function that runs a much more efficient version of the Gauss-Jordan function. To use the rref
function you must first convert your matrix into a sympy.Matrix
and then run the function. For example, lets do this for the following matrix $B$:
B = np.matrix([[ 50, 13, 30 ], [100, 26, 60 ], [20.5, 25, 650]])
sym.Matrix(B).rref()
This function outputs two values (a matrix and a tuple). For the purposes of this class we only care about the matrix. I generally use the following syntax when using rref()
sym.Matrix(B).rref()[0]
✅QUESTION: Although we do not use it often in this course, what does the second output of the rref
mean (i.e. what does (0,1)
mean? hint: read the documentation for rref
.
Put your answer to the above question here
How lets consider the multi-week example from a previous assignment, where:
Week 1: $$ c + b = 30 $$ $$ 20c + 25b = 690 $$
Week 2: $$ c + b = 35 $$ $$ 20c + 25b = 750 $$
Week 3: $$ c + b = 30 $$ $$ 20c + 25b = 650 $$
✅DO THIS: Write a $2 \times 5$ augmented matrix representing the 6 equations above. (you can just copy and paste this from the pre-class if you got it right there), Name your Matrix $G$ to verify your answer using the checkanswer
function below.
#Put your answer to the above question here.
The following function will apply the rref function to the matrix $G$ and store it in a variable called, wait for it, rref
:
rref,_ = sym.Matrix(G).rref()
rref
✅QUESTION: Given the above, How many hours did Giselle work as a capenter for the three weeks and how many hours did she work as a blacksmith. Fill in your answers below to check if you are correct:
#Replace the zeros with your answers
carpenter_week1 = 0
carpenter_week2 = 0
carpenter_week3 = 0
blacksmith_week1 = 0
blacksmith_week2 = 0
blacksmith_week3 = 0
from answercheck import checkanswer
hours = [[carpenter_week1, carpenter_week2, carpenter_week3],
[blacksmith_week1, blacksmith_week2, blacksmith_week3]]
hours = np.matrix(hours).astype('float')
checkanswer.matrix(hours,'b2d4a73cac3c95204f5ed743b507093a');
In this section we will cover some of the basic vector math we will use this semester.
✅DO THIS: Watch the following summary video about calculation of vector length, Normalizing vectors and the distance between points then answer the questions.
from IPython.display import YouTubeVideo
YouTubeVideo("S0BIhbV6reI",width=640,height=360, cc_load_policy=True)
✅QUESTION: Calculate length of vector (4.5, 2.6, 3.3, 4.1)?
#Put your answer to the above question here
from answercheck import checkanswer
checkanswer.float(length,'695da96d4a240e54bd8c61e75ff5a3e2');
✅QUESTION: What is a normalized form of the vector (4.5, 2.6, 3.3, 4.1)?
#Put your answer to the above question here
from answercheck import checkanswer
checkanswer.vector(norm,'12c94f16ba11222987ca20006790182d');
✅QUESTION: What is the distance between (4.5, 2.6, 3.3, 4.1) and (4, 3, 2, 1)?
#Put your answer to the above question here
from answercheck import checkanswer
checkanswer.float(distance,'d73defc9a514eb70434190e1757f5bb8');
✅DO THIS: Review Sections 1.4 and 1.5 of the Boyd and Vandenberghe text and answer the questions below.
✅QUESTION: What is the dot product between $u = [ 1, 7, 9, 11]$ and $v = [ 7, 1, 2, 2]$ (Store the information in a variable called uv
)?
#Put your answer to the above question here
from answercheck import checkanswer
checkanswer.float(uv,'48044bf058c2d7d21b311b173a0ca7e5');
✅QUESTION: What is the norm of vector $u$ defined above (store this value in a variabled called n
)?
#Put your answer to the above question here
from answercheck import checkanswer
checkanswer.float(n,'96078eb552924d7bdb9e67f9ecab88c1');
✅QUESTION: What is the distance between points $u$ and $v$ defined above. (put your answer in a variable named d
)
#Put your answer to the above question here
from answercheck import checkanswer
checkanswer.float(d,'71f49beeb28061bc60eb3d9966497416');
There are two properties that define a vector space these are:
For now we will consider vector spaces in $R^n$ which are just vectors of real numbers (ex: [10,20,3.2], [5,8,32], [8,-0.7], etc) where $n$ is just the length of the vector (ex: 3, 3, and 2 in the earlier example). In the general case a vector does not have to be composed of real numbers but can be almost any type of object as long as it maintains the two above properties, we will get into this concept later in the semester. In the case of real number the above concepts can be described as follows:
The following are some properties of vector addition and multiplication for vectors $u$ and $v$:
✅QUESTION: Compute the following linear combinations for $u = (1,2), v = (4,-1)$, and $w = (-3,5)$.
(a) $a = u+w$
Put your answer here
from answercheck import checkanswer
checkanswer.vector(a,'af464d466ae982f2cd4461af494e86d6');
(b) $a = 2u+v$
Put your answer here
from answercheck import checkanswer
checkanswer.vector(a,'393468eff8c6ba5d27b7d0aa1b18f929');
(c) $a = u+3w$
Put your answer here
from answercheck import checkanswer
checkanswer.vector(a,'d5e5ca43a86501bcde09b1cbc0ba49b5');
Please fill out the form that appears when you run the code below. You must completely fill this out in order to receive credit for the assignment!
If you have trouble with the embedded form, please make sure you log on with your MSU google account at googleapps.msu.edu and then click on the direct link above.
✅ **Assignment-Specific QUESTION:** What is the distance between (4.5, 2.6, 3.3, 4.1) and (4, 3, 2, 1)?
Put your answer to the above question here
✅ **QUESTION:** Summarize what you did in this assignment.
Put your answer to the above question here
✅ **QUESTION:** What questions do you have, if any, about any of the topics discussed in this assignment after working through the jupyter notebook?
Put your answer to the above question here
✅ **QUESTION:** How well do you feel this assignment helped you to achieve a better understanding of the above mentioned topic(s)?
Put your answer to the above question here
✅ **QUESTION:** What was the most challenging part of this assignment for you?
Put your answer to the above question here
✅ **QUESTION:** What was the least challenging part of this assignment for you?
Put your answer to the above question here
✅ **QUESTION:** What kind of additional questions or support, if any, do you feel you need to have a better understanding of the content in this assignment?
Put your answer to the above question here
✅ **QUESTION:** Do you have any further questions or comments about this material, or anything else that's going on in class?
Put your answer to the above question here
✅ **QUESTION:** Approximately how long did this pre-class assignment take?
Put your answer to the above question here
from IPython.display import HTML
HTML(
"""
<iframe
src="https://cmse.msu.edu/cmse314-pc-survey"
width="100%"
height="1000px"
frameborder="0"
marginheight="0"
marginwidth="0">
Loading...
</iframe>
"""
)
To get credits for this assignment, you must fill out and submit the above survey form on or before the assignment due date.
Written by Dr. Dirk Colbry, Michigan State University
This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.