Fix automatic evaluation for sin/cos(pi*n/2): consider n.is_even case

fixes #8298