Calculating vectors with the cosine law (Python)
Question: I was trying to develop a little console aplication for solving additions
between vectors using the Cosine Law:

    
    
    sum = sqrt((s1 ** 2) + (s2 ** 2) + (2 * s1 * s2 * cos(angle)))
    print(sum)
    

`# Where s1 and s2 are the sizes of the vectors, respectively.`

But the, the cos in the equation returned a weird value (the angle was 60, so
the `cos(angle)` should be 1/2, right?).

Also, I tried changing the `cos` with `acos` after reading other solutions,
but it returned `ValueError: math domain error`.

Does anyone know how to solve this?


Answer: Python's trigonometric functions use radians, rather than degrees.
Fortunately, the `math` module includes a function to perform the conversion
for you:

    
    
    from math import cos, radians
    
    sum = sqrt((s1 ** 2) + (s2 ** 2) + (2 * s1 * s2 * cos(radians(angle))))
    print(sum)
    

