Some mathematical algorithms