dot product r code example
Example 1: dot product
Let a be a vector with coordinates (a1, a2, a3)
Let b be a vector with coordinates (b1, b2, b3)
Dot Product:
<a1, a2, a3> • <b1, b2, b3> = a1*b1 + a2*b2 + a3*b3
a • b = |a||b|cosθ, where θ is the angle between the two vectors
Example 2: r dot product
a = c(1,2)
b = c(0,1)
# Perform the dot product
a%*%b