import numpy as np
import scipy
import sympy
from numpy import linalg as lg
from numpy.linalg import solve
from numpy.linalg import eig
from scipy.integrate import quad

# Question 1
'''
	  [1]
T(u) =[2]
	 [-3]

	 [k/4]
T(v)=[c/4]
	 [a/4]
'''

# Question 2
a1 = np.matrix([[1, -4, 3], [0, 1, -2], [2, -9, 6]])
b1 = np.matrix([[-6, -5, -5]]).T
c1 = np.column_stack([a1, b1])
print(c1)

d1 = sympy.Matrix(c1).rref()
print(d1) # Correct

# Is the vector x found in the previous step​ unique?
# Yes, because there are no free variables in the system of equations.

# Question 3
'''
	[-8]
v1 =[-9]

	[-1]
v2 = [4]

	[-8 -1]
A = [-9  4]

'''



# Question 4
'''
a. A linear transformation is a special type of function.
True. A linear transformation is a function from set of real numbers R Superscript n to set of real numbers R Superscript m that assigns to each vector x in set of real numbers R Superscript n a vector ​T(x​) in set of real numbers R Superscript m.

b. If A is a 3 times 5 matrix and T is a transformation defined by ​T(x​)equalsAx​, then the domain of T is set of real numbers R cubed.

False. The domain is actually set of real numbers R Superscript 5​, because in the product Ax​, if A is an m times n matrix then x must be a vector in set of real numbers R Superscript n.

c. If A is an m times n ​matrix, then the range of the transformation x maps to  Ax is set of real numbers R Superscript m.
False. The range of the transformation is the set of all linear combinations of the columns of​ A, because each image of the transformation is of the form Ax.

d. Every linear transformation is a matrix transformation.

False. A matrix transformation is a special linear transformation of the form x maps to Ax where A is a matrix.

e. e. A transformation T is linear if and only if Tleft parenthesis c 1 Bold v 1 plus c 2 Bold v 2 right parenthesisequalsc 1 Upper T left parenthesis Bold v 1 right parenthesis plus c 2 Upper T left parenthesis Bold v 2 right parenthesis for all Bold v 1 and Bold v 2 in the domain of T and for all scalars c 1 and c 2.

True. This equation correctly summarizes the properties necessary for a transformation to be linear.

'''


# Question 5
'''
Assume that T is a linear transformation. Find the standard matrix of T.
​T: set of real numbers R squaredright arrowset of real numbers R Superscript 4​, Upper T left parenthesis Bold e 1 right parenthesisequals​(6​, 1​, 6​, 1​), and Upper T left parenthesis Bold e 2 right parenthesisequals​(negative 7​, 4​, ​0, 0), where Bold e 1equals​(1,0) and Bold e 2equals​(0,1)


	[6, -7]
	[1,  4]
A = [6,  0]
	[1,  0]

'''

# Question 6
# Trig question

# Question 7
'''
Assume that T is a linear transformation. Find the standard matrix of T.
​T: set of real numbers R squaredright arrowset of real numbers R squared​, first performs a horizontal shear that transforms Bold e 2 into Bold e 2 plus 17 Bold e 1 ​(leaving Bold e 1 ​unchanged) and then reflects points through the line x 2 equals negative x 1.

	 [0 -1]
A =[-1 -17]

'''

# Question 8
# Fill in the missing entries for the matrix

# Question 9
# Fill in the missing entries for the matrix

# Question 10
a2 = np.matrix([[1, 1, 2],[2, 6, -16]])
print(a2)
b2 = sympy.Matrix(a2).rref()
print(b2) # Correct


# Question 11
'''
a. If A is a 4 times 3 ​matrix, then the transformation x maps to Ax maps set of real numbers R cubed onto set of real numbers R Superscript 4. Choose the correct answer below.
False. The columns of A do not span set of real numbers R Superscript 4.

b. Every linear transformation from set of real numbers R Superscript n to set of real numbers R Superscript m is a matrix transformation. Choose the correct answer below.
True. There exists a unique matrix A such that Upper T left parenthesis Bold x right parenthesis equals Upper A Bold x for all x in set of real numbers R Superscript n.

c. The columns of the standard matrix for a linear transformation from set of real numbers R Superscript n to set of real numbers R Superscript m are the images of the columns of the n times n identity matrix under T. Choose the correct answer below.
True. The standard matrix is the m times n matrix whose jth column is the vector Upper T left parenthesis Bold e Subscript j right parenthesis​, where Bold e Subscript j is the jth column of the identity matrix in set of real numbers R Superscript n.

d. A mapping​ T: set of real numbers R Superscript nmaps toset of real numbers R Superscript m is​ one-to-one if each vector in set of real numbers R Superscript n maps onto a unique vector in set of real numbers R Superscript m. Choose the correct answer below.
False. A mapping T is said to be​ one-to-one if each b in set of real numbers R Superscript m is the image of at most one x in set of real numbers R Superscript n.

e. The standard matrix of a horizontal shear transformation from set of real numbers R squared to set of real numbers R squared has the form left bracket Start 2 By 2 Matrix 1st Row 1st Column a 2nd Column 0 2nd Row 1st Column 0 2nd Column d EndMatrix right bracket . Choose the correct answer below.
False. The standard matrix has the form left bracket Start 2 By 2 Matrix 1st Row 1st Column 1 2nd Column k 2nd Row 1st Column 0 2nd Column 1 EndMatrix right bracket .

'''

# Question 12
'''
Determine if the specified linear transformation is ​(a​) ​one-to-one and ​(b​) onto. Justify each answer.

a.
T is not​ one-to-one because the columns of the standard matrix A are linearly dependent.

b. 
T is onto because the columns of the standard matrix A span set of real numbers R squared.
'''

# Question 13
# The transformation T is not​ one-to-one because the equation Upper T left #parenthesis Bold x right parenthesis equals Bold 0 has a nontrivial solution. 

# Question 14
a3 = np.matrix([[110, 120, 350], [4, 2, 8], [20, 18, 56], [2, 5, 12]])
print(a3)
b3 = sympy.Matrix(a3).rref()
print(b3) # Correct