I think that your quaternion is not normalised. Only normalised quaternions represent rotations in 3D, you must have that
q[0]*q[0] + q[1]*q[1] + q[2]*q[2] + q[3]*q[3] == 1
If this is the case, then we always have
d = q[1]*q[3] + q[0]*q[2] <= 0.5
as we have that
q[1]*q[3] <= 0.25 *(q[1] + q[3])^2
where ^
denotes power, by the AM-GM, and similarly for q[0]*q[2]
now we have that
d <= 0.25 * ( (q[1] + q[3])^2 + (q[0] + q[2])^2 )
<= 0.25 * ( q[1]^2 + q[2]^2 + q[3]^2 + q[4]^2 )
<= 0.25
by the normality assumption.