Loading...
Given two vectors (as comma-separated floats), compute the cosine similarity between them.
Cosine similarity measures the cosine of the angle between two vectors: cosine_similarity=∥A∥×∥B∥A⋅B
Round the result to 4 decimal places.
Input format:
1.0,0.0,1.0 0.0,1.0,1.0
0.5
Step 1: Compute dot product A·B = 1.00.0 + 0.01.0 + 1.0*1.0 = 1.0
Step 2: Compute magnitudes ||A|| = sqrt(1+0+1) = sqrt(2) ≈ 1.4142 ||B|| = sqrt(0+1+1) = sqrt(2) ≈ 1.4142
Step 3: Divide 1.0 / (1.4142 * 1.4142) = 1.0 / 2.0 = 0.5