Find the bug
This is an easy bug to spot. Although the given equation appears to be complex, it is correct. The problem is that the sampling frequency is given to be almost the exact same as the function period, meaning that it may only mark points about once every period:
very unfortunate looking :p
When the sampling frequency is made much smaller, the function is good one.
much better, nice try at tricks though