If you look at what the results actually are:
>>> sin(pi/4)
0.70710678118654746
>>> cos(pi/4)
0.70710678118654757
You will note that they are very, very close, but not exactly the same. Due to these kinds of floating point representation issues, it is usual to use a threshold to compare values that should be the same:
>>> abs(sin(pi/4) - cos(pi/4)) < 1e-9
True
Fun fact: using numpy
's sqrt
, too:
>>> sqrt(2)/2
0.70710678118654757
>>> sqrt(2)/2 == cos(pi/4)
True