sample program (newton method)