Create a vector A by assigning a list of elements in square brackets. Use the colon(:) followed by the equal(=) sign :=
Create a second vector, B
Add the two vectors
Subtract them
Now load the linear algebra library
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
Now take the dot or inner product using the innerprod(...) function
Compute the Euclidean Norm of A using the norm(...,2) function. 2 signifies the Euclidean norm.
Now try the cross product using the crossprod(...) function
The cross product is perpendicular to either vector so
The angle between A and B can be computed using the angle(...) function
Or we can use the book definition
Are they the same?
Use evalf to evaluate each one.
Hmmm...pretty close. Just realize that the values within the arccos(...) are the same so the answers really are the same.
Different algorithms produce different rounding results
Clear A and B. Assigning a variable to itself in quotes, clears the variable
Now make two generic vectors. (To create the subscript use shift hyphen to drop the into subscript mode)
Now perform the dot product, norm and cross product to get the book formulas.