checkanswer.matrix(D, '8313fe0f529090d6a8cdb36248cfdd6c');


# &#9989;  **<font color=red>Do this:</font>** Find the eigenvalues and eigenvectors of $A$. Set variables ```e1``` and ```vec1``` to be the largest eigenvalue and it's associated eigenvector and ```e2, vec2``` to represent the  smallest.

# In[ ]:


#Put your answer to the above question here.


# In[ ]:


from answercheck import checkanswer
checkanswer.float(e1, "d1bd83a33f1a841ab7fda32449746cc4");


# In[ ]:


from answercheck import checkanswer
checkanswer.float(e2, "e4c2e8edac362acab7123654b9e73432");


# In[ ]:


from answercheck import checkanswer
checkanswer.eq_vector(vec1, "09d9df5806bc8ef975074779da1f1023", decimal_accuracy = 4)
#  &#9989; **<font color=red>QUESTION:</font>** What is a good value to set for ```e``` and why?

# Put your answer to the above question here.

# &#9989; **<font color=red>QUESTION:</font>** The errors seen in this example seem like they would be fairly common in Python.  See if you can find a function in ```Numpy``` that has the same purpose as  ```checktrue```:

# **_Put your answer to the above question here._**

# The class ```answercheck``` program will take into consideration round off error.  For example, the ```checkanswer.float``` command would consider both of the above correct:

# In[7]:

from answercheck import checkanswer

checkanswer.float(0.300, 'e85b79abfd76b7c13b1334d8d8c194a5')

# In[ ]:

checkanswer.float(0.1 + 0.2, 'e85b79abfd76b7c13b1334d8d8c194a5')

#
#
# ---
# <a name=Solving-Systems-of-Linear-Equations></a>
# ## 2. Solving  Square Systems of Linear Equations Using Numpy
#
#
# Remember the following set of equations from the mass weight example:
#
# <img src="https://lh4.googleusercontent.com/48AcnVEBkzXJ_heu4fR0DbP5BBunyRlzPsTeK8WSBsMTSjZ5QNhdhtnVsdAw7wD0NBITIiSmh9Jn0gTPABkxqDa-LrhRicZGdpfbYakgWjJetZfOPk636Eu-vjmj=w740" align="center" width="70%" alt="Image showing two balanced beams, each with three weights. In the top beam is unknown weight A is a distance of 40 to the left of the fulcrum, unknown weight B is a distance of 15 to the left of the fulcrum and a weight of 2 is 50 to the right of the fulcrum. In the bottom beam is the same unknown weights.  Weight A is now a distance of 50 to the right of the fulcrum, weight B is a distance of 25 to the left of the fulcrum and the weight of 2 is a distance of 25 to the right of the fulcrum.">
# or:
#
# $$ u \cdot v = \sum^n_{i=1} u_i v_i$$
#
# &#9989;  **<font color=red>Do This</font>**: Find the dot product of the vectors $u = (1,2,3)$ and $v = (7,9,11)$.

# In[6]:

##Do your work here

# In[7]:

from answercheck import checkanswer

checkanswer.detailedwarnings = False
checkanswer.float(dot, '9ed469ac3b8ef2d21d85e191c8cd24cd')

#
#
# ---
# <a name=Matrix-Multiply></a>
# ## 3. Matrix Multiply
#
# Two matrices $A$ and $B$ can be multiplied together if and only if their "inner dimensions" are the same, i.e. $A$ is
# $m\times d$ and $B$ is $d\times n$ (note that the columns of $A$ and the rows of $B$ are both $d$).
# Multiplication of these two matrices results in a third matrix $C$ with the dimension of $m\times n$.
# Note that $C$ has the same first dimension as $A$ and the same second dimension as $B$. i.e $m\times n$.
#
# _**The $(i,j)$ element in $C$ is the dot product of the $i$th row of $A$ and the $j$th column of $B$.**_
#
# The $i$th row of $A$ is:
Ejemplo n.º 4
0
def test_float_error():
    f = 4.0
    with pytest.raises(Exception) as e_info:
        checkanswer.float(f, '2e55d74f5c78981f6b877b198bdc61ba')
Ejemplo n.º 5
0
# \end{matrix}
# \right] 
# $$

# In[2]:


#Put your answer here


# In[3]:


from answercheck import checkanswer

checkanswer.float(det,'49afb719e0cd46f74578ebf335290f81');


# ----
# 
# <a name="Properties_of_Determinants"></a>
# ## 2. Properties of Determinants
# 
# The following are some helpful properties when working with determinants.  These properties are often used in proofs and can sometimes be utilized to make faster calculations.
# 
# ### Row Operations
# 
# Let $A$ be an $n \times n$ matrix and $c$ be a nonzero scalar. Let $|A|$ be a simplified syntax for writing the determinant of $A$: 
# 
# 1. If a matrix $B$ is obtained from $A$ by multiplying a row (column) by $c$ then $|B| = c|A|$.
# 2. If a matrix $B$ is obtained from $A$ by interchanging two rows (columns) then $|B| = -|A|$.
Ejemplo n.º 6
0
def test_float_int():
    f = 1
    checkanswer.float(f, 'e4c2e8edac362acab7123654b9e73432')
Ejemplo n.º 7
0
def test_float_negative_zero():
    f = -0.00
    checkanswer.float(f, '30565a8911a6bb487e3745c0ea3c8224')
Ejemplo n.º 8
0
def test_float_array():
    f = [[0.0111]]
    checkanswer.float(f, '2e55d74f5c78981f6b877b198bdc61ba')
Ejemplo n.º 9
0
def test_float_roundoff():
    f = 0.011100001
    checkanswer.float(f, '2e55d74f5c78981f6b877b198bdc61ba')
Ejemplo n.º 10
0
def test_float():
    f = 0.0111
    checkanswer.float(f, '2e55d74f5c78981f6b877b198bdc61ba')
Ejemplo n.º 11
0
# Put your answer to the above question here

# In[ ]:


##work here

# dist = 


# In[ ]:


from answercheck import checkanswer
checkanswer.float(dist,'f8f24a9cedb159fc084bc4e6e347dc07')


# ---- 
# <a name='innerP'></a>
# ## 6. Inner Products and Matrices
# 
# The following is a review from the pre-class assignment.
# 
# An inner product on a real vector space $V$ is a function that associates a number, denoted as $\langle u,v \rangle$, with each pair of vectors $u$ and $v$ of $V$. This function satisfies the following conditions for vectors $u, v, w$ and scalar $c$:
# 
# 
# $$\langle u,v \rangle = \langle v,u \rangle \text{ Symmetry axiom}$$ 
# 
# $$\langle u+v,w \rangle = \langle u,w \rangle + \langle v,w \rangle \text{ Additive axiom}$$ 
# 
Ejemplo n.º 12
0
# &#9989; **<font color=red>QUESTION:</font>**   Assuming each team starts with 500,000 fans, what is the steady state of this model? (i.e. in the long term how many Spartan and Wolverine fans will there be?).

# In[ ]:


#Put your answer here


# In[ ]:


steadystate


# In[ ]:


from answercheck import checkanswer
checkanswer.float(spartans,'06d263de629f4dbe51eafd524b69ddd9');


# In[ ]:


from answercheck import checkanswer
checkanswer.float(wolverines,'62d63699c8f7b886ec9b3cb651bba753');


# 
#