working for both sin(x) and sin(cos(x))