code for gen. Frechet bounds