Compute Hann window without cos function In an environment with limited memory and computing power it is interesting to be able to generate a Hann window without using a cache or repetitive calling of expensive functions such as sine and cosine functions.
The following document demonstrate the use of an alternative approach in order to compute a pure tone by storing only a coefficient and the two last results:
http://ww1.microchip.com/downloads/en/appnotes/00543c.pdf
Rewrite using python code:
import math
import matplotlib.pyplot as plt

tone = [0.0] * 50
tone_freq = 1720.0
sample_rate = 44100.0
ffs = tone_freq / sample_rate;
k1 = math.cos(2 * math.pi * ffs)
k2 = math.sin(2 * math.pi * ffs)
tone[1] = k2
for i in range(2, len(tone)):
    tone[i] = 2 * k1 * tone[i-1] - tone[i-2]

plt.plot(tone)
plt.show()

Using the same approach is it possible to generate the Hann window ?
Note:
You can generate a Hann window with sin function like that:
tone = [(0.5 - 0.5 * math.sin(0.5 * math.pi +( 2 * math.pi * i) / (len(tone) - 1))) for i in range(len(tone))]
i think this generates a sinusoid:
$$ y[n] = 2 \cos(\omega_0) y[n-1] - y[n-2] $$
if you initialize
$$ y[-2] = \cos(2 \omega_0) $$
$$ y[-1] = \cos(\omega_0) $$
then the result is
$$ y[n] = \cos(\omega_0 n) \qquad n \ge 0$$
the period of this cosine function is $N=\frac{2\pi}{\omega_0}$ and you want $N-1$ to be the non-zero width of the window.
finally you construct your window with
$$ w[n] = \tfrac{1}{2} (1 - y[n]) \qquad  0 \le n \le N$$