Newton square in scala