u<-c(0.5,0.5)
v<-c(3,-4)
uvDotproduct <- u%*%v
uvDotproduct
## [,1]
## [1,] -0.5
What are the lengths of u and v? Please note that the mathematical notion of the length of a vector is not the same as a computer science definition. The length or magnitute of a vector is the hypotenuse as in a pythogorean theorem. Hypotenuse = Squareroot of ((square(0->0.5) + square(0->0.5)))
hypotenuseU <- sqrt(sum(u^2))
hypotenuseU
## [1] 0.7071068
hypotenuseV <- sqrt(sum(v^2))
hypotenuseV
## [1] 5
What is the linear combination: 3u - ???? 2v?
lc = 3*u-2*v
lc
## [1] -4.5 9.5
What is the angle between u and v ? The angle between u and v is the arcCosine of the dot product of u and v divided by the product of Magnitude of u and maginitude of v Theta = ArcCosine( u.v/ ||u||.||v||)
theta = acos(uvDotproduct/(hypotenuseU*hypotenuseV))
angle = theta * 180/pi
angle
## [,1]
## [1,] 98.1301
Question 2 : Set up a system of equations with 3 variables and 3 constraints and solve for x. Please write a function in R that will take two variables (matrix A & constraint vector b) and solve using elimination. Your function should produce the right answer for the system of equations for any 3-variable, 3-equation system. You don’t have to worry about degenerate cases and can safely assume that the function will only be tested with a system of equations that has a solution. Please note that you do have to worry about zero pivots, though. Please note that you should not use the built-in function solve to solve this system or use matrix inverses. The approach that you should employ is to construct an Upper Triangular Matrix and then back-substitute to get the solution. Alternatively, you can augment the matrix A with vector b and jointly apply the Gauss Jordan elimination procedure.
#THis seems a bit diffucult for me . I want to take some time to solve this problem.
#I hope to do this by the end of the week.