Question: cos() in a custom function does not return 0

This is a piece of code from my file.

 g(1,a) should be 0, but not. I find some other questions  mentioned  assuming n::posint, but it does not take effect, so how could I avoid this? Thanks.

a := 0.12;
kn := n -> (n + 0.5)*Pi/a;
g := (n, x) -> cos(kn(n)*x);
g(1, a);
 

Please Wait...