coseAlgorithm