value_type Stokhos::KL::OneDExponentialCovarianceFunction<value_type>:: newton(const Func& func, const value_type& a, const value_type& b, magnitude_type tol, int max_num_its) { value_type u = (a+b)/2.0; value_type f = func.eval(u); int nit = 0; while (Teuchos::ScalarTraits<value_type>::magnitude(f) > tol && nit < max_num_its) { std::cout << "u = " << u << " f = " << f << std::endl; value_type dfdu = func.deriv(u); u -= f / dfdu; f = func.eval(u); ++nit; } TEUCHOS_TEST_FOR_EXCEPTION(nit >= max_num_its, std::logic_error, "Nonlinear solver did not converge!" << std::endl); return u; }