A discrete approach to Wirtinger's inequality