Solution of nonlinear equations by an ancient Chinese algorithm