Good answer. The Mystery function is indeed mimicking the cosine function.
I'm only saying 'mimicking' rather than 'is equal to' because the cosine function is defined throughout the whole real line, whereas the Mystery function above is only defined from x = 0 to x = pi. That can be rectified, however, by adding:
If pi < x < 2pi, then Mystery(x) = Mystery(2pi - x)
If x = 2n pi + a, where 0<=a<2pi and n is any integer, then Mystery(x) = Mystery(a).
If the above are added to the definition of Mystery, then the Mystery becomes equal to the cosine function exactly.