<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Learning About the Singular Value Decomposition
This notebook explores the Singular Value Decomposition (SVD)
Step1:  Start With A Simple Matrix
Step2:  Now Take the SVD
Step3:  Check U, S and V^T Do Actually Reconstruct A
<ASSISTANT_TASK:>
Python Code:
# import numpy for SVD function
import numpy
# import matplotlib.pyplot for visualising arrays
import matplotlib.pyplot as plt
Explanation: Learning About the Singular Value Decomposition
This notebook explores the Singular Value Decomposition (SVD)
End of explanation
# create a really simple matrix
A = numpy.array([[-1,1], [1,1]])
# and show it
print("A = \n", A)
# plot the array
p = plt.subplot(111)
p.axis('scaled'); p.axis([-2, 2, -2, 2]); p.axhline(y=0, color='lightgrey'); p.axvline(x=0, color='lightgrey')
p.set_yticklabels([]); p.set_xticklabels([])
p.set_title("A")
p.plot(A[0,],A[1,],'ro')
plt.show()
Explanation: Start With A Simple Matrix
End of explanation
# break it down into an SVD
U, s, VT = numpy.linalg.svd(A, full_matrices=False)
S = numpy.diag(s)
# what are U, S and V
print("U =\n", U, "\n")
print("S =\n", S, "\n")
print("V^T =\n", VT, "\n")
for px in [(131,U, "U"), (132,S, "S"), (133,VT, "VT")]:
    subplot = px[0]
    matrix = px[1]
    matrix_name = px[2]
    p = plt.subplot(subplot)
    
    p.axis('scaled'); p.axis([-2, 2, -2, 2]); p.axhline(y=0, color='lightgrey'); p.axvline(x=0, color='lightgrey')
    p.set_yticklabels([]); p.set_xticklabels([])
    p.set_title(matrix_name)
    p.plot(matrix[0,],matrix[1,],'ro')
    pass
plt.show()
Explanation: Now Take the SVD
End of explanation
# rebuild A2 from U.S.V
A2 = numpy.dot(U,numpy.dot(S,VT))
print("A2 = \n", A2)
# plot the reconstructed A2
p = plt.subplot(111)
p.axis('scaled'); p.axis([-2, 2, -2, 2]); p.axhline(y=0, color='lightgrey'); p.axvline(x=0, color='lightgrey')
p.set_yticklabels([]); p.set_xticklabels([])
p.set_title("A2")
p.plot(A2[0,],A2[1,],'ro')
plt.show()
Explanation: Check U, S and V^T Do Actually Reconstruct A
End of explanation
<END_TASK>