Write a function angle_between(v1, v2) that computes the angle in radians between two vectors using the cosine similarity formula.
**Formula:** angle = arccos(dot(v1, v2) / (||v1|| * ||v2||))
Example:
Input: v1 = [1, 0], v2 = [0, 1]
Output: 1.5708
**Explanation:** cos(angle) = 0/(1*1) = 0, so angle = arccos(0) = pi/2 ≈ 1.5708
Constraints:
Test Cases
Test Case 1
Input:
[1, 0], [0, 1]Expected:
1.5708Test Case 2
Input:
[1, 0], [1, 0]Expected:
0.0Test Case 3
Input:
[1, 0], [-1, 0]Expected:
3.1416+ 2 hidden test cases