Algorithm for proper drawing of cosine function
There is in fact a way to avoid this effect and it is outlined by the NYQUIST sampling theorem - which states that the sampling rate should be at least twice as high as the maximum frequency of the function of interest. 
In this case where cos(a * t) is the function of interest, the frequency is a/(2*pi) - therefore your sampling rate should be greater than 2 * a/(2*pi) (in this case you may even want the sampling rate to be even higher so that the cosine function has a nice curve to it). 
To get the step size from this sampling rate just use t = 1/(sampling rate) 
Hope this helps :)