A general algorithm for the linear and quadratic gradients of physical quantities based on 10 or more point measurements