def cosine(vector1, vector2)
      dot_product = vector1.inner_product(vector2)
      dot_product / (vector1.r * vector2.r) # Vector#r is same as ||v||
    end
def cosine(vector1, vector2)
      dot_product = vector1.inner_product(vector2)
      dot_product / (vector1.r * vector2.r) # Vector#r is same as ||v||
    end
see http://www.ltcconline.net/greenl/courses/107/vectors/DOTCROS.HTM
 and http://ruby-doc.org/stdlib/libdoc/matrix/rdoc/index.html
 will be in range 0 to 1, as vectors always positive